Fix None handling for simplify_type in for_each_relevant_impl

This commit is contained in:
reddevilmidzy 2025-11-24 16:06:15 +09:00
parent c23ed3ef28
commit eb72e6764e
3 changed files with 33 additions and 4 deletions

View file

@ -589,13 +589,13 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
| ty::Never
| ty::Tuple(_)
| ty::UnsafeBinder(_) => {
let simp = ty::fast_reject::simplify_type(
if let Some(simp) = ty::fast_reject::simplify_type(
tcx,
self_ty,
ty::fast_reject::TreatParams::AsRigid,
)
.unwrap();
consider_impls_for_simplified_type(simp);
) {
consider_impls_for_simplified_type(simp);
}
}
// HACK: For integer and float variables we have to manually look at all impls

View file

@ -0,0 +1,10 @@
// Test that blanket impl of DispatchFromDyn is rejected.
// regression test for issue <https://github.com/rust-lang/rust/issues/148062>
#![feature(dispatch_from_dyn)]
impl<T> std::ops::DispatchFromDyn<T> for T {}
//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
//~| ERROR the trait `DispatchFromDyn` may only be implemented for a coercion between structures
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> $DIR/dispatch-from-dyn-blanket-impl.rs:6:6
|
LL | impl<T> std::ops::DispatchFromDyn<T> for T {}
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
--> $DIR/dispatch-from-dyn-blanket-impl.rs:6:1
|
LL | impl<T> std::ops::DispatchFromDyn<T> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0210, E0377.
For more information about an error, try `rustc --explain E0210`.