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 Mar 20, 2024
1 parent 3a7fd6c commit b86a6f8
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,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 @@ -432,6 +432,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
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 @@ -90,7 +90,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 @@ -99,7 +99,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:102: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 @@ -441,6 +441,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

0 comments on commit b86a6f8

Please sign in to comment.