diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 30fb5f4d5d8..e571fc8ea0c 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -302,8 +302,9 @@ Attribute::get_traits_to_derive () auto word = static_cast (meta_item); // Convert current word to path current = std::make_unique ( - AST::MetaItemPath ( - AST::SimplePath (word->get_ident ()))); + AST::MetaItemPath (AST::SimplePath::from_str ( + word->get_ident ().as_string (), + word->get_locus ()))); auto path = static_cast (current.get ()); diff --git a/gcc/testsuite/rust/compile/issue-4433.rs b/gcc/testsuite/rust/compile/issue-4433.rs new file mode 100644 index 00000000000..37f829e0dcf --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-4433.rs @@ -0,0 +1,19 @@ +// { dg-options "-frust-incomplete-and-experimental-compiler-do-not-use" } +#![feature(no_core)] +#![no_core] + +#[derive(Toto)] // { dg-error "macro not found" } +// { dg-error "could not resolve trait" "" { target *-*-* } .-1 } +struct Test {} + +#[derive( + Happy, // { dg-error "macro not found" } + // { dg-error "could not resolve trait" "" { target *-*-* } .-1 } + Birthday // { dg-error "macro not found" } + // { dg-error "could not resolve trait" "" { target *-*-* } .-1 } +)] +struct MultiLine {} + +#[derive(One, Two)] // { dg-error "macro not found" } +// { dg-error "could not resolve trait" "" { target *-*-* } .-1 } +struct SingleLine {} \ No newline at end of file