Label struct/enum constructor instead of fn item, mention that it should be called on type mismatch#106524
Merged
bors merged 2 commits intorust-lang:masterfrom Jan 12, 2023
Merged
Conversation
Collaborator
|
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
cjgillot
reviewed
Jan 7, 2023
Comment on lines
+322
to
+326
Contributor
There was a problem hiding this comment.
Why not use the existing descr method? The output is a bit different, but also more uniform with other diags.
Suggested change
| 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(), |
Contributor
Author
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
Oh, also, I'm not really a fan of renaming functions from "fn item" to their descr "function".
5b77761 to
43d69cd
Compare
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit 43d69cdba0d60e673465de27038a61dfade96d24 has been approved by It is now in the queue for this repository. |
43d69cd to
d375440
Compare
Contributor
Author
|
rebased @bors r=cjgillot |
Collaborator
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jan 12, 2023
…r=cjgillot Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch Fixes rust-lang#106516
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 12, 2023
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #106516