Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c27a2b

Browse files
committedSep 21, 2024
Auto merge of #130569 - cuviper:beta-next, r=cuviper
[beta] backports - Don't warn empty branches unreachable for now #129103 - Win: Add dbghelp to the list of import libraries #130047 - `RepeatN`: use MaybeUninit #130145 - Update LLVM to 19 327ca6c #130212 - Revert #129749 to fix segfault in LLVM #130477 - Check params for unsafety in THIR #130531 r? cuviper try-job: dist-various-1
2 parents 4976ae4 + 4bf632f commit 8c27a2b

File tree

27 files changed

+214
-470
lines changed

27 files changed

+214
-470
lines changed
 

‎compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,7 @@ struct LLVMRustThinLTOData {
12121212
// Not 100% sure what these are, but they impact what's internalized and
12131213
// what's inlined across modules, I believe.
12141214
#if LLVM_VERSION_GE(18, 0)
1215-
#if LLVM_VERSION_GE(20, 0)
1216-
FunctionImporter::ImportListsTy ImportLists;
1217-
#else
12181215
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
1219-
#endif
12201216
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
12211217
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
12221218
#else
@@ -1425,13 +1421,13 @@ LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data,
14251421
return true;
14261422
}
14271423

1428-
extern "C" bool LLVMRustPrepareThinLTOImport(LLVMRustThinLTOData *Data,
1424+
extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data,
14291425
LLVMModuleRef M,
14301426
LLVMTargetMachineRef TM) {
14311427
Module &Mod = *unwrap(M);
14321428
TargetMachine &Target = *unwrap(TM);
14331429

1434-
const auto &ImportList = Data->ImportLists[Mod.getModuleIdentifier()];
1430+
const auto &ImportList = Data->ImportLists.lookup(Mod.getModuleIdentifier());
14351431
auto Loader = [&](StringRef Identifier) {
14361432
const auto &Memory = Data->ModuleMap.lookup(Identifier);
14371433
auto &Context = Mod.getContext();
@@ -1614,7 +1610,7 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut,
16141610
LLVMRustThinLTOData *Data) {
16151611
SmallString<40> Key;
16161612
llvm::lto::Config conf;
1617-
const auto &ImportList = Data->ImportLists[ModId];
1613+
const auto &ImportList = Data->ImportLists.lookup(ModId);
16181614
const auto &ExportList = Data->ExportLists.lookup(ModId);
16191615
const auto &ResolvedODR = Data->ResolvedODR.lookup(ModId);
16201616
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(ModId);

‎compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
218218
warnings: self.warnings,
219219
suggest_unsafe_block: self.suggest_unsafe_block,
220220
};
221+
// params in THIR may be unsafe, e.g. a union pattern.
222+
for param in &inner_thir.params {
223+
if let Some(param_pat) = param.pat.as_deref() {
224+
inner_visitor.visit_pat(param_pat);
225+
}
226+
}
227+
// Visit the body.
221228
inner_visitor.visit_expr(&inner_thir[expr]);
222229
// Unsafe blocks can be used in the inner body, make sure to take it into account
223230
self.safety_context = inner_visitor.safety_context;
@@ -1066,6 +1073,13 @@ pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
10661073
warnings: &mut warnings,
10671074
suggest_unsafe_block: true,
10681075
};
1076+
// params in THIR may be unsafe, e.g. a union pattern.
1077+
for param in &thir.params {
1078+
if let Some(param_pat) = param.pat.as_deref() {
1079+
visitor.visit_pat(param_pat);
1080+
}
1081+
}
1082+
// Visit the body.
10691083
visitor.visit_expr(&thir[expr]);
10701084

10711085
warnings.sort_by_key(|w| w.block_span);

‎compiler/rustc_pattern_analysis/src/usefulness.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,11 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
951951
self.is_scrutinee && matches!(ctors_for_ty, ConstructorSet::NoConstructors);
952952
// Whether empty patterns are counted as useful or not. We only warn an empty arm unreachable if
953953
// it is guaranteed unreachable by the opsem (i.e. if the place is `known_valid`).
954-
let empty_arms_are_unreachable = self.validity.is_known_valid();
954+
// We don't want to warn empty patterns as unreachable by default just yet. We will in a
955+
// later version of rust or under a different lint name, see
956+
// https://github.com/rust-lang/rust/pull/129103.
957+
let empty_arms_are_unreachable = self.validity.is_known_valid()
958+
&& (is_toplevel_exception || cx.is_exhaustive_patterns_feature_on());
955959
// Whether empty patterns can be omitted for exhaustiveness. We ignore place validity in the
956960
// toplevel exception and `exhaustive_patterns` cases for backwards compatibility.
957961
let can_omit_empty_arms = self.validity.is_known_valid()

‎library/core/src/iter/sources/repeat_n.rs

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use crate::fmt;
12
use crate::iter::{FusedIterator, TrustedLen, UncheckedIterator};
2-
use crate::mem::ManuallyDrop;
3+
use crate::mem::{self, MaybeUninit};
34
use crate::num::NonZero;
45

