diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-27 16:32:21 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-31 21:07:20 +0200 |
commit | 564d76525f6a7a17deb5632da84ff6eefd7c0ce5 (patch) | |
tree | 1a233c8aaf9dfb29b17389275f3a2dc7158de60f /gcc/testsuite/rust | |
parent | 405a294780dd12f242bb96540b1251091f13b051 (diff) | |
download | gcc-564d76525f6a7a17deb5632da84ff6eefd7c0ce5.zip gcc-564d76525f6a7a17deb5632da84ff6eefd7c0ce5.tar.gz gcc-564d76525f6a7a17deb5632da84ff6eefd7c0ce5.tar.bz2 |
gccrs: Fix ICE when compiling path which resolves to trait constant
Fixes Rust-GCC#3552
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): check for Expr trait
* hir/rust-hir-dump.cc (Dump::visit): expr is optional
gcc/testsuite/ChangeLog:
* rust/compile/issue-3552.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3552.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-3552.rs b/gcc/testsuite/rust/compile/issue-3552.rs new file mode 100644 index 0000000..9a4451b14b --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3552.rs @@ -0,0 +1,14 @@ +trait Foo { + const BAR: u32; +} + +const TRAIT_REF_BAR: u32 = <Foo>::BAR; +// { dg-error "no default expression on trait constant" "" { target *-*-* } .-1 } + +struct GlobalTraitRef; + +impl Foo for GlobalTraitRef { + const BAR: u32 = TRAIT_REF_BAR; +} + +fn main() {} |