From 9746832c0603ff9ca2427813d19009808cb6a6cb Mon Sep 17 00:00:00 2001 From: loikki <851651-loikki@users.noreply.gitlab.com> Date: Thu, 25 Jul 2024 16:57:58 +0200 Subject: [PATCH 1/5] Derive FromParam for Enum #2826 --- core/codegen/src/derive/from_param.rs | 43 +++++++++++++++++++++++++++ core/codegen/src/derive/mod.rs | 1 + core/codegen/src/lib.rs | 22 ++++++++++++++ core/codegen/tests/from_param.rs | 18 +++++++++++ core/lib/src/request/mod.rs | 3 ++ 5 files changed, 87 insertions(+) create mode 100644 core/codegen/src/derive/from_param.rs create mode 100644 core/codegen/tests/from_param.rs diff --git a/core/codegen/src/derive/from_param.rs b/core/codegen/src/derive/from_param.rs new file mode 100644 index 0000000000..89b166ea2f --- /dev/null +++ b/core/codegen/src/derive/from_param.rs @@ -0,0 +1,43 @@ +use devise::Support; +use proc_macro2::TokenStream; +use quote::quote; +use devise::*; +use devise::ext::SpanDiagnosticExt; +use crate::exports::*; + +pub fn derive_from_param(input: proc_macro::TokenStream) -> TokenStream { + DeriveGenerator::build_for(input, quote!(impl<'a> #_request::FromParam<'a>)) + .support(Support::Enum) + .validator(ValidatorBuild::new() + .fields_validate(|_, fields| { + if !fields.is_empty() { + return Err(fields.span().error("Only empty enums are accepted")); + } + + Ok(()) + }) + ) + .inner_mapper(MapperBuild::new() + .enum_map(|_, data| { + let mut matches = quote!(); + + for field in data.variants() { + let field_name = &field; + matches.extend(quote!( + stringify!(#field_name) => Ok(Self::#field_name), + )) + } + + quote! { + type Error = &'a str; + fn from_param(param: &'a str) -> Result { + match param { + #matches + _ => Err("Failed to find enum") + } + } + } + }) + ) + .to_tokens() +} diff --git a/core/codegen/src/derive/mod.rs b/core/codegen/src/derive/mod.rs index 134279e733..ef77c74947 100644 --- a/core/codegen/src/derive/mod.rs +++ b/core/codegen/src/derive/mod.rs @@ -3,3 +3,4 @@ pub mod from_form; pub mod from_form_field; pub mod responder; pub mod uri_display; +pub mod from_param; diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs index 39401f1c5d..1902a49f18 100644 --- a/core/codegen/src/lib.rs +++ b/core/codegen/src/lib.rs @@ -774,6 +774,28 @@ pub fn derive_from_form(input: TokenStream) -> TokenStream { emit!(derive::from_form::derive_from_form(input)) } +/// Derive for the [`FromParam`] trait. +/// +/// The [`FromParam`] derive can be applied to enums with nullary +/// (zero-length) fields: +/// +/// ```rust +/// # #[macro_use] extern crate rocket; +/// # +/// #[derive(FromParam)] +/// enum MyParam { +/// A, +/// B, +/// } +/// ``` +/// +/// Now `MyParam` can be used in an endpoint and will accept either 'A' or 'B'. +/// +#[proc_macro_derive(FromParam)] +pub fn derive_from_param(input: TokenStream) -> TokenStream { + emit!(derive::from_param::derive_from_param(input)) +} + /// Derive for the [`Responder`] trait. /// /// The [`Responder`] derive can be applied to enums and structs with named diff --git a/core/codegen/tests/from_param.rs b/core/codegen/tests/from_param.rs new file mode 100644 index 0000000000..5df883fbe7 --- /dev/null +++ b/core/codegen/tests/from_param.rs @@ -0,0 +1,18 @@ +use rocket::request::FromParam; + +#[derive(Debug, FromParam, PartialEq)] +enum Test { + Test1, + Test2 +} + + + +#[test] +fn derive_from_param() { + let test1 = Test::from_param("Test1").expect("Should be valid"); + assert_eq!(test1, Test::Test1); + + let test2 = Test::from_param("Test2").expect("Should be valid"); + assert_eq!(test2, Test::Test2); +} diff --git a/core/lib/src/request/mod.rs b/core/lib/src/request/mod.rs index 0393f96b51..48ac79c7bd 100644 --- a/core/lib/src/request/mod.rs +++ b/core/lib/src/request/mod.rs @@ -12,6 +12,9 @@ pub use self::request::Request; pub use self::from_request::{FromRequest, Outcome}; pub use self::from_param::{FromParam, FromSegments}; +#[doc(hidden)] +pub use rocket_codegen::FromParam; + #[doc(inline)] pub use crate::response::flash::FlashMessage; From 9df9014c751a1984475c965766ba69347d486a0f Mon Sep 17 00:00:00 2001 From: loikki <851651-loikki@users.noreply.gitlab.com> Date: Fri, 2 Aug 2024 17:09:06 +0200 Subject: [PATCH 2/5] Apply suggestions --- core/codegen/src/derive/from_param.rs | 6 +++--- core/codegen/src/lib.rs | 5 ++++- core/codegen/tests/from_param.rs | 5 +++-- core/codegen/tests/ui-fail/from_param.rs | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 core/codegen/tests/ui-fail/from_param.rs diff --git a/core/codegen/src/derive/from_param.rs b/core/codegen/src/derive/from_param.rs index 89b166ea2f..9d42bde9ea 100644 --- a/core/codegen/src/derive/from_param.rs +++ b/core/codegen/src/derive/from_param.rs @@ -19,11 +19,11 @@ pub fn derive_from_param(input: proc_macro::TokenStream) -> TokenStream { ) .inner_mapper(MapperBuild::new() .enum_map(|_, data| { - let mut matches = quote!(); + let mut matches = vec![]; for field in data.variants() { let field_name = &field; - matches.extend(quote!( + matches.push(quote!( stringify!(#field_name) => Ok(Self::#field_name), )) } @@ -32,7 +32,7 @@ pub fn derive_from_param(input: proc_macro::TokenStream) -> TokenStream { type Error = &'a str; fn from_param(param: &'a str) -> Result { match param { - #matches + #(#matches)* _ => Err("Failed to find enum") } } diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs index 1902a49f18..9d75ca6ac2 100644 --- a/core/codegen/src/lib.rs +++ b/core/codegen/src/lib.rs @@ -782,6 +782,8 @@ pub fn derive_from_form(input: TokenStream) -> TokenStream { /// ```rust /// # #[macro_use] extern crate rocket; /// # +/// use rocket::request::FromParam; +/// /// #[derive(FromParam)] /// enum MyParam { /// A, @@ -789,7 +791,8 @@ pub fn derive_from_form(input: TokenStream) -> TokenStream { /// } /// ``` /// -/// Now `MyParam` can be used in an endpoint and will accept either 'A' or 'B'. +/// Now `MyParam` can be used in an endpoint and will accept either `A` or `B`. +/// [`FromParam`]: ../rocket/request/trait.FromParam.html /// #[proc_macro_derive(FromParam)] pub fn derive_from_param(input: TokenStream) -> TokenStream { diff --git a/core/codegen/tests/from_param.rs b/core/codegen/tests/from_param.rs index 5df883fbe7..6595e21b6c 100644 --- a/core/codegen/tests/from_param.rs +++ b/core/codegen/tests/from_param.rs @@ -6,8 +6,6 @@ enum Test { Test2 } - - #[test] fn derive_from_param() { let test1 = Test::from_param("Test1").expect("Should be valid"); @@ -15,4 +13,7 @@ fn derive_from_param() { let test2 = Test::from_param("Test2").expect("Should be valid"); assert_eq!(test2, Test::Test2); + + let test3 = Test::from_param("not_test"); + assert!(test3.is_err()) } diff --git a/core/codegen/tests/ui-fail/from_param.rs b/core/codegen/tests/ui-fail/from_param.rs new file mode 100644 index 0000000000..21168297f0 --- /dev/null +++ b/core/codegen/tests/ui-fail/from_param.rs @@ -0,0 +1,23 @@ +use rocket::request::FromParam; + +#[derive(FromParam)] +struct Foo1 { + a: String +} + +#[derive(FromParam)] +struct Foo2 {} + +#[derive(FromParam)] +enum Foo3 { + A(String), + B(String) +} + +#[derive(FromParam)] +enum Foo4 {} + +#[derive(FromForm)] +struct Foo5(usize); + +fn main() {} From 69dac9a936dc76ad8f9b81f6857f40e1e1f7225e Mon Sep 17 00:00:00 2001 From: loikki <851651-loikki@users.noreply.gitlab.com> Date: Fri, 2 Aug 2024 23:23:59 +0200 Subject: [PATCH 3/5] Correctly implement failed tests --- .../tests/ui-fail-stable/from_param.rs | 1 + .../tests/ui-fail-stable/from_param.stderr | 55 +++++++++++++++++++ core/codegen/tests/ui-fail/from_param.rs | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 120000 core/codegen/tests/ui-fail-stable/from_param.rs create mode 100644 core/codegen/tests/ui-fail-stable/from_param.stderr diff --git a/core/codegen/tests/ui-fail-stable/from_param.rs b/core/codegen/tests/ui-fail-stable/from_param.rs new file mode 120000 index 0000000000..fcbf79fca6 --- /dev/null +++ b/core/codegen/tests/ui-fail-stable/from_param.rs @@ -0,0 +1 @@ +../ui-fail/from_param.rs \ No newline at end of file diff --git a/core/codegen/tests/ui-fail-stable/from_param.stderr b/core/codegen/tests/ui-fail-stable/from_param.stderr new file mode 100644 index 0000000000..c4ef4ebfaf --- /dev/null +++ b/core/codegen/tests/ui-fail-stable/from_param.stderr @@ -0,0 +1,55 @@ +error: named structs are not supported + --> tests/ui-fail-stable/from_param.rs:4:1 + | +4 | struct Foo1 { + | ^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:3:10 + | +3 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: named structs are not supported + --> tests/ui-fail-stable/from_param.rs:9:1 + | +9 | struct Foo2 {} + | ^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:8:10 + | +8 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: Only empty enums are accepted + --> tests/ui-fail-stable/from_param.rs:13:6 + | +13 | A(String), + | ^^^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:11:10 + | +11 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: tuple structs are not supported + --> tests/ui-fail-stable/from_param.rs:21:1 + | +21 | struct Foo5(usize); + | ^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:20:10 + | +20 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail/from_param.rs b/core/codegen/tests/ui-fail/from_param.rs index 21168297f0..bfbe3edf1b 100644 --- a/core/codegen/tests/ui-fail/from_param.rs +++ b/core/codegen/tests/ui-fail/from_param.rs @@ -17,7 +17,7 @@ enum Foo3 { #[derive(FromParam)] enum Foo4 {} -#[derive(FromForm)] +#[derive(FromParam)] struct Foo5(usize); fn main() {} From 01f676230ad0519c805a758a3065f3c50cec46c4 Mon Sep 17 00:00:00 2001 From: loikki <851651-loikki@users.noreply.gitlab.com> Date: Sat, 3 Aug 2024 12:18:59 +0200 Subject: [PATCH 4/5] Add nightly ui-fail test + update ui-fail, add assert in doc string --- core/codegen/src/derive/from_param.rs | 1 - core/codegen/src/lib.rs | 2 + .../tests/ui-fail-nightly/from_param.rs | 1 + .../tests/ui-fail-nightly/from_param.stderr | 57 +++++++++++++++++++ .../tests/ui-fail-stable/from_param.stderr | 18 +++--- core/codegen/tests/ui-fail/from_param.rs | 5 +- 6 files changed, 71 insertions(+), 13 deletions(-) create mode 120000 core/codegen/tests/ui-fail-nightly/from_param.rs create mode 100644 core/codegen/tests/ui-fail-nightly/from_param.stderr diff --git a/core/codegen/src/derive/from_param.rs b/core/codegen/src/derive/from_param.rs index 9d42bde9ea..ac66e7c54f 100644 --- a/core/codegen/src/derive/from_param.rs +++ b/core/codegen/src/derive/from_param.rs @@ -13,7 +13,6 @@ pub fn derive_from_param(input: proc_macro::TokenStream) -> TokenStream { if !fields.is_empty() { return Err(fields.span().error("Only empty enums are accepted")); } - Ok(()) }) ) diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs index 9d75ca6ac2..f5217bc07b 100644 --- a/core/codegen/src/lib.rs +++ b/core/codegen/src/lib.rs @@ -789,6 +789,8 @@ pub fn derive_from_form(input: TokenStream) -> TokenStream { /// A, /// B, /// } +/// +/// assert_eq!(MyParam::from_param("A").unwrap(), MyParam::A); /// ``` /// /// Now `MyParam` can be used in an endpoint and will accept either `A` or `B`. diff --git a/core/codegen/tests/ui-fail-nightly/from_param.rs b/core/codegen/tests/ui-fail-nightly/from_param.rs new file mode 120000 index 0000000000..fcbf79fca6 --- /dev/null +++ b/core/codegen/tests/ui-fail-nightly/from_param.rs @@ -0,0 +1 @@ +../ui-fail/from_param.rs \ No newline at end of file diff --git a/core/codegen/tests/ui-fail-nightly/from_param.stderr b/core/codegen/tests/ui-fail-nightly/from_param.stderr new file mode 100644 index 0000000000..9bb79c62bf --- /dev/null +++ b/core/codegen/tests/ui-fail-nightly/from_param.stderr @@ -0,0 +1,57 @@ +error: named structs are not supported + --> tests/ui-fail-stable/from_param.rs:4:1 + | +4 | / struct Foo1 { +5 | | a: String +6 | | } + | |_^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:3:10 + | +3 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: named structs are not supported + --> tests/ui-fail-stable/from_param.rs:9:1 + | +9 | struct Foo2 {} + | ^^^^^^^^^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:8:10 + | +8 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: Only empty enums are accepted + --> tests/ui-fail-stable/from_param.rs:13:6 + | +13 | A(String), + | ^^^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:11:10 + | +11 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: tuple structs are not supported + --> tests/ui-fail-stable/from_param.rs:18:1 + | +18 | struct Foo4(usize); + | ^^^^^^^^^^^^^^^^^^^ + +error: [note] error occurred while deriving `FromParam` + --> tests/ui-fail-stable/from_param.rs:17:10 + | +17 | #[derive(FromParam)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-stable/from_param.stderr b/core/codegen/tests/ui-fail-stable/from_param.stderr index c4ef4ebfaf..9bb79c62bf 100644 --- a/core/codegen/tests/ui-fail-stable/from_param.stderr +++ b/core/codegen/tests/ui-fail-stable/from_param.stderr @@ -1,8 +1,10 @@ error: named structs are not supported --> tests/ui-fail-stable/from_param.rs:4:1 | -4 | struct Foo1 { - | ^^^^^^ +4 | / struct Foo1 { +5 | | a: String +6 | | } + | |_^ error: [note] error occurred while deriving `FromParam` --> tests/ui-fail-stable/from_param.rs:3:10 @@ -16,7 +18,7 @@ error: named structs are not supported --> tests/ui-fail-stable/from_param.rs:9:1 | 9 | struct Foo2 {} - | ^^^^^^ + | ^^^^^^^^^^^^^^ error: [note] error occurred while deriving `FromParam` --> tests/ui-fail-stable/from_param.rs:8:10 @@ -41,15 +43,15 @@ error: [note] error occurred while deriving `FromParam` = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) error: tuple structs are not supported - --> tests/ui-fail-stable/from_param.rs:21:1 + --> tests/ui-fail-stable/from_param.rs:18:1 | -21 | struct Foo5(usize); - | ^^^^^^ +18 | struct Foo4(usize); + | ^^^^^^^^^^^^^^^^^^^ error: [note] error occurred while deriving `FromParam` - --> tests/ui-fail-stable/from_param.rs:20:10 + --> tests/ui-fail-stable/from_param.rs:17:10 | -20 | #[derive(FromParam)] +17 | #[derive(FromParam)] | ^^^^^^^^^ | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail/from_param.rs b/core/codegen/tests/ui-fail/from_param.rs index bfbe3edf1b..45018a38d5 100644 --- a/core/codegen/tests/ui-fail/from_param.rs +++ b/core/codegen/tests/ui-fail/from_param.rs @@ -15,9 +15,6 @@ enum Foo3 { } #[derive(FromParam)] -enum Foo4 {} - -#[derive(FromParam)] -struct Foo5(usize); +struct Foo4(usize); fn main() {} From fe8506d3a7fd5de444e3ee54996816d6b6641f79 Mon Sep 17 00:00:00 2001 From: loikki <851651-loikki@users.noreply.gitlab.com> Date: Wed, 7 Aug 2024 21:44:13 +0200 Subject: [PATCH 5/5] Apply suggestions --- core/codegen/src/derive/from_param.rs | 15 ++++---- core/codegen/src/lib.rs | 10 ++++- core/codegen/tests/from_param.rs | 2 +- .../tests/ui-fail-nightly/from_param.stderr | 38 +++++++++---------- .../tests/ui-fail-stable/from_param.stderr | 2 +- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/core/codegen/src/derive/from_param.rs b/core/codegen/src/derive/from_param.rs index ac66e7c54f..8767128147 100644 --- a/core/codegen/src/derive/from_param.rs +++ b/core/codegen/src/derive/from_param.rs @@ -11,21 +11,22 @@ pub fn derive_from_param(input: proc_macro::TokenStream) -> TokenStream { .validator(ValidatorBuild::new() .fields_validate(|_, fields| { if !fields.is_empty() { - return Err(fields.span().error("Only empty enums are accepted")); + return Err( + fields.span().error("Only enums without data fields are supported") + ); } Ok(()) }) ) .inner_mapper(MapperBuild::new() .enum_map(|_, data| { - let mut matches = vec![]; - - for field in data.variants() { + let matches = data.variants().map(|field| { let field_name = &field; - matches.push(quote!( + quote!( stringify!(#field_name) => Ok(Self::#field_name), - )) - } + ) + + }); quote! { type Error = &'a str; diff --git a/core/codegen/src/lib.rs b/core/codegen/src/lib.rs index f5217bc07b..3d6b957c39 100644 --- a/core/codegen/src/lib.rs +++ b/core/codegen/src/lib.rs @@ -777,20 +777,26 @@ pub fn derive_from_form(input: TokenStream) -> TokenStream { /// Derive for the [`FromParam`] trait. /// /// The [`FromParam`] derive can be applied to enums with nullary -/// (zero-length) fields: +/// (zero-length) fields. To implement FromParam, the function matches each variant +/// to its stringified field name (case sensitive): /// /// ```rust /// # #[macro_use] extern crate rocket; /// # /// use rocket::request::FromParam; /// -/// #[derive(FromParam)] +/// #[derive(FromParam, Debug, PartialEq)] /// enum MyParam { /// A, /// B, /// } /// /// assert_eq!(MyParam::from_param("A").unwrap(), MyParam::A); +/// assert_eq!(MyParam::from_param("B").unwrap(), MyParam::B); +/// assert!(MyParam::from_param("a").is_err()); +/// assert!(MyParam::from_param("b").is_err()); +/// assert!(MyParam::from_param("c").is_err()); +/// assert!(MyParam::from_param("C").is_err()); /// ``` /// /// Now `MyParam` can be used in an endpoint and will accept either `A` or `B`. diff --git a/core/codegen/tests/from_param.rs b/core/codegen/tests/from_param.rs index 6595e21b6c..a753131619 100644 --- a/core/codegen/tests/from_param.rs +++ b/core/codegen/tests/from_param.rs @@ -15,5 +15,5 @@ fn derive_from_param() { assert_eq!(test2, Test::Test2); let test3 = Test::from_param("not_test"); - assert!(test3.is_err()) + assert!(test3.is_err()); } diff --git a/core/codegen/tests/ui-fail-nightly/from_param.stderr b/core/codegen/tests/ui-fail-nightly/from_param.stderr index 9bb79c62bf..697bb4e4d9 100644 --- a/core/codegen/tests/ui-fail-nightly/from_param.stderr +++ b/core/codegen/tests/ui-fail-nightly/from_param.stderr @@ -1,57 +1,53 @@ error: named structs are not supported - --> tests/ui-fail-stable/from_param.rs:4:1 + --> tests/ui-fail-nightly/from_param.rs:4:1 | 4 | / struct Foo1 { 5 | | a: String 6 | | } | |_^ - -error: [note] error occurred while deriving `FromParam` - --> tests/ui-fail-stable/from_param.rs:3:10 + | +note: error occurred while deriving `FromParam` + --> tests/ui-fail-nightly/from_param.rs:3:10 | 3 | #[derive(FromParam)] | ^^^^^^^^^ - | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) error: named structs are not supported - --> tests/ui-fail-stable/from_param.rs:9:1 + --> tests/ui-fail-nightly/from_param.rs:9:1 | 9 | struct Foo2 {} | ^^^^^^^^^^^^^^ - -error: [note] error occurred while deriving `FromParam` - --> tests/ui-fail-stable/from_param.rs:8:10 + | +note: error occurred while deriving `FromParam` + --> tests/ui-fail-nightly/from_param.rs:8:10 | 8 | #[derive(FromParam)] | ^^^^^^^^^ - | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) -error: Only empty enums are accepted - --> tests/ui-fail-stable/from_param.rs:13:6 +error: Only enums without data fields are supported + --> tests/ui-fail-nightly/from_param.rs:13:6 | 13 | A(String), | ^^^^^^^^ - -error: [note] error occurred while deriving `FromParam` - --> tests/ui-fail-stable/from_param.rs:11:10 + | +note: error occurred while deriving `FromParam` + --> tests/ui-fail-nightly/from_param.rs:11:10 | 11 | #[derive(FromParam)] | ^^^^^^^^^ - | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) error: tuple structs are not supported - --> tests/ui-fail-stable/from_param.rs:18:1 + --> tests/ui-fail-nightly/from_param.rs:18:1 | 18 | struct Foo4(usize); | ^^^^^^^^^^^^^^^^^^^ - -error: [note] error occurred while deriving `FromParam` - --> tests/ui-fail-stable/from_param.rs:17:10 + | +note: error occurred while deriving `FromParam` + --> tests/ui-fail-nightly/from_param.rs:17:10 | 17 | #[derive(FromParam)] | ^^^^^^^^^ - | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/core/codegen/tests/ui-fail-stable/from_param.stderr b/core/codegen/tests/ui-fail-stable/from_param.stderr index 9bb79c62bf..97a9e65ded 100644 --- a/core/codegen/tests/ui-fail-stable/from_param.stderr +++ b/core/codegen/tests/ui-fail-stable/from_param.stderr @@ -28,7 +28,7 @@ error: [note] error occurred while deriving `FromParam` | = note: this error originates in the derive macro `FromParam` (in Nightly builds, run with -Z macro-backtrace for more info) -error: Only empty enums are accepted +error: Only enums without data fields are supported --> tests/ui-fail-stable/from_param.rs:13:6 | 13 | A(String),