-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #64739 - guanqun:remove-as-str, r=estebank
Remove as_str if the type is already &str Fix #62642 r? @estebank do you think the suggestion tip is good enough?
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn foo1(s: &str) { | ||
s.as_str(); | ||
//~^ ERROR no method named `as_str` found for type `&str` in the current scope | ||
} | ||
|
||
fn foo2<'a>(s: &'a str) { | ||
s.as_str(); | ||
//~^ ERROR no method named `as_str` found for type `&'a str` in the current scope | ||
} | ||
|
||
fn foo3(s: &mut str) { | ||
s.as_str(); | ||
//~^ ERROR no method named `as_str` found for type `&mut str` in the current scope | ||
} | ||
|
||
fn foo4(s: &&str) { | ||
s.as_str(); | ||
//~^ ERROR no method named `as_str` found for type `&&str` in the current scope | ||
} | ||
|
||
fn main() {} |
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,27 @@ | ||
error[E0599]: no method named `as_str` found for type `&str` in the current scope | ||
--> $DIR/remove-as_str.rs:2:7 | ||
| | ||
LL | s.as_str(); | ||
| ^^^^^^ try removing `as_str` | ||
|
||
error[E0599]: no method named `as_str` found for type `&'a str` in the current scope | ||
--> $DIR/remove-as_str.rs:7:7 | ||
| | ||
LL | s.as_str(); | ||
| ^^^^^^ try removing `as_str` | ||
|
||
error[E0599]: no method named `as_str` found for type `&mut str` in the current scope | ||
--> $DIR/remove-as_str.rs:12:7 | ||
| | ||
LL | s.as_str(); | ||
| ^^^^^^ try removing `as_str` | ||
|
||
error[E0599]: no method named `as_str` found for type `&&str` in the current scope | ||
--> $DIR/remove-as_str.rs:17:7 | ||
| | ||
LL | s.as_str(); | ||
| ^^^^^^ try removing `as_str` | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0599`. |