rustc_resolve: point the label span at the segment that could not be resolved#157623
Conversation
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I'm not really sure that the diagnostic is clearer? It just got larger, and visually highlights the part that actually can be resolved?
Am I reading this wrong? At first glance I'd think the errors is in the bar part, but it might equally well be in the foo part (when it has a typo, for instance).
LL | use bar::foo;
| ^^^^^---
| |
| no `foo` in `bar`
| LL | invoke_with_crate!{input proc_macro_item} | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `proc_macro_item` in the root | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^---------------^ | ||
| | | | ||
| | no `proc_macro_item` in the root |
There was a problem hiding this comment.
idk this just kind of looks weird now?
| macro_rules! mac1 { | ||
| ($thing: ident) => {{ | ||
| const _x: u32 = things::$thing; | ||
| //~^NOTE due to this macro variable |
There was a problem hiding this comment.
| //~^NOTE due to this macro variable | |
| //~^ NOTE due to this macro variable |
very nitpicky but I believe this is how we do it everywhere?
There was a problem hiding this comment.
(usually) yes. I'll edit this.
The main error message points at the entire path. The label points to the segment that could not be resolved. You get This is not unique to this error or this PR: #![deny(forgetting_references)]
fn main(){
std::mem::forget(&());
}Here, the main error span is the entire function path, function call syntax and the arguments. The label is just of the function argument. |
|
Hmm allright then @bors r+ rollup |
rustc_resolve: point the label span at the segment that could not be resolved This is part of work that @weiznich and I are doing for `#[diagnostic::on_unknown]`. This means that you can put the attribute in macro_rules macros and have the label message point at the input the user gave. It's imo also the right thing to point the span at in general. ```rust mod things {} macro_rules! mac { ($thing: ident) => {{ const _x: u32 = { #[diagnostic::on_unknown(label = "you did the bad thing")] use things::$thing; //~^ERROR unresolved import `things::what` [E0432] //~|ERROR unresolved import `things::what2` [E0432] $thing }; }}; } ``` ``` LL | | what2 | | ----- you did the bad thing ``` See also the first and last commit for what these messages look(ed) like. cc @estebank
Rollup of 4 pull requests Successful merges: - #157547 (Reorganize `tests/ui/issues` [6/N]) - #157549 (Remove comments already covered by rustdoc) - #157591 (Simplify the HIR ty lowering of trait object lifetime bounds) - #157623 (rustc_resolve: point the label span at the segment that could not be resolved)
Rollup merge of #157623 - mejrs:not_found_in, r=folkertdev rustc_resolve: point the label span at the segment that could not be resolved This is part of work that @weiznich and I are doing for `#[diagnostic::on_unknown]`. This means that you can put the attribute in macro_rules macros and have the label message point at the input the user gave. It's imo also the right thing to point the span at in general. ```rust mod things {} macro_rules! mac { ($thing: ident) => {{ const _x: u32 = { #[diagnostic::on_unknown(label = "you did the bad thing")] use things::$thing; //~^ERROR unresolved import `things::what` [E0432] //~|ERROR unresolved import `things::what2` [E0432] $thing }; }}; } ``` ``` LL | | what2 | | ----- you did the bad thing ``` See also the first and last commit for what these messages look(ed) like. cc @estebank
This is part of work that @weiznich and I are doing for
#[diagnostic::on_unknown].This means that you can put the attribute in macro_rules macros and have the label message point at the input the user gave. It's imo also the right thing to point the span at in general.
See also the first and last commit for what these messages look(ed) like.
cc @estebank