-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Label struct/enum constructor
instead of fn item
, mention that it should be called on type mismatch
#106524
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
ty::FnDef(def_id, ..) => match tcx.def_kind(def_id) { | ||
DefKind::Ctor(CtorOf::Struct, _) => "struct constructor".into(), | ||
DefKind::Ctor(CtorOf::Variant, _) => "enum constructor".into(), | ||
_ => "fn item".into(), | ||
}, |
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.
Why not use the existing descr
method? The output is a bit different, but also more uniform with other diags.
ty::FnDef(def_id, ..) => match tcx.def_kind(def_id) { | |
DefKind::Ctor(CtorOf::Struct, _) => "struct constructor".into(), | |
DefKind::Ctor(CtorOf::Variant, _) => "enum constructor".into(), | |
_ => "fn item".into(), | |
}, | |
ty::FnDef(def_id, ..) => tcx.def_kind(def_id).descr(def_id).into(), |
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.
Mostly because descr is pretty verbose here.. I didn't like how it sounded for these ctor DefKinds, but I don't have a particularly strong opinion.
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.
Oh, also, I'm not really a fan of renaming functions from "fn item" to their descr "function".
@@ -366,7 +370,11 @@ impl<'tcx> Ty<'tcx> { | |||
_ => "reference", | |||
} | |||
.into(), | |||
ty::FnDef(..) => "fn item".into(), | |||
ty::FnDef(def_id, ..) => match tcx.def_kind(def_id) { |
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.
Likewise.
5b77761
to
43d69cd
Compare
@bors r+ |
📌 Commit 43d69cdba0d60e673465de27038a61dfade96d24 has been approved by It is now in the queue for this repository. |
43d69cd
to
d375440
Compare
rebased @bors r=cjgillot |
…r=cjgillot Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch Fixes rust-lang#106516
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#103236 (doc: rewrite doc for signed int::{carrying_add,borrowing_sub}) - rust-lang#103800 (Stabilize `::{core,std}::pin::pin!`) - rust-lang#106097 (Migrate mir_build diagnostics 2 of 3) - rust-lang#106170 (Move autoderef to `rustc_hir_analysis`) - rust-lang#106323 (Stabilize f16c_target_feature) - rust-lang#106360 (Tweak E0277 `&`-removal suggestions) - rust-lang#106524 (Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch) - rust-lang#106739 (Remove `<dyn AstConv<'tcx>>::fun(c, ...)` calls in favour of `c.astconv().fun(...)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #106516