From 0efc299ce665c7af728c42273bf7b5c438ee5260 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 28 Jun 2026 10:43:11 +0200 Subject: [PATCH 1/8] Add `named_fn_trait_parameters` feature gate --- compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + .../feature-gate-named-fn-trait-parameters.rs | 7 +++++++ .../feature-gate-named-fn-trait-parameters.stderr | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs create mode 100644 tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index ebd57baac151e..34d1868f0446b 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -668,6 +668,8 @@ declare_features! ( (unstable, naked_functions_rustic_abi, "1.88.0", Some(138997)), /// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions. (unstable, naked_functions_target_feature, "1.86.0", Some(138568)), + /// Allows providing names to parameters of `impl Fn` etc + (unstable, named_fn_trait_parameters, "CURRENT_RUSTC_VERSION", Some(158499)), /// Allows specifying the as-needed link modifier (unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)), /// Allow negative trait implementations. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index a293e106bd914..b33492ff004e9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1384,6 +1384,7 @@ symbols! { naked_functions_rustic_abi, naked_functions_target_feature, name, + named_fn_trait_parameters, names, native_link_modifiers, native_link_modifiers_as_needed, diff --git a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs new file mode 100644 index 0000000000000..c679428db3dd2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs @@ -0,0 +1,7 @@ +fn parse_my_data( + data: &str, + log: impl Fn(msg: String), + //~^ ERROR `Trait(...)` syntax does not support named parameters +) { } + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr new file mode 100644 index 0000000000000..8dcd3cc521b6e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr @@ -0,0 +1,8 @@ +error: `Trait(...)` syntax does not support named parameters + --> $DIR/feature-gate-named-fn-trait-parameters.rs:3:18 + | +LL | log: impl Fn(msg: String), + | ^^^ help: remove the parameter name + +error: aborting due to 1 previous error + From 858e0640414b2cb07544c6081781fd2d0f2626fb Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 28 Jun 2026 11:00:12 +0200 Subject: [PATCH 2/8] Implement named fn trait parameters --- compiler/rustc_ast_passes/src/feature_gate.rs | 4 ++ compiler/rustc_parse/src/diagnostics.rs | 8 --- compiler/rustc_parse/src/parser/path.rs | 12 ++-- compiler/rustc_session/src/parse.rs | 2 +- .../feature-gate-named-fn-trait-parameters.rs | 2 +- ...ture-gate-named-fn-trait-parameters.stderr | 9 ++- .../fn-trait-use-named-params-issue-140169.rs | 8 +-- ...trait-use-named-params-issue-140169.stderr | 55 ++++++++++++------- ...hesized-type-arguments-ice-issue-122345.rs | 2 +- ...zed-type-arguments-ice-issue-122345.stderr | 16 ++++-- 10 files changed, 70 insertions(+), 48 deletions(-) diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 348e179018002..8641b334ff24b 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -512,6 +512,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { half_open_range_patterns_in_slices, "half-open range patterns in slices are unstable" ); + gate_all!( + named_fn_trait_parameters, + "named parameters in parenthesized generic argument lists are experimental" + ); // `associated_const_equality` will be stabilized as part of `min_generic_const_args`. for &span in spans.get(&sym::associated_const_equality).into_flat_iter() { diff --git a/compiler/rustc_parse/src/diagnostics.rs b/compiler/rustc_parse/src/diagnostics.rs index 238eebd73a0fa..1a9198742377d 100644 --- a/compiler/rustc_parse/src/diagnostics.rs +++ b/compiler/rustc_parse/src/diagnostics.rs @@ -2075,14 +2075,6 @@ pub(crate) struct ExpectedFnPathFoundFnKeyword { pub fn_token_span: Span, } -#[derive(Diagnostic)] -#[diag("`Trait(...)` syntax does not support named parameters")] -pub(crate) struct FnPathFoundNamedParams { - #[primary_span] - #[suggestion("remove the parameter name", applicability = "machine-applicable", code = "")] - pub named_param_span: Span, -} - #[derive(Diagnostic)] #[diag("`Trait(...)` syntax does not support c_variadic parameters")] pub(crate) struct PathFoundCVariadicParams { diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 066d4402d5fde..a0fb94db4924a 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -17,8 +17,8 @@ use super::{Parser, Restrictions, TokenType}; use crate::ast::{PatKind, TyKind}; use crate::diagnostics::{ self, AttributeOnEmptyType, AttributeOnGenericArg, ConstGenericWithoutBraces, - ConstGenericWithoutBracesSugg, FnPathFoundNamedParams, PathFoundAttributeInParams, - PathFoundCVariadicParams, PathSingleColon, PathTripleColon, + ConstGenericWithoutBracesSugg, PathFoundAttributeInParams, PathFoundCVariadicParams, + PathSingleColon, PathTripleColon, }; use crate::exp; use crate::parser::{ @@ -408,11 +408,11 @@ impl<'a> Parser<'a> { req_body: false, }; let param = p.parse_param_general(&mode, false, false); - param.map(move |param| { + param.map(|param| { if !matches!(param.pat.kind, PatKind::Missing) { - dcx.emit_err(FnPathFoundNamedParams { - named_param_span: param.pat.span, - }); + self.psess + .gated_spans + .gate(sym::named_fn_trait_parameters, param.pat.span); } if matches!(param.ty.kind, TyKind::CVarArgs) { dcx.emit_err(PathFoundCVariadicParams { span: param.pat.span }); diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 54058e9f5f046..0e79d220b3962 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -22,7 +22,7 @@ use crate::Session; use crate::lint::{Lint, LintId}; /// Collected spans during parsing for places where a certain feature was -/// used and should be feature gated accordingly in `check_crate`. +/// used and should be feature gated accordingly in `check_crate` in `rustc_ast_passes`. #[derive(Default)] pub struct GatedSpans { pub spans: Lock>>, diff --git a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs index c679428db3dd2..23307e798950f 100644 --- a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs +++ b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.rs @@ -1,7 +1,7 @@ fn parse_my_data( data: &str, log: impl Fn(msg: String), - //~^ ERROR `Trait(...)` syntax does not support named parameters + //~^ ERROR named parameters in parenthesized generic argument lists are experimental [E0658] ) { } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr index 8dcd3cc521b6e..d50966c9352b0 100644 --- a/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr +++ b/tests/ui/feature-gates/feature-gate-named-fn-trait-parameters.stderr @@ -1,8 +1,13 @@ -error: `Trait(...)` syntax does not support named parameters +error[E0658]: named parameters in parenthesized generic argument lists are experimental --> $DIR/feature-gate-named-fn-trait-parameters.rs:3:18 | LL | log: impl Fn(msg: String), - | ^^^ help: remove the parameter name + | ^^^ + | + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs b/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs index 218450abd4998..036627ae3d913 100644 --- a/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs +++ b/tests/ui/fn/fn-trait-use-named-params-issue-140169.rs @@ -1,9 +1,9 @@ fn f1(_: fn(a: u8)) {} -fn f2(_: impl Fn(u8, vvvv: u8)) {} //~ ERROR `Trait(...)` syntax does not support named parameters -fn f3(_: impl Fn(aaaa: u8, u8)) {} //~ ERROR `Trait(...)` syntax does not support named parameters +fn f2(_: impl Fn(u8, vvvv: u8)) {} //~ ERROR named parameters in parenthesized generic argument lists are experimental +fn f3(_: impl Fn(aaaa: u8, u8)) {} //~ ERROR named parameters in parenthesized generic argument lists are experimental fn f4(_: impl Fn(aaaa: u8, vvvv: u8)) {} -//~^ ERROR `Trait(...)` syntax does not support named parameters -//~| ERROR `Trait(...)` syntax does not support named parameters +//~^ ERROR named parameters in parenthesized generic argument lists are experimental +//~| ERROR named parameters in parenthesized generic argument lists are experimental fn f5(_: impl Fn(u8, ...)) {} //~^ ERROR `Trait(...)` syntax does not support c_variadic parameters fn f6(_: impl Fn(u8, #[allow(unused_attributes)] u8)) {} diff --git a/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr b/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr index b72d5b7b3bc48..ac7758e9d5373 100644 --- a/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr +++ b/tests/ui/fn/fn-trait-use-named-params-issue-140169.stderr @@ -1,38 +1,55 @@ -error: `Trait(...)` syntax does not support named parameters +error: `Trait(...)` syntax does not support c_variadic parameters + --> $DIR/fn-trait-use-named-params-issue-140169.rs:7:22 + | +LL | fn f5(_: impl Fn(u8, ...)) {} + | ^^^ help: remove the `...` + +error: `Trait(...)` syntax does not support attributes in parameters + --> $DIR/fn-trait-use-named-params-issue-140169.rs:9:22 + | +LL | fn f6(_: impl Fn(u8, #[allow(unused_attributes)] u8)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the attributes + +error[E0658]: named parameters in parenthesized generic argument lists are experimental --> $DIR/fn-trait-use-named-params-issue-140169.rs:2:22 | LL | fn f2(_: impl Fn(u8, vvvv: u8)) {} - | ^^^^ help: remove the parameter name + | ^^^^ + | + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: `Trait(...)` syntax does not support named parameters +error[E0658]: named parameters in parenthesized generic argument lists are experimental --> $DIR/fn-trait-use-named-params-issue-140169.rs:3:18 | LL | fn f3(_: impl Fn(aaaa: u8, u8)) {} - | ^^^^ help: remove the parameter name + | ^^^^ + | + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: `Trait(...)` syntax does not support named parameters +error[E0658]: named parameters in parenthesized generic argument lists are experimental --> $DIR/fn-trait-use-named-params-issue-140169.rs:4:18 | LL | fn f4(_: impl Fn(aaaa: u8, vvvv: u8)) {} - | ^^^^ help: remove the parameter name + | ^^^^ + | + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: `Trait(...)` syntax does not support named parameters +error[E0658]: named parameters in parenthesized generic argument lists are experimental --> $DIR/fn-trait-use-named-params-issue-140169.rs:4:28 | LL | fn f4(_: impl Fn(aaaa: u8, vvvv: u8)) {} - | ^^^^ help: remove the parameter name - -error: `Trait(...)` syntax does not support c_variadic parameters - --> $DIR/fn-trait-use-named-params-issue-140169.rs:7:22 + | ^^^^ | -LL | fn f5(_: impl Fn(u8, ...)) {} - | ^^^ help: remove the `...` - -error: `Trait(...)` syntax does not support attributes in parameters - --> $DIR/fn-trait-use-named-params-issue-140169.rs:9:22 - | -LL | fn f6(_: impl Fn(u8, #[allow(unused_attributes)] u8)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the attributes + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 6 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs index db25ce440893d..60d87bbe0bfdf 100644 --- a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs +++ b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs @@ -2,7 +2,7 @@ fn main() { unsafe { - dealloc(ptr2, Layout::(x: !)(1, 1)); //~ ERROR `Trait(...)` syntax does not support named parameters + dealloc(ptr2, Layout::(x: !)(1, 1)); //~ ERROR named parameters in parenthesized generic argument lists are experimental //~^ ERROR cannot find function `dealloc` in this scope [E0425] //~| ERROR cannot find value `ptr2` in this scope [E0425] //~| ERROR the `!` type is experimental [E0658] diff --git a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr index a083883af219f..1b76e0cd8abed 100644 --- a/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr +++ b/tests/ui/parser/diagnostics-parenthesized-type-arguments-ice-issue-122345.stderr @@ -1,9 +1,3 @@ -error: `Trait(...)` syntax does not support named parameters - --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:32 - | -LL | dealloc(ptr2, Layout::(x: !)(1, 1)); - | ^ help: remove the parameter name - error[E0425]: cannot find function `dealloc` in this scope --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:9 | @@ -21,6 +15,16 @@ error[E0425]: cannot find value `ptr2` in this scope LL | dealloc(ptr2, Layout::(x: !)(1, 1)); | ^^^^ not found in this scope +error[E0658]: named parameters in parenthesized generic argument lists are experimental + --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:32 + | +LL | dealloc(ptr2, Layout::(x: !)(1, 1)); + | ^ + | + = note: see issue #158499 for more information + = help: add `#![feature(named_fn_trait_parameters)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error[E0658]: the `!` type is experimental --> $DIR/diagnostics-parenthesized-type-arguments-ice-issue-122345.rs:5:35 | From e2a4a5849843b3795993478b0291642a5e8295b8 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 31 Jul 2026 14:54:21 +0200 Subject: [PATCH 3/8] Add test for named fn trait parameters --- tests/ui/fn/named-fn-trait-parameters.rs | 80 ++++++++++++++ tests/ui/fn/named-fn-trait-parameters.stderr | 110 +++++++++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 tests/ui/fn/named-fn-trait-parameters.rs create mode 100644 tests/ui/fn/named-fn-trait-parameters.stderr diff --git a/tests/ui/fn/named-fn-trait-parameters.rs b/tests/ui/fn/named-fn-trait-parameters.rs new file mode 100644 index 0000000000000..00b00b53a94d6 --- /dev/null +++ b/tests/ui/fn/named-fn-trait-parameters.rs @@ -0,0 +1,80 @@ +#![feature(named_fn_trait_parameters)] + +fn allowed( + data: &str, + f1: impl Fn(msg: String), + f2: impl Fn(_: String), + f3: impl Fn(String, msg: String), + f4: impl Fn(msg: String, String), + f5: impl Fn(duplicate_name: bool, duplicate_name: bool), + fg: F +) where F: Fn(msg: String) +{ } + + +// Patterns are semantically rejected +fn semantics( + pat1: impl Fn(1..3: bool), + //~^ ERROR expected type, found `1` + pat2: impl Fn((x, y): (bool, bool)), + //~^ ERROR unexpected token: `:` + pat3: impl Fn(Thing { a, b }: Thing), + //~^ ERROR expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + pat4: impl Fn(NoThing { a, b }: NoThing), + //~^ ERROR expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + pat5: impl Fn((((((x))))): bool), + //~^ ERROR unexpected token: `:` + + self1: impl Fn(self), + //~^ ERROR unexpected `self` parameter in function + self2: impl Fn(self, self), + //~^ ERROR unexpected `self` parameter in function + //~| ERROR unexpected `self` parameter in function + self3: impl Fn(bool, self), + //~^ ERROR unexpected `self` parameter in function + + // FIXME should be rejected + restricted_pat1: impl Fn(mut x: ()), + restricted_pat2: impl Fn(&x: ()), + restricted_pat3: impl Fn(&&x: ()), + restricted_pat4: impl Fn(false: ()), + restricted_pat5: impl Fn(&_: ()), + restricted_pat6: impl Fn(&true: ()), +) { } + +// Patterns are also syntactically rejected, but restricted patterns are not +#[cfg(false)] +fn syntax( + pat1: impl Fn(1..3: bool), + //~^ ERROR expected type, found `1` + pat2: impl Fn((x, y): (bool, bool)), + //~^ ERROR unexpected token: `:` + pat3: impl Fn(Thing { a, b }: Thing), + //~^ ERROR expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + pat4: impl Fn(NoThing { a, b }: NoThing), + //~^ ERROR expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + pat5: impl Fn((((((x))))): bool), + //~^ ERROR unexpected token: `:` + + self1: impl Fn(self), // FIXME should be accepted + //~^ ERROR unexpected `self` parameter in function + self2: impl Fn(self, self), + //~^ ERROR unexpected `self` parameter in function + //~| ERROR unexpected `self` parameter in function + self3: impl Fn(bool, self), + //~^ ERROR unexpected `self` parameter in function + + // These are correctly accepted, as to match the behaviour `fn` ptrs + restricted_pat1: impl Fn(mut x: ()), + restricted_pat2: impl Fn(&x: ()), + restricted_pat3: impl Fn(&&x: ()), + restricted_pat4: impl Fn(false: ()), + restricted_pat5: impl Fn(&_: ()), + restricted_pat6: impl Fn(&true: ()), +) { } + +struct Thing { a: bool, b: bool } + +fn main() { + +} diff --git a/tests/ui/fn/named-fn-trait-parameters.stderr b/tests/ui/fn/named-fn-trait-parameters.stderr new file mode 100644 index 0000000000000..fa583ec52c543 --- /dev/null +++ b/tests/ui/fn/named-fn-trait-parameters.stderr @@ -0,0 +1,110 @@ +error: expected type, found `1` + --> $DIR/named-fn-trait-parameters.rs:17:19 + | +LL | pat1: impl Fn(1..3: bool), + | ^ expected type + +error: unexpected token: `:` + --> $DIR/named-fn-trait-parameters.rs:19:25 + | +LL | pat2: impl Fn((x, y): (bool, bool)), + | ^ unexpected token after this + +error: expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + --> $DIR/named-fn-trait-parameters.rs:21:25 + | +LL | pat3: impl Fn(Thing { a, b }: Thing), + | ^ expected one of `!`, `(`, `+`, `::`, or `<` + +error: expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + --> $DIR/named-fn-trait-parameters.rs:23:27 + | +LL | pat4: impl Fn(NoThing { a, b }: NoThing), + | ^ expected one of `!`, `(`, `+`, `::`, or `<` + +error: unexpected token: `:` + --> $DIR/named-fn-trait-parameters.rs:25:30 + | +LL | pat5: impl Fn((((((x))))): bool), + | ^ unexpected token after this + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:28:20 + | +LL | self1: impl Fn(self), + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:30:20 + | +LL | self2: impl Fn(self, self), + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:30:26 + | +LL | self2: impl Fn(self, self), + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:33:26 + | +LL | self3: impl Fn(bool, self), + | ^^^^ must be the first parameter of an associated function + +error: expected type, found `1` + --> $DIR/named-fn-trait-parameters.rs:48:19 + | +LL | pat1: impl Fn(1..3: bool), + | ^ expected type + +error: unexpected token: `:` + --> $DIR/named-fn-trait-parameters.rs:50:25 + | +LL | pat2: impl Fn((x, y): (bool, bool)), + | ^ unexpected token after this + +error: expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + --> $DIR/named-fn-trait-parameters.rs:52:25 + | +LL | pat3: impl Fn(Thing { a, b }: Thing), + | ^ expected one of `!`, `(`, `+`, `::`, or `<` + +error: expected one of `!`, `(`, `+`, `::`, or `<`, found `{` + --> $DIR/named-fn-trait-parameters.rs:54:27 + | +LL | pat4: impl Fn(NoThing { a, b }: NoThing), + | ^ expected one of `!`, `(`, `+`, `::`, or `<` + +error: unexpected token: `:` + --> $DIR/named-fn-trait-parameters.rs:56:30 + | +LL | pat5: impl Fn((((((x))))): bool), + | ^ unexpected token after this + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:59:20 + | +LL | self1: impl Fn(self), // FIXME should be accepted + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:61:20 + | +LL | self2: impl Fn(self, self), + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:61:26 + | +LL | self2: impl Fn(self, self), + | ^^^^ must be the first parameter of an associated function + +error: unexpected `self` parameter in function + --> $DIR/named-fn-trait-parameters.rs:64:26 + | +LL | self3: impl Fn(bool, self), + | ^^^^ must be the first parameter of an associated function + +error: aborting due to 18 previous errors + From 6c901cee795a9ba7fc29b7e4792e87bc58b13e02 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 2 Aug 2026 12:19:51 +0200 Subject: [PATCH 4/8] Mark `named_fn_trait_parameters` as incomplete --- compiler/rustc_feature/src/unstable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 34d1868f0446b..9176fd47e69bf 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -669,7 +669,7 @@ declare_features! ( /// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions. (unstable, naked_functions_target_feature, "1.86.0", Some(138568)), /// Allows providing names to parameters of `impl Fn` etc - (unstable, named_fn_trait_parameters, "CURRENT_RUSTC_VERSION", Some(158499)), + (incomplete, named_fn_trait_parameters, "CURRENT_RUSTC_VERSION", Some(158499)), /// Allows specifying the as-needed link modifier (unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)), /// Allow negative trait implementations. From d43f980bfc14522b4513807438ddacb30870ce20 Mon Sep 17 00:00:00 2001 From: sjwang05 <63834813+sjwang05@users.noreply.github.com> Date: Mon, 29 Jun 2026 15:48:15 -0700 Subject: [PATCH 5/8] check if len of array const arg matches the expected len --- .../src/hir_ty_lowering/mod.rs | 25 ++++++++++-- tests/crashes/160553.rs | 26 +++++++++++++ .../mgca/array-const-arg-len-mismatch.rs | 39 +++++++++++++++++++ .../mgca/array-const-arg-len-mismatch.stderr | 32 +++++++++++++++ 4 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 tests/crashes/160553.rs create mode 100644 tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs create mode 100644 tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index fa3dca042ba0c..c590540914496 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2478,13 +2478,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ) -> Const<'tcx> { let tcx = self.tcx(); - let elem_ty = match ty.kind() { - ty::Array(elem_ty, _) => elem_ty, + let (elem_ty, len) = match ty.kind() { + ty::Array(elem_ty, len) => (elem_ty, len), ty::Error(e) => return Const::new_error(tcx, *e), _ => { let e = tcx .dcx() - .span_err(array_expr.span, format!("expected `{}`, found const array", ty)); + .span_err(array_expr.span, format!("expected `{ty}`, found const array")); return Const::new_error(tcx, e); } }; @@ -2495,6 +2495,25 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .map(|elem| self.lower_const_arg(elem, *elem_ty)) .collect::>(); + let len = tcx + .try_normalize_erasing_regions( + ty::TypingEnv::new(ty::ParamEnv::empty(), TypingMode::non_body_analysis()), + Unnormalized::new_wip(*len), + ) + .unwrap_or(*len); + if let Some(expected_len) = len.try_to_target_usize(tcx) + && expected_len != elems.len() as u64 + { + let e = tcx.dcx().span_err( + array_expr.span, + format!( + "expected array with {expected_len} elements, found {} elements", + array_expr.elems.len() + ), + ); + return Const::new_error(tcx, e); + } + let valtree = ty::ValTree::from_branches(tcx, elems); ty::Const::new_value(tcx, valtree, ty) diff --git a/tests/crashes/160553.rs b/tests/crashes/160553.rs new file mode 100644 index 0000000000000..faf993e102756 --- /dev/null +++ b/tests/crashes/160553.rs @@ -0,0 +1,26 @@ +//@ known-bug: #160553 +//@ compile-flags: -Copt-level=0 +#![allow(incomplete_features)] +#![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] +#![feature(generic_const_parameter_types)] + +trait Trait { + type const LEN: usize; +} + +struct S; +impl Trait for S { + type const LEN: usize = 2; +} + +fn foo::LEN]>() -> [u8; ::LEN] { + A +} + +fn bar() -> [u8; ::LEN] { + foo::() +} + +fn main() { + bar::(); +} diff --git a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs new file mode 100644 index 0000000000000..10b824fed4f36 --- /dev/null +++ b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs @@ -0,0 +1,39 @@ +//! Regression test for #155168 +//! +//! Ensure that providing an array const arg with the wrong number of elements +//! doesn't ICE or silently cause UB. +#![expect(incomplete_features)] +#![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] +#![feature(unsized_const_params, generic_const_parameter_types)] + +use std::marker::ConstParamTy_; + +fn foo() -> [T; N] { + M +} + +fn bar() {} + +trait Trait { + type const LEN: usize; +} + +struct S; +impl Trait for S { + type const LEN: usize = 3; +} + +fn baz::LEN]>() {} + +fn main() { + foo::(); + //~^ ERROR: expected array with 2 elements, found 0 elements + foo::(); + //~^ ERROR: expected array with 2 elements, found 3 elements + bar::<{ [] }>(); + //~^ ERROR: expected array with 2 elements, found 0 elements + bar::<{ [1, 2, 3] }>(); + //~^ ERROR: expected array with 2 elements, found 3 elements + baz::<{ [42] }>(); + //~^ ERROR: expected array with 3 elements, found 1 elements +} diff --git a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr new file mode 100644 index 0000000000000..42eea34bf6bc7 --- /dev/null +++ b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr @@ -0,0 +1,32 @@ +error: expected array with 2 elements, found 0 elements + --> $DIR/array-const-arg-len-mismatch.rs:29:20 + | +LL | foo::(); + | ^^ + +error: expected array with 2 elements, found 3 elements + --> $DIR/array-const-arg-len-mismatch.rs:31:20 + | +LL | foo::(); + | ^^^^^^^^^ + +error: expected array with 2 elements, found 0 elements + --> $DIR/array-const-arg-len-mismatch.rs:33:13 + | +LL | bar::<{ [] }>(); + | ^^ + +error: expected array with 2 elements, found 3 elements + --> $DIR/array-const-arg-len-mismatch.rs:35:13 + | +LL | bar::<{ [1, 2, 3] }>(); + | ^^^^^^^^^ + +error: expected array with 3 elements, found 1 elements + --> $DIR/array-const-arg-len-mismatch.rs:37:13 + | +LL | baz::<{ [42] }>(); + | ^^^^ + +error: aborting due to 5 previous errors + From fc6672ee1b69782187f5b58496b3507e12959f32 Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Fri, 7 Aug 2026 16:28:46 +0200 Subject: [PATCH 6/8] remove old update mechanism --- .github/workflows/dependencies.yml | 146 ----------------------------- src/tools/update-lockfile.sh | 18 ---- 2 files changed, 164 deletions(-) delete mode 100644 .github/workflows/dependencies.yml delete mode 100755 src/tools/update-lockfile.sh diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml deleted file mode 100644 index 77f94f2f12ba9..0000000000000 --- a/.github/workflows/dependencies.yml +++ /dev/null @@ -1,146 +0,0 @@ -# Automatically run `cargo update` periodically - ---- -name: Bump dependencies in Cargo.lock -on: - schedule: - # Run weekly - - cron: '0 0 * * Sun' - workflow_dispatch: - # Needed so we can run it manually -permissions: - contents: read -defaults: - run: - shell: bash -env: - # So cargo doesn't complain about unstable features - RUSTC_BOOTSTRAP: 1 - PR_TITLE: Weekly `cargo update` - PR_MESSAGE: | - Automation to keep dependencies in `Cargo.lock` current. - r? dep-bumps - - The following is the output from `cargo update`: - COMMIT_MESSAGE: "cargo update \n\n" - -jobs: - not-waiting-on-bors: - if: github.repository_owner == 'rust-lang' - name: skip if S-waiting-on-bors - runs-on: ubuntu-24.04 - steps: - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Fetch state and labels of PR - # Or exit successfully if PR does not exist - JSON=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json labels,state || exit 0) - STATE=$(echo "$JSON" | jq -r '.state') - WAITING_ON_BORS=$(echo "$JSON" | jq '.labels[] | any(.name == "S-waiting-on-bors"; .)') - - # Exit with error if open and S-waiting-on-bors - if [[ "$STATE" == "OPEN" && "$WAITING_ON_BORS" == "true" ]]; then - exit 1 - fi - - update: - if: github.repository_owner == 'rust-lang' - name: update dependencies - needs: not-waiting-on-bors - runs-on: ubuntu-24.04 - steps: - - name: checkout the source code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - submodules: recursive - - name: install the bootstrap toolchain - run: | - # Extract the stage0 version - TOOLCHAIN=$(awk -F= '{a[$1]=$2} END {print(a["compiler_version"] "-" a["compiler_date"])}' src/stage0) - # Install and set as default - rustup toolchain install --no-self-update --profile minimal $TOOLCHAIN - rustup default $TOOLCHAIN - - - name: cargo update - run: ./src/tools/update-lockfile.sh - - - name: upload Cargo.lock artifact for use in PR - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: Cargo-lock - path: | - Cargo.lock - library/Cargo.lock - src/tools/rustbook/Cargo.lock - retention-days: 1 - - name: upload cargo-update log artifact for use in PR - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 - with: - name: cargo-updates - path: cargo_update.log - retention-days: 1 - - pr: - if: github.repository_owner == 'rust-lang' - name: amend PR - needs: update - runs-on: ubuntu-24.04 - permissions: - contents: write - pull-requests: write - steps: - - name: checkout the source code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: download Cargo.lock from update job - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: Cargo-lock - - name: download cargo-update log from update job - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: cargo-updates - - - name: craft PR body and commit message - run: | - echo "${COMMIT_MESSAGE}" > commit.txt - cat cargo_update.log >> commit.txt - - echo "${PR_MESSAGE}" > body.md - echo '```txt' >> body.md - cat cargo_update.log >> body.md - echo '```' >> body.md - - - name: commit - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git switch --force-create cargo_update - git add ./Cargo.lock ./library/Cargo.lock ./src/tools/rustbook/Cargo.lock - git commit --no-verify --file=commit.txt - - - name: push - run: git push --no-verify --force --set-upstream origin cargo_update - - - name: edit existing open pull request - id: edit - # Don't fail job if we need to open new PR - continue-on-error: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Exit with error if PR is closed - STATE=$(gh pr view cargo_update --repo $GITHUB_REPOSITORY --json state --jq '.state') - if [[ "$STATE" != "OPEN" ]]; then - exit 1 - fi - - gh pr edit cargo_update --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY - - - name: open new pull request - # Only run if there wasn't an existing PR - if: steps.edit.outcome != 'success' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr create --title "${PR_TITLE}" --body-file body.md --repo $GITHUB_REPOSITORY diff --git a/src/tools/update-lockfile.sh b/src/tools/update-lockfile.sh deleted file mode 100755 index 123481b6b681c..0000000000000 --- a/src/tools/update-lockfile.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Updates the workspaces in `.`, `library` and `src/tools/rustbook` -# Logs are written to `cargo_update.log` -# Used as part of regular dependency bumps - -set -euo pipefail - -printf "\ncompiler & tools dependencies:" > cargo_update.log -# Remove first line that always just says "Updating crates.io index" -cargo update 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log -printf "\nlibrary dependencies:" >> cargo_update.log -cargo update --manifest-path library/Cargo.toml 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log -printf "\nrustbook dependencies:" >> cargo_update.log -cargo update --manifest-path src/tools/rustbook/Cargo.toml 2>&1 | sed '/crates.io index/d' | \ - tee -a cargo_update.log From 1a049129e6585178f900a6ff01daa0b80131014c Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Sat, 8 Aug 2026 14:30:27 +0330 Subject: [PATCH 7/8] Add regression test for cross-crate assoc const private field leak --- .../assoc-const-private-fields-99630.rs | 14 ++++++++++++++ .../auxiliary/assoc-const-private-fields.rs | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/rustdoc-html/inline_cross/assoc-const-private-fields-99630.rs create mode 100644 tests/rustdoc-html/inline_cross/auxiliary/assoc-const-private-fields.rs diff --git a/tests/rustdoc-html/inline_cross/assoc-const-private-fields-99630.rs b/tests/rustdoc-html/inline_cross/assoc-const-private-fields-99630.rs new file mode 100644 index 0000000000000..b37c11d607d21 --- /dev/null +++ b/tests/rustdoc-html/inline_cross/assoc-const-private-fields-99630.rs @@ -0,0 +1,14 @@ +//! Regression test for . +//! +//! Re-exporting a type from another crate must not leak the private fields used +//! in the initializer of one of its associated constants. + +//@ aux-build:assoc-const-private-fields.rs + +#![crate_name = "foo"] + +extern crate assoc_const_private_fields; + +//@ has foo/struct.HasPrivateFields.html +//@ matches - '//*[@id="associatedconstant.ASSOC"]' '^pub const ASSOC: HasPrivateFields$' +pub use assoc_const_private_fields::HasPrivateFields; diff --git a/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-private-fields.rs b/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-private-fields.rs new file mode 100644 index 0000000000000..42f838cf4fc6d --- /dev/null +++ b/tests/rustdoc-html/inline_cross/auxiliary/assoc-const-private-fields.rs @@ -0,0 +1,7 @@ +pub struct HasPrivateFields { + _private: (), +} + +impl HasPrivateFields { + pub const ASSOC: Self = Self { _private: () }; +} From acd2f653755fa89423dbf007320ff0b481d2cb5f Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sat, 8 Aug 2026 20:06:10 +0200 Subject: [PATCH 8/8] Add expected error messages to `autodiff_illegal.rs` --- tests/ui/autodiff/autodiff_illegal.rs | 7 ++- tests/ui/autodiff/autodiff_illegal.stderr | 56 +++++++++++++++++------ 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/tests/ui/autodiff/autodiff_illegal.rs b/tests/ui/autodiff/autodiff_illegal.rs index 6bb384cc87e8d..5143d26406d5b 100644 --- a/tests/ui/autodiff/autodiff_illegal.rs +++ b/tests/ui/autodiff/autodiff_illegal.rs @@ -47,15 +47,18 @@ pub fn f6(x: f64) { fn dummy() { #[autodiff_forward(df7, Dual)] + //~^ ERROR macro attributes on statements are unstable let mut x = 5; //~^ ERROR autodiff must be applied to function #[autodiff_forward(df7, Dual)] x = x + 3; - //~^^ ERROR attributes on expressions are experimental [E0658] - //~^^ ERROR autodiff must be applied to function + //~^^ ERROR attributes on expressions are experimental [E0658] + //~| ERROR macro attributes on expressions are unstable + //~^^^ ERROR autodiff must be applied to function #[autodiff_forward(df7, Dual)] + //~^ ERROR macro attributes on statements are unstable let add_one_v2 = |x: u32| -> u32 { x + 1 }; //~^ ERROR autodiff must be applied to function } diff --git a/tests/ui/autodiff/autodiff_illegal.stderr b/tests/ui/autodiff/autodiff_illegal.stderr index 848ae1155e9c4..f9f31c3b90a08 100644 --- a/tests/ui/autodiff/autodiff_illegal.stderr +++ b/tests/ui/autodiff/autodiff_illegal.stderr @@ -1,5 +1,5 @@ error[E0658]: attributes on expressions are experimental - --> $DIR/autodiff_illegal.rs:53:5 + --> $DIR/autodiff_illegal.rs:54:5 | LL | #[autodiff_forward(df7, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,26 +44,56 @@ error: Duplicated can not be used for this type LL | pub fn f6(x: f64) { | ^^^ +error[E0658]: macro attributes on statements are unstable + --> $DIR/autodiff_illegal.rs:49:5 + | +LL | #[autodiff_forward(df7, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54727 for more information + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error: autodiff must be applied to function - --> $DIR/autodiff_illegal.rs:50:5 + --> $DIR/autodiff_illegal.rs:51:5 | LL | let mut x = 5; | ^^^^^^^^^^^^^^ -error: autodiff must be applied to function +error[E0658]: macro attributes on expressions are unstable --> $DIR/autodiff_illegal.rs:54:5 | +LL | #[autodiff_forward(df7, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54727 for more information + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: autodiff must be applied to function + --> $DIR/autodiff_illegal.rs:55:5 + | LL | x = x + 3; | ^ +error[E0658]: macro attributes on statements are unstable + --> $DIR/autodiff_illegal.rs:60:5 + | +LL | #[autodiff_forward(df7, Dual)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54727 for more information + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error: autodiff must be applied to function - --> $DIR/autodiff_illegal.rs:59:5 + --> $DIR/autodiff_illegal.rs:62:5 | LL | let add_one_v2 = |x: u32| -> u32 { x + 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:65:1 + --> $DIR/autodiff_illegal.rs:68:1 | LL | / pub fn f7(x: f64) { LL | | @@ -72,7 +102,7 @@ LL | | } | |_^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:72:1 + --> $DIR/autodiff_illegal.rs:75:1 | LL | / pub fn f8(x: f64) { LL | | @@ -81,7 +111,7 @@ LL | | } | |_^ error: autodiff requires at least a name and mode - --> $DIR/autodiff_illegal.rs:79:1 + --> $DIR/autodiff_illegal.rs:82:1 | LL | / pub fn f9(x: f64) { LL | | @@ -90,7 +120,7 @@ LL | | } | |_^ error[E0428]: the name `fn_exists` is defined multiple times - --> $DIR/autodiff_illegal.rs:87:1 + --> $DIR/autodiff_illegal.rs:90:1 | LL | fn fn_exists() {} | -------------- previous definition of the value `fn_exists` here @@ -101,30 +131,30 @@ LL | #[autodiff_reverse(fn_exists, Active)] = note: `fn_exists` must be defined only once in the value namespace of this module error: did not recognize Activity: `Reverse` - --> $DIR/autodiff_illegal.rs:95:26 + --> $DIR/autodiff_illegal.rs:98:26 | LL | #[autodiff_reverse(df13, Reverse)] | ^^^^^^^ error: invalid return activity Active in Forward Mode - --> $DIR/autodiff_illegal.rs:131:1 + --> $DIR/autodiff_illegal.rs:134:1 | LL | #[autodiff_forward(df19, Dual, Active)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Dual in Reverse Mode - --> $DIR/autodiff_illegal.rs:137:1 + --> $DIR/autodiff_illegal.rs:140:1 | LL | #[autodiff_reverse(df20, Active, Dual)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid return activity Duplicated in Reverse Mode - --> $DIR/autodiff_illegal.rs:144:1 + --> $DIR/autodiff_illegal.rs:147:1 | LL | #[autodiff_reverse(df21, Active, Duplicated)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 18 previous errors +error: aborting due to 21 previous errors Some errors have detailed explanations: E0428, E0658. For more information about an error, try `rustc --explain E0428`.