public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Default type checking on CallExpr's to TyTy::ErrorType
@ 2022-06-08 11:47 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:fc5f8d746362a42adc52e538dec248bd2992a794

commit fc5f8d746362a42adc52e538dec248bd2992a794
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Tue Nov 2 11:48:06 2021 +0000

    Default type checking on CallExpr's to TyTy::ErrorType
    
    It is ok for type checking to error/fail on a construct within the crate,
    we can try our best to continue on to find as many errors as possible. To
    achieve this without running into nullptr's we can use the ErrorType node
    to signify an error. This also cleans up alot of noise in our error
    handling.

Diff:
---
 gcc/rust/typecheck/rust-tyty-call.h         | 3 ++-
 gcc/testsuite/rust/compile/func2.rs         | 2 --
 gcc/testsuite/rust/compile/func3.rs         | 2 --
 gcc/testsuite/rust/compile/tuple_struct1.rs | 2 --
 gcc/testsuite/rust/compile/tuple_struct2.rs | 2 --
 gcc/testsuite/rust/compile/tuple_struct3.rs | 2 --
 6 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/gcc/rust/typecheck/rust-tyty-call.h b/gcc/rust/typecheck/rust-tyty-call.h
index 9ff5f6f3934..c11fd4d6da6 100644
--- a/gcc/rust/typecheck/rust-tyty-call.h
+++ b/gcc/rust/typecheck/rust-tyty-call.h
@@ -71,7 +71,8 @@ public:
 private:
   TypeCheckCallExpr (HIR::CallExpr &c, TyTy::VariantDef &variant,
 		     Resolver::TypeCheckContext *context)
-    : resolved (nullptr), call (c), variant (variant), context (context),
+    : resolved (new TyTy::ErrorType (c.get_mappings ().get_hirid ())), call (c),
+      variant (variant), context (context),
       mappings (Analysis::Mappings::get ())
   {}
 
diff --git a/gcc/testsuite/rust/compile/func2.rs b/gcc/testsuite/rust/compile/func2.rs
index 219bbfe8152..0b8d999fec1 100644
--- a/gcc/testsuite/rust/compile/func2.rs
+++ b/gcc/testsuite/rust/compile/func2.rs
@@ -4,6 +4,4 @@ fn test(a: i32, b: i32) -> i32 {
 
 fn main() {
     let a = test(1); // { dg-error "unexpected number of arguments 1 expected 2" }
-    // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
-    // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
 }
diff --git a/gcc/testsuite/rust/compile/func3.rs b/gcc/testsuite/rust/compile/func3.rs
index 3ab374a97b4..2a329476118 100644
--- a/gcc/testsuite/rust/compile/func3.rs
+++ b/gcc/testsuite/rust/compile/func3.rs
@@ -6,6 +6,4 @@ fn main() {
     let a = test(1, true);
     // { dg-error "expected .i32. got .bool." "" { target *-*-* } .-1 }
     // { dg-error "Type Resolution failure on parameter" "" { target *-*-* } .-2 }
-    // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-3 }
-    // { dg-error "failed to type resolve expression" "" { target *-*-* } .-4 }
 }
diff --git a/gcc/testsuite/rust/compile/tuple_struct1.rs b/gcc/testsuite/rust/compile/tuple_struct1.rs
index c382909811d..2f4cb4a353b 100644
--- a/gcc/testsuite/rust/compile/tuple_struct1.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct1.rs
@@ -5,6 +5,4 @@ struct Foo {
 
 fn main() {
     let a = Foo(1, 2); // { dg-error "expected function, tuple struct or tuple variant, found struct 'Foo'" }
-    // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
-    // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
 }
diff --git a/gcc/testsuite/rust/compile/tuple_struct2.rs b/gcc/testsuite/rust/compile/tuple_struct2.rs
index dba0511a3bd..1fc18968577 100644
--- a/gcc/testsuite/rust/compile/tuple_struct2.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct2.rs
@@ -2,6 +2,4 @@ struct Bar(i32, i32, bool);
 
 fn main() {
     let a = Bar(1, 2); // { dg-error "unexpected number of arguments 2 expected 3" }
-    // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-1 }
-    // { dg-error "failed to type resolve expression" "" { target *-*-* } .-2 }
 }
diff --git a/gcc/testsuite/rust/compile/tuple_struct3.rs b/gcc/testsuite/rust/compile/tuple_struct3.rs
index a70306df852..4af66b8370e 100644
--- a/gcc/testsuite/rust/compile/tuple_struct3.rs
+++ b/gcc/testsuite/rust/compile/tuple_struct3.rs
@@ -3,6 +3,4 @@ struct Foo(i32, i32, bool);
 fn main() {
     let c = Foo(1, 2f32, true);
     // { dg-error "expected .i32. got .f32." "" { target *-*-* } .-1 }
-    // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-2 }
-    // { dg-error "failed to type resolve expression" "" { target *-*-* } .-3 }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:47 [gcc/devel/rust/master] Default type checking on CallExpr's to TyTy::ErrorType Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).