Auto merge of #75126 - JohnTitor:rollup-aejluzx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #74759 (add `unsigned_abs` to signed integers)
 - #75043 (rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`)
 - #75056 (Lint path statements to suggest using drop when the type needs drop)
 - #75081 (Fix logging for rustdoc)
 - #75083 (Do not trigger `unused_braces` for `while let`)
 - #75084 (Stabilize Ident::new_raw)
 - #75103 (Disable building rust-analyzer on riscv64)
 - #75106 (Enable docs on in the x86_64-unknown-linux-musl manifest)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-08-04 01:48:32 +00:00
commit 60c2e8d438
46 changed files with 297 additions and 149 deletions

View file

@ -15,15 +15,8 @@ fn main() {
while let Some(_) = ((yield)) {} //~ ERROR: unnecessary parentheses
{{yield}}; //~ ERROR: unnecessary braces
{( yield )}; //~ ERROR: unnecessary parentheses
// FIXME: Reduce duplicate warnings.
// Perhaps we should tweak checks in `BlockRetValue`?
while let Some(_) = {(yield)} {}
//~^ ERROR: unnecessary braces
//~| ERROR: unnecessary parentheses
while let Some(_) = {{yield}} {}
//~^ ERROR: unnecessary braces
//~| ERROR: unnecessary braces
while let Some(_) = {(yield)} {} //~ ERROR: unnecessary parentheses
while let Some(_) = {{yield}} {} //~ ERROR: unnecessary braces
// FIXME: It'd be great if we could also warn them.
((yield));

View file

@ -34,29 +34,17 @@ error: unnecessary parentheses around block return value
LL | {( yield )};
| ^^^^^^^^^ help: remove these parentheses
error: unnecessary braces around `let` scrutinee expression
--> $DIR/issue-74883-unused-paren-baren-yield.rs:21:29
|
LL | while let Some(_) = {(yield)} {}
| ^^^^^^^^^ help: remove these braces
error: unnecessary parentheses around block return value
--> $DIR/issue-74883-unused-paren-baren-yield.rs:21:30
--> $DIR/issue-74883-unused-paren-baren-yield.rs:18:30
|
LL | while let Some(_) = {(yield)} {}
| ^^^^^^^ help: remove these parentheses
error: unnecessary braces around `let` scrutinee expression
--> $DIR/issue-74883-unused-paren-baren-yield.rs:24:29
|
LL | while let Some(_) = {{yield}} {}
| ^^^^^^^^^ help: remove these braces
error: unnecessary braces around block return value
--> $DIR/issue-74883-unused-paren-baren-yield.rs:24:30
--> $DIR/issue-74883-unused-paren-baren-yield.rs:19:30
|
LL | while let Some(_) = {{yield}} {}
| ^^^^^^^ help: remove these braces
error: aborting due to 8 previous errors
error: aborting due to 6 previous errors

View file

@ -0,0 +1,12 @@
// check-pass
#![deny(unused_braces)]
fn main() {
let mut a = Some(3);
// Shouldn't warn below `a`.
while let Some(ref mut v) = {a} {
a.as_mut().map(|a| std::mem::swap(a, v));
break;
}
}

View file

@ -0,0 +1,35 @@
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::{TokenStream, TokenTree, Ident, Punct, Spacing, Span};
#[proc_macro]
pub fn make_struct(input: TokenStream) -> TokenStream {
match input.into_iter().next().unwrap() {
TokenTree::Ident(ident) => {
vec![
TokenTree::Ident(Ident::new("struct", Span::call_site())),
TokenTree::Ident(Ident::new_raw(&ident.to_string(), Span::call_site())),
TokenTree::Punct(Punct::new(';', Spacing::Alone))
].into_iter().collect()
}
_ => panic!()
}
}
#[proc_macro]
pub fn make_bad_struct(input: TokenStream) -> TokenStream {
match input.into_iter().next().unwrap() {
TokenTree::Ident(ident) => {
vec![
TokenTree::Ident(Ident::new_raw("struct", Span::call_site())),
TokenTree::Ident(Ident::new(&ident.to_string(), Span::call_site())),
TokenTree::Punct(Punct::new(';', Spacing::Alone))
].into_iter().collect()
}
_ => panic!()
}
}

View file

@ -0,0 +1,16 @@
// aux-build:raw-ident.rs
#[macro_use] extern crate raw_ident;
fn main() {
make_struct!(fn);
make_struct!(Foo);
make_struct!(await);
r#fn;
r#Foo;
Foo;
r#await;
make_bad_struct!(S); //~ ERROR expected one of
}

View file

@ -0,0 +1,10 @@
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `S`
--> $DIR/raw-ident.rs:15:5
|
LL | make_bad_struct!(S);
| ^^^^^^^^^^^^^^^^^^^^ expected one of 8 possible tokens
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error

View file

@ -1,6 +1,17 @@
// compile-flags: -D path-statements
fn main() {
struct Droppy;
impl Drop for Droppy {
fn drop(&mut self) {}
}
fn main() {
let x = 10;
x; //~ ERROR path statement with no effect
let y = Droppy;
y; //~ ERROR path statement drops value
let z = (Droppy,);
z; //~ ERROR path statement drops value
}

View file

@ -1,10 +1,22 @@
error: path statement with no effect
--> $DIR/warn-path-statement.rs:5:5
--> $DIR/warn-path-statement.rs:10:5
|
LL | x;
| ^^
|
= note: requested on the command line with `-D path-statements`
error: aborting due to previous error
error: path statement drops value
--> $DIR/warn-path-statement.rs:13:5
|
LL | y;
| ^^ help: use `drop` to clarify the intent: `drop(y);`
error: path statement drops value
--> $DIR/warn-path-statement.rs:16:5
|
LL | z;
| ^^ help: use `drop` to clarify the intent: `drop(z);`
error: aborting due to 3 previous errors