File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
compiler/rustc_borrowck/src/region_infer Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -1726,9 +1726,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
17261726 // `BoringNoLocation` constraints can point to user-written code, but are less
17271727 // specific, and are not used for relations that would make sense to blame.
17281728 ConstraintCategory :: BoringNoLocation => 6 ,
1729- // Do not blame internal constraints.
1730- ConstraintCategory :: OutlivesUnnameablePlaceholder ( _) => 7 ,
1731- ConstraintCategory :: Internal => 8 ,
1729+ // Do not blame internal constraints if we can avoid it. Never blame
1730+ // the `'region: 'static` constraints introduced by placeholder outlives.
1731+ ConstraintCategory :: Internal => 7 ,
1732+ ConstraintCategory :: OutlivesUnnameablePlaceholder ( _) => 8 ,
17321733 } ;
17331734
17341735 debug ! ( "constraint {constraint:?} category: {category:?}, interest: {interest:?}" ) ;
Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Zdeduplicate-diagnostics=yes
2+
3+ // Regression test for #146467.
4+ trait Trait { type Assoc ; }
5+
6+ impl Trait for fn ( & ( ) ) { type Assoc = ( ) ; }
7+
8+ fn f ( _: for <' a > fn ( <fn ( & ' a ( ) ) as Trait >:: Assoc ) ) { }
9+ //~^ ERROR implementation of `Trait` is not general enough
10+ //~| ERROR higher-ranked subtype error
11+
12+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: implementation of `Trait` is not general enough
2+ --> $DIR/do-not-blame-outlives-static-ice.rs:7:9
3+ |
4+ LL | fn f(_: for<'a> fn(<fn(&'a ()) as Trait>::Assoc)) {}
5+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough
6+ |
7+ = note: `for<'a> fn(&'a ())` must implement `Trait`, for any lifetime `'0`...
8+ = note: ...but `Trait` is actually implemented for the type `for<'a> fn(&'a ())`
9+
10+ error: higher-ranked subtype error
11+ --> $DIR/do-not-blame-outlives-static-ice.rs:7:1
12+ |
13+ LL | fn f(_: for<'a> fn(<fn(&'a ()) as Trait>::Assoc)) {}
14+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+ error: aborting due to 2 previous errors
17+
You can’t perform that action at this time.
0 commit comments