3

Add notes to macro-not-found diagnostics to point out how things with the same n...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/88232
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

estebank left a comment

I love how these are looking

I'm leaving some nitpicks, but we don't need to address them all to land this.

@@ -32,15 +32,15 @@ error: cannot find macro `Box` in this scope

LL | Box!();

| ^^^

|

= note: `Box` is in scope, but it is a struct

= note: `Box` is in scope, but it is a struct, not a macro

estebank 5 days ago

Contributor

For the cases where we don't have a span, wouldn't it make sense to turn this into the primary span? Something like:

error: cannot find macro `Copy` in this scope
  --> $DIR/issue-88206.rs:56:5
   |
LL |     Copy!();
   |     ^^^^ this is not a macro, it is a derive macro: `#[derive(Copy)]`

m-ou-se 4 days ago

Author

Member

I'd avoid pointing the note at the identifier the user wrote, because the error already says cannot find `Thing`, and the note is about another Thing, not the Thing they wrote. (Even though they have the same name.)

So in the case we can point at an import, we do that to highlight Thing here is not found, but Thing there exists but is something else. Pointing both at the same identifier would make it less clear that we're talking about two different Things.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK