Skip to content
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

Look at proc-macro attributes when encountering unknown attribute #110342

Closed
wants to merge 1 commit into from

Conversation

estebank
Copy link
Contributor

error: cannot find attribute `sede` in this scope
  --> src/main.rs:18:7
   |
18 |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute
   |
18 |     #[serde(untagged)]
   |       ~~~~~

error: cannot find attribute `serde` in this scope
  --> src/main.rs:12:7
   |
12 |     #[serde(untagged)]
   |       ^^^^^
   |
   = note: `serde` is in scope, but it is a crate, not an attribute
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute
   |
10 + #[derive(Serialize, Deserialize)]
11 | struct Foo {
   |

Mitigate #47608. Split off of #109278 as requested.

```
error: cannot find attribute `sede` in this scope
  --> src/main.rs:18:7
   |
18 |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Serialize` and `Deserialize` accept the similarly named `serde` attribute
   |
18 |     #[serde(untagged)]
   |       ~~~~~

error: cannot find attribute `serde` in this scope
  --> src/main.rs:12:7
   |
12 |     #[serde(untagged)]
   |       ^^^^^
   |
   = note: `serde` is in scope, but it is a crate, not an attribute
help: `serde` is an attribute that can be used by the derive macros `Serialize` and `Deserialize`, you might be missing a `derive` attribute
   |
10 + #[derive(Serialize, Deserialize)]
11 | struct Foo {
   |
```

Mitigate rust-lang#47608.
@rustbot
Copy link
Collaborator

rustbot commented Apr 14, 2023

r? @WaffleLapkin

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 14, 2023
@petrochenkov
Copy link
Contributor

r? @petrochenkov

@rustbot rustbot assigned petrochenkov and unassigned WaffleLapkin Apr 15, 2023
@estebank
Copy link
Contributor Author

estebank commented Apr 16, 2023

@petrochenkov let me know if this was the split you desired. I guess I could have removed the additional span tracking as well and forego the structured suggestion, but that seemed to significantly reduce the utility of landing the PR in the first place.

@petrochenkov
Copy link
Contributor

let me know if this was the split you desired

No, visit_scopes and add_derive_for_attribute should not be used separately.

Derive helper attributes should be added to suggestion candidates inside fn lookup_import_candidates and fn early_lookup_typo_candidate.
When we encounter a derive macro during the lookup we "open" it and add its helper attributes to the list of candidates too, if they fit.

I guess I could have removed the additional span tracking as well and forego the structured suggestion, but that seemed to significantly reduce the utility of landing the PR in the first place.

Yeah, let's drop all that, I want to land the core change cleanly.
Then we can add more detailed data to TypoSuggestion/ImportSuggestion structures to beautify the output.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2023
@bors
Copy link
Contributor

bors commented May 3, 2023

☔ The latest upstream changes (presumably #110579) made this pull request unmergeable. Please resolve the merge conflicts.

@estebank estebank closed this Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants