mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Find lowest span out of use + attrs
This commit is contained in:
parent
4da6eb2ec6
commit
03bee1f53d
@ -2753,7 +2753,13 @@ fn search_for_any_use_in_items(items: &[P<ast::Item>]) -> Option<Span> {
|
||||
for item in items {
|
||||
if let ItemKind::Use(..) = item.kind {
|
||||
if is_span_suitable_for_use_injection(item.span) {
|
||||
return Some(item.span.shrink_to_lo());
|
||||
let mut lo = item.span.lo();
|
||||
for attr in &item.attrs {
|
||||
if attr.span.eq_ctxt(item.span) {
|
||||
lo = std::cmp::min(lo, attr.span.lo());
|
||||
}
|
||||
}
|
||||
return Some(Span::new(lo, lo, item.span.ctxt(), item.span.parent()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// run-rustfix
|
||||
// compile-flags: --cfg=whatever -Aunused
|
||||
|
||||
#[cfg(whatever)]
|
||||
use y::z;
|
||||
#[cfg(whatever)]
|
||||
use y::Whatever;
|
||||
|
||||
mod y {
|
||||
|
Loading…
Reference in New Issue
Block a user