Do not call fn_sig on non-functions.#105201
Merged
bors merged 1 commit intorust-lang:masterfrom Dec 4, 2022
Merged
Conversation
Collaborator
|
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
Member
|
Does this also fix #89271 ? |
Contributor
Author
|
Yes. |
compiler-errors
approved these changes
Dec 3, 2022
Contributor
compiler-errors
left a comment
There was a problem hiding this comment.
r=me comment addressed or not
| // Do not call `fn_sig` on non-functions. | ||
| if !matches!( | ||
| self.tcx.def_kind(def_id), | ||
| DefKind::Fn | DefKind::AssocFn | DefKind::Variant | DefKind::Ctor(..) |
Contributor
There was a problem hiding this comment.
Hm, what about closures? Side-note, there's DefKind::is_fn_like, but it's slightly different that this case... Maybe worth checking use-cases and syncing them up.
Contributor
There was a problem hiding this comment.
Wait, closures make no sense -- they have no where clauses, lol.
Contributor
Author
There was a problem hiding this comment.
Calling fn_sig on closures and generators ICEs too.
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 3, 2022
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#104199 (Keep track of the start of the argument block of a closure) - rust-lang#105050 (Remove useless borrows and derefs) - rust-lang#105153 (Create a hacky fail-fast mode that stops tests at the first failure) - rust-lang#105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`) - rust-lang#105193 (Disable coverage instrumentation for naked functions) - rust-lang#105200 (Remove useless filter in unused extern crate check.) - rust-lang#105201 (Do not call fn_sig on non-functions.) - rust-lang#105208 (Add AmbiguityError for inconsistent resolution for an import) - rust-lang#105214 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Dec 6, 2022
…fn-ptr-arg, r=cjgillot Point at args in associated const fn pointers Tiny follow-up to rust-lang#105201, not so sure it's worth it but 🤷 The UI test example is a bit more compelling when it's `GlUniformScalar::FACTORY` r? `@cjgillot`
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 26, 2022
…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. Fixes rust-lang#105594. r? `@cjgillot`
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Dec 28, 2022
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/rust#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/rust#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. Fixes #105594. r? `@cjgillot`
Aaron1011
pushed a commit
to Aaron1011/rust
that referenced
this pull request
Jan 6, 2023
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#104199 (Keep track of the start of the argument block of a closure) - rust-lang#105050 (Remove useless borrows and derefs) - rust-lang#105153 (Create a hacky fail-fast mode that stops tests at the first failure) - rust-lang#105164 (Restore `use` suggestion for `dyn` method call requiring `Sized`) - rust-lang#105193 (Disable coverage instrumentation for naked functions) - rust-lang#105200 (Remove useless filter in unused extern crate check.) - rust-lang#105201 (Do not call fn_sig on non-functions.) - rust-lang#105208 (Add AmbiguityError for inconsistent resolution for an import) - rust-lang#105214 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #105040
Fixes #89271