Skip to content

Commit

Permalink
Fixes in various places
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Aug 6, 2024
1 parent a1d0cdb commit 52c4b2d
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ pub enum E2<X> {
V4,
}

#[allow(unreachable_patterns)]
fn check_niche_behavior() {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ pub enum E2<X> {
V4,
}

#[allow(unreachable_patterns)]
fn check_niche_behavior () {
if let E1::V2 { .. } = (E1::V1 { f: true }) {
intrinsics::abort();
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
moved_before_use,
same_ctxt,
},
#[allow(unreachable_patterns)]
Some(ControlFlow::Break(_)) => unreachable!("type of node is ControlFlow<!>"),
None => ExprUseCtxt {
node: Node::Crate(cx.tcx.hir().root_module()),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/single_match_else.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn main() {

// lint here
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");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/single_match_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn main() {

// lint here
use std::convert::Infallible;
match Result::<i32, Infallible>::Ok(1) {
match Result::<i32, &Infallible>::Ok(1) {
Ok(a) => println!("${:?}", a),
Err(_) => {
println!("else block");
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/single_match_else.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ LL + }
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
|
LL | / match Result::<i32, Infallible>::Ok(1) {
LL | / match Result::<i32, &Infallible>::Ok(1) {
LL | | Ok(a) => println!("${:?}", a),
LL | | Err(_) => {
LL | | println!("else block");
Expand All @@ -75,7 +75,7 @@ LL | | }
|
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 + return;
LL + }
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ pub fn eval_entry<'tcx>(
let res = match res {
Err(res) => res,
// `Ok` can never happen
#[cfg(bootstrap)]
Ok(never) => match never {},
};

Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/tests/pass/async-fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async fn hello_world() {
}

// This example comes from https://github.com/rust-lang/rust/issues/115145
#[allow(unreachable_patterns)]
async fn uninhabited_variant() {
async fn unreachable(_: Never) {}

Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/tests/pass/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn discriminant_overflow() {
}
}

#[allow(unreachable_patterns)]
fn more_discriminant_overflow() {
pub enum Infallible {}

Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-ty/src/mir/eval/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ macro_rules! from_bytes {
($ty:tt, $value:expr) => {
($ty::from_le_bytes(match ($value).try_into() {
Ok(it) => it,
#[allow(unreachable_patterns)]
Err(_) => return Err(MirEvalError::InternalError("mismatched size".into())),
}))
};
Expand Down

0 comments on commit 52c4b2d

Please sign in to comment.