-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Add note when inherent impl for a alias type defined outside of the crate #142415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.stderr
Show resolved
Hide resolved
tests/ui/incoherent-inherent-impls/insufficient-suggestion-issue-141679.stderr
Show resolved
Hide resolved
|
r? compiler |
xizheyin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rustbot ready
|
do you not get TyKind::Alias when you use type_of on the impl? coherence is probably fine to use middle queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried using type_of before, but I don't seem to be getting the information I'm looking for. When I try this code
let ty = self.tcx.type_of(impl_def_id).skip_binder();
if let ty::Adt(def, _) = ty.kind() {
let def_id = def.did();
let ty_name = self.tcx.def_path_str(def_id);
let alias_ty_name = self.tcx.type_of(def_id).skip_binder().to_string();
println!("ty_name: {:?}", ty_name);
println!("alias_ty_name: {:?}", alias_ty_name);
}
it prints:
ty_name: "Rc"
alias_ty_name: "Rc<T, A>"
It should be:
ty_name: "Function"
alias_ty_name: "Rc<Foo>"
Local variable ty is a adt of type Rc. Maybe the information we need only exists in HIR? Or am I using it wrong?
| if let hir::TyKind::Path(rustc_hir::QPath::Resolved(_, path)) = | ||
| self.tcx.hir_node_by_def_id(impl_def_id).expect_item().expect_impl().self_ty.kind | ||
| && let rustc_hir::def::Res::Def(DefKind::TyAlias, def_id) = path.res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged the two ifs.
|
r? compiler |
|
Only under the experimental feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's deal with the structured suggestion later.
r=me after addressing nitpicks
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@estebank I have rebased and fix the nits. CI green. Sorry for late response. |
Fixes #141679
r? compiler