File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
compiler/rustc_borrowck/src/region_infer
tests/ui/type-alias-impl-trait Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
69
69
continue ;
70
70
}
71
71
72
+ // Ignore non-universal regions because they result in an error eventually.
73
+ // FIXME(aliemjay): This logic will be rewritten in a later commit.
74
+ let Some ( r1) = self . universal_name ( r1) else {
75
+ continue ;
76
+ } ;
77
+ let Some ( r2) = self . universal_name ( r2) else {
78
+ continue ;
79
+ } ;
80
+
72
81
infcx. dcx ( ) . emit_err ( LifetimeMismatchOpaqueParam {
73
- arg : self . universal_name ( r1 ) . unwrap ( ) . into ( ) ,
74
- prev : self . universal_name ( r2 ) . unwrap ( ) . into ( ) ,
82
+ arg : r1 . into ( ) ,
83
+ prev : r2 . into ( ) ,
75
84
span : a_ty. span ,
76
85
prev_span : b_ty. span ,
77
86
} ) ;
Original file line number Diff line number Diff line change
1
+ //! This test checks that when checking for opaque types that
2
+ //! only differ in lifetimes, we handle the case of non-generic
3
+ //! regions correctly.
4
+ #![ feature( type_alias_impl_trait) ]
5
+
6
+ type Opq < ' a > = impl Sized ;
7
+
8
+ // Two defining uses: Opq<'{empty}> and Opq<'a>.
9
+ // This used to ICE.
10
+ // issue: #122782
11
+ fn build < ' a > ( ) -> Opq < ' a > {
12
+ let _: Opq < ' _ > = ( ) ;
13
+ //~^ ERROR expected generic lifetime parameter, found `'_`
14
+ }
15
+
16
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0792]: expected generic lifetime parameter, found `'_`
2
+ --> $DIR/param_mismatch4.rs:12:12
3
+ |
4
+ LL | type Opq<'a> = impl Sized;
5
+ | -- this generic parameter must be used with a generic lifetime parameter
6
+ ...
7
+ LL | let _: Opq<'_> = ();
8
+ | ^^^^^^^
9
+
10
+ error: aborting due to 1 previous error
11
+
12
+ For more information about this error, try `rustc --explain E0792`.
You can’t perform that action at this time.
0 commit comments