mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Auto merge of #17939 - ShoyuVanilla:maybe-sized-fix, r=Veykril
fix: Wrong `Sized` predicate for `generic_predicates_for_param` I found this gathers wrong `Self: Sized` bound while implementing object safety, though I couldn't find proper test for this. If we call `generic_predicates_for_param` to `Bar` in the following code; ```rust trait Foo<T: ?Sized> {} trait Bar<T: Foo<Self> + ?Sized> {} ``` it returns `T: Sized` and `Self: Sized` bound, because normaly, the `?Sized` bound applied properly in L1059 with;3723e5910c/crates/hir-ty/src/lower.rs (L1035-L1061)
But we filter them before it is lowered with that function here;3723e5910c/crates/hir-ty/src/lower.rs (L1540-L1586)
So, the `?Sized` bounded params are not gathered into `ctx.unsized_types` and thus we are applying them implicit `Sized` bound here;3723e5910c/crates/hir-ty/src/lower.rs (L1591-L1602)
This commit is contained in:
commit
011e3bb9ac
1 changed files with 4 additions and 0 deletions
|
@ -1551,6 +1551,10 @@ pub(crate) fn generic_predicates_for_param_query(
|
|||
}
|
||||
};
|
||||
if invalid_target {
|
||||
// If this is filtered out without lowering, `?Sized` is not gathered into `ctx.unsized_types`
|
||||
if let TypeBound::Path(_, TraitBoundModifier::Maybe) = &**bound {
|
||||
ctx.lower_where_predicate(pred, &def, true).for_each(drop);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue