Skip to content

Commit 42ec52b

Browse files
committed
Auto merge of #149258 - reddevilmidzy:ice, r=Kivooeo
Fix None handling for simplify_type in for_each_relevant_impl resolve: #148062
2 parents 69408a8 + eb72e67 commit 42ec52b

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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`.

0 commit comments

Comments
 (0)