56
/// Creates a new iterator that repeats a single element a given number of times.
@@ -58,14 +59,12 @@ use crate::num::NonZero;
5859
#[inline]
5960
#[stable(feature = "iter_repeat_n", since = "1.82.0")]
6061
pub fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T> {
61-
let mut element = ManuallyDrop::new(element);
62-
63-
if count == 0 {
64-
// SAFETY: we definitely haven't dropped it yet, since we only just got
65-
// passed it in, and because the count is zero the instance we're about
66-
// to create won't drop it, so to avoid leaking we need to now.
67-
unsafe { ManuallyDrop::drop(&mut element) };
68-
}
62+
let element = if count == 0 {
63+
// `element` gets dropped eagerly.
64+
MaybeUninit::uninit()
65+
} else {
66+
MaybeUninit::new(element)
67+
};
6968

7069
RepeatN { element, count }
7170
}
@@ -74,31 +73,60 @@ pub fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T> {
7473
///
7574
/// This `struct` is created by the [`repeat_n()`] function.
7675
/// See its documentation for more.
77-
#[derive(Clone, Debug)]
7876
#[stable(feature = "iter_repeat_n", since = "1.82.0")]
7977
pub struct RepeatN<A> {
8078
count: usize,
81-
// Invariant: has been dropped iff count == 0.
82-
element: ManuallyDrop<A>,
79+
// Invariant: uninit iff count == 0.
80+
element: MaybeUninit<A>,
8381
}
8482

8583
impl<A> RepeatN<A> {
84+
/// Returns the element if it hasn't been dropped already.
85+
fn element_ref(&self) -> Option<&A> {
86+
if self.count > 0 {
87+
// SAFETY: The count is non-zero, so it must be initialized.
88+
Some(unsafe { self.element.assume_init_ref() })
89+
} else {
90+
None
91+
}
92+
}
8693
/// If we haven't already dropped the element, return it in an option.
8794
///
8895
/// Clears the count so it won't be dropped again later.
8996
#[inline]
9097
fn take_element(&mut self) -> Option<A> {
9198
if self.count > 0 {
9299
self.count = 0;
100+
let element = mem::replace(&mut self.element, MaybeUninit::uninit());
93101
// SAFETY: We just set count to zero so it won't be dropped again,
94102
// and it used to be non-zero so it hasn't already been dropped.
95-
unsafe { Some(ManuallyDrop::take(&mut self.element)) }
103+
unsafe { Some(element.assume_init()) }
96104
} else {
97105
None
98106
}
99107
}
100108
}
101109

110+
#[stable(feature = "iter_repeat_n", since = "1.82.0")]
111+
impl<A: Clone> Clone for RepeatN<A> {
112+
fn clone(&self) -> RepeatN<A> {
113+
RepeatN {
114+
count: self.count,
115+
element: self.element_ref().cloned().map_or_else(MaybeUninit::uninit, MaybeUninit::new),
116+
}
117+
}
118+
}
119+
120+
#[stable(feature = "iter_repeat_n", since = "1.82.0")]
121+
impl<A: fmt::Debug> fmt::Debug for RepeatN<A> {
122+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
123+
f.debug_struct("RepeatN")
124+
.field("count", &self.count)
125+
.field("element", &self.element_ref())
126+
.finish()
127+
}
128+
}
129+
102130
#[stable(feature = "iter_repeat_n", since = "1.82.0")]
103131
impl<A> Drop for RepeatN<A> {
104132
fn drop(&mut self) {
@@ -194,9 +222,11 @@ impl<A: Clone> UncheckedIterator for RepeatN<A> {
194222
// SAFETY: the check above ensured that the count used to be non-zero,
195223
// so element hasn't been dropped yet, and we just lowered the count to
196224
// zero so it won't be dropped later, and thus it's okay to take it here.
197-
unsafe { ManuallyDrop::take(&mut self.element) }
225+
unsafe { mem::replace(&mut self.element, MaybeUninit::uninit()).assume_init() }
198226
} else {
199-
A::clone(&self.element)
227+
// SAFETY: the count is non-zero, so it must have not been dropped yet.
228+
let element = unsafe { self.element.assume_init_ref() };
229+
A::clone(element)
200230
}
201231
}
202232
}

‎library/core/tests/iter/sources.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,27 @@ fn test_repeat_n_drop() {
156156
drop((x0, x1, x2));
157157
assert_eq!(count.get(), 3);
158158
}
159+
160+
#[test]
161+
fn test_repeat_n_soundness() {
162+
let x = std::iter::repeat_n(String::from("use after free"), 0);
163+
println!("{x:?}");
164+
165+
pub struct PanicOnClone;
166+
167+
impl Clone for PanicOnClone {
168+
fn clone(&self) -> Self {
169+
unreachable!()
170+
}
171+
}
172+
173+
// `repeat_n` should drop the element immediately if `count` is zero.
174+
// `Clone` should then not try to clone the element.
175+
let x = std::iter::repeat_n(PanicOnClone, 0);
176+
let _ = x.clone();
177+
178+
let mut y = std::iter::repeat_n(Box::new(0), 1);
179+
let x = y.next().unwrap();
180+
let _z = y;
181+
assert_eq!(0, *x);
182+
}

‎library/windows_targets/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ pub macro link {
3838
#[link(name = "ntdll")]
3939
#[link(name = "userenv")]
4040
#[link(name = "ws2_32")]
41+
#[link(name = "dbghelp")] // required for backtrace-rs symbolization
4142
extern "C" {}

‎src/llvm-project

Submodule llvm-project updated 188 files

‎tests/run-make/compiler-builtins/rmake.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// wasm and nvptx targets don't produce rlib files that object can parse.
1212
//@ ignore-wasm
1313
//@ ignore-nvptx64
14+
//@ only-nightly
1415

1516
#![deny(warnings)]
1617

‎tests/run-make/thumb-none-cortex-m/rmake.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//! - thumbv7m-none-eabi (Bare Cortex-M3)
1414
1515
//@ only-thumb
16+
//@ only-nightly
1617

1718
use std::path::PathBuf;
1819

‎tests/ui/pattern/usefulness/empty-types.never_pats.stderr

Lines changed: 1 addition & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,6 @@ LL + _ => todo!(),
4343
LL + }
4444
|
4545

46-
error: unreachable pattern
47-
--> $DIR/empty-types.rs:70:9
48-
|
49-
LL | (_, _) => {}
50-
| ^^^^^^ matches no values because `(u32, !)` is uninhabited
51-
|
52-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
53-
54-
error: unreachable pattern
55-
--> $DIR/empty-types.rs:76:9
56-
|
57-
LL | _ => {}
58-
| ^ matches no values because `(!, !)` is uninhabited
59-
|
60-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
61-
62-
error: unreachable pattern
63-
--> $DIR/empty-types.rs:79:9
64-
|
65-
LL | (_, _) => {}
66-
| ^^^^^^ matches no values because `(!, !)` is uninhabited
67-
|
68-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
69-
7046
error: unreachable pattern
7147
--> $DIR/empty-types.rs:83:9
7248
|
@@ -94,22 +70,6 @@ LL + Ok(_) => todo!(),
9470
LL + }
9571
|
9672

