Skip to content

Avoid recording unnameable extern crate aliases in diagnostic metadata - #158997

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
raushan728:issues/153459
Sep 29, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
raushan728:issues/153459

Conversation

@raushan728

@raushan728 raushan728 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

the root cause was that block scoped extern crate aliases were still being recorded as ExternCrateSource::Extern(def_id). later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as crate::_::_my_crate.

this change detects extern crate items whose DefPath passes through a value namespace (for example inside functions or const blocks) and records them as ExternCrateSource::Path instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes #153459

@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 Jul 9, 2026
@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

Comment thread compiler/rustc_middle/src/ty/print/pretty.rs Outdated
@cjgillot cjgillot self-assigned this Aug 4, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@raushan728
raushan728 force-pushed the issues/153459 branch 2 times, most recently from b236ee3 to 5d31258 Compare August 6, 2026 07:39
@rustbot

This comment has been minimized.

@raushan728
raushan728 requested a review from cjgillot August 6, 2026 07:58
@rust-log-analyzer

This comment has been minimized.

@raushan728 raushan728 changed the title Avoid suggesting crate::_::_... paths for trait imports Avoid recording unnameable extern crate aliases in diagnostic metadata Aug 6, 2026
…Source::Path`

Use the `DefPath` to determine whether an `extern crate` item is
globally nameable.

`extern crate` items nested inside value namespaces cannot be referred
to by a stable path outside their enclosing scope. Record them as
`ExternCrateSource::Path` instead of `ExternCrateSource::Extern` so
later path resolution does not reconstruct unnameable paths.
@rustbot

rustbot commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot assigned tiif and unassigned cjgillot and TaKO8Ki Sep 27, 2026
@raushan728

Copy link
Copy Markdown
Contributor Author

@rustbot reroll

@rustbot rustbot assigned nnethercote and unassigned tiif Sep 27, 2026
@nnethercote

Copy link
Copy Markdown
Contributor

@cjgillot's availability recently dropped. I'm not a good reviewer for this, I think the best alternative is probably:

r? @petrochenkov

@rust-bors

rust-bors Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2e4b8e5 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Sep 28, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…henkov

Avoid recording unnameable `extern crate` aliases in diagnostic metadata

the root cause was that block scoped `extern crate` aliases were still being recorded as `ExternCrateSource::Extern(def_id)`. later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as `crate::_::_my_crate`.

this change detects `extern crate` items whose `DefPath` passes through a value namespace (for example inside functions or `const` blocks) and records them as `ExternCrateSource::Path` instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes rust-lang#153459
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 28, 2026
…henkov

Avoid recording unnameable `extern crate` aliases in diagnostic metadata

the root cause was that block scoped `extern crate` aliases were still being recorded as `ExternCrateSource::Extern(def_id)`. later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as `crate::_::_my_crate`.

this change detects `extern crate` items whose `DefPath` passes through a value namespace (for example inside functions or `const` blocks) and records them as `ExternCrateSource::Path` instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes rust-lang#153459
rust-bors Bot pushed a commit that referenced this pull request Sep 28, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #158936 (Add `std::fs::{Home|Media}Dirs`)
 - #129036 (Additional NonZero conversions)
 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #161015 (Stabilize `funnel_shifts` (including `const`))
 - #161712 (Stabilize `Result::into_{ok,err}`)
 - #162493 (Add support for -Zsanitizer-cfi-minimal-runtime)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163427 (implement #![feature(gca_adts)])
 - #163428 (do not complain about unstable target features on nightly)
 - #163444 (Add `stable_rustc` helper in `run-make-support`)
 - #163447 (Allow using different index types when reading and writing to tables)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
Avoid recording unnameable `extern crate` aliases in diagnostic metadata

the root cause was that block scoped `extern crate` aliases were still being recorded as `ExternCrateSource::Extern(def_id)`. later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as `crate::_::_my_crate`.

this change detects `extern crate` items whose `DefPath` passes through a value namespace (for example inside functions or `const` blocks) and records them as `ExternCrateSource::Path` instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes #153459
@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 29, 2026
@rust-bors

rust-bors Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 74f4062 failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors retry

@rust-bors rust-bors Bot 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 Sep 29, 2026
@rust-bors

rust-bors Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⌛ Testing commit 2e4b8e5 with merge 2063b57...

Workflow: https://github.com/rust-lang/rust/actions/runs/36538712471

rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
Avoid recording unnameable `extern crate` aliases in diagnostic metadata

the root cause was that block scoped `extern crate` aliases were still being recorded as `ExternCrateSource::Extern(def_id)`. later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as `crate::_::_my_crate`.

this change detects `extern crate` items whose `DefPath` passes through a value namespace (for example inside functions or `const` blocks) and records them as `ExternCrateSource::Path` instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes #153459
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors yield
Yielding to enclosing rollup

@rust-bors

rust-bors Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #163472.

rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - #162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - #162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - #162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - #163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - #163210 (std: split stack overflow module)
 - #163331 (Move `Arc` and `Rc` into `rcs` mod)
 - #163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - #163450 (Force the correct type variable to never for method resolution on an adjusted never type)
@rust-bors
rust-bors Bot merged commit dce0308 into rust-lang:main Sep 29, 2026
13 of 14 checks passed
rust-bors Bot pushed a commit that referenced this pull request Sep 29, 2026
Rollup merge of #158997 - raushan728:issues/153459, r=petrochenkov

Avoid recording unnameable `extern crate` aliases in diagnostic metadata

the root cause was that block scoped `extern crate` aliases were still being recorded as `ExternCrateSource::Extern(def_id)`. later, diagnostics reused that metadata and attempted to print paths through those aliases, producing unnameable paths such as `crate::_::_my_crate`.

this change detects `extern crate` items whose `DefPath` passes through a value namespace (for example inside functions or `const` blocks) and records them as `ExternCrateSource::Path` instead. diagnostics then fall back to the crate name rather than an unnameable alias.

Closes #153459
@rustbot rustbot added this to the 1.101.0 milestone Sep 29, 2026
@raushan728
raushan728 deleted the issues/153459 branch September 29, 2026 11:32
pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Sep 30, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#158997 (Avoid recording unnameable `extern crate` aliases in diagnostic metadata)
 - rust-lang/rust#162655 (next solver: prefer to select impl candidates over global where-clause candidates)
 - rust-lang/rust#162832 (add `Div` and `Mul` for `Complex<{float}>`)
 - rust-lang/rust#162862 (Fix intra doc link resolution when a doc comment is composed of both inner and outer doc comment)
 - rust-lang/rust#163200 (make `RustaceansAreAwesome` satisfy trait bounds)
 - rust-lang/rust#163210 (std: split stack overflow module)
 - rust-lang/rust#163331 (Move `Arc` and `Rc` into `rcs` mod)
 - rust-lang/rust#163183 (Add .seek_read_buf_exact() to std::os::windows::fs::FileExt)
 - rust-lang/rust#163450 (Force the correct type variable to never for method resolution on an adjusted never type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

#[derive(Deserialize)] makes rustc sugget suggests bizarre and non-working use crate::_::_serde::de::Error; instead of use serde::de::Error;

9 participants