diff options
| author | bors <bors@rust-lang.org> | 2019-10-07 05:35:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-10-07 05:35:17 +0000 |
| commit | f92f3c4bc67c003fe66afaf5d772731c074d7459 (patch) | |
| tree | 0d8a3dca45934a1c674c1672e1df4cf11e34e553 /src/test/ui/suggestions | |
| parent | 4ac4809ccf5f77083ae7155dcc83e921341c2614 (diff) | |
| parent | 11c2d43485e92a00d86b3a5bc1655165b6b8371b (diff) | |
| download | rust-f92f3c4bc67c003fe66afaf5d772731c074d7459.tar.gz rust-f92f3c4bc67c003fe66afaf5d772731c074d7459.zip | |
Auto merge of #64739 - guanqun:remove-as-str, r=estebank
Remove as_str if the type is already &str Fix https://github.com/rust-lang/rust/issues/62642 r? @estebank do you think the suggestion tip is good enough?
Diffstat (limited to 'src/test/ui/suggestions')
| -rw-r--r-- | src/test/ui/suggestions/remove-as_str.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/suggestions/remove-as_str.stderr | 27 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/remove-as_str.rs b/src/test/ui/suggestions/remove-as_str.rs new file mode 100644 index 00000000000..d10300b48ba --- /dev/null +++ b/src/test/ui/suggestions/remove-as_str.rs @@ -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() {} diff --git a/src/test/ui/suggestions/remove-as_str.stderr b/src/test/ui/suggestions/remove-as_str.stderr new file mode 100644 index 00000000000..2e8b72ebd4f --- /dev/null +++ b/src/test/ui/suggestions/remove-as_str.stderr @@ -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`. |
