The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.
Fixes #3036
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
* resolve/rust-ast-resolve-type.h: likewise
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3036.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
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 ())
{}
void visit (AST::NeverType &type) override;
+ void visit (AST::TupleType &type) override;
+
private:
ResolveTypeToCanonicalPath ();
--- /dev/null
+#[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() -> () {
+ ()
+ }
+}
issue-3139-1.rs
issue-3139-2.rs
issue-3139-3.rs
+issue-3036.rs