Give error when an identifier was used like a function
name or a value was expected and the identifier exists
but it belongs to a different namespace.
gcc/rust/ChangeLog:
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
called error function.
gcc/testsuite/ChangeLog:
* rust/compile/found_struct.rs: New test.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
if (variant.get_variant_type () != TyTy::VariantDef::VariantType::TUPLE)
{
rust_error_at (
- call.get_locus (),
+ call.get_locus (), ErrorCode ("E0423"),
"expected function, tuple struct or tuple variant, found struct %<%s%>",
type.get_name ().c_str ());
return;
--- /dev/null
+// https://doc.rust-lang.org/error_codes/E0423.html
+#![allow(unused)]
+fn main() {
+ struct Foo {
+ a: bool,
+ };
+
+ let f = Foo(); // { dg-error "expected function, tuple struct or tuple variant, found struct .Foo." }
+ // error: expected function, tuple struct or tuple variant, found `Foo`
+ // `Foo` is a struct name, but this expression uses it like a function name
+}