Skip to content

Commit 43cd0f2

Browse files
committed
Allow unreachable_patterns in rust-analyzer.
1 parent f1ad4d6 commit 43cd0f2

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/deconstruct_pat.rs

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
//! or-patterns; instead we just try the alternatives one-by-one. For details on splitting
4242
//! wildcards, see [`SplitWildcard`]; for integer ranges, see [`SplitIntRange`].
4343
44+
// This uses uninhabited types to encode statically unused variants.
45+
#![allow(unreachable_patterns)]
46+
4447
use std::{
4548
cell::Cell,
4649
cmp::{max, min},

src/tools/rust-analyzer/crates/hir-ty/src/display.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,7 @@ impl HirDisplay for LifetimeData {
16201620
}
16211621
LifetimeData::Static => write!(f, "'static"),
16221622
LifetimeData::Erased => Ok(()),
1623+
#[allow(unreachable_patterns)]
16231624
LifetimeData::Phantom(_, _) => Ok(()),
16241625
}
16251626
}

src/tools/rust-analyzer/crates/hir-ty/src/infer/closure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl CapturedItem {
214214
result = format!("{result}.{field}");
215215
field_need_paren = false;
216216
}
217+
#[allow(unreachable_patterns)]
217218
ProjectionElem::Index(_)
218219
| ProjectionElem::ConstantIndex { .. }
219220
| ProjectionElem::Subslice { .. }

src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ macro_rules! from_bytes {
99
($ty:tt, $value:expr) => {
1010
($ty::from_le_bytes(match ($value).try_into() {
1111
Ok(x) => x,
12+
#[allow(unreachable_patterns)]
1213
Err(_) => return Err(MirEvalError::TypeError("mismatched size")),
1314
}))
1415
};

src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
10281028
ProjectionElem::ConstantIndex { offset, from_end } => ProjectionElem::ConstantIndex { offset, from_end },
10291029
ProjectionElem::Subslice { from, to } => ProjectionElem::Subslice { from, to },
10301030
ProjectionElem::OpaqueCast(x) => ProjectionElem::OpaqueCast(x),
1031+
#[allow(unreachable_patterns)]
10311032
ProjectionElem::Index(x) => match x { },
10321033
}
10331034
}).collect(),

0 commit comments

Comments
 (0)