Skip to content

Commit 6615dee

Browse files
committed
Explain allow(unreachable_code).
1 parent 7f9451c commit 6615dee

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

compiler/rustc_target/src/asm/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl InlineAsmReg {
326326
InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => {
327327
Self::RiscV(RiscVInlineAsmReg::parse(name)?)
328328
}
329+
#[allow(unreachable_code)] // NvptxInlineAsmReg::parse does not return.
329330
InlineAsmArch::Nvptx64 => Self::Nvptx(NvptxInlineAsmReg::parse(name)?),
330331
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {
331332
Self::PowerPC(PowerPCInlineAsmReg::parse(name)?)
@@ -336,7 +337,9 @@ impl InlineAsmReg {
336337
Self::Mips(MipsInlineAsmReg::parse(name)?)
337338
}
338339
InlineAsmArch::S390x => Self::S390x(S390xInlineAsmReg::parse(name)?),
340+
#[allow(unreachable_code)] // SpirVInlineAsmReg::parse does not return.
339341
InlineAsmArch::SpirV => Self::SpirV(SpirVInlineAsmReg::parse(name)?),
342+
#[allow(unreachable_code)] // WasmInlineAsmReg::parse does not return.
340343
InlineAsmArch::Wasm32 | InlineAsmArch::Wasm64 => {
341344
Self::Wasm(WasmInlineAsmReg::parse(name)?)
342345
}

src/tools/miri/src/shims/unix/dlsym.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4646
match dlsym {
4747
Dlsym::Android(dlsym) =>
4848
android::EvalContextExt::call_dlsym(this, dlsym, args, dest, ret),
49-
#[allow(unreachable_code)]
49+
#[allow(unreachable_code)] // `dlsym` is uninhabited, and stage1 emits a lint.
5050
Dlsym::FreeBsd(dlsym) =>
5151
freebsd::EvalContextExt::call_dlsym(this, dlsym, args, dest, ret),
52-
#[allow(unreachable_code)]
52+
#[allow(unreachable_code)] // `dlsym` is uninhabited, and stage1 emits a lint.
5353
Dlsym::Linux(dlsym) => linux::EvalContextExt::call_dlsym(this, dlsym, args, dest, ret),
5454
Dlsym::MacOs(dlsym) => macos::EvalContextExt::call_dlsym(this, dlsym, args, dest, ret),
5555
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl Constructor {
348348

349349
fn as_slice(&self) -> Option<Slice> {
350350
match self {
351+
#[allow(unreachable_code)] // `Slice` is uninhabilted.
351352
Slice(slice) => Some(*slice),
352353
_ => None,
353354
}
@@ -470,7 +471,7 @@ impl Constructor {
470471
(IntRange(self_range), IntRange(other_range)) => self_range.is_covered_by(other_range),
471472
(FloatRange(void), FloatRange(..)) => match *void {},
472473
(Str(void), Str(..)) => match *void {},
473-
#[allow(unreachable_code)]
474+
#[allow(unreachable_code)] // `Slice` is uninhabited, and stage1 emits a lint.
474475
(Slice(self_slice), Slice(other_slice)) => self_slice.is_covered_by(*other_slice),
475476

476477
// We are trying to inspect an opaque constant. Thus we skip the row.
@@ -503,7 +504,7 @@ impl Constructor {
503504
.iter()
504505
.filter_map(|c| c.as_int_range())
505506
.any(|other| range.is_covered_by(other)),
506-
#[allow(unreachable_code)]
507+
#[allow(unreachable_code)] // `Slice` is uninhabited, and stage1 emits a lint.
507508
Slice(slice) => used_ctors
508509
.iter()
509510
.filter_map(|c| c.as_slice())

0 commit comments

Comments
 (0)