rust/compiler/rustc_resolve/src
bors d95745e5fa Auto merge of #85427 - ehuss:fix-use-placement, r=jackh726
Fix use placement for suggestions near main.

This fixes an edge case for the suggestion to add a `use`. When running with `--test`, the `main` function will be annotated with an `#[allow(dead_code)]` attribute. The `UsePlacementFinder` would end up using the dummy span of that synthetic attribute. If there are top-level inner attributes, this would place the `use` in the wrong position. The solution here is to ignore attributes with dummy spans.

In the process of working on this, I discovered that the `use_suggestion_placement` test was broken. `UsePlacementFinder` is unaware of active attributes. Attributes like `#[derive]` don't exist in the AST since they are removed. Fixing that is difficult, since the AST does not retain enough information. I considered trying to place the `use` towards the top of the module after any `extern crate` items, but I couldn't find a way to get a span for the start of a module block (the `mod` span starts at the `mod` keyword, and it seems tricky to find the spot just after the opening bracket and past inner attributes). For now, I just put some comments about the issue. This appears to have been a known issue in #44215 where the test for it was introduced, and the fix seemed to be deferred to later.
2021-06-24 14:56:28 +00:00
..
late Remove lifetime hack 2021-06-07 10:00:58 -05:00
build_reduced_graph.rs Fix diagnostic for matching/creating x-crate re-exported tuple structs with private fields. 2021-05-08 00:33:31 -07:00
check_unused.rs Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
def_collector.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
diagnostics.rs Add test for forward declared const param defaults 2021-06-01 17:44:54 +01:00
imports.rs Fix ICE with use clippy:🅰️:b; 2021-03-21 14:20:28 -07:00
late.rs Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
lib.rs Auto merge of #85427 - ehuss:fix-use-placement, r=jackh726 2021-06-24 14:56:28 +00:00
macros.rs expand: Move some more derive logic to rustc_builtin_macros 2021-06-20 18:48:42 +03:00