97-
error: unreachable pattern
98-
--> $DIR/empty-types.rs:94:9
99-
|
100-
LL | Err(_) => {}
101-
| ^^^^^^ matches no values because `!` is uninhabited
102-
|
103-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
104-
105-
error: unreachable pattern
106-
--> $DIR/empty-types.rs:99:9
107-
|
108-
LL | Err(_) => {}
109-
| ^^^^^^ matches no values because `!` is uninhabited
110-
|
111-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
112-
11373
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
11474
--> $DIR/empty-types.rs:96:11
11575
|
@@ -156,54 +116,6 @@ help: you might want to use `let else` to handle the variant that isn't matched
156116
LL | let Ok(_x) = &res_u32_never else { todo!() };
157117
| ++++++++++++++++
158118

159-
error: unreachable pattern
160-
--> $DIR/empty-types.rs:112:9
161-
|
162-
LL | _ => {}
163-
| ^ matches no values because `Result<!, !>` is uninhabited
164-
|
165-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
166-
167-
error: unreachable pattern
168-
--> $DIR/empty-types.rs:115:9
169-
|
170-
LL | Ok(_) => {}
171-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
172-
|
173-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
174-
175-
error: unreachable pattern
176-
--> $DIR/empty-types.rs:118:9
177-
|
178-
LL | Ok(_) => {}
179-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
180-
|
181-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
182-
183-
error: unreachable pattern
184-
--> $DIR/empty-types.rs:119:9
185-
|
186-
LL | _ => {}
187-
| ^ matches no values because `Result<!, !>` is uninhabited
188-
|
189-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
190-
191-
error: unreachable pattern
192-
--> $DIR/empty-types.rs:122:9
193-
|
194-
LL | Ok(_) => {}
195-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
196-
|
197-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
198-
199-
error: unreachable pattern
200-
--> $DIR/empty-types.rs:123:9
201-
|
202-
LL | Err(_) => {}
203-
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
204-
|
205-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
206-
207119
error: unreachable pattern
208120
--> $DIR/empty-types.rs:132:13
209121
|
@@ -220,22 +132,6 @@ LL | _ if false => {}
220132
|
221133
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
222134

223-
error: unreachable pattern
224-
--> $DIR/empty-types.rs:143:13
225-
|
226-
LL | Some(_) => {}
227-
| ^^^^^^^ matches no values because `Void` is uninhabited
228-
|
229-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
230-
231-
error: unreachable pattern
232-
--> $DIR/empty-types.rs:147:13
233-
|
234-
LL | None => {}
235-
| ---- matches all the relevant values
236-
LL | _ => {}
237-
| ^ no value can reach this
238-
239135
error[E0004]: non-exhaustive patterns: `Some(!)` not covered
240136
--> $DIR/empty-types.rs:156:15
241137
|
@@ -303,30 +199,6 @@ LL | _ => {}
303199
|
304200
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
305201

306-
error: unreachable pattern
307-
--> $DIR/empty-types.rs:284:9
308-
|
309-
LL | (_, _) => {}
310-
| ^^^^^^ matches no values because `(!, !)` is uninhabited
311-
|
312-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
313-
314-
error: unreachable pattern
315-
--> $DIR/empty-types.rs:287:9
316-
|
317-
LL | Ok(_) => {}
318-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
319-
|
320-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
321-
322-
error: unreachable pattern
323-
--> $DIR/empty-types.rs:288:9
324-
|
325-
LL | Err(_) => {}
326-
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
327-
|
328-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
329-
330202
error[E0005]: refutable pattern in local binding
331203
--> $DIR/empty-types.rs:297:13
332204
|
@@ -474,30 +346,6 @@ LL + _ => todo!(),
474346
LL + }
475347
|
476348

477-
error: unreachable pattern
478-
--> $DIR/empty-types.rs:368:9
479-
|
480-
LL | _ => {}
481-
| ^ matches no values because `[!; 3]` is uninhabited
482-
|
483-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
484-
485-
error: unreachable pattern
486-
--> $DIR/empty-types.rs:371:9
487-
|
488-
LL | [_, _, _] => {}
489-
| ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited
490-
|
491-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
492-
493-
error: unreachable pattern
494-
--> $DIR/empty-types.rs:374:9
495-
|
496-
LL | [_, ..] => {}
497-
| ^^^^^^^ matches no values because `[!; 3]` is uninhabited
498-
|
499-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
500-
501349
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
502350
--> $DIR/empty-types.rs:388:11
503351
|
@@ -534,40 +382,6 @@ LL ~ [..] if false => {},
534382
LL + [] => todo!()
535383
|
536384

537-
error: unreachable pattern
538-
--> $DIR/empty-types.rs:416:9
539-
|
540-
LL | Some(_) => {}
541-
| ^^^^^^^ matches no values because `!` is uninhabited
542-
|
543-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
544-
545-
error: unreachable pattern
546-
--> $DIR/empty-types.rs:421:9
547-
|
548-
LL | Some(_a) => {}
549-
| ^^^^^^^^ matches no values because `!` is uninhabited
550-
|
551-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
552-
553-
error: unreachable pattern
554-
--> $DIR/empty-types.rs:426:9
555-
|
556-
LL | None => {}
557-
| ---- matches all the relevant values
558-
LL | // !useful, !reachable
559-
LL | _ => {}
560-
| ^ no value can reach this
561-
562-
error: unreachable pattern
563-
--> $DIR/empty-types.rs:431:9
564-
|
565-
LL | None => {}
566-
| ---- matches all the relevant values
567-
LL | // !useful, !reachable
568-
LL | _a => {}
569-
| ^^ no value can reach this
570-
571385
error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
572386
--> $DIR/empty-types.rs:451:11
573387
|
@@ -744,7 +558,7 @@ LL ~ None => {},
744558
LL + Some(!)
745559
|
746560

