-
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 #106914 - matthiaskrgr:rollup-yh0x4gq, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #106888 (Add tidy check to ensure that rustdoc GUI tests start with a small description) - #106896 (suggest `is_empty` for collections when casting to `bool`) - #106900 (Fix regression in `unused_braces` with macros) - #106906 (remove redundant clones) - #106909 (Only suggest adding type param if path being resolved was a type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
18 changed files
with
213 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Tidy check to ensure that rustdoc GUI tests start with a small description. | ||
use std::path::Path; | ||
|
||
pub fn check(path: &Path, bad: &mut bool) { | ||
crate::walk::walk( | ||
&path.join("rustdoc-gui"), | ||
&mut |p| { | ||
// If there is no extension, it's very likely a folder and we want to go into it. | ||
p.extension().map(|e| e != "goml").unwrap_or(false) | ||
}, | ||
&mut |entry, content| { | ||
for line in content.lines() { | ||
if !line.starts_with("// ") { | ||
tidy_error!( | ||
bad, | ||
"{}: rustdoc-gui tests must start with a small description", | ||
entry.path().display(), | ||
); | ||
return; | ||
} else if line.starts_with("// ") { | ||
let parts = line[2..].trim(); | ||
// We ignore tidy comments. | ||
if parts.starts_with("// tidy-") { | ||
continue; | ||
} | ||
// All good! | ||
return; | ||
} | ||
} | ||
}, | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::ops::Deref; | ||
|
||
struct Foo; | ||
|
||
impl Deref for Foo { | ||
type Target = [u8]; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&[] | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = "foo" as bool; | ||
//~^ ERROR casting `&'static str` as `bool` is invalid [E0606] | ||
|
||
let _ = String::from("foo") as bool; | ||
//~^ ERROR non-primitive cast: `String` as `bool` [E0605] | ||
|
||
let _ = Foo as bool; | ||
//~^ ERROR non-primitive cast: `Foo` as `bool` [E0605] | ||
} | ||
|
||
fn _slice(bar: &[i32]) -> bool { | ||
bar as bool | ||
//~^ ERROR casting `&[i32]` as `bool` is invalid [E0606] | ||
} |
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,58 @@ | ||
error[E0606]: casting `&'static str` as `bool` is invalid | ||
--> $DIR/issue-106883-is-empty.rs:14:13 | ||
| | ||
LL | let _ = "foo" as bool; | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: consider using the `is_empty` method on `&'static str` to determine if it contains anything | ||
| | ||
LL | let _ = !"foo".is_empty(); | ||
| + ~~~~~~~~~~~ | ||
|
||
error[E0605]: non-primitive cast: `String` as `bool` | ||
--> $DIR/issue-106883-is-empty.rs:17:13 | ||
| | ||
LL | let _ = String::from("foo") as bool; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | ||
| | ||
note: this expression `Deref`s to `str` which implements `is_empty` | ||
--> $DIR/issue-106883-is-empty.rs:17:13 | ||
| | ||
LL | let _ = String::from("foo") as bool; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
help: consider using the `is_empty` method on `String` to determine if it contains anything | ||
| | ||
LL | let _ = !String::from("foo").is_empty(); | ||
| + ~~~~~~~~~~~ | ||
|
||
error[E0605]: non-primitive cast: `Foo` as `bool` | ||
--> $DIR/issue-106883-is-empty.rs:20:13 | ||
| | ||
LL | let _ = Foo as bool; | ||
| ^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object | ||
| | ||
note: this expression `Deref`s to `[u8]` which implements `is_empty` | ||
--> $DIR/issue-106883-is-empty.rs:20:13 | ||
| | ||
LL | let _ = Foo as bool; | ||
| ^^^ | ||
help: consider using the `is_empty` method on `Foo` to determine if it contains anything | ||
| | ||
LL | let _ = !Foo.is_empty(); | ||
| + ~~~~~~~~~~~ | ||
|
||
error[E0606]: casting `&[i32]` as `bool` is invalid | ||
--> $DIR/issue-106883-is-empty.rs:25:5 | ||
| | ||
LL | bar as bool | ||
| ^^^^^^^^^^^ | ||
| | ||
help: consider using the `is_empty` method on `&[i32]` to determine if it contains anything | ||
| | ||
LL | !bar.is_empty() | ||
| + ~~~~~~~~~~~ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0605, E0606. | ||
For more information about an error, try `rustc --explain E0605`. |
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