Fix unused_variables in tests

This commit is contained in:
hkalbasi 2023-09-24 23:45:36 +03:30
parent 7834b8fadb
commit ab52ba2de7
13 changed files with 122 additions and 104 deletions

View file

@ -1774,13 +1774,14 @@ impl<'ctx> MirLowerCtx<'ctx> {
} }
} }
} }
hir_def::hir::Statement::Expr { expr, has_semi: _ } => { &hir_def::hir::Statement::Expr { expr, has_semi: _ } => {
let scope2 = self.push_drop_scope(); let scope2 = self.push_drop_scope();
let Some((_, c)) = self.lower_expr_as_place(current, *expr, true)? else { let Some((p, c)) = self.lower_expr_as_place(current, expr, true)? else {
scope2.pop_assume_dropped(self); scope2.pop_assume_dropped(self);
scope.pop_assume_dropped(self); scope.pop_assume_dropped(self);
return Ok(None); return Ok(None);
}; };
self.push_fake_read(c, p, expr.into());
current = scope2.pop_and_drop(self, c); current = scope2.pop_and_drop(self, c);
} }
} }

View file

@ -166,7 +166,7 @@ fn main() {
check_diagnostics( check_diagnostics(
r#" r#"
struct A { a: &'static str } struct A { a: &'static str }
fn f(a: A) { let A { a: hello } = a; } fn f(a: A) { let A { a: _hello } = a; }
"#, "#,
); );
check_diagnostics( check_diagnostics(
@ -181,12 +181,14 @@ fn f(a: A) { let A { 0: 0 } = a; }
struct A { a: &'static str } struct A { a: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a$0: a } = a; let A { a$0: a } = a;
_ = a;
} }
"#, "#,
r#" r#"
struct A { a: &'static str } struct A { a: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a } = a; let A { a } = a;
_ = a;
} }
"#, "#,
); );
@ -196,12 +198,14 @@ fn f(a: A) {
struct A { a: &'static str, b: &'static str } struct A { a: &'static str, b: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a$0: a, b } = a; let A { a$0: a, b } = a;
_ = (a, b);
} }
"#, "#,
r#" r#"
struct A { a: &'static str, b: &'static str } struct A { a: &'static str, b: &'static str }
fn f(a: A) { fn f(a: A) {
let A { a, b } = a; let A { a, b } = a;
_ = (a, b);
} }
"#, "#,
); );

View file

