mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
internal: test diagnostic severeties and presense of fixes
This commit is contained in:
parent
58712088ac
commit
4cfc767d7f
16 changed files with 155 additions and 140 deletions
|
@ -23,7 +23,7 @@ mod tests {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { break; }
|
fn foo() { break; }
|
||||||
//^^^^^ break outside of loop
|
//^^^^^ error: break outside of loop
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,26 +49,26 @@ fn f() {
|
||||||
// The three g̶e̶n̶d̶e̶r̶s̶ statements:
|
// The three g̶e̶n̶d̶e̶r̶s̶ statements:
|
||||||
|
|
||||||
#[cfg(a)] fn f() {} // Item statement
|
#[cfg(a)] fn f() {} // Item statement
|
||||||
//^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
#[cfg(a)] {} // Expression statement
|
#[cfg(a)] {} // Expression statement
|
||||||
//^^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
#[cfg(a)] let x = 0; // let statement
|
#[cfg(a)] let x = 0; // let statement
|
||||||
//^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
|
|
||||||
abc(#[cfg(a)] 0);
|
abc(#[cfg(a)] 0);
|
||||||
//^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
let x = Struct {
|
let x = Struct {
|
||||||
#[cfg(a)] f: 0,
|
#[cfg(a)] f: 0,
|
||||||
//^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
};
|
};
|
||||||
match () {
|
match () {
|
||||||
() => (),
|
() => (),
|
||||||
#[cfg(a)] () => (),
|
#[cfg(a)] () => (),
|
||||||
//^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(a)] 0 // Trailing expression of block
|
#[cfg(a)] 0 // Trailing expression of block
|
||||||
//^^^^^^^^^^^ code is inactive due to #[cfg] directives: a is disabled
|
//^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: a is disabled
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -81,16 +81,16 @@ fn f() {
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
#[cfg(no)] pub fn f() {}
|
#[cfg(no)] pub fn f() {}
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: no is disabled
|
||||||
|
|
||||||
#[cfg(no)] #[cfg(no2)] mod m;
|
#[cfg(no)] #[cfg(no2)] mod m;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no and no2 are disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: no and no2 are disabled
|
||||||
|
|
||||||
#[cfg(all(not(a), b))] enum E {}
|
#[cfg(all(not(a), b))] enum E {}
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: b is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: b is disabled
|
||||||
|
|
||||||
#[cfg(feature = "std")] use std;
|
#[cfg(feature = "std")] use std;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: feature = "std" is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: feature = "std" is disabled
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -102,14 +102,14 @@ fn f() {
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
#[cfg_attr(not(never), cfg(no))] fn f() {}
|
#[cfg_attr(not(never), cfg(no))] fn f() {}
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: no is disabled
|
||||||
|
|
||||||
#[cfg_attr(not(never), cfg(not(no)))] fn f() {}
|
#[cfg_attr(not(never), cfg(not(no)))] fn f() {}
|
||||||
|
|
||||||
#[cfg_attr(never, cfg(no))] fn g() {}
|
#[cfg_attr(never, cfg(no))] fn g() {}
|
||||||
|
|
||||||
#[cfg_attr(not(never), inline, cfg(no))] fn h() {}
|
#[cfg_attr(not(never), inline, cfg(no))] fn h() {}
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ code is inactive due to #[cfg] directives: no is disabled
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives: no is disabled
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ impl TestStruct {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn FOO() {}
|
fn FOO() {}
|
||||||
// ^^^ Function `FOO` should have snake_case name, e.g. `foo`
|
// ^^^ 💡 weak: Function `FOO` should have snake_case name, e.g. `foo`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
check_fix(r#"fn FOO$0() {}"#, r#"fn foo() {}"#);
|
check_fix(r#"fn FOO$0() {}"#, r#"fn foo() {}"#);
|
||||||
|
@ -160,7 +160,7 @@ fn FOO() {}
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn NonSnakeCaseName() {}
|
fn NonSnakeCaseName() {}
|
||||||
// ^^^^^^^^^^^^^^^^ Function `NonSnakeCaseName` should have snake_case name, e.g. `non_snake_case_name`
|
// ^^^^^^^^^^^^^^^^ 💡 weak: Function `NonSnakeCaseName` should have snake_case name, e.g. `non_snake_case_name`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,10 @@ fn NonSnakeCaseName() {}
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn foo(SomeParam: u8) {}
|
fn foo(SomeParam: u8) {}
|
||||||
// ^^^^^^^^^ Parameter `SomeParam` should have snake_case name, e.g. `some_param`
|
// ^^^^^^^^^ 💡 weak: 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) {}
|
||||||
// ^^^^^^^^^^ Parameter `CAPS_PARAM` should have snake_case name, e.g. `caps_param`
|
// ^^^^^^^^^^ 💡 weak: Parameter `CAPS_PARAM` should have snake_case name, e.g. `caps_param`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -184,9 +184,9 @@ fn foo2(ok_param: &str, CAPS_PARAM: u8) {}
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let SOME_VALUE = 10;
|
let SOME_VALUE = 10;
|
||||||
// ^^^^^^^^^^ Variable `SOME_VALUE` should have snake_case name, e.g. `some_value`
|
// ^^^^^^^^^^ 💡 weak: Variable `SOME_VALUE` should have snake_case name, e.g. `some_value`
|
||||||
let AnotherValue = 20;
|
let AnotherValue = 20;
|
||||||
// ^^^^^^^^^^^^ Variable `AnotherValue` should have snake_case name, e.g. `another_value`
|
// ^^^^^^^^^^^^ 💡 weak: Variable `AnotherValue` should have snake_case name, e.g. `another_value`
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -197,10 +197,10 @@ fn foo() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
struct non_camel_case_name {}
|
struct non_camel_case_name {}
|
||||||
// ^^^^^^^^^^^^^^^^^^^ Structure `non_camel_case_name` should have CamelCase name, e.g. `NonCamelCaseName`
|
// ^^^^^^^^^^^^^^^^^^^ 💡 weak: Structure `non_camel_case_name` should have CamelCase name, e.g. `NonCamelCaseName`
|
||||||
|
|
||||||
struct SCREAMING_CASE {}
|
struct SCREAMING_CASE {}
|
||||||
// ^^^^^^^^^^^^^^ Structure `SCREAMING_CASE` should have CamelCase name, e.g. `ScreamingCase`
|
// ^^^^^^^^^^^^^^ 💡 weak: Structure `SCREAMING_CASE` should have CamelCase name, e.g. `ScreamingCase`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ struct AABB {}
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
struct SomeStruct { SomeField: u8 }
|
struct SomeStruct { SomeField: u8 }
|
||||||
// ^^^^^^^^^ Field `SomeField` should have snake_case name, e.g. `some_field`
|
// ^^^^^^^^^ 💡 weak: Field `SomeField` should have snake_case name, e.g. `some_field`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -229,10 +229,10 @@ struct SomeStruct { SomeField: u8 }
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
enum some_enum { Val(u8) }
|
enum some_enum { Val(u8) }
|
||||||
// ^^^^^^^^^ Enum `some_enum` should have CamelCase name, e.g. `SomeEnum`
|
// ^^^^^^^^^ 💡 weak: Enum `some_enum` should have CamelCase name, e.g. `SomeEnum`
|
||||||
|
|
||||||
enum SOME_ENUM {}
|
enum SOME_ENUM {}
|
||||||
// ^^^^^^^^^ Enum `SOME_ENUM` should have CamelCase name, e.g. `SomeEnum`
|
// ^^^^^^^^^ 💡 weak: Enum `SOME_ENUM` should have CamelCase name, e.g. `SomeEnum`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ enum AABB {}
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
enum SomeEnum { SOME_VARIANT(u8) }
|
enum SomeEnum { SOME_VARIANT(u8) }
|
||||||
// ^^^^^^^^^^^^ Variant `SOME_VARIANT` should have CamelCase name, e.g. `SomeVariant`
|
// ^^^^^^^^^^^^ 💡 weak: Variant `SOME_VARIANT` should have CamelCase name, e.g. `SomeVariant`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ enum SomeEnum { SOME_VARIANT(u8) }
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
const some_weird_const: u8 = 10;
|
const some_weird_const: u8 = 10;
|
||||||
// ^^^^^^^^^^^^^^^^ Constant `some_weird_const` should have UPPER_SNAKE_CASE name, e.g. `SOME_WEIRD_CONST`
|
// ^^^^^^^^^^^^^^^^ 💡 weak: Constant `some_weird_const` should have UPPER_SNAKE_CASE name, e.g. `SOME_WEIRD_CONST`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ const some_weird_const: u8 = 10;
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
static some_weird_const: u8 = 10;
|
static some_weird_const: u8 = 10;
|
||||||
// ^^^^^^^^^^^^^^^^ Static variable `some_weird_const` should have UPPER_SNAKE_CASE name, e.g. `SOME_WEIRD_CONST`
|
// ^^^^^^^^^^^^^^^^ 💡 weak: Static variable `some_weird_const` should have UPPER_SNAKE_CASE name, e.g. `SOME_WEIRD_CONST`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -281,13 +281,13 @@ static some_weird_const: u8 = 10;
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
struct someStruct;
|
struct someStruct;
|
||||||
// ^^^^^^^^^^ Structure `someStruct` should have CamelCase name, e.g. `SomeStruct`
|
// ^^^^^^^^^^ 💡 weak: Structure `someStruct` should have CamelCase name, e.g. `SomeStruct`
|
||||||
|
|
||||||
impl someStruct {
|
impl someStruct {
|
||||||
fn SomeFunc(&self) {
|
fn SomeFunc(&self) {
|
||||||
// ^^^^^^^^ Function `SomeFunc` should have snake_case name, e.g. `some_func`
|
// ^^^^^^^^ 💡 weak: Function `SomeFunc` should have snake_case name, e.g. `some_func`
|
||||||
let WHY_VAR_IS_CAPS = 10;
|
let WHY_VAR_IS_CAPS = 10;
|
||||||
// ^^^^^^^^^^^^^^^ Variable `WHY_VAR_IS_CAPS` should have snake_case name, e.g. `why_var_is_caps`
|
// ^^^^^^^^^^^^^^^ 💡 weak: Variable `WHY_VAR_IS_CAPS` should have snake_case name, e.g. `why_var_is_caps`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -319,7 +319,7 @@ enum Option { Some, None }
|
||||||
fn main() {
|
fn main() {
|
||||||
match Option::None {
|
match Option::None {
|
||||||
SOME_VAR @ None => (),
|
SOME_VAR @ None => (),
|
||||||
// ^^^^^^^^ Variable `SOME_VAR` should have snake_case name, e.g. `some_var`
|
// ^^^^^^^^ 💡 weak: Variable `SOME_VAR` should have snake_case name, e.g. `some_var`
|
||||||
Some => (),
|
Some => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,11 +421,11 @@ extern {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
trait BAD_TRAIT {
|
trait BAD_TRAIT {
|
||||||
// ^^^^^^^^^ Trait `BAD_TRAIT` should have CamelCase name, e.g. `BadTrait`
|
// ^^^^^^^^^ 💡 weak: Trait `BAD_TRAIT` should have CamelCase name, e.g. `BadTrait`
|
||||||
fn BAD_FUNCTION();
|
fn BAD_FUNCTION();
|
||||||
// ^^^^^^^^^^^^ Function `BAD_FUNCTION` should have snake_case name, e.g. `bad_function`
|
// ^^^^^^^^^^^^ 💡 weak: Function `BAD_FUNCTION` should have snake_case name, e.g. `bad_function`
|
||||||
fn BadFunction();
|
fn BadFunction();
|
||||||
// ^^^^^^^^^^^^ Function `BadFunction` should have snake_case name, e.g. `bad_function`
|
// ^^^^^^^^^^^^ 💡 weak: Function `BadFunction` should have snake_case name, e.g. `bad_function`
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,7 @@ mod tests {
|
||||||
macro_rules! include { () => {} }
|
macro_rules! include { () => {} }
|
||||||
|
|
||||||
include!("doesntexist");
|
include!("doesntexist");
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `doesntexist`
|
//^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `doesntexist`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ macro_rules! env { () => {} }
|
||||||
macro_rules! concat { () => {} }
|
macro_rules! concat { () => {} }
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/out.rs"));
|
include!(concat!(env!("OUT_DIR"), "/out.rs"));
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, enable "run build scripts" to fix
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -108,23 +108,23 @@ fn main() {
|
||||||
// Test a handful of built-in (eager) macros:
|
// Test a handful of built-in (eager) macros:
|
||||||
|
|
||||||
include!(invalid);
|
include!(invalid);
|
||||||
//^^^^^^^^^^^^^^^^^ could not convert tokens
|
//^^^^^^^^^^^^^^^^^ error: could not convert tokens
|
||||||
include!("does not exist");
|
include!("does not exist");
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^ failed to load file `does not exist`
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to load file `does not exist`
|
||||||
|
|
||||||
env!(invalid);
|
env!(invalid);
|
||||||
//^^^^^^^^^^^^^ could not convert tokens
|
//^^^^^^^^^^^^^ error: could not convert tokens
|
||||||
|
|
||||||
env!("OUT_DIR");
|
env!("OUT_DIR");
|
||||||
//^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix
|
//^^^^^^^^^^^^^^^ error: `OUT_DIR` not set, enable "run build scripts" to fix
|
||||||
|
|
||||||
compile_error!("compile_error works");
|
compile_error!("compile_error works");
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compile_error works
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: compile_error works
|
||||||
|
|
||||||
// Lazy:
|
// Lazy:
|
||||||
|
|
||||||
format_args!();
|
format_args!();
|
||||||
//^^^^^^^^^^^^^^ no rule matches input tokens
|
//^^^^^^^^^^^^^^ error: no rule matches input tokens
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -141,7 +141,7 @@ fn f() {
|
||||||
m!();
|
m!();
|
||||||
|
|
||||||
m!(hi);
|
m!(hi);
|
||||||
//^^^^^^ leftover tokens
|
//^^^^^^ error: leftover tokens
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -166,7 +166,7 @@ macro_rules! outer {
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
outer!();
|
outer!();
|
||||||
} //^^^^^^^^ leftover tokens
|
} //^^^^^^^^ error: leftover tokens
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ mod tests {
|
||||||
r#"
|
r#"
|
||||||
fn zero() {}
|
fn zero() {}
|
||||||
fn f() { zero(1); }
|
fn f() { zero(1); }
|
||||||
//^^^^^^^ expected 0 arguments, found 1
|
//^^^^^^^ error: expected 0 arguments, found 1
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ fn f() { zero(); }
|
||||||
r#"
|
r#"
|
||||||
fn one(arg: u8) {}
|
fn one(arg: u8) {}
|
||||||
fn f() { one(); }
|
fn f() { one(); }
|
||||||
//^^^^^ expected 1 argument, found 0
|
//^^^^^ error: expected 1 argument, found 0
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ impl S { fn method(&self) {} }
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
S::method();
|
S::method();
|
||||||
} //^^^^^^^^^^^ expected 1 argument, found 0
|
} //^^^^^^^^^^^ error: expected 1 argument, found 0
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ impl S { fn method(&self, arg: u8) {} }
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
S.method();
|
S.method();
|
||||||
} //^^^^^^^^^^ expected 1 argument, found 0
|
} //^^^^^^^^^^ error: expected 1 argument, found 0
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ fn f() {
|
||||||
struct Tup(u8, u16);
|
struct Tup(u8, u16);
|
||||||
fn f() {
|
fn f() {
|
||||||
Tup(0);
|
Tup(0);
|
||||||
} //^^^^^^ expected 2 arguments, found 1
|
} //^^^^^^ error: expected 2 arguments, found 1
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ fn f() {
|
||||||
enum En { Variant(u8, u16), }
|
enum En { Variant(u8, u16), }
|
||||||
fn f() {
|
fn f() {
|
||||||
En::Variant(0);
|
En::Variant(0);
|
||||||
} //^^^^^^^^^^^^^^ expected 2 arguments, found 1
|
} //^^^^^^^^^^^^^^ error: expected 2 arguments, found 1
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,9 @@ impl Foo {
|
||||||
fn new() {
|
fn new() {
|
||||||
Foo::Bar(0);
|
Foo::Bar(0);
|
||||||
Foo::Bar(0, 1);
|
Foo::Bar(0, 1);
|
||||||
//^^^^^^^^^^^^^^ expected 1 argument, found 2
|
//^^^^^^^^^^^^^^ error: expected 1 argument, found 2
|
||||||
Foo::Bar();
|
Foo::Bar();
|
||||||
//^^^^^^^^^^ expected 1 argument, found 0
|
//^^^^^^^^^^ error: expected 1 argument, found 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -185,7 +185,7 @@ fn f() {
|
||||||
unsafe {
|
unsafe {
|
||||||
fixed(0);
|
fixed(0);
|
||||||
fixed(0, 1);
|
fixed(0, 1);
|
||||||
//^^^^^^^^^^^ expected 1 argument, found 2
|
//^^^^^^^^^^^ error: expected 1 argument, found 2
|
||||||
varargs(0);
|
varargs(0);
|
||||||
varargs(0, 1);
|
varargs(0, 1);
|
||||||
varargs2();
|
varargs2();
|
||||||
|
@ -204,10 +204,10 @@ fn f() {
|
||||||
fn main() {
|
fn main() {
|
||||||
let f = |()| ();
|
let f = |()| ();
|
||||||
f();
|
f();
|
||||||
//^^^ expected 1 argument, found 0
|
//^^^ error: expected 1 argument, found 0
|
||||||
f(());
|
f(());
|
||||||
f((), ());
|
f((), ());
|
||||||
//^^^^^^^^^ expected 1 argument, found 2
|
//^^^^^^^^^ error: expected 1 argument, found 2
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::{fix, Diagnostic, DiagnosticsContext};
|
||||||
// let a = A { a: 10 };
|
// let a = A { a: 10 };
|
||||||
// ```
|
// ```
|
||||||
pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic {
|
pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic {
|
||||||
let mut message = String::from("Missing structure fields:\n");
|
let mut message = String::from("missing structure fields:\n");
|
||||||
for field in &d.missed_fields {
|
for field in &d.missed_fields {
|
||||||
format_to!(message, "- {}\n", field);
|
format_to!(message, "- {}\n", field);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ mod tests {
|
||||||
struct S { foo: i32, bar: () }
|
struct S { foo: i32, bar: () }
|
||||||
fn baz(s: S) {
|
fn baz(s: S) {
|
||||||
let S { foo: _ } = s;
|
let S { foo: _ } = s;
|
||||||
//^ Missing structure fields:
|
//^ error: missing structure fields:
|
||||||
//| - bar
|
//| - bar
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
|
|
@ -31,9 +31,9 @@ mod tests {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match () { }
|
match () { }
|
||||||
//^^ missing match arm
|
//^^ error: missing match arm
|
||||||
match (()) { }
|
match (()) { }
|
||||||
//^^^^ missing match arm
|
//^^^^ error: missing match arm
|
||||||
|
|
||||||
match () { _ => (), }
|
match () { _ => (), }
|
||||||
match () { () => (), }
|
match () { () => (), }
|
||||||
|
@ -49,7 +49,7 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match ((), ()) { }
|
match ((), ()) { }
|
||||||
//^^^^^^^^ missing match arm
|
//^^^^^^^^ error: missing match arm
|
||||||
|
|
||||||
match ((), ()) { ((), ()) => (), }
|
match ((), ()) { ((), ()) => (), }
|
||||||
}
|
}
|
||||||
|
@ -63,21 +63,21 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn test_main() {
|
fn test_main() {
|
||||||
match false { }
|
match false { }
|
||||||
//^^^^^ missing match arm
|
//^^^^^ error: missing match arm
|
||||||
match false { true => (), }
|
match false { true => (), }
|
||||||
//^^^^^ missing match arm
|
//^^^^^ error: missing match arm
|
||||||
match (false, true) {}
|
match (false, true) {}
|
||||||
//^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^ error: missing match arm
|
||||||
match (false, true) { (true, true) => (), }
|
match (false, true) { (true, true) => (), }
|
||||||
//^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^ error: missing match arm
|
||||||
match (false, true) {
|
match (false, true) {
|
||||||
//^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^ error: missing match arm
|
||||||
(false, true) => (),
|
(false, true) => (),
|
||||||
(false, false) => (),
|
(false, false) => (),
|
||||||
(true, false) => (),
|
(true, false) => (),
|
||||||
}
|
}
|
||||||
match (false, true) { (true, _x) => (), }
|
match (false, true) { (true, _x) => (), }
|
||||||
//^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^ error: missing match arm
|
||||||
|
|
||||||
match false { true => (), false => (), }
|
match false { true => (), false => (), }
|
||||||
match (false, true) {
|
match (false, true) {
|
||||||
|
@ -116,11 +116,11 @@ fn test_main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match (false, ((), false)) {}
|
match (false, ((), false)) {}
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
match (false, ((), false)) { (true, ((), true)) => (), }
|
match (false, ((), false)) { (true, ((), true)) => (), }
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
match (false, ((), false)) { (true, _) => (), }
|
match (false, ((), false)) { (true, _) => (), }
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
|
|
||||||
match (false, ((), false)) {
|
match (false, ((), false)) {
|
||||||
(true, ((), true)) => (),
|
(true, ((), true)) => (),
|
||||||
|
@ -146,12 +146,12 @@ enum Either { A, B, }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Either::A { }
|
match Either::A { }
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
match Either::B { Either::A => (), }
|
match Either::B { Either::A => (), }
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
|
|
||||||
match &Either::B {
|
match &Either::B {
|
||||||
//^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^ error: missing match arm
|
||||||
Either::A => (),
|
Either::A => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,9 +174,9 @@ enum Either { A(bool), B }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Either::B { }
|
match Either::B { }
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
match Either::B {
|
match Either::B {
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
Either::A(true) => (), Either::B => ()
|
Either::A(true) => (), Either::B => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ enum Either { A(bool), B(bool, bool) }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Either::A(false) {
|
match Either::A(false) {
|
||||||
//^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
Either::A(_) => (),
|
Either::A(_) => (),
|
||||||
Either::B(false, _) => (),
|
Either::B(false, _) => (),
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ fn main() {
|
||||||
Either::A => (),
|
Either::A => (),
|
||||||
}
|
}
|
||||||
match loop { break Foo::A } {
|
match loop { break Foo::A } {
|
||||||
//^^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
Either::A => (),
|
Either::A => (),
|
||||||
}
|
}
|
||||||
match loop { break Foo::A } {
|
match loop { break Foo::A } {
|
||||||
|
@ -390,19 +390,19 @@ enum Either { A { foo: bool }, B }
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = Either::A { foo: true };
|
let a = Either::A { foo: true };
|
||||||
match a { }
|
match a { }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match a { Either::A { foo: true } => () }
|
match a { Either::A { foo: true } => () }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match a {
|
match a {
|
||||||
Either::A { } => (),
|
Either::A { } => (),
|
||||||
//^^^^^^^^^ Missing structure fields:
|
//^^^^^^^^^ error: missing structure fields:
|
||||||
// | - foo
|
// | - foo
|
||||||
Either::B => (),
|
Either::B => (),
|
||||||
}
|
}
|
||||||
match a {
|
match a {
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
Either::A { } => (),
|
Either::A { } => (),
|
||||||
} //^^^^^^^^^ Missing structure fields:
|
} //^^^^^^^^^ error: missing structure fields:
|
||||||
// | - foo
|
// | - foo
|
||||||
|
|
||||||
match a {
|
match a {
|
||||||
|
@ -431,7 +431,7 @@ enum Either {
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = Either::A { foo: true, bar: () };
|
let a = Either::A { foo: true, bar: () };
|
||||||
match a {
|
match a {
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
Either::A { bar: (), foo: false } => (),
|
Either::A { bar: (), foo: false } => (),
|
||||||
Either::A { foo: true, bar: () } => (),
|
Either::A { foo: true, bar: () } => (),
|
||||||
}
|
}
|
||||||
|
@ -458,12 +458,12 @@ enum Either {
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = Either::B;
|
let a = Either::B;
|
||||||
match a {
|
match a {
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
Either::A { foo: true, .. } => (),
|
Either::A { foo: true, .. } => (),
|
||||||
Either::B => (),
|
Either::B => (),
|
||||||
}
|
}
|
||||||
match a {
|
match a {
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
Either::A { .. } => (),
|
Either::A { .. } => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,14 +493,14 @@ enum Either {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Either::B {
|
match Either::B {
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
Either::A(true, .., true) => (),
|
Either::A(true, .., true) => (),
|
||||||
Either::A(true, .., false) => (),
|
Either::A(true, .., false) => (),
|
||||||
Either::A(false, .., false) => (),
|
Either::A(false, .., false) => (),
|
||||||
Either::B => (),
|
Either::B => (),
|
||||||
}
|
}
|
||||||
match Either::B {
|
match Either::B {
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
Either::A(true, .., true) => (),
|
Either::A(true, .., true) => (),
|
||||||
Either::A(true, .., false) => (),
|
Either::A(true, .., false) => (),
|
||||||
Either::A(.., true) => (),
|
Either::A(.., true) => (),
|
||||||
|
@ -537,7 +537,7 @@ fn enum_(never: Never) {
|
||||||
}
|
}
|
||||||
fn enum_ref(never: &Never) {
|
fn enum_ref(never: &Never) {
|
||||||
match never {}
|
match never {}
|
||||||
//^^^^^ missing match arm
|
//^^^^^ error: missing match arm
|
||||||
}
|
}
|
||||||
fn bang(never: !) {
|
fn bang(never: !) {
|
||||||
match never {}
|
match never {}
|
||||||
|
@ -561,7 +561,7 @@ fn main() {
|
||||||
Some(never) => match never {},
|
Some(never) => match never {},
|
||||||
}
|
}
|
||||||
match Option::<Never>::None {
|
match Option::<Never>::None {
|
||||||
//^^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
Option::Some(_never) => {},
|
Option::Some(_never) => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match (false, true, false) {
|
match (false, true, false) {
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
(false, ..) => (),
|
(false, ..) => (),
|
||||||
}
|
}
|
||||||
}"#,
|
}"#,
|
||||||
|
@ -588,7 +588,7 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match (false, true, false) {
|
match (false, true, false) {
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
(.., false) => (),
|
(.., false) => (),
|
||||||
}
|
}
|
||||||
}"#,
|
}"#,
|
||||||
|
@ -601,7 +601,7 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match (false, true, false) {
|
match (false, true, false) {
|
||||||
//^^^^^^^^^^^^^^^^^^^^ missing match arm
|
//^^^^^^^^^^^^^^^^^^^^ error: missing match arm
|
||||||
(true, .., false) => (),
|
(true, .., false) => (),
|
||||||
}
|
}
|
||||||
}"#,
|
}"#,
|
||||||
|
@ -614,11 +614,11 @@ fn main() {
|
||||||
r#"struct Foo { a: bool }
|
r#"struct Foo { a: bool }
|
||||||
fn main(f: Foo) {
|
fn main(f: Foo) {
|
||||||
match f {}
|
match f {}
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match f { Foo { a: true } => () }
|
match f { Foo { a: true } => () }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match &f { Foo { a: true } => () }
|
match &f { Foo { a: true } => () }
|
||||||
//^^ missing match arm
|
//^^ error: missing match arm
|
||||||
match f { Foo { a: _ } => () }
|
match f { Foo { a: _ } => () }
|
||||||
match f {
|
match f {
|
||||||
Foo { a: true } => (),
|
Foo { a: true } => (),
|
||||||
|
@ -639,9 +639,9 @@ fn main(f: Foo) {
|
||||||
r#"struct Foo(bool);
|
r#"struct Foo(bool);
|
||||||
fn main(f: Foo) {
|
fn main(f: Foo) {
|
||||||
match f {}
|
match f {}
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match f { Foo(true) => () }
|
match f { Foo(true) => () }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match f {
|
match f {
|
||||||
Foo(true) => (),
|
Foo(true) => (),
|
||||||
Foo(false) => (),
|
Foo(false) => (),
|
||||||
|
@ -657,7 +657,7 @@ fn main(f: Foo) {
|
||||||
r#"struct Foo;
|
r#"struct Foo;
|
||||||
fn main(f: Foo) {
|
fn main(f: Foo) {
|
||||||
match f {}
|
match f {}
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match f { Foo => () }
|
match f { Foo => () }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -670,9 +670,9 @@ fn main(f: Foo) {
|
||||||
r#"struct Foo { foo: bool, bar: bool }
|
r#"struct Foo { foo: bool, bar: bool }
|
||||||
fn main(f: Foo) {
|
fn main(f: Foo) {
|
||||||
match f { Foo { foo: true, .. } => () }
|
match f { Foo { foo: true, .. } => () }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
match f {
|
match f {
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
Foo { foo: true, .. } => (),
|
Foo { foo: true, .. } => (),
|
||||||
Foo { bar: false, .. } => ()
|
Foo { bar: false, .. } => ()
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ fn main(f: Foo) {
|
||||||
fn main() {
|
fn main() {
|
||||||
enum Either { A(bool), B }
|
enum Either { A(bool), B }
|
||||||
match Either::B {
|
match Either::B {
|
||||||
//^^^^^^^^^ missing match arm
|
//^^^^^^^^^ error: missing match arm
|
||||||
Either::A(true | false) => (),
|
Either::A(true | false) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ fn main(v: S) {
|
||||||
match v { S{..} => {} }
|
match v { S{..} => {} }
|
||||||
match v { _ => {} }
|
match v { _ => {} }
|
||||||
match v { }
|
match v { }
|
||||||
//^ missing match arm
|
//^ error: missing match arm
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -731,7 +731,7 @@ fn main() {
|
||||||
false => {}
|
false => {}
|
||||||
}
|
}
|
||||||
match true { _x @ true => {} }
|
match true { _x @ true => {} }
|
||||||
//^^^^ missing match arm
|
//^^^^ error: missing match arm
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -786,12 +786,12 @@ use lib::E;
|
||||||
fn main() {
|
fn main() {
|
||||||
match E::A { _ => {} }
|
match E::A { _ => {} }
|
||||||
match E::A {
|
match E::A {
|
||||||
//^^^^ missing match arm
|
//^^^^ error: missing match arm
|
||||||
E::A => {}
|
E::A => {}
|
||||||
E::B => {}
|
E::B => {}
|
||||||
}
|
}
|
||||||
match E::A {
|
match E::A {
|
||||||
//^^^^ missing match arm
|
//^^^^ error: missing match arm
|
||||||
E::A | E::B => {}
|
E::A | E::B => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -810,7 +810,7 @@ fn main() {
|
||||||
false => {}
|
false => {}
|
||||||
}
|
}
|
||||||
match true {
|
match true {
|
||||||
//^^^^ missing match arm
|
//^^^^ error: missing match arm
|
||||||
true if false => {}
|
true if false => {}
|
||||||
false => {}
|
false => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ 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;
|
||||||
} //^^ this operation is unsafe and requires an unsafe function or block
|
} //^^ error: this operation is unsafe and requires an unsafe function or block
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ unsafe fn unsafe_fn() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe_fn();
|
unsafe_fn();
|
||||||
//^^^^^^^^^^^ this operation is unsafe and requires an unsafe function or block
|
//^^^^^^^^^^^ error: this operation is unsafe and requires an unsafe function or block
|
||||||
HasUnsafe.unsafe_fn();
|
HasUnsafe.unsafe_fn();
|
||||||
//^^^^^^^^^^^^^^^^^^^^^ 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 {
|
||||||
unsafe_fn();
|
unsafe_fn();
|
||||||
HasUnsafe.unsafe_fn();
|
HasUnsafe.unsafe_fn();
|
||||||
|
@ -72,7 +72,7 @@ static mut STATIC_MUT: Ty = Ty { a: 0 };
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = STATIC_MUT.a;
|
let x = STATIC_MUT.a;
|
||||||
//^^^^^^^^^^ 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;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ extern "rust-intrinsic" {
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = bitreverse(12);
|
let _ = bitreverse(12);
|
||||||
let _ = floorf32(12.0);
|
let _ = floorf32(12.0);
|
||||||
//^^^^^^^^^^^^^^ this operation is unsafe and requires an unsafe function or block
|
//^^^^^^^^^^^^^^ error: this operation is unsafe and requires an unsafe function or block
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
|
@ -119,11 +119,11 @@ struct S { foo: i32, bar: () }
|
||||||
impl S {
|
impl S {
|
||||||
fn new() -> S {
|
fn new() -> S {
|
||||||
S {
|
S {
|
||||||
//^ Missing structure fields:
|
//^ 💡 error: missing structure fields:
|
||||||
//| - bar
|
//| - bar
|
||||||
foo: 92,
|
foo: 92,
|
||||||
baz: 62,
|
baz: 62,
|
||||||
//^^^^^^^ no such field
|
//^^^^^^^ 💡 error: no such field
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ mod tests {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn test() -> i32 { 123; }
|
fn test() -> i32 { 123; }
|
||||||
//^^^ remove this semicolon
|
//^^^ 💡 error: remove this semicolon
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ pub mod iter {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3].iter().filter_map(|x| if *x == 2 { Some (4) } else { None }).next();
|
let m = [1, 2, 3].iter().filter_map(|x| Some(92)).next();
|
||||||
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ replace filter_map(..).next() with find_map(..)
|
} //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: replace filter_map(..).next() with find_map(..)
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ pub mod iter {
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3]
|
let m = [1, 2, 3]
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| if *x == 2 { Some (4) } else { None })
|
.filter_map(|x| Some(92))
|
||||||
.len();
|
.len();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -118,7 +118,7 @@ fn foo() {
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3]
|
let m = [1, 2, 3]
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| if *x == 2 { Some (4) } else { None })
|
.filter_map(|x| Some(92))
|
||||||
.map(|x| x + 2)
|
.map(|x| x + 2)
|
||||||
.len();
|
.len();
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ fn foo() {
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3]
|
let m = [1, 2, 3]
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| if *x == 2 { Some (4) } else { None });
|
.filter_map(|x| Some(92));
|
||||||
let n = m.next();
|
let n = m.next();
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -148,7 +148,7 @@ fn foo() {
|
||||||
use core::iter::Iterator;
|
use core::iter::Iterator;
|
||||||
use core::option::Option::{self, Some, None};
|
use core::option::Option::{self, Some, None};
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3].iter().$0filter_map(|x| if *x == 2 { Some (4) } else { None }).next();
|
let m = [1, 2, 3].iter().$0filter_map(|x| Some(92)).next();
|
||||||
}
|
}
|
||||||
//- /core/lib.rs crate:core
|
//- /core/lib.rs crate:core
|
||||||
pub mod option {
|
pub mod option {
|
||||||
|
@ -171,7 +171,7 @@ pub mod iter {
|
||||||
use core::iter::Iterator;
|
use core::iter::Iterator;
|
||||||
use core::option::Option::{self, Some, None};
|
use core::option::Option::{self, Some, None};
|
||||||
fn foo() {
|
fn foo() {
|
||||||
let m = [1, 2, 3].iter().find_map(|x| if *x == 2 { Some (4) } else { None });
|
let m = [1, 2, 3].iter().find_map(|x| Some(92));
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod tests {
|
||||||
//- /main.rs crate:main deps:core
|
//- /main.rs crate:main deps:core
|
||||||
extern crate core;
|
extern crate core;
|
||||||
extern crate doesnotexist;
|
extern crate doesnotexist;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unresolved extern crate
|
||||||
//- /lib.rs crate:core
|
//- /lib.rs crate:core
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -38,7 +38,7 @@ extern crate core;
|
||||||
r#"
|
r#"
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
extern crate doesnotexist;
|
extern crate doesnotexist;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unresolved extern crate
|
||||||
// Should not error.
|
// Should not error.
|
||||||
extern crate self as foo;
|
extern crate self as foo;
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod tests {
|
||||||
r#"
|
r#"
|
||||||
use does_exist;
|
use does_exist;
|
||||||
use does_not_exist;
|
use does_not_exist;
|
||||||
//^^^^^^^^^^^^^^ unresolved import
|
//^^^^^^^^^^^^^^ error: unresolved import
|
||||||
|
|
||||||
mod does_exist {}
|
mod does_exist {}
|
||||||
"#,
|
"#,
|
||||||
|
@ -43,18 +43,18 @@ mod does_exist {}
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
use does_exist::{Exists, DoesntExist};
|
use does_exist::{Exists, DoesntExist};
|
||||||
//^^^^^^^^^^^ unresolved import
|
//^^^^^^^^^^^ error: unresolved import
|
||||||
|
|
||||||
use {does_not_exist::*, does_exist};
|
use {does_not_exist::*, does_exist};
|
||||||
//^^^^^^^^^^^^^^^^^ unresolved import
|
//^^^^^^^^^^^^^^^^^ error: unresolved import
|
||||||
|
|
||||||
use does_not_exist::{
|
use does_not_exist::{
|
||||||
a,
|
a,
|
||||||
//^ unresolved import
|
//^ error: unresolved import
|
||||||
b,
|
b,
|
||||||
//^ unresolved import
|
//^ error: unresolved import
|
||||||
c,
|
c,
|
||||||
//^ unresolved import
|
//^ error: unresolved import
|
||||||
};
|
};
|
||||||
|
|
||||||
mod does_exist {
|
mod does_exist {
|
||||||
|
@ -71,18 +71,18 @@ mod does_exist {
|
||||||
//- /main.rs crate:main
|
//- /main.rs crate:main
|
||||||
mod a {
|
mod a {
|
||||||
extern crate doesnotexist;
|
extern crate doesnotexist;
|
||||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
|
//^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unresolved extern crate
|
||||||
|
|
||||||
// Should not error, since we already errored for the missing crate.
|
// Should not error, since we already errored for the missing crate.
|
||||||
use doesnotexist::{self, bla, *};
|
use doesnotexist::{self, bla, *};
|
||||||
|
|
||||||
use crate::doesnotexist;
|
use crate::doesnotexist;
|
||||||
//^^^^^^^^^^^^^^^^^^^ unresolved import
|
//^^^^^^^^^^^^^^^^^^^ error: unresolved import
|
||||||
}
|
}
|
||||||
|
|
||||||
mod m {
|
mod m {
|
||||||
use super::doesnotexist;
|
use super::doesnotexist;
|
||||||
//^^^^^^^^^^^^^^^^^^^ unresolved import
|
//^^^^^^^^^^^^^^^^^^^ error: unresolved import
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,7 @@ mod tests {
|
||||||
r#"
|
r#"
|
||||||
fn f() {
|
fn f() {
|
||||||
m!();
|
m!();
|
||||||
} //^ unresolved macro `m!`
|
} //^ error: unresolved macro `m!`
|
||||||
|
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -51,7 +51,7 @@ fn f() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
foo::bar!(92);
|
foo::bar!(92);
|
||||||
//^^^ unresolved macro `foo::bar!`
|
//^^^ error: unresolved macro `foo::bar!`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ foo::bar!(92);
|
||||||
macro_rules! m { () => {} }
|
macro_rules! m { () => {} }
|
||||||
|
|
||||||
m!(); m2!();
|
m!(); m2!();
|
||||||
//^^ unresolved macro `self::m2!`
|
//^^ error: unresolved macro `self::m2!`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ mod mac {
|
||||||
macro_rules! m { () => {} } }
|
macro_rules! m { () => {} } }
|
||||||
|
|
||||||
self::m!(); self::m2!();
|
self::m!(); self::m2!();
|
||||||
//^^ unresolved macro `self::m2!`
|
//^^ error: unresolved macro `self::m2!`
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ mod tests {
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
mod foo;
|
mod foo;
|
||||||
mod bar;
|
mod bar;
|
||||||
//^^^^^^^^ unresolved module
|
//^^^^^^^^ 💡 error: unresolved module
|
||||||
mod baz {}
|
mod baz {}
|
||||||
//- /foo.rs
|
//- /foo.rs
|
||||||
"#,
|
"#,
|
||||||
|
|
|
@ -235,7 +235,7 @@ mod tests {
|
||||||
use stdx::trim_indent;
|
use stdx::trim_indent;
|
||||||
use test_utils::{assert_eq_text, extract_annotations};
|
use test_utils::{assert_eq_text, extract_annotations};
|
||||||
|
|
||||||
use crate::DiagnosticsConfig;
|
use crate::{DiagnosticsConfig, Severity};
|
||||||
|
|
||||||
/// Takes a multi-file input fixture with annotated cursor positions,
|
/// Takes a multi-file input fixture with annotated cursor positions,
|
||||||
/// and checks that:
|
/// and checks that:
|
||||||
|
@ -331,8 +331,23 @@ mod tests {
|
||||||
super::diagnostics(&db, &config, &AssistResolveStrategy::All, file_id);
|
super::diagnostics(&db, &config, &AssistResolveStrategy::All, file_id);
|
||||||
|
|
||||||
let expected = extract_annotations(&*db.file_text(file_id));
|
let expected = extract_annotations(&*db.file_text(file_id));
|
||||||
let mut actual =
|
let mut actual = diagnostics
|
||||||
diagnostics.into_iter().map(|d| (d.range, d.message)).collect::<Vec<_>>();
|
.into_iter()
|
||||||
|
.map(|d| {
|
||||||
|
let mut annotation = String::new();
|
||||||
|
if let Some(fixes) = &d.fixes {
|
||||||
|
assert!(!fixes.is_empty());
|
||||||
|
annotation.push_str("💡 ")
|
||||||
|
}
|
||||||
|
annotation.push_str(match d.severity {
|
||||||
|
Severity::Error => "error",
|
||||||
|
Severity::WeakWarning => "weak",
|
||||||
|
});
|
||||||
|
annotation.push_str(": ");
|
||||||
|
annotation.push_str(&d.message);
|
||||||
|
(d.range, annotation)
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
actual.sort_by_key(|(range, _)| range.start());
|
actual.sort_by_key(|(range, _)| range.start());
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue