File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
compiler/rustc_mir_build/src/thir/pattern Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,9 @@ fn extend_type_not_partial_eq<'tcx>(
382382 fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> Self :: Result {
383383 match ty. kind ( ) {
384384 ty:: Dynamic ( ..) => return ControlFlow :: Break ( ( ) ) ,
385+ // Unsafe binders never implement `PartialEq`, so avoid walking into them
386+ // which would require instantiating its binder with placeholders too.
387+ ty:: UnsafeBinder ( ..) => return ControlFlow :: Break ( ( ) ) ,
385388 ty:: FnPtr ( ..) => return ControlFlow :: Continue ( ( ) ) ,
386389 ty:: Adt ( def, _args) => {
387390 let ty_def_id = def. did ( ) ;
Original file line number Diff line number Diff line change 1+ // regression test for <https://github.com/rust-lang/rust/issues/141422>.
2+
3+ #![ feature( unsafe_binders) ]
4+ #![ allow( incomplete_features) ]
5+
6+ #[ derive( Copy , Clone ) ]
7+ struct Adt < ' a > ( & ' a ( ) ) ;
8+
9+ const C : Option < ( unsafe <' a > Adt < ' a > , Box < dyn Send > ) > = None ;
10+
11+ fn main ( ) {
12+ match None {
13+ C => { }
14+ //~^ ERROR constant of non-structural type
15+ _ => { }
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)>` in a pattern
2+ --> $DIR/non-strucutral-type-diag.rs:13:9
3+ |
4+ LL | const C: Option<(unsafe<'a> Adt<'a>, Box<dyn Send>)> = None;
5+ | ---------------------------------------------------- constant defined here
6+ ...
7+ LL | C => {}
8+ | ^ constant of non-structural type
9+ |
10+ = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
11+
12+ error: aborting due to 1 previous error
13+
You can’t perform that action at this time.
0 commit comments