Skip to content

Commit 4f3c252

Browse files
committed
privacy: reachability: Don't ICE on traits' Self generic parameter
The `Self` type of a Trait is part of its generic parameter list. This fails lookup since it's not a properly defined type. We need to be able to identify `Self` parameters and skip them in the reachability pass.
1 parent 5b14291 commit 4f3c252

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

gcc/rust/privacy/rust-reachability.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ ReachabilityVisitor::visit_generic_predicates (
5353
TyTy::BaseType *generic_ty = nullptr;
5454
auto ok = ty_ctx.lookup_type (generic->get_mappings ().get_hirid (),
5555
&generic_ty);
56-
rust_assert (ok);
56+
57+
// FIXME: This fails lookup on the `Self` generic parameter of the
58+
// trait definition. We can skip it for now, but that's not a real fix
59+
if (!ok)
60+
break;
61+
62+
// rust_assert (ok);
5763
rust_assert (generic_ty->get_kind () == TyTy::PARAM);
5864

5965
auto generic_param = static_cast<TyTy::ParamType *> (generic_ty);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Hasher {
2+
fn write(&mut self, bytes: &[u8]);
3+
fn write_u8(&mut self, i: u8) {
4+
self.write(&[i])
5+
}
6+
}
7+
8+
pub trait PubHasher {
9+
fn p_write(&mut self, bytes: &[u8]);
10+
fn p_write_u8(&mut self, i: u8) {
11+
self.write(&[i])
12+
}
13+
}

0 commit comments

Comments
 (0)