- 
        Couldn't load subscription status. 
- Fork 13.9k
Error on invalid signatures for interrupt ABIs #142633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on invalid signatures for interrupt ABIs #142633
Conversation
| These commits modify the  If this was unintentional then you should revert the changes before this PR is merged. | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
6c041ae    to
    6086486      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass of style nits, will doublecheck more closely a bit later, you can apply them now or wait until second pass
6086486    to
    411fce5      
    Compare
  
    | ☔ The latest upstream changes (presumably #142817) made this pull request unmergeable. Please resolve the merge conflicts. | 
411fce5    to
    aec1f72      
    Compare
  
    aec1f72    to
    32fbbc2      
    Compare
  
    | ast_passes_abi_must_not_have_return_type= | ||
| invalid signature for `extern {$abi}` function | ||
| .note = functions with the `"custom"` ABI cannot have a return type | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover
| .note = functions with the `"custom"` ABI cannot have a return type | |
| .note = functions with the "custom" ABI cannot have a return type | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, I left those unchanged easier but we can fold that into this PR. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, was this not new? GH UI may have fooled me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe this one was? but some others in that file were older. Anyway, it's all fixed now.
| // An `extern "custom"` function cannot be `async` and/or `gen`. | ||
| self.check_abi_is_not_coroutine(abi, sig); | ||
|  | ||
| // An `extern "custom"` function must have type `fn()`. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pedantic note: its type is unsafe extern "custom" fn(). and yes, you can have different implementations on unsafe fn() and fn().
don't actually change anything, I just couldn't resist noting.
| /// type. | ||
| fn check_custom_abi(&self, ctxt: FnCtxt, ident: &Ident, sig: &FnSig) { | ||
| /// Check that this function does not violate the constraints of its ABI. | ||
| fn check_abi(&self, abi: ExternAbi, ctxt: FnCtxt, ident: &Ident, sig: &FnSig) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find these check_this names to be slightly nondescript.
- sometimes they warn. sometimes they error.
- we specifically check only the signature.
| fn check_abi(&self, abi: ExternAbi, ctxt: FnCtxt, ident: &Ident, sig: &FnSig) { | |
| fn reject_invalid_abi_sig(&self, abi: ExternAbi, ctxt: FnCtxt, ident: &Ident, sig: &FnSig) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also be, at least, check_extern_fn_sig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some renaming. Most functions in that module do start with check_ so that is what I followed.
32fbbc2    to
    7d6e5aa      
    Compare
  
    | ☔ The latest upstream changes (presumably #142929) made this pull request unmergeable. Please resolve the merge conflicts. | 
7d6e5aa    to
    943d379      
    Compare
  
    | hell yeah. @bors r+ | 
…signature, r=workingjubilee Error on invalid signatures for interrupt ABIs We recently added `extern "custom"`, which must have type `fn()`. The various `extern "interrupt"` ABIs impose similar constraints on the signature of functions with that ABI: `x86-interrupt` should not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type. r? `@workingjubilee`
…signature, r=workingjubilee Error on invalid signatures for interrupt ABIs We recently added `extern "custom"`, which must have type `fn()`. The various `extern "interrupt"` ABIs impose similar constraints on the signature of functions with that ABI: `x86-interrupt` should not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type. r? ``@workingjubilee``
Rollup of 15 pull requests Successful merges: - #135731 (Implement parsing of pinned borrows) - #138780 (Add `#[loop_match]` for improved DFA codegen) - #142453 (Windows: make `read_dir` stop iterating after the first error is encountered) - #142633 (Error on invalid signatures for interrupt ABIs) - #142768 (Avoid a bitcast FFI call in transmuting) - #142825 (Port `#[track_caller]` to the new attribute system) - #142844 (Enable short-ice for Windows) - #142934 (Tweak `-Zmacro-stats` measurement.) - #142955 (Couple of test suite fixes for cg_clif) - #142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠) - #142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect) - #142982 (Corrected spelling mistake in c_str.rs) - #142983 (Taint body on invalid call ABI) - #142988 (Update wasm-component-ld to 0.5.14) - #142993 (Update cargo) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142633 - folkertdev:interrupt-abi-restrict-signature, r=workingjubilee Error on invalid signatures for interrupt ABIs We recently added `extern "custom"`, which must have type `fn()`. The various `extern "interrupt"` ABIs impose similar constraints on the signature of functions with that ABI: `x86-interrupt` should not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type. r? ```@workingjubilee```
Rollup of 15 pull requests Successful merges: - rust-lang/rust#135731 (Implement parsing of pinned borrows) - rust-lang/rust#138780 (Add `#[loop_match]` for improved DFA codegen) - rust-lang/rust#142453 (Windows: make `read_dir` stop iterating after the first error is encountered) - rust-lang/rust#142633 (Error on invalid signatures for interrupt ABIs) - rust-lang/rust#142768 (Avoid a bitcast FFI call in transmuting) - rust-lang/rust#142825 (Port `#[track_caller]` to the new attribute system) - rust-lang/rust#142844 (Enable short-ice for Windows) - rust-lang/rust#142934 (Tweak `-Zmacro-stats` measurement.) - rust-lang/rust#142955 (Couple of test suite fixes for cg_clif) - rust-lang/rust#142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠) - rust-lang/rust#142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect) - rust-lang/rust#142982 (Corrected spelling mistake in c_str.rs) - rust-lang/rust#142983 (Taint body on invalid call ABI) - rust-lang/rust#142988 (Update wasm-component-ld to 0.5.14) - rust-lang/rust#142993 (Update cargo) r? `@ghost` `@rustbot` modify labels: rollup
| ast_passes_abi_must_not_have_return_type= | ||
| invalid signature for `extern {$abi}` function | ||
| .note = functions with the "custom" ABI cannot have a return type | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, missed this.
…kingjubilee Rollup of 15 pull requests Successful merges: - rust-lang#135731 (Implement parsing of pinned borrows) - rust-lang#138780 (Add `#[loop_match]` for improved DFA codegen) - rust-lang#142453 (Windows: make `read_dir` stop iterating after the first error is encountered) - rust-lang#142633 (Error on invalid signatures for interrupt ABIs) - rust-lang#142768 (Avoid a bitcast FFI call in transmuting) - rust-lang#142825 (Port `#[track_caller]` to the new attribute system) - rust-lang#142844 (Enable short-ice for Windows) - rust-lang#142934 (Tweak `-Zmacro-stats` measurement.) - rust-lang#142955 (Couple of test suite fixes for cg_clif) - rust-lang#142977 (rustdoc: Don't mark `#[target_feature]` functions as ⚠) - rust-lang#142980 (Reduce mismatched-lifetime-syntaxes suggestions to MaybeIncorrect) - rust-lang#142982 (Corrected spelling mistake in c_str.rs) - rust-lang#142983 (Taint body on invalid call ABI) - rust-lang#142988 (Update wasm-component-ld to 0.5.14) - rust-lang#142993 (Update cargo) r? `@ghost` `@rustbot` modify labels: rollup
…rn-nevermore, r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang#143072
…rn-nevermore, r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang#143072
…rn-nevermore, r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang#143072
…rn-nevermore, r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang#143072
…ore, r=davidtwco compiler: Allow `extern "interrupt" fn() -> !` While reviewing rust-lang/rust#142633 I overlooked a few details because I was kind of excited. - Fixes rust-lang/rust#143072
We recently added
extern "custom", which must have typefn(). The variousextern "interrupt"ABIs impose similar constraints on the signature of functions with that ABI:x86-interruptshould not have a return type (linting on the exact argument types is left as future work), and the other interrupt ABIs cannot have any parameters or a return type.r? @workingjubilee
Closes #132841