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

On outer attr not found, avoid knock-down errors #118511

Closed
wants to merge 1 commit into from

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Dec 1, 2023

When we encounter code like

#![non_existent]

#[derive(Clone)]
struct S;

fn main() {
    S.clone();
}

we avoid emitting errors about the derive (which isn't early resolved as normal, but has a later resolution) and stop the compiler from advancing to later stages, to avoid knock down errors from the derive not being evaluated. Recovering these would be possible, but would produce incorrect errors in the cases where had the outer attribute been present it would have modified the behavior/evaluation of the derive attributes.

Furthermore, the fan-out of knock down errors caused by this case is incredibly high, easily causing thousands of errors by the introduction of a single incorrect outer attribute in the crate root.

Fix #118455.

@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2023

r? @TaKO8Ki

(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 Dec 1, 2023
Copy link
Member

@TaKO8Ki TaKO8Ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the suggestion from compiler-errors, r=me

When we encounter code like

```rust

struct S;

fn main() {
    S.clone();
}
```

we avoid emitting errors about the `derive` (which isn't early resolved
as normal, but *has* a later resolution) and stop the compiler from
advancing to later stages, to avoid knock down errors from the `derive`
not being evaluated. Recovering these would be possible, but would
produce incorrect errors in the cases where had the outer attribute been
present it would have modified the behavior/evaluation of the `derive`
attributes.

Fix rust-lang#118455.
@estebank
Copy link
Contributor Author

estebank commented Dec 4, 2023

@bors r=TaKO8Ki

@bors
Copy link
Contributor

bors commented Dec 4, 2023

📌 Commit c0ebfe9 has been approved by TaKO8Ki

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 4, 2023
@chenyukang
Copy link
Member

chenyukang commented Dec 5, 2023

can we hold on this PR since it will conflict with #118533

My PR may suppress more these kinds of errors by checking builtin macros and attrs.

Let's wait for @petrochenkov 's comments.

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Dec 5, 2023

@chenyukang Ok. I will cancel my approval temporarily. @bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 5, 2023
@bors
Copy link
Contributor

bors commented Jan 10, 2024

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

@petrochenkov
Copy link
Contributor

r? @petrochenkov

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

Closing in favor of #118533.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A nonexistent inner attribute in lib.rs or main.rs breaks every procedural macro used within the entire crate
7 participants