From: Owen Avery <[email protected]>
Type param bounds are allowed to use forward declared generic
parameters.
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit (TypeParam)): Visit bounds outside of
ForwardTypeParamBan rib.
gcc/testsuite/ChangeLog:
* rust/compile/generics15.rs: New test.
Signed-off-by: Owen Avery <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/76fc766f34824f3d4695dbc805a9bf58e19788be
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4684
gcc/rust/resolve/rust-default-resolver.cc | 12 ++++++++++--
gcc/testsuite/rust/compile/generics15.rs | 9 +++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/generics15.rs
diff --git a/gcc/rust/resolve/rust-default-resolver.cc
b/gcc/rust/resolve/rust-default-resolver.cc
index 10f506bb2..ba6530868 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -433,9 +433,17 @@ DefaultResolver::visit (AST::StaticItem &item)
void
DefaultResolver::visit (AST::TypeParam ¶m)
{
- auto expr_vis = [this, ¶m] () { AST::DefaultASTVisitor::visit (param); };
+ auto param_ban_vis = [this, ¶m] () {
+ visit_outer_attrs (param);
+ if (param.has_type ())
+ visit (param.get_type ());
+ };
+
+ ctx.scoped (Rib::Kind::ForwardTypeParamBan, param.get_node_id (),
+ param_ban_vis);
- ctx.scoped (Rib::Kind::ForwardTypeParamBan, param.get_node_id (), expr_vis);
+ for (auto &bound : param.get_type_param_bounds ())
+ visit (bound);
}
void
diff --git a/gcc/testsuite/rust/compile/generics15.rs
b/gcc/testsuite/rust/compile/generics15.rs
new file mode 100644
index 000000000..bb50be4e8
--- /dev/null
+++ b/gcc/testsuite/rust/compile/generics15.rs
@@ -0,0 +1,9 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+pub trait A<T> {}
+
+pub struct B<T: A<T>> (T);
base-commit: 0e19cee2e9b0b004f3ce6aaded424c2d3a072f26
--
2.54.0