File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -589,13 +589,13 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
589589 | ty:: Never
590590 | ty:: Tuple ( _)
591591 | ty:: UnsafeBinder ( _) => {
592- let simp = ty:: fast_reject:: simplify_type (
592+ if let Some ( simp) = ty:: fast_reject:: simplify_type (
593593 tcx,
594594 self_ty,
595595 ty:: fast_reject:: TreatParams :: AsRigid ,
596- )
597- . unwrap ( ) ;
598- consider_impls_for_simplified_type ( simp ) ;
596+ ) {
597+ consider_impls_for_simplified_type ( simp ) ;
598+ }
599599 }
600600
601601 // HACK: For integer and float variables we have to manually look at all impls
Original file line number Diff line number Diff line change 1+ // Test that blanket impl of DispatchFromDyn is rejected.
2+ // regression test for issue <https://github.com/rust-lang/rust/issues/148062>
3+
4+ #![ feature( dispatch_from_dyn) ]
5+
6+ impl < T > std:: ops:: DispatchFromDyn < T > for T { }
7+ //~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
8+ //~| ERROR the trait `DispatchFromDyn` may only be implemented for a coercion between structures
9+
10+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
2+ --> $DIR/dispatch-from-dyn-blanket-impl.rs:6:6
3+ |
4+ LL | impl<T> std::ops::DispatchFromDyn<T> for T {}
5+ | ^ type parameter `T` must be used as the type parameter for some local type
6+ |
7+ = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
8+ = note: only traits defined in the current crate can be implemented for a type parameter
9+
10+ error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
11+ --> $DIR/dispatch-from-dyn-blanket-impl.rs:6:1
12+ |
13+ LL | impl<T> std::ops::DispatchFromDyn<T> for T {}
14+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+ error: aborting due to 2 previous errors
17+
18+ Some errors have detailed explanations: E0210, E0377.
19+ For more information about an error, try `rustc --explain E0210`.
You can’t perform that action at this time.
0 commit comments