Repository navigation
Allow attributes in function trait parameters #164595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #![feature(named_fn_trait_parameters)] | ||
|
|
||
| fn f1(f: impl Fn(#[cfg(false)] x: u8)) { f() } | ||
|
JonathanBrouwer marked this conversation as resolved.
Resolved
|
||
| fn f2(_: impl Fn(#[inline] x: u8)) {} | ||
| //~^ ERROR the `inline` attribute cannot be used on function params | ||
| //~| ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
| fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} | ||
| //~^ ERROR the `inline` attribute cannot be used on function params | ||
| //~| ERROR: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
| fn f4(_: impl Fn(/** */ x: u8)) {} | ||
| //~^ ERROR documentation comments cannot be applied to function parameters | ||
|
|
||
| fn f5(_: impl Fn(#[forbid(non_snake_case)] NON_SNAKE: u8)) {} | ||
| fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} | ||
| //~^ ERROR `gen` is a keyword in the 2024 edition [keyword_idents_2024] | ||
| //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! | ||
| fn f7(_: impl Fn(#[allow(keyword_idents_2024)] gen: u8)) {} | ||
| fn f8(_: fn(#[rustc_splat] a: usize)) {} | ||
| //~^ ERROR the `rustc_splat` attribute is an experimental feature | ||
|
|
||
|
|
||
|
|
||
| fn main(){} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| error: `gen` is a keyword in the 2024 edition | ||
| --> $DIR/fn-trait-use-named-params.rs:14:49 | ||
| | | ||
| LL | fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} | ||
| | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` | ||
| | | ||
| = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! | ||
| = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/gen-keyword.html> | ||
| note: the lint level is defined here | ||
| --> $DIR/fn-trait-use-named-params.rs:14:27 | ||
| | | ||
| LL | fn f6(_: impl Fn(#[forbid(keyword_idents_2024)] gen: u8)) {} | ||
| | ^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
| --> $DIR/fn-trait-use-named-params.rs:4:18 | ||
| | | ||
| LL | fn f2(_: impl Fn(#[inline] x: u8)) {} | ||
| | ^^^^^^^^^ | ||
|
|
||
| error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
| --> $DIR/fn-trait-use-named-params.rs:7:35 | ||
| | | ||
| LL | fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} | ||
| | ^^^^^^ | ||
|
|
||
| error: documentation comments cannot be applied to function parameters | ||
| --> $DIR/fn-trait-use-named-params.rs:10:18 | ||
| | | ||
| LL | fn f4(_: impl Fn(/** */ x: u8)) {} | ||
| | ^^^^^^ doc comments are not allowed here | ||
|
|
||
| error: the `inline` attribute cannot be used on function params | ||
| --> $DIR/fn-trait-use-named-params.rs:4:20 | ||
| | | ||
| LL | fn f2(_: impl Fn(#[inline] x: u8)) {} | ||
| | ^^^^^^ | ||
| | | ||
| = help: the `inline` attribute can only be applied to functions | ||
|
|
||
| error: the `inline` attribute cannot be used on function params | ||
| --> $DIR/fn-trait-use-named-params.rs:7:35 | ||
| | | ||
| LL | fn f3(_: impl Fn(#[cfg_attr(true, inline)] a1: usize)) {} | ||
| | ^^^^^^ | ||
| | | ||
| = help: the `inline` attribute can only be applied to functions | ||
|
|
||
| error[E0658]: the `rustc_splat` attribute is an experimental feature | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok this error is actually kinda terrible, maybe we should split the feature or find some other way to improve it...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you mean this error per chance? fn f7(_: impl Fn(#[inline] u8)) {}
//~^ ERROR named parameters in parenthesized generic argument lists are experimentalI feel like splitting the feature would make sense? Don't know the process for that though.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just made a PR yesterday that improves this error slightly: |
||
| --> $DIR/fn-trait-use-named-params.rs:18:15 | ||
| | | ||
| LL | fn f8(_: fn(#[rustc_splat] a: usize)) {} | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: see issue #153629 <https://github.com/rust-lang/rust/issues/153629> for more information | ||
| = help: add `#![feature(splat)]` to the crate attributes to enable | ||
| = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
| = note: the `rustc_splat` attribute is experimental | ||
|
|
||
| error: aborting due to 7 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0658`. | ||
Uh oh!
There was an error while loading. Please reload this page.