1
Fork 0

Rollup merge of #79072 - oli-obk:byte_str_pat, r=estebank

Fix exhaustiveness in case a byte string literal is used at slice type

fixes #79048
This commit is contained in:
Mara Bos 2020-11-17 16:13:53 +01:00 committed by GitHub
commit b6f52410bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 12 deletions

View file

@ -422,6 +422,12 @@ pub struct TypeckResults<'tcx> {
/// Stores the type, expression, span and optional scope span of all types
/// that are live across the yield of this generator (if a generator).
pub generator_interior_types: Vec<GeneratorInteriorTypeCause<'tcx>>,
/// We sometimes treat byte string literals (which are of type `&[u8; N]`)
/// as `&[u8]`, depending on the pattern in which they are used.
/// This hashset records all instances where we behave
/// like this to allow `const_to_pat` to reliably handle this situation.
pub treat_byte_string_as_slice: ItemLocalSet,
}
impl<'tcx> TypeckResults<'tcx> {
@ -448,6 +454,7 @@ impl<'tcx> TypeckResults<'tcx> {
closure_captures: Default::default(),
closure_min_captures: Default::default(),
generator_interior_types: Default::default(),
treat_byte_string_as_slice: Default::default(),
}
}
@ -683,6 +690,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
ref closure_captures,
ref closure_min_captures,
ref generator_interior_types,
ref treat_byte_string_as_slice,
} = *self;
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
@ -717,6 +725,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
closure_captures.hash_stable(hcx, hasher);
closure_min_captures.hash_stable(hcx, hasher);
generator_interior_types.hash_stable(hcx, hasher);
treat_byte_string_as_slice.hash_stable(hcx, hasher);
})
}
}