about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-24 14:56:28 +0000
committerbors <bors@rust-lang.org>2021-06-24 14:56:28 +0000
commitd95745e5fa39680d97a52d0e07ed7842b163bacc (patch)
tree5121952dd0824b51d5e5a998d93fb53ce7f88a58 /compiler/rustc_codegen_llvm/src
parent456a03227e3c81a51631f87ec80cac301e5fa6d7 (diff)
parent1400cb0295210bc500aa27f6cca3ccb546b38814 (diff)
downloadrust-d95745e5fa39680d97a52d0e07ed7842b163bacc.tar.gz
rust-d95745e5fa39680d97a52d0e07ed7842b163bacc.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions