diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-28 18:24:57 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-03-28 19:10:35 +0000 |
commit | 8b5f1f296b60f9343ed995f14552d022f077e1f6 (patch) | |
tree | 0c2d859ba0e62f057147d2e5c14a443b9eab069e /gcc | |
parent | 6130523c8b98178e6bdbde9e33a4ca8c95226bf1 (diff) | |
download | gcc-8b5f1f296b60f9343ed995f14552d022f077e1f6.zip gcc-8b5f1f296b60f9343ed995f14552d022f077e1f6.tar.gz gcc-8b5f1f296b60f9343ed995f14552d022f077e1f6.tar.bz2 |
gccrs: fix ice when setting up regions
num regions is based on the used arguments of regions which can be
less than the substutions requirements. So lets check for that and allow
anon regions to be created for them.
Fixes Rust-GCC#3605
gcc/rust/ChangeLog:
* typecheck/rust-tyty-subst.h: check for min range
gcc/testsuite/ChangeLog:
* rust/compile/issue-3605.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-subst.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3605.rs | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-tyty-subst.h b/gcc/rust/typecheck/rust-tyty-subst.h index 86bc08b..65d5d5a 100644 --- a/gcc/rust/typecheck/rust-tyty-subst.h +++ b/gcc/rust/typecheck/rust-tyty-subst.h @@ -125,7 +125,7 @@ public: std::vector<Region> subst) { RegionParamList list (num_regions); - for (size_t i = 0; i < subst.size (); i++) + for (size_t i = 0; i < MIN (num_regions, subst.size ()); i++) list.regions.at (i) = subst.at (i); for (size_t i = subst.size (); i < num_regions; i++) { diff --git a/gcc/testsuite/rust/compile/issue-3605.rs b/gcc/testsuite/rust/compile/issue-3605.rs new file mode 100644 index 0000000..05e6e48 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3605.rs @@ -0,0 +1,5 @@ +enum Foo<'a> {} + +enum Bar<'a> { + in_band_def_explicit_impl(Foo<'a>), +} |