mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-06 03:52:53 +00:00
Update rustc_pattern_analysis dependency
This commit is contained in:
parent
c2d21242aa
commit
ba7b12e062
83
Cargo.lock
generated
83
Cargo.lock
generated
@ -167,7 +167,7 @@ checksum = "5676cea088c32290fe65c82895be9d06dd21e0fa49bb97ca840529e9417ab71a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@ -313,17 +313,6 @@ dependencies = [
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_arbitrary"
|
||||
version = "1.3.2"
|
||||
@ -332,7 +321,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1436,17 +1425,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra-ap-rustc_index"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5313d7f243b63ef9e58d94355b11aa8499f1328055f1f58adf0a5ea7d2faca"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"ra-ap-rustc_index_macros 0.33.0",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra-ap-rustc_index"
|
||||
version = "0.35.0"
|
||||
@ -1459,15 +1437,14 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra-ap-rustc_index_macros"
|
||||
version = "0.33.0"
|
||||
name = "ra-ap-rustc_index"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a83108ebf3e73dde205b9c25706209bcd7736480820f90ded28eabaf8b469f25"
|
||||
checksum = "f8a41dee58608b1fc93779ea365edaa70ac9927e3335ae914b675be0fa063cd7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"synstructure",
|
||||
"arrayvec",
|
||||
"ra-ap-rustc_index_macros 0.36.0",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1478,7 +1455,19 @@ checksum = "054e25eac52f0506c1309ca4317c11ad4925d7b99eb897f71aa7c3cbafb46c2b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ra-ap-rustc_index_macros"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbfe98def54c4337a2f7d8233850bd5d5349972b185fe8a0db2b979164b30ed8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
@ -1504,12 +1493,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ra-ap-rustc_pattern_analysis"
|
||||
version = "0.33.0"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c4085e0c771fd4b883930b599ef42966b855762bbe4052c17673b3253421a6d"
|
||||
checksum = "b5529bffec7530b4a3425640bfdfd9b95d87c4c620f740266c0de6572561aab4"
|
||||
dependencies = [
|
||||
"derivative",
|
||||
"ra-ap-rustc_index 0.33.0",
|
||||
"ra-ap-rustc_index 0.36.0",
|
||||
"rustc-hash",
|
||||
"rustc_apfloat",
|
||||
"smallvec",
|
||||
@ -1649,7 +1637,7 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1736,7 +1724,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1759,7 +1747,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1836,17 +1824,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.39"
|
||||
@ -1866,7 +1843,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
@ -1955,7 +1932,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2056,7 +2033,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.39",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -83,7 +83,7 @@ ra-ap-rustc_lexer = { version = "0.35.0", default-features = false }
|
||||
ra-ap-rustc_parse_format = { version = "0.35.0", default-features = false }
|
||||
ra-ap-rustc_index = { version = "0.35.0", default-features = false }
|
||||
ra-ap-rustc_abi = { version = "0.35.0", default-features = false }
|
||||
ra-ap-rustc_pattern_analysis = { version = "0.33.0", default-features = false }
|
||||
ra-ap-rustc_pattern_analysis = { version = "0.36.0", default-features = false }
|
||||
|
||||
# local crates that aren't published to crates.io. These should not have versions.
|
||||
sourcegen = { path = "./crates/sourcegen" }
|
||||
|
@ -207,7 +207,7 @@ impl ExprValidator {
|
||||
}
|
||||
|
||||
let report = match compute_match_usefulness(
|
||||
rustc_pattern_analysis::MatchCtxt { tycx: &cx },
|
||||
&cx,
|
||||
m_arms.as_slice(),
|
||||
scrut_ty.clone(),
|
||||
ValidityConstraint::ValidOnly,
|
||||
|
@ -43,6 +43,13 @@ pub(crate) struct MatchCheckCtx<'p> {
|
||||
pub(crate) pattern_arena: &'p Arena<DeconstructedPat<'p>>,
|
||||
ty_arena: &'p Arena<Ty>,
|
||||
exhaustive_patterns: bool,
|
||||
min_exhaustive_patterns: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct PatData<'p> {
|
||||
/// Keep db around so that we can print variant names in `Debug`.
|
||||
pub(crate) db: &'p dyn HirDatabase,
|
||||
}
|
||||
|
||||
impl<'p> MatchCheckCtx<'p> {
|
||||
@ -55,7 +62,17 @@ impl<'p> MatchCheckCtx<'p> {
|
||||
) -> Self {
|
||||
let def_map = db.crate_def_map(module.krate());
|
||||
let exhaustive_patterns = def_map.is_unstable_feature_enabled("exhaustive_patterns");
|
||||
Self { module, body, db, pattern_arena, exhaustive_patterns, ty_arena }
|
||||
let min_exhaustive_patterns =
|
||||
def_map.is_unstable_feature_enabled("min_exhaustive_patterns");
|
||||
Self {
|
||||
module,
|
||||
body,
|
||||
db,
|
||||
pattern_arena,
|
||||
exhaustive_patterns,
|
||||
min_exhaustive_patterns,
|
||||
ty_arena,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_uninhabited(&self, ty: &Ty) -> bool {
|
||||
@ -238,7 +255,8 @@ impl<'p> MatchCheckCtx<'p> {
|
||||
fields = self.pattern_arena.alloc_extend(subpats);
|
||||
}
|
||||
}
|
||||
DeconstructedPat::new(ctor, fields, pat.ty.clone(), ())
|
||||
let data = PatData { db: self.db };
|
||||
DeconstructedPat::new(ctor, fields, pat.ty.clone(), data)
|
||||
}
|
||||
|
||||
pub(crate) fn hoist_witness_pat(&self, pat: &WitnessPat<'p>) -> Pat {
|
||||
@ -304,11 +322,14 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
|
||||
type VariantIdx = EnumVariantId;
|
||||
type StrLit = Void;
|
||||
type ArmData = ();
|
||||
type PatData = ();
|
||||
type PatData = PatData<'p>;
|
||||
|
||||
fn is_exhaustive_patterns_feature_on(&self) -> bool {
|
||||
self.exhaustive_patterns
|
||||
}
|
||||
fn is_min_exhaustive_patterns_feature_on(&self) -> bool {
|
||||
self.min_exhaustive_patterns
|
||||
}
|
||||
|
||||
fn ctor_arity(
|
||||
&self,
|
||||
@ -344,16 +365,16 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
|
||||
}
|
||||
}
|
||||
|
||||
fn ctor_sub_tys(
|
||||
&self,
|
||||
ctor: &rustc_pattern_analysis::constructor::Constructor<Self>,
|
||||
ty: &Self::Ty,
|
||||
) -> &[Self::Ty] {
|
||||
fn ctor_sub_tys<'a>(
|
||||
&'a self,
|
||||
ctor: &'a rustc_pattern_analysis::constructor::Constructor<Self>,
|
||||
ty: &'a Self::Ty,
|
||||
) -> impl Iterator<Item = Self::Ty> + ExactSizeIterator + Captures<'a> {
|
||||
use std::iter::once;
|
||||
fn alloc<'a>(cx: &'a MatchCheckCtx<'_>, iter: impl Iterator<Item = Ty>) -> &'a [Ty] {
|
||||
cx.ty_arena.alloc_extend(iter)
|
||||
}
|
||||
match ctor {
|
||||
let slice = match ctor {
|
||||
Struct | Variant(_) | UnionField => match ty.kind(Interner) {
|
||||
TyKind::Tuple(_, substs) => {
|
||||
let tys = substs.iter(Interner).map(|ty| ty.assert_ty_ref(Interner));
|
||||
@ -391,7 +412,8 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
|
||||
never!("called `Fields::wildcards` on an `Or` ctor");
|
||||
&[]
|
||||
}
|
||||
}
|
||||
};
|
||||
slice.into_iter().cloned()
|
||||
}
|
||||
|
||||
fn ctors_for_ty(
|
||||
@ -453,11 +475,27 @@ impl<'p> TypeCx for MatchCheckCtx<'p> {
|
||||
})
|
||||
}
|
||||
|
||||
fn debug_pat(
|
||||
_f: &mut fmt::Formatter<'_>,
|
||||
_pat: &rustc_pattern_analysis::pat::DeconstructedPat<'_, Self>,
|
||||
fn write_variant_name(
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
pat: &rustc_pattern_analysis::pat::DeconstructedPat<'_, Self>,
|
||||
) -> fmt::Result {
|
||||
// FIXME: implement this, as using `unimplemented!()` causes panics in `tracing`.
|
||||
let variant =
|
||||
pat.ty().as_adt().and_then(|(adt, _)| Self::variant_id_for_adt(pat.ctor(), adt));
|
||||
|
||||
let db = pat.data().unwrap().db;
|
||||
if let Some(variant) = variant {
|
||||
match variant {
|
||||
VariantId::EnumVariantId(v) => {
|
||||
write!(f, "{}", db.enum_variant_data(v).name.display(db.upcast()))?;
|
||||
}
|
||||
VariantId::StructId(s) => {
|
||||
write!(f, "{}", db.struct_data(s).name.display(db.upcast()))?
|
||||
}
|
||||
VariantId::UnionId(u) => {
|
||||
write!(f, "{}", db.union_data(u).name.display(db.upcast()))?
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user