fix ICE in suggest_param_env_shadowing with incompatible args

remove comments
This commit is contained in:
Takayuki Maeda 2026-02-17 16:33:21 +09:00
parent 139651428d
commit cbfa215893
3 changed files with 41 additions and 0 deletions

View file

@ -301,6 +301,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let rebased_args = alias.args.rebase_onto(tcx, trait_def_id, impl_substs);
let impl_item_def_id = leaf_def.item.def_id;
if !tcx.check_args_compatible(impl_item_def_id, rebased_args) {
return false;
}
let impl_assoc_ty = tcx.type_of(impl_item_def_id).instantiate(tcx, rebased_args);
self.infcx.can_eq(param_env, impl_assoc_ty, concrete)

View file

@ -0,0 +1,18 @@
//@ compile-flags: -Znext-solver=globally
// Regression test for https://github.com/rust-lang/rust/issues/152684.
#![feature(associated_type_defaults)]
trait Foo {
type Assoc<T = u8> = T;
//~^ ERROR defaults for generic parameters are not allowed here
fn foo() -> Self::Assoc;
}
impl Foo for () {
fn foo() -> Self::Assoc {
[] //~ ERROR mismatched types
}
}
fn main() {}

View file

@ -0,0 +1,20 @@
error: defaults for generic parameters are not allowed here
--> $DIR/suggest-param-env-shadowing-incompatible-args.rs:8:16
|
LL | type Assoc<T = u8> = T;
| ^^^^^^
error[E0308]: mismatched types
--> $DIR/suggest-param-env-shadowing-incompatible-args.rs:14:9
|
LL | fn foo() -> Self::Assoc {
| ----------- expected `<() as Foo>::Assoc` because of return type
LL | []
| ^^ expected `u8`, found `[_; 0]`
|
= note: expected type `u8`
found array `[_; 0]`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.