@ -175,10 +175,10 @@ fn NonSnakeCaseName() {}
fn incorrect_function_params() { fn incorrect_function_params() {
check_diagnostics( check_diagnostics(
r#" r#"
fn foo(SomeParam: u8) {} fn foo(SomeParam: u8) { _ = SomeParam; }
// ^^^^^^^^^ 💡 warn: Parameter `SomeParam` should have snake_case name, e.g. `some_param` // ^^^^^^^^^ 💡 warn: Parameter `SomeParam` should have snake_case name, e.g. `some_param`
fn foo2(ok_param: &str, CAPS_PARAM: u8) {} fn foo2(ok_param: &str, CAPS_PARAM: u8) { _ = (ok_param, CAPS_PARAM); }
// ^^^^^^^^^^ 💡 warn: Parameter `CAPS_PARAM` should have snake_case name, e.g. `caps_param` // ^^^^^^^^^^ 💡 warn: Parameter `CAPS_PARAM` should have snake_case name, e.g. `caps_param`
"#, "#,
); );
@ -188,6 +188,7 @@ fn foo2(ok_param: &str, CAPS_PARAM: u8) {}
fn incorrect_variable_names() { fn incorrect_variable_names() {
check_diagnostics( check_diagnostics(
r#" r#"
#[allow(unused)]
fn foo() { fn foo() {
let SOME_VALUE = 10; let SOME_VALUE = 10;
// ^^^^^^^^^^ 💡 warn: Variable `SOME_VALUE` should have snake_case name, e.g. `some_value` // ^^^^^^^^^^ 💡 warn: Variable `SOME_VALUE` should have snake_case name, e.g. `some_value`
@ -294,6 +295,7 @@ impl someStruct {
// ^^^^^^^^ 💡 warn: Function `SomeFunc` should have snake_case name, e.g. `some_func` // ^^^^^^^^ 💡 warn: Function `SomeFunc` should have snake_case name, e.g. `some_func`
let WHY_VAR_IS_CAPS = 10; let WHY_VAR_IS_CAPS = 10;
// ^^^^^^^^^^^^^^^ 💡 warn: Variable `WHY_VAR_IS_CAPS` should have snake_case name, e.g. `why_var_is_caps` // ^^^^^^^^^^^^^^^ 💡 warn: Variable `WHY_VAR_IS_CAPS` should have snake_case name, e.g. `why_var_is_caps`
_ = WHY_VAR_IS_CAPS;
} }
} }
"#, "#,
@ -306,6 +308,7 @@ impl someStruct {
r#" r#"
enum Option { Some, None } enum Option { Some, None }
#[allow(unused)]
fn main() { fn main() {
match Option::None { match Option::None {
None => (), None => (),
@ -322,6 +325,7 @@ fn main() {
r#" r#"
enum Option { Some, None } enum Option { Some, None }
#[allow(unused)]
fn main() { fn main() {
match Option::None { match Option::None {
SOME_VAR @ None => (), SOME_VAR @ None => (),
@ -349,7 +353,9 @@ enum E {
} }
mod F { mod F {
fn CheckItWorksWithCrateAttr(BAD_NAME_HI: u8) {} fn CheckItWorksWithCrateAttr(BAD_NAME_HI: u8) {
_ = BAD_NAME_HI;
}
} }
"#, "#,
); );
@ -395,7 +401,7 @@ fn qualify() {
#[test] // Issue #8809. #[test] // Issue #8809.
fn parenthesized_parameter() { fn parenthesized_parameter() {
check_diagnostics(r#"fn f((O): _) {}"#) check_diagnostics(r#"fn f((O): _) { _ = O; }"#)
} }
#[test] #[test]
@ -472,7 +478,9 @@ mod CheckBadStyle {
mod F { mod F {
#![allow(non_snake_case)] #![allow(non_snake_case)]
fn CheckItWorksWithModAttr(BAD_NAME_HI: u8) {} fn CheckItWorksWithModAttr(BAD_NAME_HI: u8) {
_ = BAD_NAME_HI;
}
} }
#[allow(non_snake_case, non_camel_case_types)] #[allow(non_snake_case, non_camel_case_types)]

View file

@ -131,7 +131,7 @@ fn f() { zero(); }
fn simple_free_fn_one() { fn simple_free_fn_one() {
check_diagnostics( check_diagnostics(
r#" r#"
fn one(arg: u8) {} fn one(_arg: u8) {}
fn f() { one(); } fn f() { one(); }
//^^ error: expected 1 argument, found 0 //^^ error: expected 1 argument, found 0
"#, "#,
@ -139,7 +139,7 @@ fn f() { one(); }
check_diagnostics( check_diagnostics(
r#" r#"
fn one(arg: u8) {} fn one(_arg: u8) {}
fn f() { one(1); } fn f() { one(1); }
"#, "#,
); );
@ -176,7 +176,7 @@ fn f() {
check_diagnostics( check_diagnostics(
r#" r#"
struct S; struct S;
impl S { fn method(&self, arg: u8) {} } impl S { fn method(&self, _arg: u8) {} }
fn f() { fn f() {
S.method(); S.method();
@ -187,7 +187,7 @@ impl S { fn method(&self, arg: u8) {} }
check_diagnostics( check_diagnostics(
r#" r#"
struct S; struct S;
impl S { fn method(&self, arg: u8) {} } impl S { fn method(&self, _arg: u8) {} }
fn f() { fn f() {
S::method(&S, 0); S::method(&S, 0);
@ -335,8 +335,8 @@ struct S;
impl S { impl S {
fn method(#[cfg(NEVER)] self) {} fn method(#[cfg(NEVER)] self) {}
fn method2(#[cfg(NEVER)] self, arg: u8) {} fn method2(#[cfg(NEVER)] self, _arg: u8) {}
fn method3(self, #[cfg(NEVER)] arg: u8) {} fn method3(self, #[cfg(NEVER)] _arg: u8) {}
} }
extern "C" { extern "C" {
@ -365,8 +365,8 @@ fn main() {
r#" r#"
#[rustc_legacy_const_generics(1, 3)] #[rustc_legacy_const_generics(1, 3)]
fn mixed<const N1: &'static str, const N2: bool>( fn mixed<const N1: &'static str, const N2: bool>(
a: u8, _a: u8,
b: i8, _b: i8,
) {} ) {}
fn f() { fn f() {
@ -376,8 +376,8 @@ fn f() {
#[rustc_legacy_const_generics(1, 3)] #[rustc_legacy_const_generics(1, 3)]
fn b<const N1: u8, const N2: u8>( fn b<const N1: u8, const N2: u8>(
a: u8, _a: u8,
b: u8, _b: u8,
) {} ) {}
fn g() { fn g() {
@ -403,7 +403,7 @@ fn f(
// ^^ error: this pattern has 0 fields, but the corresponding tuple struct has 2 fields // ^^ error: this pattern has 0 fields, but the corresponding tuple struct has 2 fields
S(e, f, .., g, d): S S(e, f, .., g, d): S
// ^^^^^^^^^ error: this pattern has 4 fields, but the corresponding tuple struct has 2 fields // ^^^^^^^^^ error: this pattern has 4 fields, but the corresponding tuple struct has 2 fields
) {} ) { _ = (a, b, c, d, e, f, g); }
"#, "#,
) )
} }

View file

@ -290,6 +290,7 @@ fn x(a: S) {
struct S { s: u32 } struct S { s: u32 }
fn x(a: S) { fn x(a: S) {
let S { ref s } = a; let S { ref s } = a;
_ = s;
} }
", ",
) )
@ -626,7 +627,7 @@ struct TestStruct { one: i32, two: i64 }
fn test_fn() { fn test_fn() {
let one = 1; let one = 1;
let s = TestStruct{ one, two: 2 }; let _s = TestStruct{ one, two: 2 };
} }
"#, "#,
); );

View file

@ -19,6 +19,7 @@ pub(crate) fn missing_match_arms(
mod tests { mod tests {
use crate::tests::check_diagnostics; use crate::tests::check_diagnostics;
#[track_caller]
fn check_diagnostics_no_bails(ra_fixture: &str) { fn check_diagnostics_no_bails(ra_fixture: &str) {
cov_mark::check_count!(validate_match_bailed_out, 0); cov_mark::check_count!(validate_match_bailed_out, 0);
crate::tests::check_diagnostics(ra_fixture) crate::tests::check_diagnostics(ra_fixture)
@ -564,6 +565,7 @@ fn bang(never: !) {
r#" r#"
enum Option<T> { Some(T), None } enum Option<T> { Some(T), None }
#[allow(unused)]
fn main() { fn main() {
// `Never` is deliberately not defined so that it's an uninferred type. // `Never` is deliberately not defined so that it's an uninferred type.
match Option::<Never>::None { match Option::<Never>::None {
@ -719,7 +721,7 @@ fn main() {
r#" r#"
struct S { a: char} struct S { a: char}
fn main(v: S) { fn main(v: S) {
match v { S{ a } => {} } match v { S{ a } => { _ = a; } }
match v { S{ a: _x } => {} } match v { S{ a: _x } => {} }
match v { S{ a: 'a' } => {} } match v { S{ a: 'a' } => {} }
match v { S{..} => {} } match v { S{..} => {} }
@ -901,7 +903,7 @@ enum E{ A, B }
fn foo() { fn foo() {
match &E::A { match &E::A {
E::A => {} E::A => {}
x => {} _x => {}
} }
}", }",
); );

View file

@ -100,9 +100,9 @@ mod tests {
r#" r#"
fn main() { fn main() {
let x = &5 as *const usize; let x = &5 as *const usize;
unsafe { let y = *x; } unsafe { let _y = *x; }
let z = *x; let _z = *x;
} //^^💡 error: this operation is unsafe and requires an unsafe function or block } //^^💡 error: this operation is unsafe and requires an unsafe function or block
"#, "#,
) )
} }
@ -116,13 +116,13 @@ struct HasUnsafe;
impl HasUnsafe { impl HasUnsafe {
unsafe fn unsafe_fn(&self) { unsafe fn unsafe_fn(&self) {
let x = &5 as *const usize; let x = &5 as *const usize;
let y = *x; let _y = *x;
} }
} }
unsafe fn unsafe_fn() { unsafe fn unsafe_fn() {
let x = &5 as *const usize; let x = &5 as *const usize;
let y = *x; let _y = *x;
} }
fn main() { fn main() {
@ -152,10 +152,10 @@ struct Ty {
static mut STATIC_MUT: Ty = Ty { a: 0 }; static mut STATIC_MUT: Ty = Ty { a: 0 };
fn main() { fn main() {
let x = STATIC_MUT.a; let _x = STATIC_MUT.a;
//^^^^^^^^^^💡 error: this operation is unsafe and requires an unsafe function or block //^^^^^^^^^^💡 error: this operation is unsafe and requires an unsafe function or block
unsafe { unsafe {
let x = STATIC_MUT.a; let _x = STATIC_MUT.a;
} }
} }
"#, "#,
@ -187,13 +187,13 @@ fn main() {
r#" r#"
fn main() { fn main() {
let x = &5 as *const usize; let x = &5 as *const usize;
let z = *x$0; let _z = *x$0;
} }
"#, "#,
r#" r#"
fn main() { fn main() {
let x = &5 as *const usize; let x = &5 as *const usize;
let z = unsafe { *x }; let _z = unsafe { *x };
} }
"#, "#,
); );
@ -231,7 +231,7 @@ struct S(usize);
impl S { impl S {
unsafe fn func(&self) { unsafe fn func(&self) {
let x = &self.0 as *const usize; let x = &self.0 as *const usize;
let z = *x; let _z = *x;
} }
} }
fn main() { fn main() {
@ -244,7 +244,7 @@ struct S(usize);
impl S { impl S {
unsafe fn func(&self) { unsafe fn func(&self) {
let x = &self.0 as *const usize; let x = &self.0 as *const usize;
let z = *x; let _z = *x;
} }
} }
fn main() { fn main() {
@ -267,7 +267,7 @@ struct Ty {
static mut STATIC_MUT: Ty = Ty { a: 0 }; static mut STATIC_MUT: Ty = Ty { a: 0 };
fn main() { fn main() {
let x = STATIC_MUT$0.a; let _x = STATIC_MUT$0.a;
} }
"#, "#,
r#" r#"
@ -278,7 +278,7 @@ struct Ty {
static mut STATIC_MUT: Ty = Ty { a: 0 }; static mut STATIC_MUT: Ty = Ty { a: 0 };
fn main() { fn main() {
let x = unsafe { STATIC_MUT.a }; let _x = unsafe { STATIC_MUT.a };
} }
"#, "#,
) )
@ -382,16 +382,16 @@ fn main() {
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x; let _x;
x = STATIC_MUT$0; _x = STATIC_MUT$0;
} }
"#, "#,
r#" r#"
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x; let _x;
x = unsafe { STATIC_MUT }; _x = unsafe { STATIC_MUT };
} }
"#, "#,
) )
@ -405,14 +405,14 @@ fn main() {
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = STATIC_MUT$0 + 1; let _x = STATIC_MUT$0 + 1;
} }
"#, "#,
r#" r#"
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = unsafe { STATIC_MUT } + 1; let _x = unsafe { STATIC_MUT } + 1;
} }
"#, "#,
) )
@ -425,14 +425,14 @@ fn main() {
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = &STATIC_MUT$0; let _x = &STATIC_MUT$0;
} }
"#, "#,
r#" r#"
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = unsafe { &STATIC_MUT }; let _x = unsafe { &STATIC_MUT };
} }
"#, "#,
) )
@ -445,14 +445,14 @@ fn main() {
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = &&STATIC_MUT$0; let _x = &&STATIC_MUT$0;
} }
"#, "#,
r#" r#"
static mut STATIC_MUT: u8 = 0; static mut STATIC_MUT: u8 = 0;
fn main() { fn main() {
let x = unsafe { &&STATIC_MUT }; let _x = unsafe { &&STATIC_MUT };
} }
"#, "#,
) )

View file

@ -29,6 +29,7 @@ fn main() {
let a = &X; let a = &X;
let b = *a; let b = *a;
//^ error: cannot move `X` out of reference //^ error: cannot move `X` out of reference
_ = b;
} }
"#, "#,
); );
@ -46,6 +47,7 @@ fn main() {
let b = a.0; let b = a.0;
//^ error: cannot move `X` out of reference //^ error: cannot move `X` out of reference
let y = a.1; let y = a.1;
_ = (b, y);
} }
"#, "#,
); );
@ -59,8 +61,8 @@ fn main() {
struct X; struct X;
fn main() { fn main() {
static S: X = X; static S: X = X;
let s = S; let _s = S;
//^ error: cannot move `X` out of reference //^^ error: cannot move `X` out of reference
} }
"#, "#,
); );
@ -165,7 +167,7 @@ enum X {
fn main() { fn main() {
let x = &X::Bar; let x = &X::Bar;
let c = || match *x { let _c = || match *x {
X::Foo(t) => t, X::Foo(t) => t,
_ => 5, _ => 5,
}; };

View file

@ -74,8 +74,8 @@ mod tests {
r#" r#"
//- minicore: iterators //- minicore: iterators
fn foo() { fn foo() {
let m = core::iter::repeat(()).filter_map(|()| Some(92)).next(); let _m = core::iter::repeat(()).filter_map(|()| Some(92)).next();
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: replace filter_map(..).next() with find_map(..) } //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: replace filter_map(..).next() with find_map(..)
"#, "#,
); );
} }
@ -117,7 +117,7 @@ fn foo() {
fn foo() { fn foo() {
let mut m = core::iter::repeat(()) let mut m = core::iter::repeat(())
.filter_map(|()| Some(92)); .filter_map(|()| Some(92));
let n = m.next(); let _n = m.next();
} }
"#, "#,
); );
@ -148,22 +148,22 @@ fn foo() {
fn foo() { fn foo() {
#[allow(clippy::filter_map_next)] #[allow(clippy::filter_map_next)]
let m = core::iter::repeat(()).filter_map(|()| Some(92)).next(); let _m = core::iter::repeat(()).filter_map(|()| Some(92)).next();
} }
#[deny(clippy::filter_map_next)] #[deny(clippy::filter_map_next)]
fn foo() { fn foo() {
let m = core::iter::repeat(()).filter_map(|()| Some(92)).next(); let _m = core::iter::repeat(()).filter_map(|()| Some(92)).next();
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 error: replace filter_map(..).next() with find_map(..) } //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 error: replace filter_map(..).next() with find_map(..)
fn foo() { fn foo() {
let m = core::iter::repeat(()).filter_map(|()| Some(92)).next(); let _m = core::iter::repeat(()).filter_map(|()| Some(92)).next();
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: replace filter_map(..).next() with find_map(..) } //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: replace filter_map(..).next() with find_map(..)
#[warn(clippy::filter_map_next)] #[warn(clippy::filter_map_next)]
fn foo() { fn foo() {
let m = core::iter::repeat(()).filter_map(|()| Some(92)).next(); let _m = core::iter::repeat(()).filter_map(|()| Some(92)).next();
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 warn: replace filter_map(..).next() with find_map(..) } //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 warn: replace filter_map(..).next() with find_map(..)
"#, "#,
); );

View file

@ -205,7 +205,7 @@ fn main() {
test(123); test(123);
//^^^ 💡 error: expected &i32, found i32 //^^^ 💡 error: expected &i32, found i32
} }
fn test(arg: &i32) {} fn test(_arg: &i32) {}
"#, "#,
); );
} }
@ -217,13 +217,13 @@ fn test(arg: &i32) {}
fn main() { fn main() {
test(123$0); test(123$0);
} }
fn test(arg: &i32) {} fn test(_arg: &i32) {}
"#, "#,
r#" r#"
fn main() { fn main() {
test(&123); test(&123);
} }
fn test(arg: &i32) {} fn test(_arg: &i32) {}
"#, "#,
); );
} }
@ -235,13 +235,13 @@ fn test(arg: &i32) {}
fn main() { fn main() {
test($0123); test($0123);
} }
fn test(arg: &mut i32) {} fn test(_arg: &mut i32) {}
"#, "#,
r#" r#"
fn main() { fn main() {
test(&mut 123); test(&mut 123);
} }
fn test(arg: &mut i32) {} fn test(_arg: &mut i32) {}
"#, "#,
); );
} }
@ -254,13 +254,13 @@ fn test(arg: &mut i32) {}
fn main() { fn main() {
test($0[1, 2, 3]); test($0[1, 2, 3]);
} }
fn test(arg: &[i32]) {} fn test(_arg: &[i32]) {}
"#, "#,
r#" r#"
fn main() { fn main() {
test(&[1, 2, 3]); test(&[1, 2, 3]);
} }
fn test(arg: &[i32]) {} fn test(_arg: &[i32]) {}
"#, "#,
); );
} }
@ -279,7 +279,7 @@ impl core::ops::Deref for Foo {
fn main() { fn main() {
test($0Foo); test($0Foo);
} }
fn test(arg: &Bar) {} fn test(_arg: &Bar) {}
"#, "#,
r#" r#"
struct Foo; struct Foo;
@ -291,7 +291,7 @@ impl core::ops::Deref for Foo {
fn main() { fn main() {
test(&Foo); test(&Foo);
} }
fn test(arg: &Bar) {} fn test(_arg: &Bar) {}
"#, "#,
); );
} }
@ -305,7 +305,7 @@ fn main() {
} }
struct Test; struct Test;
impl Test { impl Test {
fn call_by_ref(&self, arg: &i32) {} fn call_by_ref(&self, _arg: &i32) {}
} }
"#, "#,
r#" r#"
@ -314,7 +314,7 @@ fn main() {
} }
struct Test; struct Test;
impl Test { impl Test {
fn call_by_ref(&self, arg: &i32) {} fn call_by_ref(&self, _arg: &i32) {}
} }
"#, "#,
); );
@ -345,7 +345,7 @@ macro_rules! thousand {
1000_u64 1000_u64
}; };
} }
fn test(foo: &u64) {} fn test(_foo: &u64) {}
fn main() { fn main() {
test($0thousand!()); test($0thousand!());
} }
@ -356,7 +356,7 @@ macro_rules! thousand {
1000_u64 1000_u64
}; };
} }
fn test(foo: &u64) {} fn test(_foo: &u64) {}
fn main() { fn main() {
test(&thousand!()); test(&thousand!());
} }
@ -369,12 +369,12 @@ fn main() {
check_fix( check_fix(
r#" r#"
fn main() { fn main() {
let test: &mut i32 = $0123; let _test: &mut i32 = $0123;
} }
"#, "#,
r#" r#"
fn main() { fn main() {
let test: &mut i32 = &mut 123; let _test: &mut i32 = &mut 123;
} }
"#, "#,
); );
@ -411,7 +411,7 @@ fn div(x: i32, y: i32) -> Option<i32> {
fn f<const N: u64>() -> Rate<N> { // FIXME: add some error fn f<const N: u64>() -> Rate<N> { // FIXME: add some error
loop {} loop {}
} }
fn run(t: Rate<5>) { fn run(_t: Rate<5>) {
} }
fn main() { fn main() {
run(f()) // FIXME: remove this error run(f()) // FIXME: remove this error
@ -426,7 +426,7 @@ fn div(x: i32, y: i32) -> Option<i32> {
check_diagnostics( check_diagnostics(
r#" r#"
pub struct Rate<T, const NOM: u32, const DENOM: u32>(T); pub struct Rate<T, const NOM: u32, const DENOM: u32>(T);
fn run(t: Rate<u32, 1, 1>) { fn run(_t: Rate<u32, 1, 1>) {
} }
fn main() { fn main() {
run(Rate::<_, _, _>(5)); run(Rate::<_, _, _>(5));
@ -650,7 +650,7 @@ fn h() {
r#" r#"
struct X<T>(T); struct X<T>(T);
fn foo(x: X<Unknown>) {} fn foo(_x: X<Unknown>) {}
fn test1() { fn test1() {
// Unknown might be `i32`, so we should not emit type mismatch here. // Unknown might be `i32`, so we should not emit type mismatch here.
foo(X(42)); foo(X(42));

View file

@ -142,8 +142,8 @@ fn t<T>() -> T { loop {} }
check_diagnostics( check_diagnostics(
r#" r#"
fn main() { fn main() {
let x = [(); _]; let _x = [(); _];
let y: [(); 10] = [(); _]; let _y: [(); 10] = [(); _];
_ = 0; _ = 0;
(_,) = (1,); (_,) = (1,);
} }

View file

@ -484,7 +484,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10739..10747, range: 10752..10760,
}, },
), ),
tooltip: "", tooltip: "",
@ -497,7 +497,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10771..10775, range: 10784..10788,
}, },
), ),
tooltip: "", tooltip: "",
@ -522,7 +522,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10739..10747, range: 10752..10760,
}, },
), ),
tooltip: "", tooltip: "",
@ -535,7 +535,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10771..10775, range: 10784..10788,
}, },
), ),
tooltip: "", tooltip: "",
@ -560,7 +560,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10739..10747, range: 10752..10760,
}, },
), ),
tooltip: "", tooltip: "",
@ -573,7 +573,7 @@ fn main() {
file_id: FileId( file_id: FileId(
1, 1,
), ),
range: 10771..10775, range: 10784..10788,
}, },
), ),
tooltip: "", tooltip: "",

