Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7e44cb8

Browse files
authoredFeb 25, 2025
Unrolled build for rust-lang#137550
Rollup merge of rust-lang#137550 - matthewjasper:panic-later-for-missing-dropck-error, r=compiler-errors Don't immediately panic if dropck fails without returning errors This span_bug was a little too optimistic. I've decided that matching on the ErrorGuaranteed is a little more sensible than a delay bug that will always be ignored. closes rust-lang#137329 r? `@compiler-errors`
2 parents 7d8c6e7 + a4a9fb4 commit 7e44cb8

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed
 

‎compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ use rustc_index::interval::IntervalSet;
44
use rustc_infer::infer::canonical::QueryRegionConstraints;
55
use rustc_infer::infer::outlives::for_liveness;
66
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, HasLocalDecls, Local, Location};
7-
use rustc_middle::span_bug;
87
use rustc_middle::traits::query::DropckOutlivesResult;
98
use rustc_middle::ty::relate::Relate;
109
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
1110
use rustc_mir_dataflow::ResultsCursor;
1211
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1312
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
1413
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
15-
use rustc_span::{DUMMY_SP, Span};
14+
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
1615
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1716
use rustc_trait_selection::traits::ObligationCtxt;
1817
use rustc_trait_selection::traits::query::dropck_outlives;
@@ -608,7 +607,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
608607
Ok(TypeOpOutput { output, constraints, .. }) => {
609608
DropData { dropck_result: output, region_constraint_data: constraints }
610609
}
611-
Err(_) => {
610+
Err(ErrorGuaranteed { .. }) => {
612611
// We don't run dropck on HIR, and dropck looks inside fields of
613612
// types, so there's no guarantee that it succeeds. We also
614613
// can't rely on the the `ErrorGuaranteed` from `fully_perform` here
@@ -631,10 +630,10 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
631630
}
632631
};
633632

633+
// Could have no errors if a type lowering error, say, caused the query
634+
// to fail.
634635
if !errors.is_empty() {
635636
typeck.infcx.err_ctxt().report_fulfillment_errors(errors);
636-
} else {
637-
span_bug!(span, "Rerunning drop data query produced no error.");
638637
}
639638
});
640639
DropData { dropck_result: Default::default(), region_constraint_data: None }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for #137329
2+
3+
trait B {
4+
type C<'a>;
5+
fn d<E>() -> F<E> {
6+
todo!()
7+
}
8+
}
9+
struct F<G> {
10+
h: Option<<G as B>::C>,
11+
//~^ ERROR missing generics for associated type `B::C`
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0107]: missing generics for associated type `B::C`
2+
--> $DIR/dropck-after-failed-type-lowering.rs:10:25
3+
|
4+
LL | h: Option<<G as B>::C>,
5+
| ^ expected 1 lifetime argument
6+
|
7+
note: associated type defined here, with 1 lifetime parameter: `'a`
8+
--> $DIR/dropck-after-failed-type-lowering.rs:4:10
9+
|
10+
LL | type C<'a>;
11+
| ^ --
12+
help: add missing lifetime argument
13+
|
14+
LL | h: Option<<G as B>::C<'a>>,
15+
| ++++
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)
Failed to load comments.