]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber
authorbors <bors@rust-lang.org>
Tue, 15 Mar 2022 03:56:33 +0000 (03:56 +0000)
committerbors <bors@rust-lang.org>
Tue, 15 Mar 2022 03:56:33 +0000 (03:56 +0000)
commit95561b336cf82a8250176eb3c61ea61c90e75d47
tree24a6e221528437c7354ea1f0fe87d86908e374e9
parent984204814e00f60c5e1ec99e2e184f326782a586
parent8f4c6b039d49cbba6a1122043fac5fd29fde92ba
Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber

More robust fallback for `use` suggestion

Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.

But this was fragile, as illustrated in issue #87613

This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.

Fix #87613
compiler/rustc_ast/src/ast.rs
compiler/rustc_ast/src/mut_visit.rs
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_expand/src/expand.rs
compiler/rustc_parse/src/parser/item.rs
compiler/rustc_resolve/src/lib.rs
compiler/rustc_typeck/src/check/method/suggest.rs