Uh oh!
There was an error while loading. Please reload this page.
Improve AttrItem::span - #159587
Conversation
Just to improve coverage.
Currently the method computes the span from the path's span and the args' span. That used to be fine but then `unsafe(..)`/`safe(..)` were added without it being changed. So it doesn't account for those optional keywords and parentheses. The only way to handle those reliably is with a dedicated span for the entire `AttrItem`. Consequences: - `NormalAttr` grows from 72 bytes to 80. (It's the only AST node that contains an `AttrItem`.) Not ideal, but non-doc-comment attributes aren't that common (not compared to expressions, for example). Also, `NormalAttr` is always boxed and jemalloc will round up 72 byte allocations to 80 bytes anyway. - In `lint-unsafe-code.rs` various spans now point to `unsafe(foo)` rather than just `foo`. (It makes sense to include the `unsafe` keyword in the complaint about unsafety.)
rustbot
commented
Jul 20, 2026
JonathanBrouwer
commented
Jul 20, 2026
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Jul 20, 2026
Finished benchmarking commit (a8ce121): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary -3.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 485.867s -> 491.733s (1.21%) |
petrochenkov
commented
Jul 20, 2026
@bors r+ rollup=maybe |
…chenkov Improve `AttrItem::span` It has some shortcomings. Details in individual commits. r? @petrochenkov
…uwer Rollup of 10 pull requests Successful merges: - #159600 (`rust-analyzer` subtree update) - #158046 (proc_macro: preserve file module spans for inner attrs) - #159000 (Small cleanups to the incr comp session code) - #159449 (Enable single Location to issue multiple borrows) - #159587 (Improve `AttrItem::span`) - #159460 (Do not mark unnormalized const aliases as rigid when normalizing param env) - #159529 (Add regression test for nested replacement ranges in `collect_tokens`) - #159585 (Minor `TokenStream` improvements) - #159586 (Separate `InterpCx` usage by `ConstAnalysis` phases) - #159603 (Clarify `push_stream`/`push_tree`) Failed merges: - #159590 (Remove some dead code)
…uwer Rollup of 18 pull requests Successful merges: - #159600 (`rust-analyzer` subtree update) - #158046 (proc_macro: preserve file module spans for inner attrs) - #159000 (Small cleanups to the incr comp session code) - #159189 (Account for type alias projections in E0308 "expected/found" shortening logic) - #159449 (Enable single Location to issue multiple borrows) - #159544 (Suggest valid command-line crate names) - #159587 (Improve `AttrItem::span`) - #159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures) - #159597 (std: use `arc4random_buf` from libc) - #159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.) - #158061 (Make `pin!()` more foolproof.) - #159460 (Do not mark unnormalized const aliases as rigid when normalizing param env) - #159529 (Add regression test for nested replacement ranges in `collect_tokens`) - #159571 (Remove unused bundled library lookup for the local crate) - #159585 (Minor `TokenStream` improvements) - #159586 (Separate `InterpCx` usage by `ConstAnalysis` phases) - #159602 (Remove `ItemLike`) - #159603 (Clarify `push_stream`/`push_tree`) Failed merges: - #159590 (Remove some dead code)
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #159587 - nnethercote:AttrItem-span, r=petrochenkov Improve `AttrItem::span` It has some shortcomings. Details in individual commits. r? @petrochenkov
…nathanBrouwer Improve workings of attribute suggestions `AttrItem` span tracking improved in rust-lang#159587, which lets us slightly simplify the workings of attribute suggestions. r? @JonathanBrouwer
Rollup merge of #159633 - nnethercote:attr-suggestions, r=JonathanBrouwer Improve workings of attribute suggestions `AttrItem` span tracking improved in #159587, which lets us slightly simplify the workings of attribute suggestions. r? @JonathanBrouwer
…uwer Improve workings of attribute suggestions `AttrItem` span tracking improved in rust-lang/rust#159587, which lets us slightly simplify the workings of attribute suggestions. r? @JonathanBrouwer
…uwer Rollup of 18 pull requests Successful merges: - rust-lang/rust#159600 (`rust-analyzer` subtree update) - rust-lang/rust#158046 (proc_macro: preserve file module spans for inner attrs) - rust-lang/rust#159000 (Small cleanups to the incr comp session code) - rust-lang/rust#159189 (Account for type alias projections in E0308 "expected/found" shortening logic) - rust-lang/rust#159449 (Enable single Location to issue multiple borrows) - rust-lang/rust#159544 (Suggest valid command-line crate names) - rust-lang/rust#159587 (Improve `AttrItem::span`) - rust-lang/rust#159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures) - rust-lang/rust#159597 (std: use `arc4random_buf` from libc) - rust-lang/rust#159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.) - rust-lang/rust#158061 (Make `pin!()` more foolproof.) - rust-lang/rust#159460 (Do not mark unnormalized const aliases as rigid when normalizing param env) - rust-lang/rust#159529 (Add regression test for nested replacement ranges in `collect_tokens`) - rust-lang/rust#159571 (Remove unused bundled library lookup for the local crate) - rust-lang/rust#159585 (Minor `TokenStream` improvements) - rust-lang/rust#159586 (Separate `InterpCx` usage by `ConstAnalysis` phases) - rust-lang/rust#159602 (Remove `ItemLike`) - rust-lang/rust#159603 (Clarify `push_stream`/`push_tree`) Failed merges: - rust-lang/rust#159590 (Remove some dead code)
It has some shortcomings. Details in individual commits.
r? @petrochenkov