Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/82329.sh: fixed with no errors #733

Merged
merged 1 commit into from
Apr 27, 2021
Merged

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#82329

#!/bin/bash

rustc -Zunpretty=hir,typed - <<'EOF'
pub fn main() {
    if true {
    } else if let a = 1 { //~ WARN irrefutable `if let`
    }
}
EOF
=== stdout ===
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
pub fn main() ({
                   (if (true as bool)
                       ({ } as
                           ()) else {match (1 as i32) {
                                         a => { //~ WARN irrefutable `if let`
                                         }
                                         _ => { }
                                     }} as ())
                    } as ())
=== stderr ===
warning: irrefutable `if let` pattern
 --> <anon>:3:12
  |
3 |       } else if let a = 1 { //~ WARN irrefutable `if let`
  |  ____________^
4 | |     }
  | |_____^
  |
  = note: `#[warn(irrefutable_let_patterns)]` on by default
  = note: this pattern will always match, so the `if let` is useless
  = help: consider replacing the `if let` with a `let`

warning: unused variable: `a`
 --> <anon>:3:19
  |
3 |     } else if let a = 1 { //~ WARN irrefutable `if let`
  |                   ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

==============

=== stdout ===
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
pub fn main() ({
                   (if (true as bool)
                       ({ } as
                           ()) else {match (1 as i32) {
                                         a => { //~ WARN irrefutable `if let`
                                         }
                                         _ => { }
                                     }} as ())
                    } as ())
=== stderr ===
warning: irrefutable `if let` pattern
 --> <anon>:3:12
  |
3 |       } else if let a = 1 { //~ WARN irrefutable `if let`
  |  ____________^
4 | |     }
  | |_____^
  |
  = note: `#[warn(irrefutable_let_patterns)]` on by default
  = note: this pattern will always match, so the `if let` is useless
  = help: consider replacing the `if let` with a `let`

warning: unused variable: `a`
 --> <anon>:3:19
  |
3 |     } else if let a = 1 { //~ WARN irrefutable `if let`
  |                   ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

==============
@JohnTitor JohnTitor merged commit 7e34812 into master Apr 27, 2021
@JohnTitor JohnTitor deleted the autofix/ices/82329.sh branch April 27, 2021 13:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants