diff options
author | Philip Herron <herron.philip@googlemail.com> | 2024-10-02 15:47:33 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:16 +0100 |
commit | 308fd792af6c220b505515e6d40e7ba0f9820cf5 (patch) | |
tree | 3eebb2a7582f269c94bdac1353a093639518199e /gcc/testsuite/rust/compile | |
parent | ac5821890051d71cf55169c4f7e91801ca5f8ba2 (diff) | |
download | gcc-308fd792af6c220b505515e6d40e7ba0f9820cf5.zip gcc-308fd792af6c220b505515e6d40e7ba0f9820cf5.tar.gz gcc-308fd792af6c220b505515e6d40e7ba0f9820cf5.tar.bz2 |
gccrs: Fix ICE when typechecking non-trait item when we expect one
We just had an assertion here for this case where we expect a trait.
This changes the assertion into error handling producing the correct
error code with fixit suggestion like rustc.
Fixes #2499
gcc/rust/ChangeLog:
* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
use error handling instead of assertion
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): reuse trait reference
* typecheck/rust-hir-type-check-item.h: update prototype
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-2499.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust/compile')
-rw-r--r-- | gcc/testsuite/rust/compile/issue-2499.rs | 11 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/nr2/exclude | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/testsuite/rust/compile/issue-2499.rs b/gcc/testsuite/rust/compile/issue-2499.rs new file mode 100644 index 0000000..662d58f --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-2499.rs @@ -0,0 +1,11 @@ +#[lang = "sized"] +pub trait Sized {} + +struct Foo; +struct Bar; + +impl Foo for Bar {} +// { dg-error "Expected a trait found .Foo. .E0404." "" { target *-*-* } .-1 } + +fn baz<T: Foo>(t: T) {} +// { dg-error "Expected a trait found .Foo. .E0404." "" { target *-*-* } .-1 } diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index e792462..dec3bdd 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -254,4 +254,5 @@ issue-3139-2.rs issue-3139-3.rs issue-3036.rs issue-2951.rs -issue-2203.rs
\ No newline at end of file +issue-2203.rs +issue-2499.rs
\ No newline at end of file |