Translate the virtual /rustc/$hash prefix back to a real directory. by eddyb · Pull Request #70642 · rust-lang/rust (original) (raw)

@ehuss It only points to the standard library to note some things, like trait/type definitions, IME, most diagnostic logic check is_imported though, especially suggestions and lints.

You can search the test suite for $SRC_DIR, or just look at the diff of this PR, those are all the tests where libstd shows up.
You'll get far more though, if you enable -Z macro-backtrace (which most tests don't).


Ideally we'd have a way to check inside the compiler if the sources are user-editable, and only emit suggestions then, does rustup make rust-src and Cargo its ~/.cargo/cache, read-only?
That'd be a nice way to hint to rustc to never emit suggestions for those files (i.e. we could gate this inside the diagnostic code itself, instead of in every place where they're emitted).

Kind of hard to test though, unless we made some test files read-only through git?

Bonus: if a suggestion arises while building Rust itself, then it would be fine for to point to the standard library, in some situations (we'd also get this if Cargo hinted workespaces to rustc directly).