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

cfg diagnostic not applied correctly #112672

Closed
Noratrieb opened this issue Jun 15, 2023 · 0 comments · Fixed by #119925
Closed

cfg diagnostic not applied correctly #112672

Noratrieb opened this issue Jun 15, 2023 · 0 comments · Fixed by #119925
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

I tried this code:
cargo add rsa

fn main() {
    println!("Hello, world!");
    rsa::sha2::Sha256;
}
error[E0433]: failed to resolve: could not find `sha2` in `rsa`
 --> src/main.rs:5:10
  |
5 |     rsa::sha2::Sha256;
  |          ^^^^ could not find `sha2` in `rsa`

the cfg diagnostic is missing, although the code path for find_cfg_stripped seems to be hit.

@Noratrieb Noratrieb added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jun 15, 2023
Noratrieb added a commit to Noratrieb/rust that referenced this issue Jan 13, 2024
store the segment name when resolution fails

Fixes rust-lang#112672

The `find_cfg_stripped` does indeed get executed within `smart_resolve_report_errors`. However, this error is not reported as it is subsequently overridden by `parent_err`. (See: https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/late.rs#L3760)

This PR changes `last_segment` to `segment`, which stores the name of the failed resolution, and ensures that the result of `find_cfg_stripped` is also included in `parent_err`.

r? `@Nilstrieb`
Noratrieb added a commit to Noratrieb/rust that referenced this issue Jan 13, 2024
store the segment name when resolution fails

Fixes rust-lang#112672

The `find_cfg_stripped` does indeed get executed within `smart_resolve_report_errors`. However, this error is not reported as it is subsequently overridden by `parent_err`. (See: https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/late.rs#L3760)

This PR changes `last_segment` to `segment`, which stores the name of the failed resolution, and ensures that the result of `find_cfg_stripped` is also included in `parent_err`.

r? ``@Nilstrieb``
@bors bors closed this as completed in 70bc26d Jan 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 14, 2024
Rollup merge of rust-lang#119925 - bvanjoi:fix-112672, r=Nilstrieb

store the segment name when resolution fails

Fixes rust-lang#112672

The `find_cfg_stripped` does indeed get executed within `smart_resolve_report_errors`. However, this error is not reported as it is subsequently overridden by `parent_err`. (See: https://github.com/rust-lang/rust/blob/master/compiler/rustc_resolve/src/late.rs#L3760)

This PR changes `last_segment` to `segment`, which stores the name of the failed resolution, and ensures that the result of `find_cfg_stripped` is also included in `parent_err`.

r? ```@Nilstrieb```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant