Auto merge of #95056 - Dylan-DPC:rollup-swtuw2n, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #91133 (Improve `unsafe` diagnostic)
 - #93222 (Make ErrorReported impossible to construct outside `rustc_errors`)
 - #93745 (Stabilize ADX target feature)
 - #94309 ([generator_interior] Be more precise with scopes of borrowed places)
 - #94698 (Remove redundant code from copy-suggestions)
 - #94731 (Suggest adding `{ .. }` around a const function call with arguments)
 - #94960 (Fix many spelling mistakes)
 - #94982 (Add deprecated_safe feature gate and attribute, cc #94978)
 - #94997 (debuginfo: Fix ICE when generating name for type that produces a layout error.)
 - #95000 (Fixed wrong type name in comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-03-18 00:35:19 +00:00
commit cd11905716
181 changed files with 1290 additions and 773 deletions

View file

@ -1,6 +1,6 @@
// compile-flags: -O
// On x86 the closure is inlined in foo() producting something like
// On x86 the closure is inlined in foo() producing something like
// define i32 @foo() [...] {
// tail call void @bar() [...]
// ret i32 0

View file

@ -1,4 +1,4 @@
// Verify that debuginfo column nubmers are 1-based byte offsets.
// Verify that debuginfo column numbers are 1-based byte offsets.
//
// ignore-windows
// compile-flags: -C debuginfo=2

View file

@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass {
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) {
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit()
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit();
});
}
}

View file

@ -34,7 +34,7 @@ macro_rules! fake_lint_pass {
if !cx.sess().contains_name(attrs, $attr) {
cx.lint(CRATE_NOT_OKAY, |lint| {
let msg = format!("crate is not marked with #![{}]", $attr);
lint.build(&msg).set_span(span).emit()
lint.build(&msg).set_span(span).emit();
});
}
)*

View file

@ -30,7 +30,7 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
let span = cx.tcx.def_span(CRATE_DEF_ID);
if !cx.sess().contains_name(attrs, Symbol::intern("crate_okay")) {
cx.lint(CRATE_NOT_OKAY, |lint| {
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit()
lint.build("crate is not marked with #![crate_okay]").set_span(span).emit();
});
}
}

View file

