From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 150C4398546B; Wed, 8 Jun 2022 11:47:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 150C4398546B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Default type checking on CallExpr's to TyTy::ErrorType X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: e3defa10bc63ba3f81da00fc322b5b1e0d1717ed X-Git-Newrev: fc5f8d746362a42adc52e538dec248bd2992a794 Message-Id: <20220608114700.150C4398546B@sourceware.org> Date: Wed, 8 Jun 2022 11:47:00 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 11:47:00 -0000 https://gcc.gnu.org/g:fc5f8d746362a42adc52e538dec248bd2992a794 commit fc5f8d746362a42adc52e538dec248bd2992a794 Author: Philip Herron 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 } }