-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Properly enforce the "patterns aren't allowed in foreign functions" rule #35015
Conversation
Started crater run. |
PR looks good, but I'd like to see the results of the crater run so as to decide if this should be a warning or what. |
Hm, if we make the plain |
Crater run failed for some reason. =( |
Trying to restart this crater run. |
Argh, sorry, that took a while. Here was the result: https://gist.github.com/nikomatsakis/47dea4e98ffa9d3f350838602cc2a080
Of those 6 regressions, only So, per rust-lang/rfcs#1589, So I'd be happy to land this change without a lint warning, but we are still missing a few things:
|
…heck Apply the same check to function pointer types
@nikomatsakis |
@petrochenkov great! @bors r+ |
📌 Commit 5c88efc has been approved by |
Properly enforce the "patterns aren't allowed in foreign functions" rule Cases like `arg @ PATTERN` or `mut arg` were missing. Apply the same rule to function pointer types. Closes #35203 [breaking-change], no breakage in sane code is expected though r? @nikomatsakis This is somewhat related to rust-lang/rfcs#1685 (cc @matklad). The goal is to eventually support full pattern syntax where it makes sense (function body may present) and to support *only* the following forms - `TYPE`, `ident: TYPE`, `_: TYPE` - where patterns don't make sense (function body doesn't present), i.e. in foreign functions and function pointer types.
Prohibit patterns in trait methods without bodies They are not properly type checked ```rust trait Tr { fn f(&a: u8); // <- This compiles } ``` , mostly rejected by the parser already and generally don't make much sense. This PR is kind of a missing part of rust-lang#35015. Needs crater run. cc rust-lang#35078 (comment) rust-lang#35015 rust-lang/rfcs#1685 rust-lang#35203 r? @eddyb
Prohibit patterns in trait methods without bodies They are not properly type checked ```rust trait Tr { fn f(&a: u8); // <- This compiles } ``` , mostly rejected by the parser already and generally don't make much sense. This PR is kind of a missing part of #35015. Given the [statistics from crater](#37378 (comment)), the effect of this PR is mostly equivalent to improving `unused_mut` lint. cc #35078 (comment) #35015 rust-lang/rfcs#1685 #35203 r? @eddyb
Cases like
arg @ PATTERN
ormut arg
were missing.Apply the same rule to function pointer types.
Closes #35203
[breaking-change], no breakage in sane code is expected though
r? @nikomatsakis
This is somewhat related to rust-lang/rfcs#1685 (cc @matklad).
The goal is to eventually support full pattern syntax where it makes sense (function body may present) and to support only the following forms -
TYPE
,ident: TYPE
,_: TYPE
- where patterns don't make sense (function body doesn't present), i.e. in foreign functions and function pointer types.