747-
error: aborting due to 65 previous errors; 1 warning emitted
561+
error: aborting due to 42 previous errors; 1 warning emitted
748562

749563
Some errors have detailed explanations: E0004, E0005.
750564
For more information about an error, try `rustc --explain E0004`.

‎tests/ui/pattern/usefulness/empty-types.normal.stderr

Lines changed: 1 addition & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ LL + _ => todo!(),
3434
LL + }
3535
|
3636

37-
error: unreachable pattern
38-
--> $DIR/empty-types.rs:70:9
39-
|
40-
LL | (_, _) => {}
41-
| ^^^^^^ matches no values because `(u32, !)` is uninhabited
42-
|
43-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
44-
45-
error: unreachable pattern
46-
--> $DIR/empty-types.rs:76:9
47-
|
48-
LL | _ => {}
49-
| ^ matches no values because `(!, !)` is uninhabited
50-
|
51-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
52-
53-
error: unreachable pattern
54-
--> $DIR/empty-types.rs:79:9
55-
|
56-
LL | (_, _) => {}
57-
| ^^^^^^ matches no values because `(!, !)` is uninhabited
58-
|
59-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
60-
6137
error: unreachable pattern
6238
--> $DIR/empty-types.rs:83:9
6339
|
@@ -85,22 +61,6 @@ LL + Ok(_) => todo!(),
8561
LL + }
8662
|
8763

88-
error: unreachable pattern
89-
--> $DIR/empty-types.rs:94:9
90-
|
91-
LL | Err(_) => {}
92-
| ^^^^^^ matches no values because `!` is uninhabited
93-
|
94-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
95-
96-
error: unreachable pattern
97-
--> $DIR/empty-types.rs:99:9
98-
|
99-
LL | Err(_) => {}
100-
| ^^^^^^ matches no values because `!` is uninhabited
101-
|
102-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
103-
10464
error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
10565
--> $DIR/empty-types.rs:96:11
10666
|
@@ -147,54 +107,6 @@ help: you might want to use `let else` to handle the variant that isn't matched
147107
LL | let Ok(_x) = &res_u32_never else { todo!() };
148108
| ++++++++++++++++
149109

150-
error: unreachable pattern
151-
--> $DIR/empty-types.rs:112:9
152-
|
153-
LL | _ => {}
154-
| ^ matches no values because `Result<!, !>` is uninhabited
155-
|
156-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
157-
158-
error: unreachable pattern
159-
--> $DIR/empty-types.rs:115:9
160-
|
161-
LL | Ok(_) => {}
162-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
163-
|
164-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
165-
166-
error: unreachable pattern
167-
--> $DIR/empty-types.rs:118:9
168-
|
169-
LL | Ok(_) => {}
170-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
171-
|
172-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
173-
174-
error: unreachable pattern
175-
--> $DIR/empty-types.rs:119:9
176-
|
177-
LL | _ => {}
178-
| ^ matches no values because `Result<!, !>` is uninhabited
179-
|
180-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
181-
182-
error: unreachable pattern
183-
--> $DIR/empty-types.rs:122:9
184-
|
185-
LL | Ok(_) => {}
186-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
187-
|
188-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
189-
190-
error: unreachable pattern
191-
--> $DIR/empty-types.rs:123:9
192-
|
193-
LL | Err(_) => {}
194-
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
195-
|
196-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
197-
198110
error: unreachable pattern
199111
--> $DIR/empty-types.rs:132:13
200112
|
@@ -211,22 +123,6 @@ LL | _ if false => {}
211123
|
212124
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
213125

214-
error: unreachable pattern
215-
--> $DIR/empty-types.rs:143:13
216-
|
217-
LL | Some(_) => {}
218-
| ^^^^^^^ matches no values because `Void` is uninhabited
219-
|
220-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
221-
222-
error: unreachable pattern
223-
--> $DIR/empty-types.rs:147:13
224-
|
225-
LL | None => {}
226-
| ---- matches all the relevant values
227-
LL | _ => {}
228-
| ^ no value can reach this
229-
230126
error[E0004]: non-exhaustive patterns: `Some(_)` not covered
231127
--> $DIR/empty-types.rs:156:15
232128
|
@@ -294,30 +190,6 @@ LL | _ => {}
294190
|
295191
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
296192

297-
error: unreachable pattern
298-
--> $DIR/empty-types.rs:284:9
299-
|
300-
LL | (_, _) => {}
301-
| ^^^^^^ matches no values because `(!, !)` is uninhabited
302-
|
303-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
304-
305-
error: unreachable pattern
306-
--> $DIR/empty-types.rs:287:9
307-
|
308-
LL | Ok(_) => {}
309-
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
310-
|
311-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
312-
313-
error: unreachable pattern
314-
--> $DIR/empty-types.rs:288:9
315-
|
316-
LL | Err(_) => {}
317-
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
318-
|
319-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
320-
321193
error[E0005]: refutable pattern in local binding
322194
--> $DIR/empty-types.rs:297:13
323195
|
@@ -465,30 +337,6 @@ LL + _ => todo!(),
465337
LL + }
466338
|
467339

468-
error: unreachable pattern
469-
--> $DIR/empty-types.rs:368:9
470-
|
471-
LL | _ => {}
472-
| ^ matches no values because `[!; 3]` is uninhabited
473-
|
474-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
475-
476-
error: unreachable pattern
477-
--> $DIR/empty-types.rs:371:9
478-
|
479-
LL | [_, _, _] => {}
480-
| ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited
481-
|
482-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
483-
484-
error: unreachable pattern
485-
--> $DIR/empty-types.rs:374:9
486-
|
487-
LL | [_, ..] => {}
488-
| ^^^^^^^ matches no values because `[!; 3]` is uninhabited
489-
|
490-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
491-
492340
error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
493341
--> $DIR/empty-types.rs:388:11
494342
|
@@ -525,40 +373,6 @@ LL ~ [..] if false => {},
525373
LL + [] => todo!()
526374
|
527375

