-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
trait Foo: Sized {
type Output;
fn func() -> Self;
}
struct Type<T> { value: T }
impl<T: Default> Foo for Type<T> {
type Output = Self;
fn func() -> Self {
Self::Output { value: Default::default() }
}
}
stores the following resolution for Self::Output
via fn write_resolution
:
Ok((AssocTy, DefId(0:4 ~ test1[f74d]::Foo::Output)))
the node_substs
for Self::Output
are however empty. This makes the stored resolution completely useless as there isn't really a way to go from Foo::Output
to Type<T>::Output
which is what we actually need.
We should probably store <Foo as Type<T>>::Output
instead. This happens here
rust/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
Lines 1592 to 1605 in 7425fb2
QPath::TypeRelative(ref qself, ref segment) => { | |
let ty = self.to_ty(qself); | |
let result = <dyn AstConv<'_>>::associated_path_to_ty( | |
self, hir_id, path_span, ty, qself, segment, true, | |
); | |
let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error()); | |
let result = result.map(|(_, kind, def_id)| (kind, def_id)); | |
// Write back the new resolution. | |
self.write_resolution(hir_id, result); | |
(result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)), ty) | |
} |
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.