@ -23,10 +23,10 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) {
match it.ident.as_str() {
"lintme" => cx.lint(TEST_LINT, |lint| {
lint.build("item is named 'lintme'").set_span(it.span).emit()
lint.build("item is named 'lintme'").set_span(it.span).emit();
}),
"pleaselintme" => cx.lint(PLEASE_LINT, |lint| {
lint.build("item is named 'pleaselintme'").set_span(it.span).emit()
lint.build("item is named 'pleaselintme'").set_span(it.span).emit();
}),
_ => {}
}

View file

@ -22,7 +22,7 @@ impl EarlyLintPass for Pass {
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
if it.ident.name.as_str() == "lintme" {
cx.lint(TEST_LINT, |lint| {
lint.build("item is named 'lintme'").set_span(it.span).emit()
lint.build("item is named 'lintme'").set_span(it.span).emit();
});
}
}

View file

@ -32,12 +32,12 @@ impl EarlyLintPass for Pass {
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
if it.ident.name.as_str() == "lintme" {
cx.lint(TEST_LINT, |lint| {
lint.build("item is named 'lintme'").set_span(it.span).emit()
lint.build("item is named 'lintme'").set_span(it.span).emit();
});
}
if it.ident.name.as_str() == "lintmetoo" {
cx.lint(TEST_GROUP, |lint| {
lint.build("item is named 'lintmetoo'").set_span(it.span).emit()
lint.build("item is named 'lintmetoo'").set_span(it.span).emit();
});
}
}

View file

@ -0,0 +1,21 @@
fn foo<const N: i32>() -> i32 {
N
}
const fn bar(n: i32, m: i32) -> i32 {
n
}
const fn baz() -> i32 {
1
}
const FOO: i32 = 3;
fn main() {
foo::<baz()>(); //~ ERROR expected type, found function `baz`
//~| ERROR unresolved item provided when a constant was expected
foo::<bar(bar(1, 1), bar(1, 1))>(); //~ ERROR expected type, found `1`
foo::<bar(1, 1)>(); //~ ERROR expected type, found `1`
foo::<bar(FOO, 2)>(); //~ ERROR expected type, found `2`
}

View file

@ -0,0 +1,54 @@
error: expected type, found `1`
--> $DIR/const-generic-function.rs:18:19
|
LL | foo::<bar(bar(1, 1), bar(1, 1))>();
| ^ expected type
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
LL | foo::<{ bar(bar(1, 1), bar(1, 1)) }>();
| + +
error: expected type, found `1`
--> $DIR/const-generic-function.rs:19:15
|
LL | foo::<bar(1, 1)>();
| ^ expected type
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
LL | foo::<{ bar(1, 1) }>();
| + +
error: expected type, found `2`
--> $DIR/const-generic-function.rs:20:20
|
LL | foo::<bar(FOO, 2)>();
| ^ expected type
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
LL | foo::<{ bar(FOO, 2) }>();
| + +
error[E0573]: expected type, found function `baz`
--> $DIR/const-generic-function.rs:16:11
|
LL | foo::<baz()>();
| ^^^^^ not a type
error[E0747]: unresolved item provided when a constant was expected
--> $DIR/const-generic-function.rs:16:11
|
LL | foo::<baz()>();
| ^^^^^
|
help: if this generic argument was intended as a const parameter, surround it with braces
|
LL | foo::<{ baz() }>();
| + +
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0573, E0747.
For more information about an error, try `rustc --explain E0573`.

View file

@ -0,0 +1,16 @@
// Make sure the compiler does not ICE when trying to generate the debuginfo name of a type that
// causes a layout error. See https://github.com/rust-lang/rust/issues/94961.
// compile-flags:-C debuginfo=2
// build-fail
// error-pattern: too big for the current architecture
// normalize-stderr-64bit "18446744073709551615" -> "SIZE"
// normalize-stderr-32bit "4294967295" -> "SIZE"
#![crate_type = "rlib"]
pub struct Foo<T>([T; usize::MAX]);
pub fn foo() -> usize {
std::mem::size_of::<Foo<u8>>()
}

View file

@ -0,0 +1,4 @@
error: values of the type `[u8; SIZE]` are too big for the current architecture
error: aborting due to previous error

View file

@ -0,0 +1,20 @@
// Make sure the compiler does not ICE when trying to generate the debuginfo name of a type that
// causes a layout error.
// This version of the test already ICE'd before the commit that introduce the ICE described in
// https://github.com/rust-lang/rust/issues/94961.
// compile-flags:-C debuginfo=2
// build-fail
// error-pattern: too big for the current architecture
// normalize-stderr-64bit "18446744073709551615" -> "SIZE"
// normalize-stderr-32bit "4294967295" -> "SIZE"
#![crate_type = "rlib"]
pub enum Foo<T> {
Bar([T; usize::MAX]),
}
pub fn foo() -> usize {
std::mem::size_of::<Foo<u8>>()
}

View file

@ -0,0 +1,4 @@
error: values of the type `[u8; SIZE]` are too big for the current architecture
error: aborting due to previous error

View file

@ -4,7 +4,7 @@ struct ReallyBig {
}
// The limit for "too big for the current architecture" is dependent on the target pointer size
// however it's artifically limited on 64 bits
// however it's artificially limited on 64 bits
// logic copied from rustc_target::abi::TargetDataLayout::obj_size_bound()
const fn max_size() -> usize {
#[cfg(target_pointer_width = "16")]

View file

@ -0,0 +1,7 @@
#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature
unsafe fn deprecated_safe_fn() {}
#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature
unsafe trait DeprecatedSafeTrait {}
fn main() {}

View file

@ -0,0 +1,21 @@
error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature
--> $DIR/feature-gate-deprecated_safe.rs:1:1
|
LL | #[deprecated_safe(since = "TBD", note = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #94978 <https://github.com/rust-lang/rust/issues/94978> for more information
= help: add `#![feature(deprecated_safe)]` to the crate attributes to enable
error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature
--> $DIR/feature-gate-deprecated_safe.rs:4:1
|
LL | #[deprecated_safe(since = "TBD", note = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #94978 <https://github.com/rust-lang/rust/issues/94978> for more information
= help: add `#![feature(deprecated_safe)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -0,0 +1,22 @@
// check-pass
// compile-flags: -Zdrop-tracking
#![feature(generators, negative_impls)]
struct Client;
impl !Sync for Client {}
fn status(_client_status: &Client) -> i16 {
200
}
fn assert_send<T: Send>(_thing: T) {}
// This is the same bug as issue 57017, but using yield instead of await
fn main() {
let client = Client;
let g = move || match status(&client) {
_status => yield,
};
assert_send(g);
}

View file

@ -1,4 +1,4 @@
// Test that multiple liftimes are allowed in impl trait types.
// Test that multiple lifetimes are allowed in impl trait types.
// build-pass (FIXME(62277): could be check-pass?)
trait X<'x>: Sized {}

View file

@ -4,10 +4,15 @@ error: expected `{`, found keyword `unsafe`
LL | trait T {
| - while parsing this item list starting here
LL | extern "Rust" unsafe fn foo();
| ^^^^^^ expected `{`
| --------------^^^^^^
| | |
| | expected `{`
| help: `unsafe` must come before `extern "Rust"`: `unsafe extern "Rust"`
LL |
LL | }
| - the item list ends here
|
= note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
error: aborting due to previous error