Skip to content

Commit

Permalink
Rollup merge of rust-lang#91298 - FabianWolff:issue-91028-source-avai…
Browse files Browse the repository at this point in the history
…l, r=cjgillot

Improve error message for `E0659` if the source is not available

Fixes rust-lang#91028. The fix is similar to those in rust-lang#89233 and rust-lang#87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
  • Loading branch information
matthiaskrgr authored Dec 1, 2021
2 parents b64951f + 6dfed31 commit d51eeef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ impl<'a> Resolver<'a> {

fn binding_description(&self, b: &NameBinding<'_>, ident: Ident, from_prelude: bool) -> String {
let res = b.res();
if b.span.is_dummy() {
if b.span.is_dummy() || self.session.source_map().span_to_snippet(b.span).is_err() {
// These already contain the "built-in" prefix or look bad with it.
let add_built_in =
!matches!(b.res(), Res::NonMacroAttr(..) | Res::PrimTy(..) | Res::ToolMod);
Expand Down

0 comments on commit d51eeef

Please sign in to comment.