diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc index e93515811ae4..15ae8db9389e 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.cc +++ b/gcc/rust/resolve/rust-ast-resolve-type.cc @@ -507,6 +507,15 @@ ResolveTypeToCanonicalPath::visit (AST::NeverType &type) result = CanonicalPath::new_seg (type.get_node_id (), "!"); } +void +ResolveTypeToCanonicalPath::visit (AST::TupleType &type) +{ + if (!type.is_unit_type ()) + rust_unreachable (); + + result = CanonicalPath::new_seg (type.get_node_id (), "()"); +} + ResolveTypeToCanonicalPath::ResolveTypeToCanonicalPath () : ResolverBase (), result (CanonicalPath::create_empty ()) {} diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h index 1df0f2605cd1..50dd890c4e31 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.h +++ b/gcc/rust/resolve/rust-ast-resolve-type.h @@ -248,6 +248,8 @@ class ResolveTypeToCanonicalPath : public ResolverBase void visit (AST::NeverType &type) override; + void visit (AST::TupleType &type) override; + private: ResolveTypeToCanonicalPath (); diff --git a/gcc/testsuite/rust/compile/issue-3036.rs b/gcc/testsuite/rust/compile/issue-3036.rs new file mode 100644 index 000000000000..4418ccc04cb9 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3036.rs @@ -0,0 +1,14 @@ +#[lang = "sized"] +trait Sized {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Default: Sized { + #[stable(feature = "rust1", since = "1.0.0")] + fn default() -> Self; +} + +impl Default for () { + fn default() -> () { + () + } +} diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index bfb51fd7fee9..50781e56b85e 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -252,3 +252,4 @@ issue-3082.rs issue-3139-1.rs issue-3139-2.rs issue-3139-3.rs +issue-3036.rs