528-
error: unreachable pattern
529-
--> $DIR/empty-types.rs:416:9
530-
|
531-
LL | Some(_) => {}
532-
| ^^^^^^^ matches no values because `!` is uninhabited
533-
|
534-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
535-
536-
error: unreachable pattern
537-
--> $DIR/empty-types.rs:421:9
538-
|
539-
LL | Some(_a) => {}
540-
| ^^^^^^^^ matches no values because `!` is uninhabited
541-
|
542-
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
543-
544-
error: unreachable pattern
545-
--> $DIR/empty-types.rs:426:9
546-
|
547-
LL | None => {}
548-
| ---- matches all the relevant values
549-
LL | // !useful, !reachable
550-
LL | _ => {}
551-
| ^ no value can reach this
552-
553-
error: unreachable pattern
554-
--> $DIR/empty-types.rs:431:9
555-
|
556-
LL | None => {}
557-
| ---- matches all the relevant values
558-
LL | // !useful, !reachable
559-
LL | _a => {}
560-
| ^^ no value can reach this
561-
562376
error[E0004]: non-exhaustive patterns: `&Some(_)` not covered
563377
--> $DIR/empty-types.rs:451:11
564378
|
@@ -735,7 +549,7 @@ LL ~ None => {},
735549
LL + Some(_) => todo!()
736550
|
737551

738-
error: aborting due to 65 previous errors
552+
error: aborting due to 42 previous errors
739553

740554
Some errors have detailed explanations: E0004, E0005.
741555
For more information about an error, try `rustc --explain E0004`.

‎tests/ui/pattern/usefulness/empty-types.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ fn basic(x: NeverBundle) {
6767
let tuple_half_never: (u32, !) = x.tuple_half_never;
6868
match tuple_half_never {}
6969
match tuple_half_never {
70-
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
70+
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
7171
}
7272

7373
let tuple_never: (!, !) = x.tuple_never;
7474
match tuple_never {}
7575
match tuple_never {
76-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
76+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
7777
}
7878
match tuple_never {
79-
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
79+
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
8080
}
8181
match tuple_never.0 {}
8282
match tuple_never.0 {
@@ -91,12 +91,12 @@ fn basic(x: NeverBundle) {
9191
}
9292
match res_u32_never {
9393
Ok(_) => {}
94-
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
94+
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
9595
}
9696
match res_u32_never {
9797
//~^ ERROR non-exhaustive
9898
Ok(0) => {}
99-
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
99+
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
100100
}
101101
let Ok(_x) = res_u32_never;
102102
let Ok(_x) = res_u32_never.as_ref();
@@ -109,18 +109,18 @@ fn basic(x: NeverBundle) {
109109
let result_never: Result<!, !> = x.result_never;
110110
match result_never {}
111111
match result_never {
112-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
112+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
113113
}
114114
match result_never {
115-
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
115+
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
116116
}
117117
match result_never {
118-
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
119-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
118+
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
119+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
120120
}
121121
match result_never {
122-
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
123-
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
122+
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
123+
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
124124
}
125125
}
126126

@@ -140,11 +140,11 @@ fn void_same_as_never(x: NeverBundle) {
140140
}
141141
match opt_void {
142142
None => {}
143-
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
143+
Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
144144
}
145145
match opt_void {
146146
None => {}
147-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
147+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
148148
}
149149

150150
let ref_void: &Void = &x.void;
@@ -281,11 +281,11 @@ fn nested_validity_tracking(bundle: NeverBundle) {
281281
_ => {} //~ ERROR unreachable pattern
282282
}
283283
match tuple_never {
284-
(_, _) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
284+
(_, _) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
285285
}
286286
match result_never {
287-
Ok(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
288-
Err(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
287+
Ok(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
288+
Err(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
289289
}
290290

291291
// These should be considered !known_valid and not warn unreachable.
@@ -365,13 +365,13 @@ fn arrays_and_slices(x: NeverBundle) {
365365
let array_3_never: [!; 3] = x.array_3_never;
366366
match array_3_never {}
367367
match array_3_never {
368-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
368+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
369369
}
370370
match array_3_never {
371-
[_, _, _] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
371+
[_, _, _] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
372372
}
373373
match array_3_never {
374-
[_, ..] => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
374+
[_, ..] => {} //[exhaustive_patterns]~ ERROR unreachable pattern
375375
}
376376

377377
let ref_array_3_never: &[!; 3] = &array_3_never;
@@ -413,22 +413,22 @@ fn bindings(x: NeverBundle) {
413413
match opt_never {
414414
None => {}
415415
// !useful, !reachable
416-
Some(_) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
416+
Some(_) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
417417
}
418418
match opt_never {
419419
None => {}
420420
// !useful, !reachable
421-
Some(_a) => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
421+
Some(_a) => {} //[exhaustive_patterns]~ ERROR unreachable pattern
422422
}
423423
match opt_never {
424424
None => {}
425425
// !useful, !reachable
426-
_ => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
426+
_ => {} //[exhaustive_patterns]~ ERROR unreachable pattern
427427
}
428428
match opt_never {
429429
None => {}
430430
// !useful, !reachable
431-
_a => {} //[exhaustive_patterns,normal,never_pats]~ ERROR unreachable pattern
431+
_a => {} //[exhaustive_patterns]~ ERROR unreachable pattern
432432
}
433433

434434
// The scrutinee is known_valid, but under the `&` isn't anymore.

‎tests/ui/pattern/usefulness/explain-unreachable-pats.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(never_type)]
2+
#![feature(exhaustive_patterns)]
23
#![deny(unreachable_patterns)]
34
//~^ NOTE lint level is defined here
45

‎tests/ui/pattern/usefulness/explain-unreachable-pats.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unreachable pattern
2-
--> $DIR/explain-unreachable-pats.rs:10:9
2+
--> $DIR/explain-unreachable-pats.rs:11:9
33
|
44
LL | (1 | 2,) => {}
55
| -------- matches all the relevant values
@@ -8,19 +8,19 @@ LL | (2,) => {}
88
| ^^^^ no value can reach this
99
|
1010
note: the lint level is defined here
11-
--> $DIR/explain-unreachable-pats.rs:2:9
11+
--> $DIR/explain-unreachable-pats.rs:3:9
1212
|
1313
LL | #![deny(unreachable_patterns)]
1414
| ^^^^^^^^^^^^^^^^^^^^
1515

1616
error: unreachable pattern
17-
--> $DIR/explain-unreachable-pats.rs:21:9
17+
--> $DIR/explain-unreachable-pats.rs:22:9
1818
|
1919
LL | (1 | 2,) => {}
2020
| ^^^^^^^^ no value can reach this
2121
|
2222
note: multiple earlier patterns match some of the same values
23-
--> $DIR/explain-unreachable-pats.rs:21:9
23+
--> $DIR/explain-unreachable-pats.rs:22:9
2424
|
2525
LL | (1,) => {}
2626
| ---- matches some of the same values
@@ -32,13 +32,13 @@ LL | (1 | 2,) => {}
3232
| ^^^^^^^^ collectively making this unreachable
3333

3434
error: unreachable pattern
35-
--> $DIR/explain-unreachable-pats.rs:40:9
35+
--> $DIR/explain-unreachable-pats.rs:41:9
3636
|
3737
LL | 1 ..= 6 => {}
3838
| ^^^^^^^ no value can reach this
3939
|
4040
note: multiple earlier patterns match some of the same values
41-
--> $DIR/explain-unreachable-pats.rs:40:9
41+
--> $DIR/explain-unreachable-pats.rs:41:9
4242
|
4343
LL | 1 => {}
4444
| - matches some of the same values
@@ -56,31 +56,31 @@ LL | 1 ..= 6 => {}
5656
| ^^^^^^^ ...and 2 other patterns collectively make this unreachable
5757

5858
error: unreachable pattern
59-
--> $DIR/explain-unreachable-pats.rs:51:9
59+
--> $DIR/explain-unreachable-pats.rs:52:9
6060
|
6161
LL | Err(_) => {}
6262
| ^^^^^^ matches no values because `!` is uninhabited
6363
|
6464
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
6565

6666
error: unreachable pattern
67-
--> $DIR/explain-unreachable-pats.rs:65:9
67+
--> $DIR/explain-unreachable-pats.rs:66:9
6868
|
6969
LL | (Err(_), Err(_)) => {}
7070
| ^^^^^^^^^^^^^^^^ matches no values because `Void2` is uninhabited
7171
|
7272
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
7373

7474
error: unreachable pattern
75-
--> $DIR/explain-unreachable-pats.rs:72:9
75+
--> $DIR/explain-unreachable-pats.rs:73:9
7676
|
7777
LL | (Err(_), Err(_)) => {}
7878
| ^^^^^^^^^^^^^^^^ matches no values because `Void1` is uninhabited
7979
|
8080
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
8181

8282
error: unreachable pattern
83-
--> $DIR/explain-unreachable-pats.rs:82:11
83+
--> $DIR/explain-unreachable-pats.rs:83:11
8484
|
8585
LL | if let (0
8686
| - matches all the relevant values
@@ -89,13 +89,13 @@ LL | | 0, _) = (0, 0) {}
8989
| ^ no value can reach this
9090

9191
error: unreachable pattern
92-
--> $DIR/explain-unreachable-pats.rs:92:9
92+
--> $DIR/explain-unreachable-pats.rs:93:9
9393
|
9494
LL | (_, true) => {}
9595
| ^^^^^^^^^ no value can reach this
9696
|
9797
note: multiple earlier patterns match some of the same values
98-
--> $DIR/explain-unreachable-pats.rs:92:9
98+
--> $DIR/explain-unreachable-pats.rs:93:9
9999
|
100100
LL | (true, _) => {}
101101
| --------- matches some of the same values
@@ -107,7 +107,7 @@ LL | (_, true) => {}
107107
| ^^^^^^^^^ collectively making this unreachable
108108

109109
error: unreachable pattern
110-
--> $DIR/explain-unreachable-pats.rs:105:9
110+
--> $DIR/explain-unreachable-pats.rs:106:9
111111
|
112112
LL | (true, _) => {}
113113
| --------- matches all the relevant values
@@ -116,7 +116,7 @@ LL | (true, true) => {}
116116
| ^^^^^^^^^^^^ no value can reach this
117117

118118
error: unreachable pattern
119-
--> $DIR/explain-unreachable-pats.rs:117:9
119+
--> $DIR/explain-unreachable-pats.rs:118:9
120120
|
121121
LL | (_, true, 0..10) => {}
122122
| ---------------- matches all the relevant values

‎tests/ui/pattern/usefulness/impl-trait.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(never_type)]
22
#![feature(type_alias_impl_trait)]
33
#![feature(non_exhaustive_omitted_patterns_lint)]
4+
#![feature(exhaustive_patterns)]
45
#![deny(unreachable_patterns)]
56
// Test that the lint traversal handles opaques correctly
67
#![deny(non_exhaustive_omitted_patterns)]

‎tests/ui/pattern/usefulness/impl-trait.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,114 @@
11
error: unreachable pattern
2-
--> $DIR/impl-trait.rs:16:13
2+
--> $DIR/impl-trait.rs:17:13
33
|
44
LL | _ => {}
55
| ^ matches no values because `Void` is uninhabited
66
|
77
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
88
note: the lint level is defined here
9-
--> $DIR/impl-trait.rs:4:9
9+
--> $DIR/impl-trait.rs:5:9
1010
|
1111
LL | #![deny(unreachable_patterns)]
1212
| ^^^^^^^^^^^^^^^^^^^^
1313

1414
error: unreachable pattern
15-
--> $DIR/impl-trait.rs:30:13
15+
--> $DIR/impl-trait.rs:31:13
1616
|
1717
LL | _ => {}
1818
| ^ matches no values because `Void` is uninhabited
1919
|
2020
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2121

2222
error: unreachable pattern
23-
--> $DIR/impl-trait.rs:44:13
23+
--> $DIR/impl-trait.rs:45:13
2424
|
2525
LL | Some(_) => {}
2626
| ^^^^^^^ matches no values because `Void` is uninhabited
2727
|
2828
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2929

3030
error: unreachable pattern
31-
--> $DIR/impl-trait.rs:48:13
31+
--> $DIR/impl-trait.rs:49:13
3232
|
3333
LL | None => {}
3434
| ---- matches all the relevant values
3535
LL | _ => {}
3636
| ^ no value can reach this
3737

3838
error: unreachable pattern
39-
--> $DIR/impl-trait.rs:58:13
39+
--> $DIR/impl-trait.rs:59:13
4040
|
4141
LL | Some(_) => {}
4242
| ^^^^^^^ matches no values because `Void` is uninhabited
4343
|
4444
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
4545

4646
error: unreachable pattern
47-
--> $DIR/impl-trait.rs:62:13
47+
--> $DIR/impl-trait.rs:63:13
4848
|
4949
LL | None => {}
5050
| ---- matches all the relevant values
5151
LL | _ => {}
5252
| ^ no value can reach this
5353

5454
error: unreachable pattern
55-
--> $DIR/impl-trait.rs:75:9
55+
--> $DIR/impl-trait.rs:76:9
5656
|
5757
LL | _ => {}
5858
| ^ matches no values because `Void` is uninhabited
5959
|
6060
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
6161

6262
error: unreachable pattern
63-
--> $DIR/impl-trait.rs:85:9
63+
--> $DIR/impl-trait.rs:86:9
6464
|
6565
LL | _ => {}
6666
| - matches any value
6767
LL | Some((a, b)) => {}
6868
| ^^^^^^^^^^^^ no value can reach this
6969

7070
error: unreachable pattern
71-
--> $DIR/impl-trait.rs:93:13
71+
--> $DIR/impl-trait.rs:94:13
7272
|
7373
LL | _ => {}
7474
| ^ matches no values because `Void` is uninhabited
7575
|
7676
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
7777

7878
error: unreachable pattern
79-
--> $DIR/impl-trait.rs:104:9
79+
--> $DIR/impl-trait.rs:105:9
8080
|
8181
LL | Some((a, b)) => {}
8282
| ------------ matches all the relevant values
8383
LL | Some((mut x, mut y)) => {
8484
| ^^^^^^^^^^^^^^^^^^^^ no value can reach this
8585

8686
error: unreachable pattern
87-
--> $DIR/impl-trait.rs:123:13
87+
--> $DIR/impl-trait.rs:124:13
8888
|
8989
LL | _ => {}
9090
| - matches any value
9191
LL | Rec { n: 0, w: Some(Rec { n: 0, w: _ }) } => {}
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no value can reach this
9393

9494
error: unreachable pattern
95-
--> $DIR/impl-trait.rs:137:13
95+
--> $DIR/impl-trait.rs:138:13
9696
|
9797
LL | _ => {}
9898
| ^ matches no values because `SecretelyVoid` is uninhabited
9999
|
100100
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
101101

102102
error: unreachable pattern
103-
--> $DIR/impl-trait.rs:150:13
103+
--> $DIR/impl-trait.rs:151:13
104104
|
105105
LL | _ => {}
106106
| ^ matches no values because `SecretelyDoubleVoid` is uninhabited
107107
|
108108
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
109109

110110
error[E0004]: non-exhaustive patterns: type `impl Copy` is non-empty
111-
--> $DIR/impl-trait.rs:22:11
111+
--> $DIR/impl-trait.rs:23:11
112112
|
113113
LL | match return_never_rpit(x) {}
114114
| ^^^^^^^^^^^^^^^^^^^^
@@ -122,7 +122,7 @@ LL + }
122122
|
123123

124124
error[E0004]: non-exhaustive patterns: type `T` is non-empty
125-
--> $DIR/impl-trait.rs:36:11
125+
--> $DIR/impl-trait.rs:37:11
126126
|
127127
LL | match return_never_tait(x) {}
128128
| ^^^^^^^^^^^^^^^^^^^^

‎tests/ui/reachable/unreachable-loop-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(exhaustive_patterns)]
12
#![feature(never_type, never_type_fallback)]
23
#![allow(unreachable_code)]
34
#![deny(unreachable_patterns)]

‎tests/ui/reachable/unreachable-loop-patterns.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: unreachable pattern
2-
--> $DIR/unreachable-loop-patterns.rs:16:9
2+
--> $DIR/unreachable-loop-patterns.rs:17:9
33
|
44
LL | for _ in unimplemented!() as Void {}
55
| ^ matches no values because `Void` is uninhabited
66
|
77
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
88
note: the lint level is defined here
9-
--> $DIR/unreachable-loop-patterns.rs:3:9
9+
--> $DIR/unreachable-loop-patterns.rs:4:9
1010
|
1111
LL | #![deny(unreachable_patterns)]
1212
| ^^^^^^^^^^^^^^^^^^^^

‎tests/ui/rfcs/rfc-0000-never_patterns/unreachable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(exhaustive_patterns)]
12
#![feature(never_patterns)]
23
#![allow(incomplete_features)]
34
#![allow(dead_code, unreachable_code)]

‎tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
error: unreachable pattern
2-
--> $DIR/unreachable.rs:14:9
2+
--> $DIR/unreachable.rs:15:9
33
|
44
LL | Err(!),
55
| ^^^^^^ matches no values because `Void` is uninhabited
66
|
77
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
88
note: the lint level is defined here
9-
--> $DIR/unreachable.rs:4:9
9+
--> $DIR/unreachable.rs:5:9
1010
|
1111
LL | #![deny(unreachable_patterns)]
1212
| ^^^^^^^^^^^^^^^^^^^^
1313

1414
error: unreachable pattern
15-
--> $DIR/unreachable.rs:17:19
15+
--> $DIR/unreachable.rs:18:19
1616
|
1717
LL | let (Ok(_x) | Err(!)) = res_void;
1818
| ^^^^^^ matches no values because `Void` is uninhabited
1919
|
2020
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2121

2222
error: unreachable pattern
23-
--> $DIR/unreachable.rs:19:12
23+
--> $DIR/unreachable.rs:20:12
2424
|
2525
LL | if let Err(!) = res_void {}
2626
| ^^^^^^ matches no values because `Void` is uninhabited
2727
|
2828
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2929

3030
error: unreachable pattern
31-
--> $DIR/unreachable.rs:21:24
31+
--> $DIR/unreachable.rs:22:24
3232
|
3333
LL | if let (Ok(true) | Err(!)) = res_void {}
3434
| ^^^^^^ matches no values because `Void` is uninhabited
3535
|
3636
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
3737

3838
error: unreachable pattern
39-
--> $DIR/unreachable.rs:23:23
39+
--> $DIR/unreachable.rs:24:23
4040
|
4141
LL | for (Ok(mut _x) | Err(!)) in [res_void] {}
4242
| ^^^^^^ matches no values because `Void` is uninhabited
4343
|
4444
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
4545

4646
error: unreachable pattern
47-
--> $DIR/unreachable.rs:27:18
47+
--> $DIR/unreachable.rs:28:18
4848
|
4949
LL | fn foo((Ok(_x) | Err(!)): Result<bool, Void>) {}
5050
| ^^^^^^ matches no values because `Void` is uninhabited

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ aux-build:uninhabited.rs
22
//@ build-pass (FIXME(62277): could be check-pass?)
3+
#![feature(exhaustive_patterns)]
34
#![deny(unreachable_patterns)]
45

56
extern crate uninhabited;

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(exhaustive_patterns)]
12
#![deny(unreachable_patterns)]
23
#![feature(never_type)]
34

‎tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
error: unreachable pattern
2-
--> $DIR/patterns_same_crate.rs:51:9
2+
--> $DIR/patterns_same_crate.rs:52:9
33
|
44
LL | Some(_x) => (),
55
| ^^^^^^^^ matches no values because `UninhabitedEnum` is uninhabited
66
|
77
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
88
note: the lint level is defined here
9-
--> $DIR/patterns_same_crate.rs:1:9
9+
--> $DIR/patterns_same_crate.rs:2:9
1010
|
1111
LL | #![deny(unreachable_patterns)]
1212
| ^^^^^^^^^^^^^^^^^^^^
1313

1414
error: unreachable pattern
15-
--> $DIR/patterns_same_crate.rs:56:9
15+
--> $DIR/patterns_same_crate.rs:57:9
1616
|
1717
LL | Some(_x) => (),
1818
| ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited
1919
|
2020
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2121

2222
error: unreachable pattern
23-
--> $DIR/patterns_same_crate.rs:60:15
23+
--> $DIR/patterns_same_crate.rs:61:15
2424
|
2525
LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() {
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ matches no values because `!` is uninhabited
2727
|
2828
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2929

3030
error: unreachable pattern
31-
--> $DIR/patterns_same_crate.rs:64:15
31+
--> $DIR/patterns_same_crate.rs:65:15
3232
|
3333
LL | while let Some(_x) = uninhabited_struct() {
3434
| ^^^^^^^^ matches no values because `UninhabitedStruct` is uninhabited
3535
|
3636
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
3737

3838
error: unreachable pattern
39-
--> $DIR/patterns_same_crate.rs:67:15
39+
--> $DIR/patterns_same_crate.rs:68:15
4040
|
4141
LL | while let Some(_x) = uninhabited_tuple_struct() {
4242
| ^^^^^^^^ matches no values because `UninhabitedTupleStruct` is uninhabited

‎tests/ui/uninhabited/uninhabited-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(exhaustive_patterns)]
12
#![feature(box_patterns)]
23
#![feature(never_type)]
34
#![deny(unreachable_patterns)]

‎tests/ui/uninhabited/uninhabited-patterns.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
error: unreachable pattern
2-
--> $DIR/uninhabited-patterns.rs:29:9
2+
--> $DIR/uninhabited-patterns.rs:30:9
33
|
44
LL | Ok(box _) => (),
55
| ^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
66
|
77
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
88
note: the lint level is defined here
9-
--> $DIR/uninhabited-patterns.rs:3:9
9+
--> $DIR/uninhabited-patterns.rs:4:9
1010
|
1111
LL | #![deny(unreachable_patterns)]
1212
| ^^^^^^^^^^^^^^^^^^^^
1313

1414
error: unreachable pattern
15-
--> $DIR/uninhabited-patterns.rs:38:9
15+
--> $DIR/uninhabited-patterns.rs:39:9
1616
|
1717
LL | Err(Ok(_y)) => (),
1818
| ^^^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
1919
|
2020
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2121

2222
error: unreachable pattern
23-
--> $DIR/uninhabited-patterns.rs:41:15
23+
--> $DIR/uninhabited-patterns.rs:42:15
2424
|
2525
LL | while let Some(_y) = foo() {
2626
| ^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited

‎tests/ui/unsafe/union-pat-in-param.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
union U {
2+
a: &'static i32,
3+
b: usize,
4+
}
5+
6+
fn fun(U { a }: U) {
7+
//~^ ERROR access to union field is unsafe
8+
dbg!(*a);
9+
}
10+
11+
fn main() {
12+
fun(U { b: 0 });
13+
14+
let closure = |U { a }| {
15+
//~^ ERROR access to union field is unsafe
16+
dbg!(*a);
17+
};
18+
closure(U { b: 0 });
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0133]: access to union field is unsafe and requires unsafe function or block
2+
--> $DIR/union-pat-in-param.rs:6:12
3+
|
4+
LL | fn fun(U { a }: U) {
5+
| ^ access to union field
6+
|
7+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
8+
9+
error[E0133]: access to union field is unsafe and requires unsafe function or block
10+
--> $DIR/union-pat-in-param.rs:14:24
11+
|
12+
LL | let closure = |U { a }| {
13+
| ^ access to union field
14+
|
15+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0133`.

0 commit comments

Comments
 (0)
Please sign in to comment.