Fixes in various places
This commit is contained in:
parent
8615a6b006
commit
e77612d3e4
11 changed files with 12 additions and 4 deletions
|
@ -585,6 +585,7 @@ pub enum E2<X> {
|
||||||
V4,
|
V4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
fn check_niche_behavior() {
|
fn check_niche_behavior() {
|
||||||
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
||||||
intrinsics::abort();
|
intrinsics::abort();
|
||||||
|
|
|
@ -430,6 +430,7 @@ pub enum E2<X> {
|
||||||
V4,
|
V4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
fn check_niche_behavior () {
|
fn check_niche_behavior () {
|
||||||
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
||||||
intrinsics::abort();
|
intrinsics::abort();
|
||||||
|
|
|
@ -2931,6 +2931,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
|
||||||
moved_before_use,
|
moved_before_use,
|
||||||
same_ctxt,
|
same_ctxt,
|
||||||
},
|
},
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"),
|
Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"),
|
||||||
None => ExprUseCtxt {
|
None => ExprUseCtxt {
|
||||||
node: Node::Crate(cx.tcx.hir().root_module()),
|
node: Node::Crate(cx.tcx.hir().root_module()),
|
||||||
|
|
|
@ -89,7 +89,7 @@ fn main() {
|
||||||
|
|
||||||
// lint here
|
// lint here
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
|
if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
|
||||||
println!("else block");
|
println!("else block");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn main() {
|
||||||
|
|
||||||
// lint here
|
// lint here
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
match Result::<i32, Infallible>::Ok(1) {
|
match Result::<i32, &Infallible>::Ok(1) {
|
||||||
Ok(a) => println!("${:?}", a),
|
Ok(a) => println!("${:?}", a),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
println!("else block");
|
println!("else block");
|
||||||
|
|
|
@ -64,7 +64,7 @@ LL + }
|
||||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||||
--> tests/ui/single_match_else.rs:101:5
|
--> tests/ui/single_match_else.rs:101:5
|
||||||
|
|
|
|
||||||
LL | / match Result::<i32, Infallible>::Ok(1) {
|
LL | / match Result::<i32, &Infallible>::Ok(1) {
|
||||||
LL | | Ok(a) => println!("${:?}", a),
|
LL | | Ok(a) => println!("${:?}", a),
|
||||||
LL | | Err(_) => {
|
LL | | Err(_) => {
|
||||||
LL | | println!("else block");
|
LL | | println!("else block");
|
||||||
|
@ -75,7 +75,7 @@ LL | | }
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL ~ if let Ok(a) = Result::<i32, Infallible>::Ok(1) { println!("${:?}", a) } else {
|
LL ~ if let Ok(a) = Result::<i32, &Infallible>::Ok(1) { println!("${:?}", a) } else {
|
||||||
LL + println!("else block");
|
LL + println!("else block");
|
||||||
LL + return;
|
LL + return;
|
||||||
LL + }
|
LL + }
|
||||||
|
|
|
@ -463,6 +463,7 @@ pub fn eval_entry<'tcx>(
|
||||||
let res = match res {
|
let res = match res {
|
||||||
Err(res) => res,
|
Err(res) => res,
|
||||||
// `Ok` can never happen
|
// `Ok` can never happen
|
||||||
|
#[cfg(bootstrap)]
|
||||||
Ok(never) => match never {},
|
Ok(never) => match never {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ async fn hello_world() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This example comes from https://github.com/rust-lang/rust/issues/115145
|
// This example comes from https://github.com/rust-lang/rust/issues/115145
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
async fn uninhabited_variant() {
|
async fn uninhabited_variant() {
|
||||||
async fn unreachable(_: Never) {}
|
async fn unreachable(_: Never) {}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ fn discriminant_overflow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
fn more_discriminant_overflow() {
|
fn more_discriminant_overflow() {
|
||||||
pub enum Infallible {}
|
pub enum Infallible {}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ macro_rules! from_bytes {
|
||||||
($ty:tt, $value:expr) => {
|
($ty:tt, $value:expr) => {
|
||||||
($ty::from_le_bytes(match ($value).try_into() {
|
($ty::from_le_bytes(match ($value).try_into() {
|
||||||
Ok(it) => it,
|
Ok(it) => it,
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
Err(_) => return Err(MirEvalError::InternalError("mismatched size".into())),
|
Err(_) => return Err(MirEvalError::InternalError("mismatched size".into())),
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
|
|
|
@ -1161,6 +1161,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
|
||||||
ProjectionElem::OpaqueCast(it) => {
|
ProjectionElem::OpaqueCast(it) => {
|
||||||
ProjectionElem::OpaqueCast(it)
|
ProjectionElem::OpaqueCast(it)
|
||||||
}
|
}
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
ProjectionElem::Index(it) => match it {},
|
ProjectionElem::Index(it) => match it {},
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue