Skip to content

Commit ebf3032

Browse files
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. Co-authored-by: philberty <[email protected]>
1 parent 5b14291 commit ebf3032

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

gcc/rust/privacy/rust-reachability.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ 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+
5657
rust_assert (ok);
5758
rust_assert (generic_ty->get_kind () == TyTy::PARAM);
5859

gcc/rust/typecheck/rust-hir-type-check-type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ class TypeResolveGenericParam : public TypeCheckBase
189189
return nullptr;
190190
}
191191

192+
resolver.context->insert_type (param->get_mappings (), resolver.resolved);
193+
192194
return resolver.resolved;
193195
}
194196

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)