Auto merge of #53662 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests Successful merges: - #53311 (Window Mutex: Document that we properly initialize the SRWLock) - #53503 (Discourage overuse of mem::forget) - #53545 (Fix #50865: ICE on impl-trait returning functions reaching private items) - #53559 (add macro check for lint) - #53562 (Lament the invincibility of the Turbofish) - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()) - #53592 (docs: minor stylistic changes to str/string docs) - #53594 (Update RELEASES.md to include clippy-preview) - #53600 (Fix a grammatical mistake in "expected generic arguments" errors) - #53614 (update nomicon and book) - #53617 (tidy: Stop requiring a license header) - #53618 (Add missing fmt examples) - #53636 (Prefer `.nth(n)` over `.skip(n).next()`.) - #53644 (Use SmallVec for SmallCStr) - #53664 (Remove unnecessary closure in rustc_mir/build/mod.rs) - #53666 (Added rustc_codegen_llvm to compiler documentation.)
This commit is contained in:
commit
727eabd681
114 changed files with 382 additions and 305 deletions
|
|
@ -19,7 +19,7 @@ use proc_macro::*;
|
|||
|
||||
#[proc_macro_attribute]
|
||||
pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let name = item.into_iter().skip(1).next().unwrap();
|
||||
let name = item.into_iter().nth(1).unwrap();
|
||||
quote!(fn $name() -> bool { true })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::sync::Arc;
|
|||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
fn main() {
|
||||
if let Some(arg) = env::args().skip(1).next() {
|
||||
if let Some(arg) = env::args().nth(1) {
|
||||
match &arg[..] {
|
||||
"test1" => println!("hello2"),
|
||||
"test2" => assert_eq!(env::var("FOO").unwrap(), "BAR"),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
pub fn bar<P>( // Error won't happen if "bar" is not generic
|
||||
_baz: P,
|
||||
) {
|
||||
hide_foo()();
|
||||
}
|
||||
|
||||
fn hide_foo() -> impl Fn() { // Error won't happen if "iterate" hasn't impl Trait or has generics
|
||||
foo
|
||||
}
|
||||
|
||||
fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics
|
||||
}
|
||||
25
src/test/run-pass/issue-50865-private-impl-trait/main.rs
Normal file
25
src/test/run-pass/issue-50865-private-impl-trait/main.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:lib.rs
|
||||
|
||||
// Regression test for #50865.
|
||||
// When using generics or specifying the type directly, this example
|
||||
// codegens `foo` internally. However, when using a private `impl Trait`
|
||||
// function which references another private item, `foo` (in this case)
|
||||
// wouldn't be codegenned until main.rs used `bar`, as with impl Trait
|
||||
// it is not cast to `fn()` automatically to satisfy e.g.
|
||||
// `fn foo() -> fn() { ... }`.
|
||||
|
||||
extern crate lib;
|
||||
|
||||
fn main() {
|
||||
lib::bar(()); // Error won't happen if bar is called from same crate
|
||||
}
|
||||
|
|
@ -36,6 +36,10 @@
|
|||
// My heart aches in sorrow, for I know I am defeated. Let this be a warning
|
||||
// to all those who come after. Here stands the bastion of the Turbofish.
|
||||
|
||||
// See https://github.com/rust-lang/rust/pull/53562
|
||||
// and https://github.com/rust-lang/rfcs/pull/2527
|
||||
// for context.
|
||||
|
||||
fn main() {
|
||||
let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated");
|
||||
let _: (bool, bool) = (oh<woe, is>(me));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0244]: wrong number of type arguments: expected at most 2, found 3
|
|||
--> $DIR/generic-impl-more-params-with-defaults.rs:23:5
|
||||
|
|
||||
LL | Vec::<isize, Heap, bool>::new();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected at most 2 type argument
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected at most 2 type arguments
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0244]: wrong number of type arguments: expected at most 2, found 3
|
|||
--> $DIR/generic-type-more-params-with-defaults.rs:19:12
|
||||
|
|
||||
LL | let _: Vec<isize, Heap, bool>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ expected at most 2 type argument
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ expected at most 2 type arguments
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@
|
|||
// aux-build:lints-in-foreign-macros.rs
|
||||
// compile-pass
|
||||
|
||||
#![warn(unused_imports)]
|
||||
#![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate lints_in_foreign_macros;
|
||||
|
|
@ -24,5 +25,7 @@ mod a { foo!(); }
|
|||
mod b { bar!(); }
|
||||
mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
|
||||
mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
|
||||
baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function
|
||||
baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: unused import: `std::string::ToString`
|
||||
--> $DIR/lints-in-foreign-macros.rs:20:16
|
||||
--> $DIR/lints-in-foreign-macros.rs:21:16
|
||||
|
|
||||
LL | () => {use std::string::ToString;} //~ WARN: unused import
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -10,18 +10,48 @@ LL | mod a { foo!(); }
|
|||
note: lint level defined here
|
||||
--> $DIR/lints-in-foreign-macros.rs:14:9
|
||||
|
|
||||
LL | #![warn(unused_imports)]
|
||||
LL | #![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused import: `std::string::ToString`
|
||||
--> $DIR/lints-in-foreign-macros.rs:25:18
|
||||
--> $DIR/lints-in-foreign-macros.rs:26:18
|
||||
|
|
||||
LL | mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused import: `std::string::ToString`
|
||||
--> $DIR/lints-in-foreign-macros.rs:26:19
|
||||
--> $DIR/lints-in-foreign-macros.rs:27:19
|
||||
|
|
||||
LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: missing documentation for crate
|
||||
--> $DIR/lints-in-foreign-macros.rs:14:1
|
||||
|
|
||||
LL | / #![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
|
||||
LL | | #![warn(missing_docs)]
|
||||
LL | |
|
||||
LL | | #[macro_use]
|
||||
... |
|
||||
LL | |
|
||||
LL | | fn main() {}
|
||||
| |____________^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lints-in-foreign-macros.rs:15:9
|
||||
|
|
||||
LL | #![warn(missing_docs)]
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
warning: missing documentation for a function
|
||||
--> $DIR/lints-in-foreign-macros.rs:28:6
|
||||
|
|
||||
LL | baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: missing documentation for a function
|
||||
--> $DIR/lints-in-foreign-macros.rs:29:7
|
||||
|
|
||||
LL | baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue