-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #97342 - JohnTitor:rollup-zqxctaw, r=JohnTitor
Rollup of 5 pull requests Successful merges: - #97240 (Typo suggestion for a variable with a name similar to struct fields) - #97289 (Lifetime variance fixes for clippy) - #97290 (Turn on `fast_submodules` unconditionally) - #97336 (typo) - #97337 (Fix stabilization version of `Ipv6Addr::to_ipv4_mapped`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
17 changed files
with
219 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
struct A { | ||
config: String, | ||
} | ||
|
||
impl A { | ||
fn new(cofig: String) -> Self { | ||
Self { config } //~ Error cannot find value `config` in this scope | ||
} | ||
|
||
fn do_something(cofig: String) { | ||
println!("{config}"); //~ Error cannot find value `config` in this scope | ||
} | ||
|
||
fn self_is_available(self, cofig: String) { | ||
println!("{config}"); //~ Error cannot find value `config` in this scope | ||
} | ||
} | ||
|
||
trait B { | ||
const BAR: u32 = 3; | ||
type Baz; | ||
fn bar(&self); | ||
fn baz(&self) {} | ||
fn bah() {} | ||
} | ||
|
||
impl B for Box<isize> { | ||
type Baz = String; | ||
fn bar(&self) { | ||
// let baz = 3; | ||
baz(); | ||
//~^ ERROR cannot find function `baz` | ||
bah; | ||
//~^ ERROR cannot find value `bah` | ||
BAR; | ||
//~^ ERROR cannot find value `BAR` in this scope | ||
let foo: Baz = "".to_string(); | ||
//~^ ERROR cannot find type `Baz` in this scope | ||
} | ||
} | ||
|
||
fn ba() {} | ||
const BARR: u32 = 3; | ||
type Bar = String; | ||
|
||
fn main() {} |
109 changes: 109 additions & 0 deletions
109
src/test/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
error[E0425]: cannot find value `config` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16 | ||
| | ||
LL | Self { config } | ||
| ^^^^^^ | ||
| | | ||
| a field by this name exists in `Self` | ||
| help: a local variable with a similar name exists: `cofig` | ||
|
||
error[E0425]: cannot find value `config` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20 | ||
| | ||
LL | println!("{config}"); | ||
| ^^^^^^ | ||
| | | ||
| a field by this name exists in `Self` | ||
| help: a local variable with a similar name exists: `cofig` | ||
|
||
error[E0425]: cannot find value `config` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20 | ||
| | ||
LL | println!("{config}"); | ||
| ^^^^^^ | ||
| | ||
help: you might have meant to use the available field | ||
| | ||
LL | println!("{self.config}"); | ||
| ~~~~~~~~~~~ | ||
help: a local variable with a similar name exists | ||
| | ||
LL | println!("{cofig}"); | ||
| ~~~~~ | ||
|
||
error[E0425]: cannot find function `baz` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9 | ||
| | ||
LL | baz(); | ||
| ^^^ | ||
... | ||
LL | fn ba() {} | ||
| ------- similarly named function `ba` defined here | ||
| | ||
help: you might have meant to call the method | ||
| | ||
LL | self.baz(); | ||
| ~~~~~~~~ | ||
help: a function with a similar name exists | ||
| | ||
LL | ba(); | ||
| ~~ | ||
|
||
error[E0425]: cannot find value `bah` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9 | ||
| | ||
LL | bah; | ||
| ^^^ | ||
... | ||
LL | fn ba() {} | ||
| ------- similarly named function `ba` defined here | ||
| | ||
help: you might have meant to call the associated function | ||
| | ||
LL | Self::bah; | ||
| ~~~~~~~~~ | ||
help: a function with a similar name exists | ||
| | ||
LL | ba; | ||
| ~~ | ||
|
||
error[E0425]: cannot find value `BAR` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:35:9 | ||
| | ||
LL | BAR; | ||
| ^^^ | ||
... | ||
LL | const BARR: u32 = 3; | ||
| -------------------- similarly named constant `BARR` defined here | ||
| | ||
help: you might have meant to use the associated `const` | ||
| | ||
LL | Self::BAR; | ||
| ~~~~~~~~~ | ||
help: a constant with a similar name exists | ||
| | ||
LL | BARR; | ||
| ~~~~ | ||
|
||
error[E0412]: cannot find type `Baz` in this scope | ||
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:37:18 | ||
| | ||
LL | let foo: Baz = "".to_string(); | ||
| ^^^ | ||
... | ||
LL | type Bar = String; | ||
| ------------------ similarly named type alias `Bar` defined here | ||
| | ||
help: you might have meant to use the associated type | ||
| | ||
LL | let foo: Self::Baz = "".to_string(); | ||
| ~~~~~~~~~ | ||
help: a type alias with a similar name exists | ||
| | ||
LL | let foo: Bar = "".to_string(); | ||
| ~~~ | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0412, E0425. | ||
For more information about an error, try `rustc --explain E0412`. |
Oops, something went wrong.