Uh oh!
There was an error while loading. Please reload this page.
Don't perform invalid checks in codegen_attrs - #105605
Conversation
bors
commented
Dec 14, 2022
☔ The latest upstream changes (presumably #105667) made this pull request unmergeable. Please resolve the merge conflicts. |
a8f3ba1 to
31dafc0Comparecollectcodegen_attrsSome attributes are only valid on function items. When checking these attributes, codegen_attrs previously sometimes called `fn_sig` on the item they were attached to without first ensuring that the item was a function. This led to an ICE (rust-lang#105594), since `fn_sig` can only be called on functions. After this change, we skip calling `fn_sig` if the item the attribute is attached to must be a function but invalidly isn't, because `check_attr` will reject such cases without codegen_attrs's intervention.
31dafc0 to
fc3bcf1CompareUh oh!
There was an error while loading. Please reload this page.
74018c2 to
47b6426CompareThere's a bit of a backwards compatibility hazard here, in that |
cjgillot
commented
Dec 25, 2022
The assertion @bors r+ |
bors
commented
Dec 25, 2022
bors
commented
Dec 26, 2022
⌛ Testing commit 47b6426 with merge c29f2720036ecf11a7b77c6e666da43436e59cf1... |
bors
commented
Dec 26, 2022
💔 Test failed - checks-actions |
rust-log-analyzer
commented
Dec 26, 2022
cjgillot
commented
Dec 26, 2022
@bors retry |
bors
commented
Dec 26, 2022
bors
commented
Dec 26, 2022
☀️ Test successful - checks-actions |
rust-timer
commented
Dec 26, 2022
Finished benchmarking commit (f206533): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
…r=cjgillot Don't perform invalid checks in `codegen_attrs` The attributes `#[track_caller]` and `#[cmse_nonsecure_entry]` are only valid on functions. When validating one of these attributes, codegen_attrs previously called `fn_sig`, [which can only be used on functions](rust-lang#105201), on the item the attribute was attached to, assuming that the item was a function without checking. This led to [ICEs in situations where the attribute was incorrectly used on non-functions](rust-lang#105594). With this change, we skip calling `fn_sig` if the item the attribute is attached to must be a function but isn't, because `check_attr` will reject such cases without codegen_attrs's intervention. As a side note, some of the attributes in codegen_attrs are only valid on functions, but that property isn't actually checked. I'm planning to fix that in a follow up PR since it's a behavior change that will need to be validated rather than an obvious bugfix. Thankfully, all the attributes like that I've found so far are unstable. Fixesrust-lang#105594. r? `@cjgillot`
The attributes
#[track_caller]and#[cmse_nonsecure_entry]are only valid on functions. When validating one of these attributes, codegen_attrs previously calledfn_sig, which can only be used on functions, on the item the attribute was attached to, assuming that the item was a function without checking. This led to ICEs in situations where the attribute was incorrectly used on non-functions.With this change, we skip calling
fn_sigif the item the attribute is attached to must be a function but isn't, becausecheck_attrwill reject such cases without codegen_attrs's intervention.As a side note, some of the attributes in codegen_attrs are only valid on functions, but that property isn't actually checked. I'm planning to fix that in a follow up PR since it's a behavior change that will need to be validated rather than an obvious bugfix. Thankfully, all the attributes like that I've found so far are unstable.
Fixes#105594.
r? @cjgillot