]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #100228 - luqmana:suggestion-ice, r=estebank
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Tue, 9 Aug 2022 12:04:55 +0000 (17:34 +0530)
committerGitHub <noreply@github.com>
Tue, 9 Aug 2022 12:04:55 +0000 (17:34 +0530)
commitfac84e8bb65349e3b26cb5c4e7acf7694b8e6659
treed6a0fadda3123fb980d5bb4fb9599650cd0f03ed
parentd910e5376b69d232071b8eeed4d65e703e13a82b
parent15b1daaca3fd4020d7a93cff14507b9104ec6d02
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