Auto merge of #89414 - Manishearth:rollup-hs11bcq, r=Manishearth

Rollup of 8 pull requests

Successful merges:

 - #88782 (Fix ICE when `start` lang item has wrong generics)
 - #89202 (Resolve infered types when complaining about unexpected call type )
 - #89248 (Suggest similarly named associated items in trait impls)
 - #89303 (Add `#[must_not_suspend]` to some types in std)
 - #89306 (thread: implements available_concurrency on haiku)
 - #89314 (fix(lint): don't suggest refutable patterns to "fix" irrefutable bind)
 - #89370 (CTFE: tweak aggregate rvalue handling)
 - #89392 (bootstrap: Update comment in config.library.toml.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-10-01 03:23:17 +00:00
commit 598d89bf14
30 changed files with 427 additions and 63 deletions

View file

@ -10,6 +10,5 @@ bench-stage = 0
incremental = true
[llvm]
# Will download LLVM from CI if available on your platform (Linux only for now)
# https://github.com/rust-lang/rust/issues/77084 tracks support for more platforms
# Will download LLVM from CI if available on your platform.
download-ci-llvm = "if-available"

View file

@ -11,7 +11,7 @@ trait Sized {}
auto trait Freeze {}
#[lang = "start"]
fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize {
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
0
}

View file

@ -2,7 +2,10 @@ error[E0407]: method `b` is not a member of trait `Foo`
--> $DIR/E0407.rs:9:5
|
LL | fn b() {}
| ^^^^^^^^^ not a member of trait `Foo`
| ^^^-^^^^^
| | |
| | help: there is an associated function with a similar name: `a`
| not a member of trait `Foo`
error: aborting due to previous error

View file

@ -2,7 +2,10 @@ error[E0407]: method `method` is not a member of trait `Tr`
--> $DIR/assoc_item_ctxt.rs:35:13
|
LL | fn method() {}
| ^^^^^^^^^^^^^^ not a member of trait `Tr`
| ^^^------^^^^^
| | |
| | help: there is an associated function with a similar name: `method`
| not a member of trait `Tr`
...
LL | mac_trait_impl!();
| ------------------ in this macro invocation

View file

