rust/compiler/rustc_resolve/src
Dylan DPC fac84e8bb6
Rollup merge of #100228 - luqmana:suggestion-ice, r=estebank
Don't ICE while suggesting updating item path.

When an item isn't found, we may suggest an appropriate import to `use`. Along with that, we also suggest updating the path to work with the `use`. Unfortunately, if the code in question originates from a macro, the span used to indicate which part of the path needs updating may not be suitable and cause an ICE (*). Since, such code is not adjustable directly by the user without modifying the macro, just skip the suggestion in such cases.

(*) The ICE happens because the emitter want to indicate to the user what code to delete by referencing a certain span. But in this case, said span has `lo == hi == 0` which means it thinks it's a dummy span. Adding a space before the proc macro attribute is enough to stop it from ICE'ing but even then the suggestion doesn't really make any sense:
```
help: if you import `DataStore`, refer to it directly
  |
1 -  #[dbstruct::dbstruct]
1 +  #[dbstruct::dbstruct]
```

Since suggestions are best-effort, I just gated this one on `can_be_used_for_suggestions` which catches cases like this.

Fixes #100199
2022-08-09 17:34:55 +05:30
..
diagnostics Implement the unused_macro_rules lint 2022-05-05 19:13:00 +02:00
late Remove guess_head_span. 2022-07-28 23:14:04 +02:00
access_levels.rs Make ResolverAstLowering a struct. 2022-06-14 22:44:27 +02:00
build_reduced_graph.rs Unused tuple fields in rustc_resolve. 2022-07-25 19:45:26 +02:00
check_unused.rs Make ResolverAstLowering a struct. 2022-06-14 22:44:27 +02:00
def_collector.rs Parse closure binders 2022-07-12 16:25:16 +04:00
diagnostics.rs Don't ICE while suggesting updating item path. 2022-08-07 04:03:28 -07:00
ident.rs Unused tuple fields in rustc_resolve. 2022-07-25 19:45:26 +02:00
imports.rs change the type of note field to Option<String> 2022-07-28 18:17:55 +09:00
late.rs Use start_point instead of next_point to point to elided lifetime ampersand. 2022-08-07 14:35:11 +02:00
lib.rs Add docs to generics_def_id_map 2022-08-04 11:27:03 -03:00
macros.rs avoid embedding StabilityLevel::Unstable reason string into metadata multiple times 2022-07-21 22:53:02 +03:00