View file

@ -489,7 +489,7 @@ pub mod ops {
I: SliceIndex<[T]>, I: SliceIndex<[T]>,
{ {
type Output = I::Output; type Output = I::Output;
fn index(&self, index: I) -> &I::Output { fn index(&self, _index: I) -> &I::Output {
loop {} loop {}
} }
} }
@ -497,7 +497,7 @@ pub mod ops {
where where
I: SliceIndex<[T]>, I: SliceIndex<[T]>,
{ {
fn index_mut(&mut self, index: I) -> &mut I::Output { fn index_mut(&mut self, _index: I) -> &mut I::Output {
loop {} loop {}
} }
} }
@ -507,7 +507,7 @@ pub mod ops {
I: SliceIndex<[T]>, I: SliceIndex<[T]>,
{ {
type Output = I::Output; type Output = I::Output;
fn index(&self, index: I) -> &I::Output { fn index(&self, _index: I) -> &I::Output {
loop {} loop {}
} }
} }
@ -515,7 +515,7 @@ pub mod ops {
where where
I: SliceIndex<[T]>, I: SliceIndex<[T]>,
{ {
fn index_mut(&mut self, index: I) -> &mut I::Output { fn index_mut(&mut self, _index: I) -> &mut I::Output {
loop {} loop {}
} }
} }
@ -863,17 +863,17 @@ pub mod fmt {
pub struct DebugTuple; pub struct DebugTuple;
pub struct DebugStruct; pub struct DebugStruct;
impl Formatter<'_> { impl Formatter<'_> {
pub fn debug_tuple(&mut self, name: &str) -> DebugTuple { pub fn debug_tuple(&mut self, _name: &str) -> DebugTuple {
DebugTuple DebugTuple
} }
pub fn debug_struct(&mut self, name: &str) -> DebugStruct { pub fn debug_struct(&mut self, _name: &str) -> DebugStruct {
DebugStruct DebugStruct
} }
} }
impl DebugTuple { impl DebugTuple {
pub fn field(&mut self, value: &dyn Debug) -> &mut Self { pub fn field(&mut self, _value: &dyn Debug) -> &mut Self {
self self
} }
@ -883,7 +883,7 @@ pub mod fmt {
} }
impl DebugStruct { impl DebugStruct {
pub fn field(&mut self, name: &str, value: &dyn Debug) -> &mut Self { pub fn field(&mut self, _name: &str, _value: &dyn Debug) -> &mut Self {
self self
} }
@ -996,7 +996,7 @@ pub mod fmt {
($($t:ty)*) => { ($($t:ty)*) => {
$( $(
impl const Debug for $t { impl const Debug for $t {
fn fmt(&self, f: &mut Formatter<'_>) -> Result { fn fmt(&self, _f: &mut Formatter<'_>) -> Result {
Ok(()) Ok(())
} }
} }
@ -1012,7 +1012,7 @@ pub mod fmt {
} }
impl<T: Debug> Debug for [T] { impl<T: Debug> Debug for [T] {
fn fmt(&self, f: &mut Formatter<'_>) -> Result { fn fmt(&self, _f: &mut Formatter<'_>) -> Result {
Ok(()) Ok(())
} }
} }
@ -1062,7 +1062,7 @@ pub mod option {
} }
} }
pub fn and<U>(self, optb: Option<U>) -> Option<U> { pub fn and<U>(self, _optb: Option<U>) -> Option<U> {
loop {} loop {}
} }
pub fn unwrap_or(self, default: T) -> T { pub fn unwrap_or(self, default: T) -> T {
@ -1080,25 +1080,25 @@ pub mod option {
} }
// endregion:result // endregion:result
// region:fn // region:fn
pub fn and_then<U, F>(self, f: F) -> Option<U> pub fn and_then<U, F>(self, _f: F) -> Option<U>
where where
F: FnOnce(T) -> Option<U>, F: FnOnce(T) -> Option<U>,
{ {
loop {} loop {}
} }
pub fn unwrap_or_else<F>(self, f: F) -> T pub fn unwrap_or_else<F>(self, _f: F) -> T
where where
F: FnOnce() -> T, F: FnOnce() -> T,
{ {
loop {} loop {}
} }
pub fn map_or<U, F>(self, default: U, f: F) -> U pub fn map_or<U, F>(self, _default: U, _f: F) -> U
where where
F: FnOnce(T) -> U, F: FnOnce(T) -> U,
{ {
loop {} loop {}
} }
pub fn map_or_else<U, D, F>(self, default: D, f: F) -> U pub fn map_or_else<U, D, F>(self, _default: D, _f: F) -> U
where where
D: FnOnce() -> U, D: FnOnce() -> U,
F: FnOnce(T) -> U, F: FnOnce(T) -> U,
@ -1129,7 +1129,7 @@ pub mod pin {
pointer: P, pointer: P,
} }
impl<P> Pin<P> { impl<P> Pin<P> {
pub fn new(pointer: P) -> Pin<P> { pub fn new(_pointer: P) -> Pin<P> {
loop {} loop {}
} }
} }
@ -1226,7 +1226,7 @@ pub mod iter {
mod sources { mod sources {
mod repeat { mod repeat {
pub fn repeat<T>(elt: T) -> Repeat<T> { pub fn repeat<T>(_elt: T) -> Repeat<T> {
loop {} loop {}
} }
@ -1266,7 +1266,7 @@ pub mod iter {
fn take(self, n: usize) -> crate::iter::Take<Self> { fn take(self, n: usize) -> crate::iter::Take<Self> {
loop {} loop {}
} }
fn filter_map<B, F>(self, f: F) -> crate::iter::FilterMap<Self, F> fn filter_map<B, F>(self, _f: F) -> crate::iter::FilterMap<Self, F>
where where
Self: Sized, Self: Sized,
F: FnMut(Self::Item) -> Option<B>, F: FnMut(Self::Item) -> Option<B>,
@ -1337,7 +1337,7 @@ mod panic {
mod panicking { mod panicking {
#[lang = "panic_fmt"] #[lang = "panic_fmt"]
pub const fn panic_fmt(fmt: crate::fmt::Arguments<'_>) -> ! { pub const fn panic_fmt(_fmt: crate::fmt::Arguments<'_>) -> ! {
loop {} loop {}
} }
} }