@ -1,9 +1,8 @@
// Checks whether declaring a lang item with the wrong number
// of generic arguments crashes the compiler (issue #83893, #87573, and part of #9307).
// Checks that declaring a lang item with the wrong number
// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559).
#![feature(lang_items, no_core)]
#![no_core]
#![crate_type = "lib"]
#[lang = "sized"]
trait MySized {}
@ -26,6 +25,14 @@ struct MyPhantomData<T, U>;
//~^ ERROR parameter `T` is never used
//~| ERROR parameter `U` is never used
// When the `start` lang item is missing generics very odd things can happen, especially when
// it comes to cross-crate monomorphization
#[lang = "start"]
//~^ ERROR `start` language item must be applied to a function with 1 generic argument [E0718]
fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
0
}
fn ice() {
// Use add
let r = 5;
@ -42,3 +49,6 @@ fn ice() {
// Use phantomdata
let _ = MyPhantomData::<(), i32>;
}
// use `start`
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:11:1
--> $DIR/lang-item-generic-requirements.rs:10:1
|
LL | #[lang = "add"]
| ^^^^^^^^^^^^^^^
@ -7,7 +7,7 @@ LL | trait MyAdd<'a, T> {}
| ------- this trait has 2 generic arguments
error[E0718]: `drop_in_place` language item must be applied to a function with at least 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:15:1
--> $DIR/lang-item-generic-requirements.rs:14:1
|
LL | #[lang = "drop_in_place"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -16,7 +16,7 @@ LL | fn my_ptr_drop() {}
| - this function has 0 generic arguments
error[E0718]: `index` language item must be applied to a trait with 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:19:1
--> $DIR/lang-item-generic-requirements.rs:18:1
|
LL | #[lang = "index"]
| ^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL | trait MyIndex<'a, T> {}
| ------- this trait has 2 generic arguments
error[E0718]: `phantom_data` language item must be applied to a struct with 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:23:1
--> $DIR/lang-item-generic-requirements.rs:22:1
|
LL | #[lang = "phantom_data"]
| ^^^^^^^^^^^^^^^^^^^^^^^^
@ -32,8 +32,17 @@ LL |
LL | struct MyPhantomData<T, U>;
| ------ this struct has 2 generic arguments
error[E0718]: `start` language item must be applied to a function with 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:30:1
|
LL | #[lang = "start"]
| ^^^^^^^^^^^^^^^^^
LL |
LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
| - this function has 0 generic arguments
error[E0392]: parameter `T` is never used
--> $DIR/lang-item-generic-requirements.rs:25:22
--> $DIR/lang-item-generic-requirements.rs:24:22
|
LL | struct MyPhantomData<T, U>;
| ^ unused parameter
@ -42,7 +51,7 @@ LL | struct MyPhantomData<T, U>;
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
error[E0392]: parameter `U` is never used
--> $DIR/lang-item-generic-requirements.rs:25:25
--> $DIR/lang-item-generic-requirements.rs:24:25
|
LL | struct MyPhantomData<T, U>;
| ^ unused parameter
@ -50,7 +59,7 @@ LL | struct MyPhantomData<T, U>;
= help: consider removing `U` or referring to it in a field
= help: if you intended `U` to be a const parameter, use `const U: usize` instead
error: aborting due to 6 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0392, E0718.
For more information about an error, try `rustc --explain E0392`.

View file

@ -0,0 +1,12 @@
// edition:2018
#![deny(must_not_suspend)]
async fn other() {}
pub async fn uhoh(m: std::sync::Mutex<()>) {
let _guard = m.lock().unwrap(); //~ ERROR `MutexGuard` held across
other().await;
}
fn main() {
}

View file

@ -0,0 +1,26 @@
error: `MutexGuard` held across a suspend point, but should not be
--> $DIR/mutex.rs:7:9
|
LL | let _guard = m.lock().unwrap();
| ^^^^^^
LL | other().await;
| ------------- the value is held across this suspend point
|
note: the lint level is defined here
--> $DIR/mutex.rs:2:9
|
LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
note: Holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send`
--> $DIR/mutex.rs:7:9
|
LL | let _guard = m.lock().unwrap();
| ^^^^^^
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
--> $DIR/mutex.rs:7:9
|
LL | let _guard = m.lock().unwrap();
| ^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,16 @@
#![allow(unused, nonstandard_style)]
#![deny(bindings_with_variant_name)]
// If an enum has two different variants,
// then it cannot be matched upon in a function argument.
// It still gets a warning, but no suggestions.
enum Foo {
C,
D,
}
fn foo(C: Foo) {} //~ERROR
fn main() {
let C = Foo::D; //~ERROR
}

View file

@ -0,0 +1,21 @@
error[E0170]: pattern binding `C` is named the same as one of the variants of the type `Foo`
--> $DIR/issue-88730.rs:12:8
|
LL | fn foo(C: Foo) {}
| ^
|
note: the lint level is defined here
--> $DIR/issue-88730.rs:2:9
|
LL | #![deny(bindings_with_variant_name)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0170]: pattern binding `C` is named the same as one of the variants of the type `Foo`
--> $DIR/issue-88730.rs:15:9
|
LL | let C = Foo::D;
| ^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0170`.

View file

@ -0,0 +1,48 @@
trait Foo {
type Type;
fn foo();
fn bar();
fn qux();
}
struct A;
impl Foo for A {
//~^ ERROR not all trait items implemented
type Typ = ();
//~^ ERROR type `Typ` is not a member of trait
//~| HELP there is an associated type with a similar name
fn fooo() {}
//~^ ERROR method `fooo` is not a member of trait
//~| HELP there is an associated function with a similar name
fn barr() {}
//~^ ERROR method `barr` is not a member of trait
//~| HELP there is an associated function with a similar name
fn quux() {}
//~^ ERROR method `quux` is not a member of trait
//~| HELP there is an associated function with a similar name
}
//~^ HELP implement the missing item
//~| HELP implement the missing item
//~| HELP implement the missing item
//~| HELP implement the missing item
trait Bar {
const Const: i32;
}
struct B;
impl Bar for B {
//~^ ERROR not all trait items implemented
const Cnst: i32 = 0;
//~^ ERROR const `Cnst` is not a member of trait
//~| HELP there is an associated constant with a similar name
}
//~^ HELP implement the missing item
fn main() {}

View file

@ -0,0 +1,74 @@
error[E0437]: type `Typ` is not a member of trait `Foo`
--> $DIR/suggest-trait-items.rs:13:5
|
LL | type Typ = ();
| ^^^^^---^^^^^^
| | |
| | help: there is an associated type with a similar name: `Type`
| not a member of trait `Foo`
error[E0407]: method `fooo` is not a member of trait `Foo`
--> $DIR/suggest-trait-items.rs:17:5
|
LL | fn fooo() {}
| ^^^----^^^^^
| | |
| | help: there is an associated function with a similar name: `foo`
| not a member of trait `Foo`
error[E0407]: method `barr` is not a member of trait `Foo`
--> $DIR/suggest-trait-items.rs:21:5
|
LL | fn barr() {}
| ^^^----^^^^^
| | |
| | help: there is an associated function with a similar name: `bar`
| not a member of trait `Foo`
error[E0407]: method `quux` is not a member of trait `Foo`
--> $DIR/suggest-trait-items.rs:25:5
|
LL | fn quux() {}
| ^^^----^^^^^
| | |
| | help: there is an associated function with a similar name: `qux`
| not a member of trait `Foo`
error[E0438]: const `Cnst` is not a member of trait `Bar`
--> $DIR/suggest-trait-items.rs:42:5
|
LL | const Cnst: i32 = 0;
| ^^^^^^----^^^^^^^^^^
| | |
| | help: there is an associated constant with a similar name: `Const`
| not a member of trait `Bar`
error[E0046]: not all trait items implemented, missing: `Type`, `foo`, `bar`, `qux`
--> $DIR/suggest-trait-items.rs:11:1
|
LL | type Type;
| ---------- `Type` from trait
LL |
LL | fn foo();
| --------- `foo` from trait
LL | fn bar();
| --------- `bar` from trait
LL | fn qux();
| --------- `qux` from trait
...
LL | impl Foo for A {
| ^^^^^^^^^^^^^^ missing `Type`, `foo`, `bar`, `qux` in implementation
error[E0046]: not all trait items implemented, missing: `Const`
--> $DIR/suggest-trait-items.rs:40:1
|
LL | const Const: i32;
| ----------------- `Const` from trait
...
LL | impl Bar for B {
| ^^^^^^^^^^^^^^ missing `Const` in implementation
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0046, E0407, E0437, E0438.
For more information about an error, try `rustc --explain E0046`.

View file

@ -0,0 +1,3 @@
fn main() {
let _ = {42}(); //~ ERROR expected function, found `{integer}`
}

View file

@ -0,0 +1,11 @@
error[E0618]: expected function, found `{integer}`
--> $DIR/call-block.rs:2:13
|
LL | let _ = {42}();
| ^^^^--
| |
| call expression requires function
error: aborting due to previous error
For more information about this error, try `rustc --explain E0618`.

View file

@ -15,11 +15,12 @@ pub trait Copy {}
pub unsafe trait Freeze {}
#[lang = "start"]
#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
0
}
fn main() {}
struct A;
impl A {

View file

@ -1,5 +1,5 @@
error: methods called `as_*` usually take `self` by reference or `self` by mutable reference
--> $DIR/def_id_nocore.rs:26:19
--> $DIR/def_id_nocore.rs:27:19
|
LL | pub fn as_ref(self) -> &'static str {
| ^^^^