Rollup merge of #135971 - compiler-errors:self-projection, r=fmease
Properly report error when object type param default references self I accidentally broke this error for cases where a type parameter references `Self` via a projection (i.e. `trait Foo<Arg = Self::Bar> {}`). This PR fixes that, and also makes the error a bit easier to understand. Fixes #135918
This commit is contained in:
commit
9ffe558455
11 changed files with 71 additions and 21 deletions
|
@ -237,16 +237,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
// Skip `Self`
|
||||
.skip(1)
|
||||
.map(|(index, arg)| {
|
||||
if arg == dummy_self.into() {
|
||||
if arg.walk().any(|arg| arg == dummy_self.into()) {
|
||||
let param = &generics.own_params[index];
|
||||
missing_type_params.push(param.name);
|
||||
Ty::new_misc_error(tcx).into()
|
||||
} else if arg.walk().any(|arg| arg == dummy_self.into()) {
|
||||
let guar = self.dcx().span_delayed_bug(
|
||||
span,
|
||||
"trait object trait bounds reference `Self`",
|
||||
);
|
||||
replace_dummy_self_with_error(tcx, arg, guar)
|
||||
} else {
|
||||
arg
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue