We cannot resolve N + 1 a this stage since N has no default and is const
generic, rustc makes a more precise error diag here but our one is
completely fine for now.
Fixes Rust-GCC#4302
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc: use error_mark_node
gcc/testsuite/ChangeLog:
* rust/compile/issue-4302.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
auto d = lookup->destructure ();
rust_assert (d->get_kind () == TyTy::TypeKind::CONST);
auto c = d->as_const_type ();
- rust_assert (c->const_kind () == TyTy::BaseConstType::ConstKind::Value);
+ if (c->const_kind () != TyTy::BaseConstType::ConstKind::Value)
+ return error_mark_node;
+
auto val = static_cast<TyTy::ConstValueType *> (c);
return val->get_value ();
}
--- /dev/null
+#![feature(no_core, intrinsics, staged_api, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+pub struct Foo<const N: usize>;
+
+pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
+ // { dg-error "failed to resolve const expression" "" { target *-*-* } .-1 }
+ Foo
+}