diff options
Diffstat (limited to 'src/test')
191 files changed, 2701 insertions, 1126 deletions
diff --git a/src/test/codegen/remap_path_prefix/main.rs b/src/test/codegen/remap_path_prefix/main.rs index 698dfe6b4f3..b13d576295c 100644 --- a/src/test/codegen/remap_path_prefix/main.rs +++ b/src/test/codegen/remap_path_prefix/main.rs @@ -22,7 +22,7 @@ fn main() { } // Here we check that local debuginfo is mapped correctly. -// CHECK: !DIFile(filename: "/the/src/remap_path_prefix/main.rs", directory: "/the/cwd/" +// CHECK: !DIFile(filename: "/the/src/remap_path_prefix/main.rs", directory: "/the/cwd" // And here that debuginfo from other crates are expanded to absolute paths. // CHECK: !DIFile(filename: "/the/aux-src/remap_path_prefix_aux.rs", directory: "" diff --git a/src/test/debuginfo/thread.rs b/src/test/debuginfo/thread.rs index 531c37a3421..388d50c5cdc 100644 --- a/src/test/debuginfo/thread.rs +++ b/src/test/debuginfo/thread.rs @@ -14,7 +14,7 @@ // // cdb-command:dx t,d // cdb-check:t,d : [...] [Type: std::thread::Thread *] -// cdb-check: [...] inner : {...} [Type: alloc::sync::Arc<std::thread::Inner>] +// cdb-check:[...] inner [...][Type: core::pin::Pin<alloc::sync::Arc<std::thread::Inner> >] use std::thread; diff --git a/src/test/run-make/issue-96498/Makefile b/src/test/run-make/issue-96498/Makefile new file mode 100644 index 00000000000..eae6400aee4 --- /dev/null +++ b/src/test/run-make/issue-96498/Makefile @@ -0,0 +1,8 @@ +# only-windows +# needs-rust-lld + +-include ../../run-make-fulldeps/tools.mk + +# Ensure that LLD can link +all: + $(RUSTC) -C linker=rust-lld foo.rs diff --git a/src/test/run-make/issue-96498/foo.rs b/src/test/run-make/issue-96498/foo.rs new file mode 100644 index 00000000000..93ac3641b09 --- /dev/null +++ b/src/test/run-make/issue-96498/foo.rs @@ -0,0 +1,4 @@ +#![crate_type = "cdylib"] + +#[no_mangle] +extern "C" fn foo() {} diff --git a/src/test/rustdoc/deref-slice-core.rs b/src/test/rustdoc/deref-slice-core.rs new file mode 100644 index 00000000000..cccf273a820 --- /dev/null +++ b/src/test/rustdoc/deref-slice-core.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/95325 +// +// Show methods reachable from Deref of primitive. +#![no_std] + +use core::ops::Deref; + +// @has 'deref_slice_core/struct.MyArray.html' +// @has '-' '//*[@id="deref-methods-%5BT%5D"]' 'Methods from Deref<Target = [T]>' +// @has '-' '//*[@class="impl-items"]//*[@id="method.len"]' 'pub fn len(&self)' + +pub struct MyArray<T> { + array: [T; 10], +} + +impl<T> Deref for MyArray<T> { + type Target = [T]; + + fn deref(&self) -> &Self::Target { + &self.array + } +} diff --git a/src/test/ui-fulldeps/session-derive-errors.rs b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index adec548b390..efbf78ac87d 100644 --- a/src/test/ui-fulldeps/session-derive-errors.rs +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -15,7 +15,7 @@ use rustc_span::symbol::Ident; use rustc_span::Span; extern crate rustc_macros; -use rustc_macros::SessionDiagnostic; +use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic}; extern crate rustc_middle; use rustc_middle::ty::Ty; @@ -44,67 +44,74 @@ enum SessionDiagnosticOnEnum { #[derive(SessionDiagnostic)] #[error(code = "E0123", slug = "foo")] #[error = "E0123"] -//~^ ERROR `#[error = ...]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error = ...]` is not a valid attribute struct WrongStructAttrStyle {} #[derive(SessionDiagnostic)] #[nonsense(code = "E0123", slug = "foo")] -//~^ ERROR `#[nonsense(...)]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[nonsense(...)]` is not a valid attribute //~^^ ERROR diagnostic kind not specified //~^^^ ERROR cannot find attribute `nonsense` in this scope struct InvalidStructAttr {} #[derive(SessionDiagnostic)] #[error("E0123")] -//~^ ERROR `#[error("...")]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error("...")]` is not a valid attribute //~^^ ERROR `slug` not specified struct InvalidLitNestedAttr {} #[derive(SessionDiagnostic)] #[error(nonsense, code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense)]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error(nonsense)]` is not a valid attribute struct InvalidNestedStructAttr {} #[derive(SessionDiagnostic)] #[error(nonsense("foo"), code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense(...))]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error(nonsense(...))]` is not a valid attribute struct InvalidNestedStructAttr1 {} #[derive(SessionDiagnostic)] #[error(nonsense = "...", code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense = ...)]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute struct InvalidNestedStructAttr2 {} #[derive(SessionDiagnostic)] #[error(nonsense = 4, code = "E0123", slug = "foo")] -//~^ ERROR `#[error(nonsense = ...)]` is not a valid `SessionDiagnostic` struct attribute +//~^ ERROR `#[error(nonsense = ...)]` is not a valid attribute struct InvalidNestedStructAttr3 {} #[derive(SessionDiagnostic)] #[error(code = "E0123", slug = "foo")] struct WrongPlaceField { #[suggestion = "bar"] - //~^ ERROR `#[suggestion = ...]` is not a valid `SessionDiagnostic` field attribute + //~^ ERROR `#[suggestion = ...]` is not a valid attribute sp: Span, } #[derive(SessionDiagnostic)] #[error(code = "E0123", slug = "foo")] -#[error(code = "E0456", slug = "bar")] //~ ERROR `error` specified multiple times +#[error(code = "E0456", slug = "bar")] +//~^ ERROR specified multiple times +//~^^ ERROR specified multiple times +//~^^^ ERROR specified multiple times struct ErrorSpecifiedTwice {} #[derive(SessionDiagnostic)] #[error(code = "E0123", slug = "foo")] #[warning(code = "E0293", slug = "bar")] -//~^ ERROR `warning` specified when `error` was already specified +//~^ ERROR specified multiple times +//~^^ ERROR specified multiple times +//~^^^ ERROR specified multiple times struct WarnSpecifiedAfterError {} #[derive(SessionDiagnostic)] -#[error(code = "E0456", code = "E0457", slug = "bar")] //~ ERROR `code` specified multiple times +#[error(code = "E0456", code = "E0457", slug = "bar")] +//~^ ERROR specified multiple times struct CodeSpecifiedTwice {} #[derive(SessionDiagnostic)] -#[error(code = "E0456", slug = "foo", slug = "bar")] //~ ERROR `slug` specified multiple times +#[error(code = "E0456", slug = "foo", slug = "bar")] +//~^ ERROR specified multiple times struct SlugSpecifiedTwice {} #[derive(SessionDiagnostic)] @@ -130,7 +137,7 @@ struct MessageWrongType { #[error(code = "E0123", slug = "foo")] struct InvalidPathFieldAttr { #[nonsense] - //~^ ERROR `#[nonsense]` is not a valid `SessionDiagnostic` field attribute + //~^ ERROR `#[nonsense]` is not a valid attribute //~^^ ERROR cannot find attribute `nonsense` in this scope foo: String, } @@ -215,7 +222,7 @@ struct SuggestWithoutCode { #[error(code = "E0123", slug = "foo")] struct SuggestWithBadKey { #[suggestion(nonsense = "bar")] - //~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid `SessionDiagnostic` field attribute + //~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute suggestion: (Span, Applicability), } @@ -223,7 +230,7 @@ struct SuggestWithBadKey { #[error(code = "E0123", slug = "foo")] struct SuggestWithShorthandMsg { #[suggestion(msg = "bar")] - //~^ ERROR `#[suggestion(msg = ...)]` is not a valid `SessionDiagnostic` field attribute + //~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute suggestion: (Span, Applicability), } @@ -276,7 +283,7 @@ struct SuggestWithDuplicateApplicabilityAndSpan { #[error(code = "E0123", slug = "foo")] struct WrongKindOfAnnotation { #[label("bar")] - //~^ ERROR `#[label(...)]` is not a valid `SessionDiagnostic` field attribute + //~^ ERROR `#[label(...)]` is not a valid attribute z: Span, } @@ -426,3 +433,44 @@ struct ErrorWithNoteWrongOrder { struct ErrorWithNoteCustomWrongOrder { val: String, } + +#[derive(SessionDiagnostic)] +#[error(code = "E0123", slug = "foo")] +struct ApplicabilityInBoth { + #[suggestion(message = "bar", code = "...", applicability = "maybe-incorrect")] + //~^ ERROR applicability cannot be set in both the field and attribute + suggestion: (Span, Applicability), +} + +#[derive(SessionDiagnostic)] +#[error(code = "E0123", slug = "foo")] +struct InvalidApplicability { + #[suggestion(message = "bar", code = "...", applicability = "batman")] + //~^ ERROR invalid applicability + suggestion: Span, +} + +#[derive(SessionDiagnostic)] +#[error(code = "E0123", slug = "foo")] +struct ValidApplicability { + #[suggestion(message = "bar", code = "...", applicability = "maybe-incorrect")] + suggestion: Span, +} + +#[derive(SessionDiagnostic)] +#[error(code = "E0123", slug = "foo")] +struct NoApplicability { + #[suggestion(message = "bar", code = "...")] + suggestion: Span, +} + +#[derive(SessionSubdiagnostic)] +#[note(slug = "note")] +struct Note; + +#[derive(SessionDiagnostic)] +#[error(slug = "subdiagnostic")] +struct Subdiagnostic { + #[subdiagnostic] + note: Note, +} diff --git a/src/test/ui-fulldeps/session-derive-errors.stderr b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index a528ae1607f..b1738b60bc0 100644 --- a/src/test/ui-fulldeps/session-derive-errors.stderr +++ b/src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -1,5 +1,5 @@ error: `#[derive(SessionDiagnostic)]` can only be used on structs - --> $DIR/session-derive-errors.rs:37:1 + --> $DIR/diagnostic-derive.rs:37:1 | LL | / #[error(code = "E0123", slug = "foo")] LL | | @@ -9,20 +9,22 @@ LL | | Bar, LL | | } | |_^ -error: `#[error = ...]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:46:1 +error: `#[error = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:46:1 | LL | #[error = "E0123"] | ^^^^^^^^^^^^^^^^^^ -error: `#[nonsense(...)]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:51:1 +error: `#[nonsense(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:51:1 | LL | #[nonsense(code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only `error` and `warning` are valid attributes error: diagnostic kind not specified - --> $DIR/session-derive-errors.rs:51:1 + --> $DIR/diagnostic-derive.rs:51:1 | LL | / #[nonsense(code = "E0123", slug = "foo")] LL | | @@ -33,14 +35,14 @@ LL | | struct InvalidStructAttr {} | = help: use the `#[error(...)]` attribute to create an error -error: `#[error("...")]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:58:9 +error: `#[error("...")]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:58:9 | LL | #[error("E0123")] | ^^^^^^^ error: `slug` not specified - --> $DIR/session-derive-errors.rs:58:1 + --> $DIR/diagnostic-derive.rs:58:1 | LL | / #[error("E0123")] LL | | @@ -50,88 +52,138 @@ LL | | struct InvalidLitNestedAttr {} | = help: use the `#[error(slug = "...")]` attribute to set this diagnostic's slug -error: `#[error(nonsense)]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:64:9 +error: `#[error(nonsense)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:64:9 | LL | #[error(nonsense, code = "E0123", slug = "foo")] | ^^^^^^^^ -error: `#[error(nonsense(...))]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:69:9 +error: `#[error(nonsense(...))]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:69:9 | LL | #[error(nonsense("foo"), code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^ -error: `#[error(nonsense = ...)]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:74:9 +error: `#[error(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:74:9 | LL | #[error(nonsense = "...", code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^^ + | + = help: only `slug` and `code` are valid nested attributes -error: `#[error(nonsense = ...)]` is not a valid `SessionDiagnostic` struct attribute - --> $DIR/session-derive-errors.rs:79:9 +error: `#[error(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:79:9 | LL | #[error(nonsense = 4, code = "E0123", slug = "foo")] | ^^^^^^^^^^^^ - | - = help: value must be a string -error: `#[suggestion = ...]` is not a valid `SessionDiagnostic` field attribute - --> $DIR/session-derive-errors.rs:86:5 +error: `#[suggestion = ...]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:86:5 | LL | #[suggestion = "bar"] | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: only `label`, `note` and `help` are valid field attributes -error: `error` specified multiple times - --> $DIR/session-derive-errors.rs:93:1 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:93:1 | LL | #[error(code = "E0456", slug = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/session-derive-errors.rs:92:1 + --> $DIR/diagnostic-derive.rs:92:1 | LL | #[error(code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `warning` specified when `error` was already specified - --> $DIR/session-derive-errors.rs:98:1 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:93:16 + | +LL | #[error(code = "E0456", slug = "bar")] + | ^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:92:16 + | +LL | #[error(code = "E0123", slug = "foo")] + | ^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:93:32 + | +LL | #[error(code = "E0456", slug = "bar")] + | ^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:92:32 + | +LL | #[error(code = "E0123", slug = "foo")] + | ^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:101:1 | LL | #[warning(code = "E0293", slug = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: previously specified here - --> $DIR/session-derive-errors.rs:97:1 + --> $DIR/diagnostic-derive.rs:100:1 | LL | #[error(code = "E0123", slug = "foo")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `code` specified multiple times - --> $DIR/session-derive-errors.rs:103:32 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:101:18 + | +LL | #[warning(code = "E0293", slug = "bar")] + | ^^^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:100:16 + | +LL | #[error(code = "E0123", slug = "foo")] + | ^^^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:101:34 + | +LL | #[warning(code = "E0293", slug = "bar")] + | ^^^^^ + | +note: previously specified here + --> $DIR/diagnostic-derive.rs:100:32 + | +LL | #[error(code = "E0123", slug = "foo")] + | ^^^^^ + +error: specified multiple times + --> $DIR/diagnostic-derive.rs:108:32 | LL | #[error(code = "E0456", code = "E0457", slug = "bar")] | ^^^^^^^ | note: previously specified here - --> $DIR/session-derive-errors.rs:103:16 + --> $DIR/diagnostic-derive.rs:108:16 | LL | #[error(code = "E0456", code = "E0457", slug = "bar")] | ^^^^^^^ -error: `slug` specified multiple times - --> $DIR/session-derive-errors.rs:107:46 +error: specified multiple times + --> $DIR/diagnostic-derive.rs:113:46 | LL | #[error(code = "E0456", slug = "foo", slug = "bar")] | ^^^^^ | note: previously specified here - --> $DIR/session-derive-errors.rs:107:32 + --> $DIR/diagnostic-derive.rs:113:32 | LL | #[error(code = "E0456", slug = "foo", slug = "bar")] | ^^^^^ error: diagnostic kind not specified - --> $DIR/session-derive-errors.rs:111:1 + --> $DIR/diagnostic-derive.rs:118:1 | LL | struct KindNotProvided {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +191,7 @@ LL | struct KindNotProvided {} = help: use the `#[error(...)]` attribute to create an error error: `slug` not specified - --> $DIR/session-derive-errors.rs:114:1 + --> $DIR/diagnostic-derive.rs:121:1 | LL | / #[error(code = "E0456")] LL | | struct SlugNotProvided {} @@ -148,31 +200,33 @@ LL | | struct SlugNotProvided {} = help: use the `#[error(slug = "...")]` attribute to set this diagnostic's slug error: the `#[primary_span]` attribute can only be applied to fields of type `Span` - --> $DIR/session-derive-errors.rs:124:5 + --> $DIR/diagnostic-derive.rs:131:5 | LL | #[primary_span] | ^^^^^^^^^^^^^^^ -error: `#[nonsense]` is not a valid `SessionDiagnostic` field attribute - --> $DIR/session-derive-errors.rs:132:5 +error: `#[nonsense]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:139:5 | LL | #[nonsense] | ^^^^^^^^^^^ + | + = help: only `skip_arg`, `primary_span`, `label`, `note`, `help` and `subdiagnostic` are valid field attributes error: the `#[label = ...]` attribute can only be applied to fields of type `Span` - --> $DIR/session-derive-errors.rs:149:5 + --> $DIR/diagnostic-derive.rs:156:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ error: `name` doesn't refer to a field on this type - --> $DIR/session-derive-errors.rs:157:42 + --> $DIR/diagnostic-derive.rs:164:42 | LL | #[suggestion(message = "bar", code = "{name}")] | ^^^^^^^^ error: invalid format string: expected `'}'` but string was terminated - --> $DIR/session-derive-errors.rs:162:16 + --> $DIR/diagnostic-derive.rs:169:16 | LL | #[derive(SessionDiagnostic)] | - ^ expected `'}'` in format string @@ -183,7 +237,7 @@ LL | #[derive(SessionDiagnostic)] = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid format string: unmatched `}` found - --> $DIR/session-derive-errors.rs:172:15 + --> $DIR/diagnostic-derive.rs:179:15 | LL | #[derive(SessionDiagnostic)] | ^ unmatched `}` in format string @@ -192,25 +246,29 @@ LL | #[derive(SessionDiagnostic)] = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `#[label = ...]` attribute can only be applied to fields of type `Span` - --> $DIR/session-derive-errors.rs:192:5 + --> $DIR/diagnostic-derive.rs:199:5 | LL | #[label = "bar"] | ^^^^^^^^^^^^^^^^ -error: `#[suggestion(nonsense = ...)]` is not a valid `SessionDiagnostic` field attribute - --> $DIR/session-derive-errors.rs:217:18 +error: `#[suggestion(nonsense = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:224:18 | LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^^^^^^^^^ + | + = help: only `message`, `code` and `applicability` are valid field attributes -error: `#[suggestion(msg = ...)]` is not a valid `SessionDiagnostic` field attribute - --> $DIR/session-derive-errors.rs:225:18 +error: `#[suggestion(msg = ...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:232:18 | LL | #[suggestion(msg = "bar")] | ^^^^^^^^^^^ + | + = help: only `message`, `code` and `applicability` are valid field attributes error: wrong field type for suggestion - --> $DIR/session-derive-errors.rs:247:5 + --> $DIR/diagnostic-derive.rs:254:5 | LL | / #[suggestion(message = "bar", code = "This is suggested code")] LL | | @@ -220,7 +278,7 @@ LL | | suggestion: Applicability, = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` error: type of field annotated with `#[suggestion(...)]` contains more than one `Span` - --> $DIR/session-derive-errors.rs:262:5 + --> $DIR/diagnostic-derive.rs:269:5 | LL | / #[suggestion(message = "bar", code = "This is suggested code")] LL | | @@ -228,57 +286,71 @@ LL | | suggestion: (Span, Span, Applicability), | |___________________________________________^ error: type of field annotated with `#[suggestion(...)]` contains more than one Applicability - --> $DIR/session-derive-errors.rs:270:5 + --> $DIR/diagnostic-derive.rs:277:5 | LL | / #[suggestion(message = "bar", code = "This is suggested code")] LL | | LL | | suggestion: (Applicability, Applicability, Span), | |____________________________________________________^ -error: `#[label(...)]` is not a valid `SessionDiagnostic` field attribute - --> $DIR/session-derive-errors.rs:278:5 +error: `#[label(...)]` is not a valid attribute + --> $DIR/diagnostic-derive.rs:285:5 | LL | #[label("bar")] | ^^^^^^^^^^^^^^^ + | + = help: only `suggestion{,_short,_hidden,_verbose}` are valid field attributes error: `#[help]` must come after `#[error(..)]` or `#[warn(..)]` - --> $DIR/session-derive-errors.rs:399:1 + --> $DIR/diagnostic-derive.rs:406:1 | LL | #[help] | ^^^^^^^ error: `#[help = ...]` must come after `#[error(..)]` or `#[warn(..)]` - --> $DIR/session-derive-errors.rs:407:1 + --> $DIR/diagnostic-derive.rs:414:1 | LL | #[help = "bar"] | ^^^^^^^^^^^^^^^ error: `#[note]` must come after `#[error(..)]` or `#[warn(..)]` - --> $DIR/session-derive-errors.rs:415:1 + --> $DIR/diagnostic-derive.rs:422:1 | LL | #[note] | ^^^^^^^ error: `#[note = ...]` must come after `#[error(..)]` or `#[warn(..)]` - --> $DIR/session-derive-errors.rs:423:1 + --> $DIR/diagnostic-derive.rs:430:1 | LL | #[note = "bar"] | ^^^^^^^^^^^^^^^ +error: applicability cannot be set in both the field and attribute + --> $DIR/diagnostic-derive.rs:440:49 + | +LL | #[suggestion(message = "bar", code = "...", applicability = "maybe-incorrect")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: invalid applicability + --> $DIR/diagnostic-derive.rs:448:49 + | +LL | #[suggestion(message = "bar", code = "...", applicability = "batman")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error: cannot find attribute `nonsense` in this scope - --> $DIR/session-derive-errors.rs:51:3 + --> $DIR/diagnostic-derive.rs:51:3 | LL | #[nonsense(code = "E0123", slug = "foo")] | ^^^^^^^^ error: cannot find attribute `nonsense` in this scope - --> $DIR/session-derive-errors.rs:132:7 + --> $DIR/diagnostic-derive.rs:139:7 | LL | #[nonsense] | ^^^^^^^^ error[E0599]: no method named `into_diagnostic_arg` found for struct `Hello` in the current scope - --> $DIR/session-derive-errors.rs:322:10 + --> $DIR/diagnostic-derive.rs:329:10 | LL | struct Hello {} | ------------ method `into_diagnostic_arg` not found for this @@ -288,6 +360,6 @@ LL | #[derive(SessionDiagnostic)] | = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 37 previous errors +error: aborting due to 43 previous errors For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs new file mode 100644 index 00000000000..bb406c35c0e --- /dev/null +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -0,0 +1,501 @@ +// check-fail +// Tests error conditions for specifying subdiagnostics using #[derive(SessionSubdiagnostic)] + +// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, +// changing the output of this test. Since SessionSubdiagnostic is strictly internal to the compiler +// the test is just ignored on stable and beta: +// ignore-beta +// ignore-stable + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_errors; +extern crate rustc_session; +extern crate rustc_span; +extern crate rustc_macros; + +use rustc_errors::Applicability; +use rustc_span::Span; +use rustc_macros::SessionSubdiagnostic; + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-a")] +struct A { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +enum B { + #[label(slug = "label-b-a")] + A { + #[primary_span] + span: Span, + var: String, + }, + #[label(slug = "label-b-b")] + B { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-c")] +//~^ ERROR label without `#[primary_span]` field +struct C { + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label] +//~^ ERROR `#[label]` is not a valid attribute +struct D { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[foo] +//~^ ERROR `#[foo]` is not a valid attribute +//~^^ ERROR cannot find attribute `foo` in this scope +struct E { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label = "..."] +//~^ ERROR `#[label = ...]` is not a valid attribute +struct F { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(bug = "...")] +//~^ ERROR `#[label(bug = ...)]` is not a valid attribute +struct G { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label("...")] +//~^ ERROR `#[label("...")]` is not a valid attribute +struct H { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = 4)] +//~^ ERROR `#[label(slug = ...)]` is not a valid attribute +struct J { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug("..."))] +//~^ ERROR `#[label(slug(...))]` is not a valid attribute +struct K { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug)] +//~^ ERROR `#[label(slug)]` is not a valid attribute +struct L { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label()] +//~^ ERROR `slug` must be set in a `#[label(...)]` attribute +struct M { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(code = "...")] +//~^ ERROR `code` is not a valid nested attribute of a `label` attribute +struct N { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[foo] +//~^ ERROR cannot find attribute `foo` in this scope +//~^^ ERROR unsupported type attribute for subdiagnostic enum +enum O { + #[label(slug = "...")] + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum P { + #[bar] +//~^ ERROR `#[bar]` is not a valid attribute +//~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum Q { + #[bar = "..."] +//~^ ERROR `#[bar = ...]` is not a valid attribute +//~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum R { + #[bar = 4] +//~^ ERROR `#[bar = ...]` is not a valid attribute +//~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum S { + #[bar("...")] +//~^ ERROR `#[bar("...")]` is not a valid attribute +//~^^ ERROR cannot find attribute `bar` in this scope + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum T { + #[label(code = "...")] +//~^ ERROR `code` is not a valid nested attribute of a `label` + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum U { + #[label(slug = "label-u")] + A { + #[primary_span] + span: Span, + var: String, + }, + B { +//~^ ERROR subdiagnostic kind not specified + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "...")] +//~^ ERROR label without `#[primary_span]` field +struct V { + #[primary_span] + //~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span` + span: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "...")] +struct W { + #[primary_span] + span: Span, + #[applicability] + //~^ ERROR `#[applicability]` is only valid on suggestions + applicability: Applicability, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "...")] +struct X { + #[primary_span] + span: Span, + #[bar] + //~^ ERROR `#[bar]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "...")] +struct Y { + #[primary_span] + span: Span, + #[bar = "..."] + //~^ ERROR `#[bar = ...]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "...")] +struct Z { + #[primary_span] + span: Span, + #[bar("...")] + //~^ ERROR `#[bar(...)]` is not a valid attribute + //~^^ ERROR cannot find attribute `bar` in this scope + bar: String, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-aa")] +struct AA { + #[primary_span] + span: Span, + #[skip_arg] + z: Z +} + +#[derive(SessionSubdiagnostic)] +union AB { +//~^ ERROR unexpected unsupported untagged union + span: u32, + b: u64 +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-ac-1")] +//~^ NOTE previously specified here +//~^^ NOTE previously specified here +#[label(slug = "label-ac-2")] +//~^ ERROR specified multiple times +//~^^ ERROR specified multiple times +struct AC { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-ad-1", slug = "label-ad-2")] +//~^ ERROR specified multiple times +//~^^ NOTE previously specified here +struct AD { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[label(slug = "label-ad-1")] +struct AE { + #[primary_span] +//~^ NOTE previously specified here + span_a: Span, + #[primary_span] +//~^ ERROR specified multiple times + span_b: Span, +} + +#[derive(SessionSubdiagnostic)] +struct AF { +//~^ ERROR subdiagnostic kind not specified + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "suggestion-af", code = "...")] +struct AG { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, +} + +#[derive(SessionSubdiagnostic)] +enum AH { + #[suggestion(slug = "suggestion-ag-a", code = "...")] + A { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, + }, + #[suggestion(slug = "suggestion-ag-b", code = "...")] + B { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code = "...", code = "...")] +//~^ ERROR specified multiple times +//~^^ NOTE previously specified here +struct AI { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code = "...")] +struct AJ { + #[primary_span] + span: Span, + #[applicability] +//~^ NOTE previously specified here + applicability_a: Applicability, + #[applicability] +//~^ ERROR specified multiple times + applicability_b: Applicability, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code = "...")] +//~^ ERROR suggestion without `applicability` +struct AK { + #[primary_span] + span: Span, + #[applicability] +//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability` + applicability: Span, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code = "...")] +//~^ ERROR suggestion without `applicability` +struct AL { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...")] +//~^ ERROR suggestion without `code = "..."` +struct AM { + #[primary_span] + span: Span, + #[applicability] + applicability: Applicability, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code ="...", applicability = "foo")] +//~^ ERROR invalid applicability +struct AN { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[help(slug = "label-am")] +struct AO { + var: String +} + +#[derive(SessionSubdiagnostic)] +#[note(slug = "label-an")] +struct AP; + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code = "...")] +//~^ ERROR suggestion without `applicability` +//~^^ ERROR suggestion without `#[primary_span]` field +struct AQ { + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code ="...", applicability = "machine-applicable")] +struct AR { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +#[label] +//~^ ERROR unsupported type attribute for subdiagnostic enum +enum AS { + #[label(slug = "...")] + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] +struct AT { + #[primary_span] + span: Span, + var: String, +} + +#[derive(SessionSubdiagnostic)] +#[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] +//~^ ERROR `var` doesn't refer to a field on this type +struct AU { + #[primary_span] + span: Span, +} + +#[derive(SessionSubdiagnostic)] +enum AV { + #[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] + A { + #[primary_span] + span: Span, + var: String, + } +} + +#[derive(SessionSubdiagnostic)] +enum AW { + #[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] +//~^ ERROR `var` doesn't refer to a field on this type + A { + #[primary_span] + span: Span, + } +} diff --git a/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr new file mode 100644 index 00000000000..4984cc4b318 --- /dev/null +++ b/src/test/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -0,0 +1,389 @@ +error: label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:47:1 + | +LL | / #[label(slug = "label-c")] +LL | | +LL | | struct C { +LL | | var: String, +LL | | } + | |_^ + +error: `#[label]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:54:1 + | +LL | #[label] + | ^^^^^^^^ + +error: `#[foo]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:63:1 + | +LL | #[foo] + | ^^^^^^ + +error: `#[label = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:73:1 + | +LL | #[label = "..."] + | ^^^^^^^^^^^^^^^^ + +error: `#[label(bug = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:82:9 + | +LL | #[label(bug = "...")] + | ^^^^^^^^^^^ + | + = help: only `code`, `slug` and `applicability` are valid nested attributes + +error: `#[label("...")]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:91:9 + | +LL | #[label("...")] + | ^^^^^ + +error: `#[label(slug = ...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:100:9 + | +LL | #[label(slug = 4)] + | ^^^^^^^^ + +error: `#[label(slug(...))]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:109:9 + | +LL | #[label(slug("..."))] + | ^^^^^^^^^^^ + +error: `#[label(slug)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:118:9 + | +LL | #[label(slug)] + | ^^^^ + +error: `slug` must be set in a `#[label(...)]` attribute + --> $DIR/subdiagnostic-derive.rs:127:1 + | +LL | #[label()] + | ^^^^^^^^^^ + +error: `code` is not a valid nested attribute of a `label` attribute + --> $DIR/subdiagnostic-derive.rs:136:1 + | +LL | #[label(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:145:1 + | +LL | #[foo] + | ^^^^^^ + +error: `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:159:5 + | +LL | #[bar] + | ^^^^^^ + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:171:5 + | +LL | #[bar = "..."] + | ^^^^^^^^^^^^^^ + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:183:5 + | +LL | #[bar = 4] + | ^^^^^^^^^^ + +error: `#[bar("...")]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:195:11 + | +LL | #[bar("...")] + | ^^^^^ + +error: `code` is not a valid nested attribute of a `label` attribute + --> $DIR/subdiagnostic-derive.rs:207:5 + | +LL | #[label(code = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: subdiagnostic kind not specified + --> $DIR/subdiagnostic-derive.rs:224:5 + | +LL | B { + | ^ + +error: the `#[primary_span]` attribute can only be applied to fields of type `Span` + --> $DIR/subdiagnostic-derive.rs:236:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + +error: label without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:233:1 + | +LL | / #[label(slug = "...")] +LL | | +LL | | struct V { +LL | | #[primary_span] +LL | | +LL | | span: String, +LL | | } + | |_^ + +error: `#[applicability]` is only valid on suggestions + --> $DIR/subdiagnostic-derive.rs:246:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: `#[bar]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:256:5 + | +LL | #[bar] + | ^^^^^^ + | + = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes + +error: `#[bar = ...]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:267:5 + | +LL | #[bar = "..."] + | ^^^^^^^^^^^^^^ + +error: `#[bar(...)]` is not a valid attribute + --> $DIR/subdiagnostic-derive.rs:278:5 + | +LL | #[bar("...")] + | ^^^^^^^^^^^^^ + +error: unexpected unsupported untagged union + --> $DIR/subdiagnostic-derive.rs:294:1 + | +LL | / union AB { +LL | | +LL | | span: u32, +LL | | b: u64 +LL | | } + | |_^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:304:9 + | +LL | #[label(slug = "label-ac-2")] + | ^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:301:9 + | +LL | #[label(slug = "label-ac-1")] + | ^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:304:1 + | +LL | #[label(slug = "label-ac-2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:301:1 + | +LL | #[label(slug = "label-ac-1")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:313:30 + | +LL | #[label(slug = "label-ad-1", slug = "label-ad-2")] + | ^^^^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:313:9 + | +LL | #[label(slug = "label-ad-1", slug = "label-ad-2")] + | ^^^^^^^^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:327:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:324:5 + | +LL | #[primary_span] + | ^^^^^^^^^^^^^^^ + +error: subdiagnostic kind not specified + --> $DIR/subdiagnostic-derive.rs:333:8 + | +LL | struct AF { + | ^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:370:42 + | +LL | #[suggestion(slug = "...", code = "...", code = "...")] + | ^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:370:28 + | +LL | #[suggestion(slug = "...", code = "...", code = "...")] + | ^^^^^^^^^^^^ + +error: specified multiple times + --> $DIR/subdiagnostic-derive.rs:388:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + | +note: previously specified here + --> $DIR/subdiagnostic-derive.rs:385:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` + --> $DIR/subdiagnostic-derive.rs:399:5 + | +LL | #[applicability] + | ^^^^^^^^^^^^^^^^ + +error: suggestion without `applicability` + --> $DIR/subdiagnostic-derive.rs:394:1 + | +LL | / #[suggestion(slug = "...", code = "...")] +LL | | +LL | | struct AK { +LL | | #[primary_span] +... | +LL | | applicability: Span, +LL | | } + | |_^ + +error: suggestion without `applicability` + --> $DIR/subdiagnostic-derive.rs:405:1 + | +LL | / #[suggestion(slug = "...", code = "...")] +LL | | +LL | | struct AL { +LL | | #[primary_span] +LL | | span: Span, +LL | | } + | |_^ + +error: suggestion without `code = "..."` + --> $DIR/subdiagnostic-derive.rs:413:1 + | +LL | / #[suggestion(slug = "...")] +LL | | +LL | | struct AM { +LL | | #[primary_span] +... | +LL | | applicability: Applicability, +LL | | } + | |_^ + +error: invalid applicability + --> $DIR/subdiagnostic-derive.rs:423:41 + | +LL | #[suggestion(slug = "...", code ="...", applicability = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: suggestion without `applicability` + --> $DIR/subdiagnostic-derive.rs:441:1 + | +LL | / #[suggestion(slug = "...", code = "...")] +LL | | +LL | | +LL | | struct AQ { +LL | | var: String, +LL | | } + | |_^ + +error: suggestion without `#[primary_span]` field + --> $DIR/subdiagnostic-derive.rs:441:1 + | +LL | / #[suggestion(slug = "...", code = "...")] +LL | | +LL | | +LL | | struct AQ { +LL | | var: String, +LL | | } + | |_^ + +error: unsupported type attribute for subdiagnostic enum + --> $DIR/subdiagnostic-derive.rs:456:1 + | +LL | #[label] + | ^^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:476:34 + | +LL | #[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: `var` doesn't refer to a field on this type + --> $DIR/subdiagnostic-derive.rs:495:38 + | +LL | #[suggestion(slug = "...", code ="{var}", applicability = "machine-applicable")] + | ^^^^^^^ + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:63:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `foo` in this scope + --> $DIR/subdiagnostic-derive.rs:145:3 + | +LL | #[foo] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:159:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:171:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:183:7 + | +LL | #[bar = 4] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:195:7 + | +LL | #[bar("...")] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:256:7 + | +LL | #[bar] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:267:7 + | +LL | #[bar = "..."] + | ^^^ + +error: cannot find attribute `bar` in this scope + --> $DIR/subdiagnostic-derive.rs:278:7 + | +LL | #[bar("...")] + | ^^^ + +error: aborting due to 51 previous errors + diff --git a/src/test/ui/array-slice-vec/repeat_empty_ok.stderr b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr index eba1a8e2278..724bdcd920a 100644 --- a/src/test/ui/array-slice-vec/repeat_empty_ok.stderr +++ b/src/test/ui/array-slice-vec/repeat_empty_ok.stderr @@ -1,22 +1,22 @@ error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied - --> $DIR/repeat_empty_ok.rs:8:19 + --> $DIR/repeat_empty_ok.rs:8:20 | LL | let headers = [Header{value: &[]}; 128]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Header<'_>` with `#[derive(Copy)]` | LL | #[derive(Copy)] | error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied - --> $DIR/repeat_empty_ok.rs:13:19 + --> $DIR/repeat_empty_ok.rs:13:20 | LL | let headers = [Header{value: &[0]}; 128]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` + | ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Header<'_>` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Header<'_>` with `#[derive(Copy)]` | LL | #[derive(Copy)] diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs b/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs index ef0443034ec..1de1ddbe3a4 100644 --- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs +++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs @@ -24,7 +24,6 @@ fn bar() -> impl Bar { fn baz() -> impl Bar<Item = i32> { //~^ ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32` - //~| ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32` bar() } diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr index b7c49570ca4..bd8c8a4414c 100644 --- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr +++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr @@ -16,29 +16,6 @@ help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i3 LL | fn bar() -> impl Bar<Item = i32> { | ++++++++++++ -error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32` - --> $DIR/impl-trait-return-missing-constraint.rs:25:34 - | -LL | fn bar() -> impl Bar { - | -------- the expected opaque type -... -LL | fn baz() -> impl Bar<Item = i32> { - | __________________________________^ -LL | | -LL | | -LL | | bar() -LL | | } - | |_^ expected associated type, found `i32` - | - = note: expected associated type `<impl Bar as Foo>::Item` - found type `i32` - = help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` or calling a method that returns `<impl Bar as Foo>::Item` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html -help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` - | -LL | fn bar() -> impl Bar<Item = i32> { - | ++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/async-await/issue-86507.stderr b/src/test/ui/async-await/issue-86507.stderr index ad0a3592241..5bbc20359c6 100644 --- a/src/test/ui/async-await/issue-86507.stderr +++ b/src/test/ui/async-await/issue-86507.stderr @@ -14,10 +14,10 @@ note: captured value is not `Send` because `&` references cannot be sent unless LL | let x = x; | ^ has type `&T` which is not `Send`, because `T` is not `Sync` = note: required for the cast to the object type `dyn Future<Output = ()> + Send` -help: consider further restricting type parameter `T` +help: consider further restricting this bound | -LL | where 'me:'async_trait, T: std::marker::Sync { - | ++++++++++++++++++++++ +LL | fn bar<'me, 'async_trait, T: Send + std::marker::Sync>(x: &'me T) + | +++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr index 2dac4a22ae7..b1e59e9d5de 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr +++ b/src/test/ui/builtin-superkinds/builtin-superkinds-self-type.stderr @@ -2,9 +2,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/builtin-superkinds-self-type.rs:10:16 | LL | impl <T: Sync> Foo for T { } - | -- ^^^ ...so that the type `T` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `T: 'static +` + | ^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | impl <T: Sync + 'static> Foo for T { } + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/conservative_impl_trait.rs b/src/test/ui/conservative_impl_trait.rs index b8488d83998..b7f795eadb7 100644 --- a/src/test/ui/conservative_impl_trait.rs +++ b/src/test/ui/conservative_impl_trait.rs @@ -2,7 +2,6 @@ fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { //~^ ERROR `()` is not an iterator - //~| ERROR `()` is not an iterator } fn main() {} diff --git a/src/test/ui/conservative_impl_trait.stderr b/src/test/ui/conservative_impl_trait.stderr index 2348f2f5297..63a4df242f8 100644 --- a/src/test/ui/conservative_impl_trait.stderr +++ b/src/test/ui/conservative_impl_trait.stderr @@ -6,18 +6,6 @@ LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { | = help: the trait `Iterator` is not implemented for `()` -error[E0277]: `()` is not an iterator - --> $DIR/conservative_impl_trait.rs:3:60 - | -LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { - | ____________________________________________________________^ -LL | | -LL | | -LL | | } - | |_^ `()` is not an iterator - | - = help: the trait `Iterator` is not implemented for `()` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr index ac693426fbd..88d9ed46e1a 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -16,53 +16,8 @@ LL | let _: [u8; bar::<N>()]; = help: const parameters may only be used as standalone arguments, i.e. `N` = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions -error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:24:23 - | -LL | let _ = [0; bar::<N>()]; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments, i.e. `N` - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:29:24 - | -LL | let _: Foo<{ foo::<T>() }>; - | ^ cannot perform const operation using `T` - | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:30:24 - | -LL | let _: Foo<{ bar::<N>() }>; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments, i.e. `N` - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:35:27 - | -LL | let _ = Foo::<{ foo::<T>() }>; - | ^ cannot perform const operation using `T` - | - = note: type parameters may not be used in const expressions - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions - -error: generic parameters may not be used in const operations - --> $DIR/const-arg-in-const-arg.rs:36:27 - | -LL | let _ = Foo::<{ bar::<N>() }>; - | ^ cannot perform const operation using `N` - | - = help: const parameters may only be used as standalone arguments, i.e. `N` - = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions - error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:15:23 + --> $DIR/const-arg-in-const-arg.rs:16:23 | LL | let _: [u8; faz::<'a>(&())]; | ^^ @@ -71,7 +26,7 @@ LL | let _: [u8; faz::<'a>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:16:23 + --> $DIR/const-arg-in-const-arg.rs:18:23 | LL | let _: [u8; baz::<'a>(&())]; | ^^ @@ -80,7 +35,7 @@ LL | let _: [u8; baz::<'a>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:17:23 + --> $DIR/const-arg-in-const-arg.rs:19:23 | LL | let _: [u8; faz::<'b>(&())]; | ^^ @@ -89,7 +44,7 @@ LL | let _: [u8; faz::<'b>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:18:23 + --> $DIR/const-arg-in-const-arg.rs:21:23 | LL | let _: [u8; baz::<'b>(&())]; | ^^ @@ -97,8 +52,17 @@ LL | let _: [u8; baz::<'b>(&())]; = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:24:23 + | +LL | let _ = [0; bar::<N>()]; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:25:23 + --> $DIR/const-arg-in-const-arg.rs:26:23 | LL | let _ = [0; faz::<'a>(&())]; | ^^ @@ -107,7 +71,7 @@ LL | let _ = [0; faz::<'a>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:26:23 + --> $DIR/const-arg-in-const-arg.rs:28:23 | LL | let _ = [0; baz::<'a>(&())]; | ^^ @@ -116,7 +80,7 @@ LL | let _ = [0; baz::<'a>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:27:23 + --> $DIR/const-arg-in-const-arg.rs:29:23 | LL | let _ = [0; faz::<'b>(&())]; | ^^ @@ -125,7 +89,7 @@ LL | let _ = [0; faz::<'b>(&())]; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:28:23 + --> $DIR/const-arg-in-const-arg.rs:31:23 | LL | let _ = [0; baz::<'b>(&())]; | ^^ @@ -133,8 +97,26 @@ LL | let _ = [0; baz::<'b>(&())]; = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:32:24 + | +LL | let _: Foo<{ foo::<T>() }>; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:33:24 + | +LL | let _: Foo<{ bar::<N>() }>; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:31:24 + --> $DIR/const-arg-in-const-arg.rs:35:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; | ^^ @@ -143,7 +125,7 @@ LL | let _: Foo<{ faz::<'a>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:32:24 + --> $DIR/const-arg-in-const-arg.rs:37:24 | LL | let _: Foo<{ baz::<'a>(&()) }>; | ^^ @@ -152,7 +134,7 @@ LL | let _: Foo<{ baz::<'a>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:33:24 + --> $DIR/const-arg-in-const-arg.rs:38:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; | ^^ @@ -161,7 +143,7 @@ LL | let _: Foo<{ faz::<'b>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:34:24 + --> $DIR/const-arg-in-const-arg.rs:40:24 | LL | let _: Foo<{ baz::<'b>(&()) }>; | ^^ @@ -169,8 +151,26 @@ LL | let _: Foo<{ baz::<'b>(&()) }>; = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:41:27 + | +LL | let _ = Foo::<{ foo::<T>() }>; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:42:27 + | +LL | let _ = Foo::<{ bar::<N>() }>; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:37:27 + --> $DIR/const-arg-in-const-arg.rs:44:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; | ^^ @@ -179,7 +179,7 @@ LL | let _ = Foo::<{ faz::<'a>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:38:27 + --> $DIR/const-arg-in-const-arg.rs:46:27 | LL | let _ = Foo::<{ baz::<'a>(&()) }>; | ^^ @@ -188,7 +188,7 @@ LL | let _ = Foo::<{ baz::<'a>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:39:27 + --> $DIR/const-arg-in-const-arg.rs:47:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; | ^^ @@ -197,7 +197,7 @@ LL | let _ = Foo::<{ faz::<'b>(&()) }>; = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable error[E0658]: a non-static lifetime is not allowed in a `const` - --> $DIR/const-arg-in-const-arg.rs:40:27 + --> $DIR/const-arg-in-const-arg.rs:49:27 | LL | let _ = Foo::<{ baz::<'b>(&()) }>; | ^^ @@ -205,6 +205,155 @@ LL | let _ = Foo::<{ baz::<'b>(&()) }>; = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable -error: aborting due to 23 previous errors +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/const-arg-in-const-arg.rs:14:23 + | +LL | let _: [u8; bar::<N>()]; + | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _: [u8; bar::<{ N }>()]; + | + + + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:16:23 + | +LL | let _: [u8; faz::<'a>(&())]; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:19:23 + | +LL | let _: [u8; faz::<'b>(&())]; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/const-arg-in-const-arg.rs:24:23 + | +LL | let _ = [0; bar::<N>()]; + | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _ = [0; bar::<{ N }>()]; + | + + + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:26:23 + | +LL | let _ = [0; faz::<'a>(&())]; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:29:23 + | +LL | let _ = [0; faz::<'b>(&())]; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/const-arg-in-const-arg.rs:33:24 + | +LL | let _: Foo<{ bar::<N>() }>; + | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _: Foo<{ bar::<{ N }>() }>; + | + + + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:35:24 + | +LL | let _: Foo<{ faz::<'a>(&()) }>; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:38:24 + | +LL | let _: Foo<{ faz::<'b>(&()) }>; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: constant expression depends on a generic parameter + --> $DIR/const-arg-in-const-arg.rs:23:17 + | +LL | let _ = [0; foo::<T>()]; + | ^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error[E0747]: unresolved item provided when a constant was expected + --> $DIR/const-arg-in-const-arg.rs:42:27 + | +LL | let _ = Foo::<{ bar::<N>() }>; + | ^ + | +help: if this generic argument was intended as a const parameter, surround it with braces + | +LL | let _ = Foo::<{ bar::<{ N }>() }>; + | + + + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:44:27 + | +LL | let _ = Foo::<{ faz::<'a>(&()) }>; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/const-arg-in-const-arg.rs:47:27 + | +LL | let _ = Foo::<{ faz::<'b>(&()) }>; + | ^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/const-arg-in-const-arg.rs:8:14 + | +LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } + | ^^ + +error: aborting due to 36 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0658, E0747. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.rs b/src/test/ui/const-generics/const-arg-in-const-arg.rs index 39f0b237330..b9daadb5474 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.rs +++ b/src/test/ui/const-generics/const-arg-in-const-arg.rs @@ -12,31 +12,40 @@ struct Foo<const N: usize>; fn test<'a, 'b, T, const N: usize>() where &'b (): Sized { let _: [u8; foo::<T>()]; //~ ERROR generic parameters may not let _: [u8; bar::<N>()]; //~ ERROR generic parameters may not + //~^ ERROR unresolved item provided when a constant was expected let _: [u8; faz::<'a>(&())]; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _: [u8; baz::<'a>(&())]; //~ ERROR a non-static lifetime let _: [u8; faz::<'b>(&())]; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _: [u8; baz::<'b>(&())]; //~ ERROR a non-static lifetime - // NOTE: This can be a future compat warning instead of an error, - // so we stop compilation before emitting this error in this test. - let _ = [0; foo::<T>()]; - + let _ = [0; foo::<T>()]; //~ ERROR constant expression depends on a generic parameter let _ = [0; bar::<N>()]; //~ ERROR generic parameters may not + //~^ ERROR unresolved item provided when a constant was expected let _ = [0; faz::<'a>(&())]; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _ = [0; baz::<'a>(&())]; //~ ERROR a non-static lifetime let _ = [0; faz::<'b>(&())]; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _ = [0; baz::<'b>(&())]; //~ ERROR a non-static lifetime let _: Foo<{ foo::<T>() }>; //~ ERROR generic parameters may not let _: Foo<{ bar::<N>() }>; //~ ERROR generic parameters may not + //~^ ERROR unresolved item provided when a constant was expected let _: Foo<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _: Foo<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime let _: Foo<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _: Foo<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime let _ = Foo::<{ foo::<T>() }>; //~ ERROR generic parameters may not let _ = Foo::<{ bar::<N>() }>; //~ ERROR generic parameters may not + //~^ ERROR unresolved item provided when a constant was expected let _ = Foo::<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _ = Foo::<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime let _ = Foo::<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime + //~^ ERROR cannot specify lifetime arguments let _ = Foo::<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime } diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs index 24031aa1e61..308c121a941 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs @@ -5,7 +5,6 @@ impl<const N: u32> Trait for Uwu<N> {} fn rawr() -> impl Trait { //~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied - //~| error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied Uwu::<10, 12> } @@ -17,13 +16,11 @@ impl Traitor<1, 2> for u64 {} fn uwu<const N: u8>() -> impl Traitor<N> { //~^ error: the trait bound `u32: Traitor<N, N>` is not satisfied - //~| error: the trait bound `u32: Traitor<N, N>` is not satisfied 1_u32 } fn owo() -> impl Traitor { //~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied - //~| error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied 1_u64 } diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index 48c61c22e7a..8031da28ca1 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -6,21 +6,8 @@ LL | fn rawr() -> impl Trait { | = help: the trait `Trait` is implemented for `Uwu<N>` -error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:6:25 - | -LL | fn rawr() -> impl Trait { - | _________________________^ -LL | | -LL | | -LL | | Uwu::<10, 12> -LL | | } - | |_^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` - | - = help: the trait `Trait` is implemented for `Uwu<N>` - error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:18:26 + --> $DIR/rp_impl_trait_fail.rs:17:26 | LL | fn uwu<const N: u8>() -> impl Traitor<N> { | ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32` @@ -29,23 +16,8 @@ LL | fn uwu<const N: u8>() -> impl Traitor<N> { <u32 as Traitor<N, 2_u8>> <u64 as Traitor<1_u8, 2_u8>> -error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:18:42 - | -LL | fn uwu<const N: u8>() -> impl Traitor<N> { - | __________________________________________^ -LL | | -LL | | -LL | | 1_u32 -LL | | } - | |_^ the trait `Traitor<N, N>` is not implemented for `u32` - | - = help: the following other types implement trait `Traitor<N, M>`: - <u32 as Traitor<N, 2_u8>> - <u64 as Traitor<1_u8, 2_u8>> - error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:24:13 + --> $DIR/rp_impl_trait_fail.rs:22:13 | LL | fn owo() -> impl Traitor { | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` @@ -54,21 +26,6 @@ LL | fn owo() -> impl Traitor { <u32 as Traitor<N, 2_u8>> <u64 as Traitor<1_u8, 2_u8>> -error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:24:26 - | -LL | fn owo() -> impl Traitor { - | __________________________^ -LL | | -LL | | -LL | | 1_u64 -LL | | } - | |_^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` - | - = help: the following other types implement trait `Traitor<N, M>`: - <u32 as Traitor<N, 2_u8>> - <u64 as Traitor<1_u8, 2_u8>> - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr index 179643a7552..43a5df117fd 100644 --- a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr @@ -6,6 +6,15 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> -error: aborting due to previous error +error: `&'static str` is forbidden as the type of a const generic parameter + --> $DIR/issue-56445-1.rs:9:25 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.rs b/src/test/ui/const-generics/issues/issue-56445-1.rs index aeef778991f..13eb2ea9f69 100644 --- a/src/test/ui/const-generics/issues/issue-56445-1.rs +++ b/src/test/ui/const-generics/issues/issue-56445-1.rs @@ -8,5 +8,6 @@ use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); //~^ ERROR: use of non-static lifetime `'a` in const generic +//[min]~| ERROR: `&'static str` is forbidden as the type of a const generic parameter impl Bug<'_, ""> {} diff --git a/src/test/ui/const-generics/issues/issue-61336-2.stderr b/src/test/ui/const-generics/issues/issue-61336-2.stderr index 48aaaf5e544..5bb35669623 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.stderr @@ -1,10 +1,10 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336-2.rs:6:5 + --> $DIR/issue-61336-2.rs:6:6 | LL | [x; { N }] - | ^^^^^^^^^^ the trait `Copy` is not implemented for `T` + | ^ the trait `Copy` is not implemented for `T` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider restricting type parameter `T` | LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { diff --git a/src/test/ui/const-generics/issues/issue-61336.stderr b/src/test/ui/const-generics/issues/issue-61336.stderr index 665a1a677a1..8d9e545b456 100644 --- a/src/test/ui/const-generics/issues/issue-61336.stderr +++ b/src/test/ui/const-generics/issues/issue-61336.stderr @@ -1,10 +1,10 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/issue-61336.rs:6:5 + --> $DIR/issue-61336.rs:6:6 | LL | [x; N] - | ^^^^^^ the trait `Copy` is not implemented for `T` + | ^ the trait `Copy` is not implemented for `T` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider restricting type parameter `T` | LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs index 19217843759..18b4dc714de 100644 --- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs @@ -12,5 +12,5 @@ const fn copy() -> u32 { fn main() { let _: [u32; 2] = [copy(); 2]; let _: [Option<Bar>; 2] = [no_copy(); 2]; - //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied + //~^ ERROR the trait bound `Bar: Copy` is not satisfied } diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr index 52a1669e330..5306fed2251 100644 --- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -1,13 +1,17 @@ -error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied - --> $DIR/fn-call-in-non-const.rs:14:31 +error[E0277]: the trait bound `Bar: Copy` is not satisfied + --> $DIR/fn-call-in-non-const.rs:14:32 | LL | let _: [Option<Bar>; 2] = [no_copy(); 2]; - | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Option<Bar>` + | ^^^^^^^^^ the trait `Copy` is not implemented for `Bar` | - = help: the trait `Copy` is implemented for `Option<T>` - = note: the `Copy` trait is required because the repeated element will be copied + = note: required because of the requirements on the impl of `Copy` for `Option<Bar>` + = note: the `Copy` trait is required because this value will be copied for each element of the array = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information +help: consider annotating `Bar` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] + | error: aborting due to previous error diff --git a/src/test/ui/consts/const-blocks/migrate-fail.rs b/src/test/ui/consts/const-blocks/migrate-fail.rs index bb12139a7ba..d5a17249cc9 100644 --- a/src/test/ui/consts/const-blocks/migrate-fail.rs +++ b/src/test/ui/consts/const-blocks/migrate-fail.rs @@ -11,13 +11,13 @@ mod non_constants { fn no_impl_copy_empty_value_multiple_elements() { let x = None; let arr: [Option<Bar>; 2] = [x; 2]; - //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277] + //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277] } fn no_impl_copy_value_multiple_elements() { let x = Some(Bar); let arr: [Option<Bar>; 2] = [x; 2]; - //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277] + //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277] } } diff --git a/src/test/ui/consts/const-blocks/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr index 318fec60290..2e7ff5cb8b3 100644 --- a/src/test/ui/consts/const-blocks/migrate-fail.stderr +++ b/src/test/ui/consts/const-blocks/migrate-fail.stderr @@ -1,20 +1,28 @@ -error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied - --> $DIR/migrate-fail.rs:13:37 +error[E0277]: the trait bound `Bar: Copy` is not satisfied + --> $DIR/migrate-fail.rs:13:38 | LL | let arr: [Option<Bar>; 2] = [x; 2]; - | ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>` + | ^ the trait `Copy` is not implemented for `Bar` + | + = note: required because of the requirements on the impl of `Copy` for `Option<Bar>` + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider annotating `Bar` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] | - = help: the trait `Copy` is implemented for `Option<T>` - = note: the `Copy` trait is required because the repeated element will be copied -error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied - --> $DIR/migrate-fail.rs:19:37 +error[E0277]: the trait bound `Bar: Copy` is not satisfied + --> $DIR/migrate-fail.rs:19:38 | LL | let arr: [Option<Bar>; 2] = [x; 2]; - | ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>` + | ^ the trait `Copy` is not implemented for `Bar` + | + = note: required because of the requirements on the impl of `Copy` for `Option<Bar>` + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider annotating `Bar` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] | - = help: the trait `Copy` is implemented for `Option<T>` - = note: the `Copy` trait is required because the repeated element will be copied error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-blocks/nll-fail.rs b/src/test/ui/consts/const-blocks/nll-fail.rs index 871387c1fd0..9d4aef39e54 100644 --- a/src/test/ui/consts/const-blocks/nll-fail.rs +++ b/src/test/ui/consts/const-blocks/nll-fail.rs @@ -10,13 +10,13 @@ mod non_constants { fn no_impl_copy_empty_value_multiple_elements() { let x = None; let arr: [Option<Bar>; 2] = [x; 2]; - //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277] + //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277] } fn no_impl_copy_value_multiple_elements() { let x = Some(Bar); let arr: [Option<Bar>; 2] = [x; 2]; - //~^ ERROR the trait bound `Option<Bar>: Copy` is not satisfied [E0277] + //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277] } } diff --git a/src/test/ui/consts/const-blocks/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr index 5a34361aa83..c0d273b5a9a 100644 --- a/src/test/ui/consts/const-blocks/nll-fail.stderr +++ b/src/test/ui/consts/const-blocks/nll-fail.stderr @@ -1,20 +1,28 @@ -error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied - --> $DIR/nll-fail.rs:12:37 +error[E0277]: the trait bound `Bar: Copy` is not satisfied + --> $DIR/nll-fail.rs:12:38 | LL | let arr: [Option<Bar>; 2] = [x; 2]; - | ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>` + | ^ the trait `Copy` is not implemented for `Bar` + | + = note: required because of the requirements on the impl of `Copy` for `Option<Bar>` + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider annotating `Bar` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] | - = help: the trait `Copy` is implemented for `Option<T>` - = note: the `Copy` trait is required because the repeated element will be copied -error[E0277]: the trait bound `Option<Bar>: Copy` is not satisfied - --> $DIR/nll-fail.rs:18:37 +error[E0277]: the trait bound `Bar: Copy` is not satisfied + --> $DIR/nll-fail.rs:18:38 | LL | let arr: [Option<Bar>; 2] = [x; 2]; - | ^^^^^^ the trait `Copy` is not implemented for `Option<Bar>` + | ^ the trait `Copy` is not implemented for `Bar` + | + = note: required because of the requirements on the impl of `Copy` for `Option<Bar>` + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider annotating `Bar` with `#[derive(Copy)]` + | +LL | #[derive(Copy)] | - = help: the trait `Copy` is implemented for `Option<T>` - = note: the `Copy` trait is required because the repeated element will be copied error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-blocks/trait-error.rs b/src/test/ui/consts/const-blocks/trait-error.rs index 5a614cbdd15..49d1e9b9434 100644 --- a/src/test/ui/consts/const-blocks/trait-error.rs +++ b/src/test/ui/consts/const-blocks/trait-error.rs @@ -3,5 +3,5 @@ struct Foo<T>(T); fn main() { [Foo(String::new()); 4]; - //~^ ERROR the trait bound `Foo<String>: Copy` is not satisfied [E0277] + //~^ ERROR the trait bound `String: Copy` is not satisfied [E0277] } diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr index 6979ff36176..ece200ad10b 100644 --- a/src/test/ui/consts/const-blocks/trait-error.stderr +++ b/src/test/ui/consts/const-blocks/trait-error.stderr @@ -1,11 +1,18 @@ -error[E0277]: the trait bound `Foo<String>: Copy` is not satisfied - --> $DIR/trait-error.rs:5:5 +error[E0277]: the trait bound `String: Copy` is not satisfied + --> $DIR/trait-error.rs:5:6 | LL | [Foo(String::new()); 4]; - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Foo<String>` + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | - = help: the trait `Copy` is implemented for `Foo<T>` - = note: the `Copy` trait is required because the repeated element will be copied +note: required because of the requirements on the impl of `Copy` for `Foo<String>` + --> $DIR/trait-error.rs:1:10 + | +LL | #[derive(Copy, Clone)] + | ^^^^ + = note: the `Copy` trait is required because this value will be copied for each element of the array + = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` + = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information + = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-fn-in-vec.stderr b/src/test/ui/consts/const-fn-in-vec.stderr index f02cb4f1ff1..9eb7524b504 100644 --- a/src/test/ui/consts/const-fn-in-vec.stderr +++ b/src/test/ui/consts/const-fn-in-vec.stderr @@ -1,10 +1,10 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/const-fn-in-vec.rs:4:32 + --> $DIR/const-fn-in-vec.rs:4:33 | LL | let strings: [String; 5] = [String::new(); 5]; - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];` = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index 7dcfe96b35c..e2bab486064 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -14,7 +14,6 @@ LL | let bar = foo_impl.into() * 1u32; | | | | | cannot infer type for type parameter `T` declared on the trait `Into` | this method call resolves to `T` - | help: use the fully qualified path for the potential candidate: `<Impl as Into<u32>>::into(foo_impl)` | note: multiple `impl`s satisfying `Impl: Into<_>` found --> $DIR/E0283.rs:17:1 @@ -24,6 +23,10 @@ LL | impl Into<u32> for Impl { = note: and another `impl` found in the `core` crate: - impl<T, U> Into<U> for T where U: From<T>; +help: use the fully qualified path for the potential candidate + | +LL | let bar = <Impl as Into<u32>>::into(foo_impl) * 1u32; + | ++++++++++++++++++++++++++ ~ error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0771.stderr b/src/test/ui/error-codes/E0771.stderr index 5a16d5845a6..3ab727f5f69 100644 --- a/src/test/ui/error-codes/E0771.stderr +++ b/src/test/ui/error-codes/E0771.stderr @@ -1,3 +1,11 @@ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/E0771.rs:4:41 + | +LL | fn function_with_str<'a, const STRING: &'a str>() {} + | ^^ + | + = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/E0771.rs:1:12 | @@ -7,14 +15,6 @@ LL | #![feature(adt_const_params)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information -error[E0771]: use of non-static lifetime `'a` in const generic - --> $DIR/E0771.rs:4:41 - | -LL | fn function_with_str<'a, const STRING: &'a str>() {} - | ^^ - | - = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> - error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr index 2bccec45894..7ffebab4153 100644 --- a/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr +++ b/src/test/ui/feature-gates/feature-gate-infer_static_outlives_requirements.stderr @@ -1,8 +1,6 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:10 | -LL | struct Foo<U> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | bar: Bar<U> | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds... | @@ -11,6 +9,10 @@ note: ...that is required by this bound | LL | struct Bar<T: 'static> { | ^^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | struct Foo<U: 'static> { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/generator/issue-88653.rs b/src/test/ui/generator/issue-88653.rs index f27956e4595..caa452060b1 100644 --- a/src/test/ui/generator/issue-88653.rs +++ b/src/test/ui/generator/issue-88653.rs @@ -7,13 +7,10 @@ use std::ops::Generator; fn foo(bar: bool) -> impl Generator<(bool,)> { //~^ ERROR: type mismatch in generator arguments [E0631] - //~| ERROR: type mismatch in generator arguments [E0631] - //~| NOTE: expected signature of `fn((bool,)) -> _` //~| NOTE: expected signature of `fn((bool,)) -> _` //~| NOTE: in this expansion of desugaring of `impl Trait` |bar| { //~^ NOTE: found signature of `fn(bool) -> _` - //~| NOTE: found signature of `fn(bool) -> _` if bar { yield bar; } diff --git a/src/test/ui/generator/issue-88653.stderr b/src/test/ui/generator/issue-88653.stderr index 25357411ce1..5bd8ad129fe 100644 --- a/src/test/ui/generator/issue-88653.stderr +++ b/src/test/ui/generator/issue-88653.stderr @@ -7,22 +7,6 @@ LL | fn foo(bar: bool) -> impl Generator<(bool,)> { LL | |bar| { | ----- found signature of `fn(bool) -> _` -error[E0631]: type mismatch in generator arguments - --> $DIR/issue-88653.rs:8:46 - | -LL | fn foo(bar: bool) -> impl Generator<(bool,)> { - | ______________________________________________^ -LL | | -LL | | -LL | | -... | -LL | | |bar| { - | | ----- found signature of `fn(bool) -> _` -... | -LL | | } -LL | | } - | |_^ expected signature of `fn((bool,)) -> _` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.rs b/src/test/ui/generator/type-mismatch-signature-deduction.rs index 77b830783c3..8d1ce6c7a43 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.rs +++ b/src/test/ui/generator/type-mismatch-signature-deduction.rs @@ -4,7 +4,6 @@ use std::ops::Generator; fn foo() -> impl Generator<Return = i32> { //~^ ERROR type mismatch - //~| ERROR type mismatch || { if false { return Ok(6); diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr index 6369e7ec4c7..f05faedf21b 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr +++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/type-mismatch-signature-deduction.rs:15:9 + --> $DIR/type-mismatch-signature-deduction.rs:14:9 | LL | 5 | ^ expected enum `Result`, found integer @@ -7,12 +7,12 @@ LL | 5 = note: expected type `Result<{integer}, _>` found type `{integer}` note: return type inferred to be `Result<{integer}, _>` here - --> $DIR/type-mismatch-signature-deduction.rs:10:20 + --> $DIR/type-mismatch-signature-deduction.rs:9:20 | LL | return Ok(6); | ^^^^^ -error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:8:5: 16:6] as Generator>::Return == i32` +error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 15:6] as Generator>::Return == i32` --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Generator<Return = i32> { @@ -21,23 +21,7 @@ LL | fn foo() -> impl Generator<Return = i32> { = note: expected enum `Result<{integer}, _>` found type `i32` -error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:8:5: 16:6] as Generator>::Return == i32` - --> $DIR/type-mismatch-signature-deduction.rs:5:42 - | -LL | fn foo() -> impl Generator<Return = i32> { - | __________________________________________^ -LL | | -LL | | -LL | | || { -... | -LL | | } -LL | | } - | |_^ expected enum `Result`, found `i32` - | - = note: expected enum `Result<{integer}, _>` - found type `i32` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0271, E0308. For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/generic-associated-types/issue-70304.rs b/src/test/ui/generic-associated-types/issue-70304.rs index 448d7ec2873..1c3d166a1af 100644 --- a/src/test/ui/generic-associated-types/issue-70304.rs +++ b/src/test/ui/generic-associated-types/issue-70304.rs @@ -46,6 +46,7 @@ where fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { //~^ ERROR: missing lifetime specifier + //~| ERROR: missing lifetime specifier DocumentImpl {} } diff --git a/src/test/ui/generic-associated-types/issue-70304.stderr b/src/test/ui/generic-associated-types/issue-70304.stderr index c5f59a24057..08efc82c886 100644 --- a/src/test/ui/generic-associated-types/issue-70304.stderr +++ b/src/test/ui/generic-associated-types/issue-70304.stderr @@ -10,6 +10,18 @@ help: consider using the `'static` lifetime LL | fn create_doc() -> impl Document<Cursor<'static> = DocCursorImpl<'_>> { | ~~~~~~~ -error: aborting due to previous error +error[E0106]: missing lifetime specifier + --> $DIR/issue-70304.rs:47:61 + | +LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'_>> { + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn create_doc() -> impl Document<Cursor<'_> = DocCursorImpl<'static>> { + | ~~~~~~~ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/generic-associated-types/issue-86483.stderr b/src/test/ui/generic-associated-types/issue-86483.stderr index 2f29cd5d9e9..a13dc043dc5 100644 --- a/src/test/ui/generic-associated-types/issue-86483.stderr +++ b/src/test/ui/generic-associated-types/issue-86483.stderr @@ -1,10 +1,7 @@ error[E0311]: the parameter type `T` may not live long enough --> $DIR/issue-86483.rs:5:1 | -LL | pub trait IceIce<T> - | ^ - help: consider adding an explicit lifetime bound...: `T: 'a` - | _| - | | +LL | / pub trait IceIce<T> LL | | where LL | | for<'a> T: 'a, LL | | { @@ -19,13 +16,14 @@ note: ...that is required by this bound | LL | for<'a> T: 'a, | ^^ +help: consider adding an explicit lifetime bound... + | +LL | for<'a> T: 'a + 'a, + | ++++ error[E0311]: the parameter type `T` may not live long enough --> $DIR/issue-86483.rs:9:5 | -LL | pub trait IceIce<T> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | type Ice<'v>: IntoIterator<Item = &'v T>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | @@ -34,6 +32,10 @@ note: ...that is required by this bound | LL | for<'a> T: 'a, | ^^ +help: consider adding an explicit lifetime bound... + | +LL | for<'a> T: 'a + 'a, + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/issue-86483.rs:9:32 diff --git a/src/test/ui/generic-associated-types/issue-91139.migrate.stderr b/src/test/ui/generic-associated-types/issue-91139.migrate.stderr index a27d8110238..b424d9a2fdb 100644 --- a/src/test/ui/generic-associated-types/issue-91139.migrate.stderr +++ b/src/test/ui/generic-associated-types/issue-91139.migrate.stderr @@ -1,10 +1,13 @@ error[E0311]: the parameter type `T` may not live long enough --> $DIR/issue-91139.rs:27:12 | -LL | fn foo<T>() { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | let _: for<'a> fn(<() as Foo<T>>::Type<'a>, &'a T) = |_, _| (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn foo<T: 'a>() { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/issue-92096.migrate.stderr b/src/test/ui/generic-associated-types/issue-92096.migrate.stderr index 72ade5774d7..c74161cd3e0 100644 --- a/src/test/ui/generic-associated-types/issue-92096.migrate.stderr +++ b/src/test/ui/generic-associated-types/issue-92096.migrate.stderr @@ -2,17 +2,23 @@ error[E0311]: the parameter type `C` may not live long enough --> $DIR/issue-92096.rs:20:33 | LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send - | - ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `C: 'a` + | ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | C: Client + Send + Sync + 'a, + | ++++ error[E0311]: the parameter type `C` may not live long enough --> $DIR/issue-92096.rs:20:33 | LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send - | - ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `C: 'a` + | ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | C: Client + Send + Sync + 'a, + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/issue-95305.rs b/src/test/ui/generic-associated-types/issue-95305.rs new file mode 100644 index 00000000000..9ead347984b --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.rs @@ -0,0 +1,17 @@ +// It's not yet clear how '_ and GATs should interact. +// Forbid it for now but proper support might be added +// at some point in the future. + +#![feature(generic_associated_types)] + +trait Foo { + type Item<'a>; +} + +fn foo(x: &impl Foo<Item<'_> = u32>) { } + //~^ ERROR missing lifetime specifier + +fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { } + //~^ ERROR missing lifetime specifier + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-95305.stderr b/src/test/ui/generic-associated-types/issue-95305.stderr new file mode 100644 index 00000000000..2b48378dc43 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.stderr @@ -0,0 +1,25 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-95305.rs:11:26 + | +LL | fn foo(x: &impl Foo<Item<'_> = u32>) { } + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &impl Foo<Item<'a> = u32>) { } + | ++++ ~~ + +error[E0106]: missing lifetime specifier + --> $DIR/issue-95305.rs:14:41 + | +LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { } + | ^^ expected named lifetime parameter + | +help: consider using the `'a` lifetime + | +LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'a u32>) { } + | ~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/generic-associated-types/missing-bounds.stderr b/src/test/ui/generic-associated-types/missing-bounds.stderr index aaeec920527..5323ee17226 100644 --- a/src/test/ui/generic-associated-types/missing-bounds.stderr +++ b/src/test/ui/generic-associated-types/missing-bounds.stderr @@ -87,10 +87,10 @@ note: tuple struct defined here | LL | struct E<B>(B); | ^ -help: consider further restricting type parameter `B` +help: consider further restricting this bound | -LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B, B: Add<Output = B> { - | ++++++++++++++++++++ +LL | impl<B: Add + Add<Output = B>> Add for E<B> where <B as Add>::Output = B { + | +++++++++++++++++ error: aborting due to 5 previous errors diff --git a/src/test/ui/generic-associated-types/unsatified-item-lifetime-bound.stderr b/src/test/ui/generic-associated-types/unsatified-item-lifetime-bound.stderr index 4f0a023ee39..ae52010cc50 100644 --- a/src/test/ui/generic-associated-types/unsatified-item-lifetime-bound.stderr +++ b/src/test/ui/generic-associated-types/unsatified-item-lifetime-bound.stderr @@ -2,7 +2,7 @@ warning: unnecessary lifetime parameter `'a` --> $DIR/unsatified-item-lifetime-bound.rs:4:12 | LL | type Y<'a: 'static>; - | ^^^^^^^^^^^ + | ^^ | = help: you can use the `'static` lifetime directly, in place of `'a` diff --git a/src/test/ui/impl-trait/bound-normalization-fail.rs b/src/test/ui/impl-trait/bound-normalization-fail.rs index 9f962fa9bba..3329592478d 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.rs +++ b/src/test/ui/impl-trait/bound-normalization-fail.rs @@ -24,7 +24,6 @@ mod impl_trait { /// `T::Assoc` can't be normalized any further here. fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { //~^ ERROR: type mismatch - //~| ERROR: type mismatch Foo(()) } } @@ -42,7 +41,6 @@ mod lifetimes { fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope //~| ERROR: type mismatch - //~| ERROR: type mismatch Foo(()) } } diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index 0344f416eb7..eac7e6b315e 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -16,37 +16,14 @@ help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ -error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` - --> $DIR/bound-normalization-fail.rs:25:64 - | -LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { - | ________________________________________________________________^ -LL | | -LL | | -LL | | Foo(()) -LL | | } - | |_____^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` - | -note: expected this to be `()` - --> $DIR/bound-normalization-fail.rs:14:19 - | -LL | type Output = T; - | ^ - = note: expected unit type `()` - found associated type `<T as impl_trait::Trait>::Assoc` -help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()` - | -LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { - | ++++++++++++ - error[E0760]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/bound-normalization-fail.rs:42:41 + --> $DIR/bound-normalization-fail.rs:41:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` - --> $DIR/bound-normalization-fail.rs:42:41 + --> $DIR/bound-normalization-fail.rs:41:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` @@ -63,31 +40,7 @@ help: consider constraining the associated type `<T as lifetimes::Trait<'static> LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ -error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` - --> $DIR/bound-normalization-fail.rs:42:73 - | -LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { - | _________________________________________________________________________^ -LL | | -LL | | -LL | | -LL | | Foo(()) -LL | | } - | |_____^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` - | -note: expected this to be `()` - --> $DIR/bound-normalization-fail.rs:14:19 - | -LL | type Output = T; - | ^ - = note: expected unit type `()` - found associated type `<T as lifetimes::Trait<'static>>::Assoc` -help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()` - | -LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { - | ++++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0271, E0760. For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/impl-trait/cross-return-site-inference.rs b/src/test/ui/impl-trait/cross-return-site-inference.rs index c27b5ca9f66..a7428f9bf12 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.rs +++ b/src/test/ui/impl-trait/cross-return-site-inference.rs @@ -29,17 +29,17 @@ fn baa(b: bool) -> impl std::fmt::Debug { } fn muh() -> Result<(), impl std::fmt::Debug> { - Err("whoops")?; //~ ERROR `?` couldn't convert the error to `impl Debug` + Err("whoops")?; //~^ ERROR type annotations needed Ok(()) } fn muh2() -> Result<(), impl std::fmt::Debug> { - return Err(From::from("foo")); //~ ERROR the trait bound `impl Debug: From<&str>` is not satisfied + return Err(From::from("foo")); //~^ ERROR type annotations needed Ok(()) } fn muh3() -> Result<(), impl std::fmt::Debug> { - Err(From::from("foo")) //~ ERROR the trait bound `impl Debug: From<&str>` is not satisfied + Err(From::from("foo")) //~^ ERROR type annotations needed } fn main() {} diff --git a/src/test/ui/impl-trait/cross-return-site-inference.stderr b/src/test/ui/impl-trait/cross-return-site-inference.stderr index d458c7be783..5209d7a5743 100644 --- a/src/test/ui/impl-trait/cross-return-site-inference.stderr +++ b/src/test/ui/impl-trait/cross-return-site-inference.stderr @@ -1,27 +1,21 @@ -error[E0277]: `?` couldn't convert the error to `impl Debug` - --> $DIR/cross-return-site-inference.rs:32:18 +error[E0282]: type annotations needed + --> $DIR/cross-return-site-inference.rs:31:24 | LL | fn muh() -> Result<(), impl std::fmt::Debug> { - | -------------------------------- expected `impl Debug` because of this -LL | Err("whoops")?; - | ^ the trait `From<&str>` is not implemented for `impl Debug` - | - = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait - = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` - = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, &str>>` for `Result<(), impl Debug>` + | ^^^^^^^^^^^^^^^^^^^^ cannot infer type -error[E0277]: the trait bound `impl Debug: From<&str>` is not satisfied - --> $DIR/cross-return-site-inference.rs:37:16 +error[E0282]: type annotations needed + --> $DIR/cross-return-site-inference.rs:36:25 | -LL | return Err(From::from("foo")); - | ^^^^^^^^^^ the trait `From<&str>` is not implemented for `impl Debug` +LL | fn muh2() -> Result<(), impl std::fmt::Debug> { + | ^^^^^^^^^^^^^^^^^^^^ cannot infer type -error[E0277]: the trait bound `impl Debug: From<&str>` is not satisfied - --> $DIR/cross-return-site-inference.rs:42:9 +error[E0282]: type annotations needed + --> $DIR/cross-return-site-inference.rs:41:25 | -LL | Err(From::from("foo")) - | ^^^^^^^^^^ the trait `From<&str>` is not implemented for `impl Debug` +LL | fn muh3() -> Result<(), impl std::fmt::Debug> { + | ^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/impl-trait/equal-hidden-lifetimes.stderr b/src/test/ui/impl-trait/equal-hidden-lifetimes.stderr index 51247f1d7b0..3e48aef553b 100644 --- a/src/test/ui/impl-trait/equal-hidden-lifetimes.stderr +++ b/src/test/ui/impl-trait/equal-hidden-lifetimes.stderr @@ -2,7 +2,7 @@ warning: unnecessary lifetime parameter `'a` --> $DIR/equal-hidden-lifetimes.rs:7:25 | LL | fn equal_regions_static<'a: 'static>(x: &'a i32) -> impl Sized { - | ^^^^^^^^^^^ + | ^^ | = help: you can use the `'static` lifetime directly, in place of `'a` diff --git a/src/test/ui/impl-trait/fallback_inference.rs b/src/test/ui/impl-trait/fallback_inference.rs new file mode 100644 index 00000000000..001f9ee4877 --- /dev/null +++ b/src/test/ui/impl-trait/fallback_inference.rs @@ -0,0 +1,7 @@ +use std::marker::PhantomData; + +fn weird() -> PhantomData<impl Sized> { + PhantomData //~^ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/impl-trait/fallback_inference.stderr b/src/test/ui/impl-trait/fallback_inference.stderr new file mode 100644 index 00000000000..b637ca694c2 --- /dev/null +++ b/src/test/ui/impl-trait/fallback_inference.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/fallback_inference.rs:3:27 + | +LL | fn weird() -> PhantomData<impl Sized> { + | ^^^^^^^^^^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/impl-trait/issue-72911.rs b/src/test/ui/impl-trait/issue-72911.rs index cf2c8b7e415..be9c643b2d8 100644 --- a/src/test/ui/impl-trait/issue-72911.rs +++ b/src/test/ui/impl-trait/issue-72911.rs @@ -5,7 +5,7 @@ pub struct Lint {} impl Lint {} pub fn gather_all() -> impl Iterator<Item = Lint> { - //~^ ERROR `()` is not an iterator + //~^ ERROR type annotations needed lint_files().flat_map(|f| gather_from_file(&f)) } diff --git a/src/test/ui/impl-trait/issue-72911.stderr b/src/test/ui/impl-trait/issue-72911.stderr index 4a990286d96..fc7200c75c2 100644 --- a/src/test/ui/impl-trait/issue-72911.stderr +++ b/src/test/ui/impl-trait/issue-72911.stderr @@ -10,15 +10,13 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> { | ^^^ use of undeclared crate or module `foo` -error[E0277]: `()` is not an iterator +error[E0282]: type annotations needed --> $DIR/issue-72911.rs:7:24 | LL | pub fn gather_all() -> impl Iterator<Item = Lint> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator - | - = help: the trait `Iterator` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0433. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0282, E0433. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/impl-trait/issues/issue-67830.stderr b/src/test/ui/impl-trait/issues/issue-67830.stderr index 74e2f99cd33..4c0490c721b 100644 --- a/src/test/ui/impl-trait/issues/issue-67830.stderr +++ b/src/test/ui/impl-trait/issues/issue-67830.stderr @@ -1,12 +1,8 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-67830.rs:21:66 + --> $DIR/issue-67830.rs:21:14 | -LL | fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> { - | __________________________________________________________________^ -LL | | -LL | | Wrap(|a| Some(a).into_iter()) -LL | | } - | |_^ implementation of `FnOnce` is not general enough +LL | fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 A) -> std::option::IntoIter<&A>` must implement `FnOnce<(&'1 A,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 A,)>`, for some specific lifetime `'2` diff --git a/src/test/ui/impl-trait/issues/issue-86800.rs b/src/test/ui/impl-trait/issues/issue-86800.rs index e8cef42f208..19edeaffc49 100644 --- a/src/test/ui/impl-trait/issues/issue-86800.rs +++ b/src/test/ui/impl-trait/issues/issue-86800.rs @@ -27,16 +27,16 @@ type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O> fn execute_transaction_fut<'f, F, O>( f: F, -) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O> +) -> impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> where - F: FnOnce(&mut dyn Transaction) -> TransactionFuture<O> + 'f + F: FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> + 'f { f } impl Context { async fn do_transaction<O>( - &self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<O> + &self, f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O> ) -> TransactionResult<O> { let mut conn = Connection {}; diff --git a/src/test/ui/impl-trait/issues/issue-88236-2.stderr b/src/test/ui/impl-trait/issues/issue-88236-2.stderr index 45fadcab3f2..9574b880f7d 100644 --- a/src/test/ui/impl-trait/issues/issue-88236-2.stderr +++ b/src/test/ui/impl-trait/issues/issue-88236-2.stderr @@ -8,15 +8,12 @@ LL | fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Sen = note: ...but `Hrtb<'1>` is actually implemented for the type `&'1 ()`, for some specific lifetime `'1` error: implementation of `Hrtb` is not general enough - --> $DIR/issue-88236-2.rs:19:82 + --> $DIR/issue-88236-2.rs:19:36 | -LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - | __________________________________________________________________________________^ -LL | | x -LL | | } - | |_^ implementation of `Hrtb` is not general enough +LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Hrtb` is not general enough | - = note: `&()` must implement `Hrtb<'0>`, for any lifetime `'0`... + = note: `Hrtb<'1>` would have to be implemented for the type `&()`, for any lifetime `'1`... = note: ...but `Hrtb<'_>` is actually implemented for the type `&()` error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index 5a190649b63..db737a9c544 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -110,13 +110,15 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:41:5 + --> $DIR/must_outlive_least_region_or_bound.rs:40:5 | -LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - | -- help: consider adding an explicit lifetime bound...: `T: 'static +` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 'static { + | +++++++++ error: aborting due to 9 previous errors diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index baa42da6446..60e4672f1b7 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -37,7 +37,6 @@ fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { //~^ ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough x } diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 1272adb35e9..dade2b91fe0 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -128,22 +128,12 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:38:51 | LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - | -- ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `T: 'static +` - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:38:72 - | -LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - | _________________________________--_____________________________________^ - | | | - | | help: consider adding an explicit lifetime bound...: `T: 'static +` -LL | | -LL | | -LL | | x -LL | | } - | |_^ ...so that the type `T` will meet its required lifetime bounds + | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 'static { + | +++++++++ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/must_outlive_least_region_or_bound.rs:16:50 @@ -231,7 +221,7 @@ help: alternatively, add an explicit `'static` bound to this reference LL | fn explicit4<'a>(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) } | ~~~~~~~~~~~~ -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors Some errors have detailed explanations: E0310, E0621, E0700, E0759. For more information about an error, try `rustc --explain E0310`. diff --git a/src/test/ui/impl-trait/nested-return-type2-tait.rs b/src/test/ui/impl-trait/nested-return-type2-tait.rs index f2217f699fb..a2a49c5535d 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait.rs +++ b/src/test/ui/impl-trait/nested-return-type2-tait.rs @@ -24,7 +24,6 @@ type Sendable = impl Send; // type does not implement `Duh`, even if its hidden type does. So we error out. fn foo() -> impl Trait<Assoc = Sendable> { //~^ ERROR `Sendable: Duh` is not satisfied - //~| ERROR `Sendable: Duh` is not satisfied || 42 } diff --git a/src/test/ui/impl-trait/nested-return-type2-tait.stderr b/src/test/ui/impl-trait/nested-return-type2-tait.stderr index 81a75e39c91..359fb909e54 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait.stderr @@ -5,30 +5,12 @@ LL | fn foo() -> impl Trait<Assoc = Sendable> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `Sendable` | = help: the trait `Duh` is implemented for `i32` -note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:28:5: 28:10]` +note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:27:5: 27:10]` --> $DIR/nested-return-type2-tait.rs:14:31 | LL | impl<R: Duh, F: FnMut() -> R> Trait for F { | ^^^^^ ^ -error[E0277]: the trait bound `Sendable: Duh` is not satisfied - --> $DIR/nested-return-type2-tait.rs:25:42 - | -LL | fn foo() -> impl Trait<Assoc = Sendable> { - | __________________________________________^ -LL | | -LL | | -LL | | || 42 -LL | | } - | |_^ the trait `Duh` is not implemented for `Sendable` - | - = help: the trait `Duh` is implemented for `i32` -note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait.rs:28:5: 28:10]` - --> $DIR/nested-return-type2-tait.rs:14:31 - | -LL | impl<R: Duh, F: FnMut() -> R> Trait for F { - | ^^^^^ ^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr index 5328b077993..3050f10b205 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr @@ -1,11 +1,13 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:10:5 + --> $DIR/type_parameters_captured.rs:9:5 | -LL | fn foo<T>(x: T) -> impl Any + 'static { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn foo<T: 'static>(x: T) -> impl Any + 'static { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/type_parameters_captured.rs b/src/test/ui/impl-trait/type_parameters_captured.rs index bb9cab742a5..6c9c9d4a42a 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.rs +++ b/src/test/ui/impl-trait/type_parameters_captured.rs @@ -6,7 +6,6 @@ impl<T> Any for T {} // Check that type parameters are captured and not considered 'static fn foo<T>(x: T) -> impl Any + 'static { //~^ ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough x } diff --git a/src/test/ui/impl-trait/type_parameters_captured.stderr b/src/test/ui/impl-trait/type_parameters_captured.stderr index c4ca34a6ed3..9f28a8d44a7 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.stderr @@ -2,23 +2,13 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/type_parameters_captured.rs:7:20 | LL | fn foo<T>(x: T) -> impl Any + 'static { - | - ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `T: 'static` - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:7:39 + | ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... | -LL | fn foo<T>(x: T) -> impl Any + 'static { - | ________-______________________________^ - | | | - | | help: consider adding an explicit lifetime bound...: `T: 'static` -LL | | -LL | | -LL | | x -LL | | } - | |_^ ...so that the type `T` will meet its required lifetime bounds +LL | fn foo<T: 'static>(x: T) -> impl Any + 'static { + | +++++++++ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/impl-trait/where-allowed-2.rs b/src/test/ui/impl-trait/where-allowed-2.rs index d5a87b5d468..1a1210d0072 100644 --- a/src/test/ui/impl-trait/where-allowed-2.rs +++ b/src/test/ui/impl-trait/where-allowed-2.rs @@ -1,7 +1,6 @@ use std::fmt::Debug; -// check-pass - fn in_adt_in_return() -> Vec<impl Debug> { panic!() } +//~^ ERROR type annotations needed fn main() {} diff --git a/src/test/ui/impl-trait/where-allowed-2.stderr b/src/test/ui/impl-trait/where-allowed-2.stderr new file mode 100644 index 00000000000..2b328c01c87 --- /dev/null +++ b/src/test/ui/impl-trait/where-allowed-2.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/where-allowed-2.rs:3:30 + | +LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() } + | ^^^^^^^^^^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/issues-71798.rs b/src/test/ui/issues-71798.rs index fde59f39b1c..14b6c0f3581 100644 --- a/src/test/ui/issues-71798.rs +++ b/src/test/ui/issues-71798.rs @@ -1,6 +1,5 @@ fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { //~^ ERROR `u32` is not a future - //~| ERROR `u32` is not a future *x } diff --git a/src/test/ui/issues-71798.stderr b/src/test/ui/issues-71798.stderr index 63669c0513d..ab72c3e41af 100644 --- a/src/test/ui/issues-71798.stderr +++ b/src/test/ui/issues-71798.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `u` in this scope - --> $DIR/issues-71798.rs:8:24 + --> $DIR/issues-71798.rs:7:24 | LL | let _ = test_ref & u; | ^ not found in this scope @@ -13,21 +13,7 @@ LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { = help: the trait `Future` is not implemented for `u32` = note: u32 must be a future or must implement `IntoFuture` to be awaited -error[E0277]: `u32` is not a future - --> $DIR/issues-71798.rs:1:69 - | -LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { - | _____________________________________________________________________^ -LL | | -LL | | -LL | | *x -LL | | } - | |_^ `u32` is not a future - | - = help: the trait `Future` is not implemented for `u32` - = note: u32 must be a future or must implement `IntoFuture` to be awaited - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0425. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-30438-c.rs b/src/test/ui/issues/issue-30438-c.rs index 813c1d3e2cc..4cf634245be 100644 --- a/src/test/ui/issues/issue-30438-c.rs +++ b/src/test/ui/issues/issue-30438-c.rs @@ -5,6 +5,7 @@ trait Trait { type Out; } struct Test<'a> { s: &'a str } fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static { + //~^ WARN unnecessary lifetime parameter `'z` let x = Test { s: "this cannot last" }; &x //~^ ERROR: cannot return reference to local variable `x` diff --git a/src/test/ui/issues/issue-30438-c.stderr b/src/test/ui/issues/issue-30438-c.stderr index 7c001088097..a7a5c0500fd 100644 --- a/src/test/ui/issues/issue-30438-c.stderr +++ b/src/test/ui/issues/issue-30438-c.stderr @@ -1,9 +1,17 @@ +warning: unnecessary lifetime parameter `'z` + --> $DIR/issue-30438-c.rs:7:74 + | +LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static { + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'z` + error[E0515]: cannot return reference to local variable `x` - --> $DIR/issue-30438-c.rs:9:5 + --> $DIR/issue-30438-c.rs:10:5 | LL | &x | ^^ returns a reference to data owned by the current function -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/iterators/collect-into-array.rs b/src/test/ui/iterators/collect-into-array.rs new file mode 100644 index 00000000000..a1144c8cb8c --- /dev/null +++ b/src/test/ui/iterators/collect-into-array.rs @@ -0,0 +1,7 @@ +fn main() { + //~^ NOTE required by a bound in this + let whatever: [u32; 10] = (0..10).collect(); + //~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator + //~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()` + //~| NOTE required by a bound in `collect` +} diff --git a/src/test/ui/iterators/collect-into-array.stderr b/src/test/ui/iterators/collect-into-array.stderr new file mode 100644 index 00000000000..7be53a4873b --- /dev/null +++ b/src/test/ui/iterators/collect-into-array.stderr @@ -0,0 +1,16 @@ +error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator + --> $DIR/collect-into-array.rs:3:39 + | +LL | let whatever: [u32; 10] = (0..10).collect(); + | ^^^^^^^ try collecting into a `Vec<{integer}>`, then using `.try_into()` + | + = help: the trait `FromIterator<{integer}>` is not implemented for `[u32; 10]` +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | +LL | fn collect<B: FromIterator<Self::Item>>(self) -> B + | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/iterators/collect-into-slice.rs b/src/test/ui/iterators/collect-into-slice.rs index 905752dec74..aafa6bc8b95 100644 --- a/src/test/ui/iterators/collect-into-slice.rs +++ b/src/test/ui/iterators/collect-into-slice.rs @@ -6,7 +6,7 @@ fn process_slice(data: &[i32]) { fn main() { let some_generated_vec = (0..10).collect(); //~^ ERROR the size for values of type `[i32]` cannot be known at compilation time - //~| ERROR a value of type `[i32]` cannot be built since `[i32]` has no definite size + //~| ERROR a slice of type `[i32]` cannot be built since `[i32]` has no definite size //~| NOTE try explicitly collecting into a `Vec<{integer}>` //~| NOTE required by a bound in `collect` //~| NOTE all local variables must have a statically known size diff --git a/src/test/ui/iterators/collect-into-slice.stderr b/src/test/ui/iterators/collect-into-slice.stderr index 521f239451d..4842e65fe97 100644 --- a/src/test/ui/iterators/collect-into-slice.stderr +++ b/src/test/ui/iterators/collect-into-slice.stderr @@ -8,7 +8,7 @@ LL | let some_generated_vec = (0..10).collect(); = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature -error[E0277]: a value of type `[i32]` cannot be built since `[i32]` has no definite size +error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size --> $DIR/collect-into-slice.rs:7:38 | LL | let some_generated_vec = (0..10).collect(); diff --git a/src/test/ui/lifetimes/copy_modulo_regions.rs b/src/test/ui/lifetimes/copy_modulo_regions.rs new file mode 100644 index 00000000000..1d5d90ffcb4 --- /dev/null +++ b/src/test/ui/lifetimes/copy_modulo_regions.rs @@ -0,0 +1,19 @@ +#![feature(nll)] + +#[derive(Clone)] +struct Foo<'a>(fn(&'a ()) -> &'a ()); + +impl Copy for Foo<'static> {} + +fn mk_foo<'a>() -> Foo<'a> { + println!("mk_foo"); + Foo(|x| x) +} + +fn foo<'a>() -> [Foo<'a>; 100] { + [mk_foo::<'a>(); 100] //~ ERROR lifetime may not live long enough +} + +fn main() { + foo(); +} diff --git a/src/test/ui/lifetimes/copy_modulo_regions.stderr b/src/test/ui/lifetimes/copy_modulo_regions.stderr new file mode 100644 index 00000000000..e027bc45426 --- /dev/null +++ b/src/test/ui/lifetimes/copy_modulo_regions.stderr @@ -0,0 +1,14 @@ +error: lifetime may not live long enough + --> $DIR/copy_modulo_regions.rs:14:5 + | +LL | fn foo<'a>() -> [Foo<'a>; 100] { + | -- lifetime `'a` defined here +LL | [mk_foo::<'a>(); 100] + | ^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + | + = note: requirement occurs because of the type `Foo<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Foo<'a>` is invariant over the parameter `'a` + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance + +error: aborting due to previous error + diff --git a/src/test/ui/lifetimes/elided-lifetime-in-path-in-impl-Fn.rs b/src/test/ui/lifetimes/elided-lifetime-in-path-in-impl-Fn.rs new file mode 100644 index 00000000000..9c9965d8fb8 --- /dev/null +++ b/src/test/ui/lifetimes/elided-lifetime-in-path-in-impl-Fn.rs @@ -0,0 +1,19 @@ +// check-pass + +struct Foo<'a>(&'a ()); + +fn with_fn() -> fn(Foo) { + |_| () +} + +fn with_impl_fn() -> impl Fn(Foo) { + |_| () +} + +fn with_where_fn<T>() +where + T: Fn(Foo), +{ +} + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr index a5bc7450bbf..48fb3fb4a22 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/issue-90170-elision-mismatch.rs:5:44 @@ -15,6 +20,11 @@ LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ~~ ++ error: lifetime may not live long enough --> $DIR/issue-90170-elision-mismatch.rs:7:63 @@ -24,6 +34,11 @@ LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++ ++ error: aborting due to 3 previous errors diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr index e5083e3a088..33f6c498b6f 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr @@ -1,18 +1,24 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:19:10 | -LL | struct Foo<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` LL | foo: &'static T | ^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | struct Foo<T: 'static> { + | +++++++++ error[E0309]: the parameter type `K` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:24:19 | -LL | trait X<K>: Sized { - | - help: consider adding an explicit lifetime bound...: `K: 'a` LL | fn foo<'a, L: X<&'a Nested<K>>>(); | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | trait X<K: 'a>: Sized { + | ++++ error[E0309]: the parameter type `Self` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:28:19 @@ -27,25 +33,34 @@ error[E0309]: the parameter type `L` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:32:22 | LL | fn baz<'a, L, M: X<&'a Nested<L>>>() { - | - ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<L>` does not outlive the data it points at - | | - | help: consider adding an explicit lifetime bound...: `L: 'a` + | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<L>` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | fn baz<'a, L: 'a, M: X<&'a Nested<L>>>() { + | ++++ error[E0309]: the parameter type `K` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:41:33 | -LL | impl<K> Nested<K> { - | - help: consider adding an explicit lifetime bound...: `K: 'a` LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() { | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<K: 'a> Nested<K> { + | ++++ error[E0309]: the parameter type `M` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:44:36 | LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() { - | ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound...: `M: 'a +` - | | - | ...so that the reference type `&'a Nested<M>` does not outlive the data it points at + | ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<M>` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b + 'a>() { + | ++++ error: aborting due to 6 previous errors diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs index 133679f30f8..5168cb20d9e 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs @@ -7,7 +7,6 @@ use std::error::Error; fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { //~^ ERROR not satisfied - //~| ERROR not satisfied Ok(()) } diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index a3badd7b25a..ef1127c59ac 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -4,17 +4,6 @@ error[E0277]: the trait bound `Result<(), _>: Future` is not satisfied LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `Result<(), _>` -error[E0277]: the trait bound `Result<(), _>: Future` is not satisfied - --> $DIR/lifetime-elision-return-type-trait.rs:8:56 - | -LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { - | ________________________________________________________^ -LL | | -LL | | -LL | | Ok(()) -LL | | } - | |_^ the trait `Future` is not implemented for `Result<(), _>` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr index a94f9a79906..5a23f1e0e9d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | let's call the lifetime of this reference `'2` LL | *v = x; | ^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(&mut (ref mut v, w): &mut (&'a u8, &u8), x: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr index 2ed4d6d4401..6ba130308a3 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | let's call the lifetime of this reference `'2` LL | z.push((x,y)); | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-3.rs:2:5 @@ -17,6 +22,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | let's call the lifetime of this reference `'4` LL | z.push((x,y)); | ^^^^^^^^^^^^^ argument requires that `'3` must outlive `'4` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(z: &mut Vec<(&u8,&'a u8)>, (x, y): (&u8, &'a u8)) { + | ++++ ++ ++ error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr index 1a19e81f235..5601335d275 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 { | let's call the lifetime of this reference `'2` LL | x | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 { + | ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr index 87b13dc1591..e221902c4a9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | let's call the lifetime of this reference `'2` LL | if true { x } else { self } | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a Foo) -> &Foo { + | ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr index 825c45b2434..a909c5fa823 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) { + | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr index f3502674849..9661f1e5144 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | let's call the lifetime of this reference `'2` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index 78a828dde86..cce0a31bfbb 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x:Box<dyn Fn(&'a u8, &'a u8)> , y: Vec<&u8>, z: &u8) { + | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr index 6989acfa196..ec9fac0c288 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | let's call the lifetime of this reference `'2` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr index 422673b361a..2906c05864b 100644 --- a/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/issue_74400.nll.stderr @@ -1,10 +1,13 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/issue_74400.rs:12:5 | -LL | fn g<T>(data: &[T]) { - | - help: consider adding an explicit lifetime bound...: `T: 'static` LL | f(data, identity) | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn g<T: 'static>(data: &[T]) { + | +++++++++ error[E0308]: mismatched types --> $DIR/issue_74400.rs:12:5 diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed b/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed index fb6cf7e8996..ba1b745ba84 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed +++ b/src/test/ui/moves/use_of_moved_value_copy_suggestions.fixed @@ -54,17 +54,17 @@ where fn duplicate_custom_3<T>(t: S<T>) -> (S<T>, S<T>) where - T: A, - T: B, T: Trait, T: Copy - //~^ HELP consider further restricting type parameter `T` + T: A + Trait + Copy, + //~^ HELP consider further restricting this bound + T: B, { (t, t) //~ use of moved value: `t` } -fn duplicate_custom_4<T: A>(t: S<T>) -> (S<T>, S<T>) +fn duplicate_custom_4<T: A + Trait + Copy>(t: S<T>) -> (S<T>, S<T>) +//~^ HELP consider further restricting this bound where - T: B + Trait + Copy, - //~^ HELP consider further restricting this bound + T: B, { (t, t) //~ use of moved value: `t` } @@ -77,8 +77,8 @@ fn existing_colon<T: Copy>(t: T) { fn existing_colon_in_where<T>(t: T) where - T: Copy, - //~^ HELP consider further restricting this bound + T:, T: Copy + //~^ HELP consider further restricting type parameter `T` { [t, t]; //~ use of moved value: `t` } diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs b/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs index cadbf2a54cc..0a43dd1a9a3 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs +++ b/src/test/ui/moves/use_of_moved_value_copy_suggestions.rs @@ -55,16 +55,16 @@ where fn duplicate_custom_3<T>(t: S<T>) -> (S<T>, S<T>) where T: A, + //~^ HELP consider further restricting this bound T: B, - //~^ HELP consider further restricting type parameter `T` { (t, t) //~ use of moved value: `t` } fn duplicate_custom_4<T: A>(t: S<T>) -> (S<T>, S<T>) +//~^ HELP consider further restricting this bound where T: B, - //~^ HELP consider further restricting this bound { (t, t) //~ use of moved value: `t` } @@ -78,7 +78,7 @@ fn existing_colon<T:>(t: T) { fn existing_colon_in_where<T>(t: T) where T:, - //~^ HELP consider further restricting this bound + //~^ HELP consider further restricting type parameter `T` { [t, t]; //~ use of moved value: `t` } diff --git a/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr b/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr index f5252084d68..2353cd079a3 100644 --- a/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr +++ b/src/test/ui/moves/use_of_moved_value_copy_suggestions.stderr @@ -121,10 +121,10 @@ LL | (t, t) | | | value moved here | -help: consider further restricting type parameter `T` +help: consider further restricting this bound | -LL | T: B, T: Trait, T: Copy - | ~~~~~~~~~~~~~~~~~~~ +LL | T: A + Trait + Copy, + | ++++++++++++++ error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:69:9 @@ -139,8 +139,8 @@ LL | (t, t) | help: consider further restricting this bound | -LL | T: B + Trait + Copy, - | ++++++++++++++ +LL | fn duplicate_custom_4<T: A + Trait + Copy>(t: S<T>) -> (S<T>, S<T>) + | ++++++++++++++ error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:83:9 @@ -153,10 +153,10 @@ LL | [t, t]; | | | value moved here | -help: consider further restricting this bound +help: consider further restricting type parameter `T` | -LL | T: Copy, - | ++++ +LL | T:, T: Copy + | ~~~~~~~~~ error[E0382]: use of moved value: `t` --> $DIR/use_of_moved_value_copy_suggestions.rs:75:9 diff --git a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr index b6856089a84..08605efa2ea 100644 --- a/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-from-trait-match.stderr @@ -36,9 +36,6 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/propagate-from-trait-match.rs:32:36 | -LL | fn supply<'a, T>(value: T) - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | establish_relationships(value, |value| { | ____________________________________^ LL | | @@ -48,6 +45,11 @@ LL | | // This function call requires that LL | | require(value); LL | | }); | |_____^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Trait<'a> + 'a, + | ++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr index 3d4cfc1610a..64b08a9b32f 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr @@ -1,20 +1,24 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:11:5 | -LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Debug + 'a, + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/impl-trait-outlives.rs:26:5 | -LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: 'b + Debug + 'a, + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr index cc5aa1eb11e..3b9b2956c51 100644 --- a/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr +++ b/src/test/ui/nll/ty-outlives/projection-implied-bounds.stderr @@ -1,10 +1,13 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/projection-implied-bounds.rs:30:18 | -LL | fn generic2<T: Iterator>(value: T) { - | -- help: consider adding an explicit lifetime bound...: `T: 'static +` LL | twice(value, |value_ref, item| invoke2(value_ref, item)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn generic2<T: Iterator + 'static>(value: T) { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 62db6dd845a..caf2e3c4747 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -31,11 +31,13 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:45:29 | -LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Anything<'b> + 'a, + | ++++ error: lifetime may not live long enough --> $DIR/projection-one-region-closure.rs:45:39 @@ -82,11 +84,13 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:56:29 | -LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Anything<'b> + 'a, + | ++++ error: lifetime may not live long enough --> $DIR/projection-one-region-closure.rs:56:39 diff --git a/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr b/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr index c51edb7868d..e28b89580bc 100644 --- a/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr +++ b/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr @@ -1,11 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-where-clause-none.rs:16:5 | -LL | fn foo<'a, T>() -> &'a () - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | bar::<T::Output>() | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: MyTrait<'a> + 'a, + | ++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 3e5e4868341..a4588730b3f 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -52,10 +52,13 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 | -LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn generic_fail<'a, T: 'a>(cell: Cell<&'a ()>, value: T) { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr index dc2f23b4fc8..084dd93cb86 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.stderr @@ -29,20 +29,24 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:26:23 | -LL | fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | with_signature(x, |y| y) | ^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Debug + 'a, + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-return-type.rs:41:5 | -LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: 'b + Debug + 'a, + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index e9f728c77b3..11a737ba291 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -37,8 +37,6 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 | -LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | with_signature(a, b, |x, y| { | __________________________^ LL | | @@ -48,6 +46,11 @@ LL | | // See `correct_region`, which explains the point of this LL | | require(&x, &y) LL | | }) | |_____^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn no_region<'a, T: 'a>(a: Cell<&'a ()>, b: T) { + | ++++ note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:43:26 @@ -121,9 +124,6 @@ LL | | } error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 | -LL | fn wrong_region<'a, 'b, T>(a: Cell<&'a ()>, b: T) - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | with_signature(a, b, |x, y| { | __________________________^ LL | | @@ -131,6 +131,11 @@ LL | | // See `correct_region` LL | | require(&x, &y) LL | | }) | |_____^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: 'b + 'a, + | ++++ note: external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:77:26 diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr b/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr index a2e6a5d57cd..ba79137d18d 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-fn-body.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn-body.rs:19:5 | -LL | fn region_static<'a, T>(cell: Cell<&'a usize>, t: T) { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | outlives(cell, t) | ^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn region_static<'a, T: 'a>(cell: Cell<&'a usize>, t: T) { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/ty-param-fn.stderr b/src/test/ui/nll/ty-outlives/ty-param-fn.stderr index fce360dd54b..729f14d84ad 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-fn.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-fn.stderr @@ -1,20 +1,24 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:11:5 | -LL | fn no_region<'a, T>(x: Box<T>) -> Box<Debug + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: Debug + 'a, + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-fn.rs:26:5 | -LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | x | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | T: 'b + Debug + 'a, + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/or-patterns/missing-bindings.stderr b/src/test/ui/or-patterns/missing-bindings.stderr index c173a3a9aba..8fafa275b5c 100644 --- a/src/test/ui/or-patterns/missing-bindings.stderr +++ b/src/test/ui/or-patterns/missing-bindings.stderr @@ -103,6 +103,22 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | pattern doesn't bind `c` +error[E0408]: variable `d` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:33 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | - ^^^^ pattern doesn't bind `d` + | | + | variable not in all patterns + +error[E0408]: variable `e` is not bound in all patterns + --> $DIR/missing-bindings.rs:45:10 + | +LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; + | ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns + | | + | pattern doesn't bind `e` + error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:45:33 | @@ -127,22 +143,6 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | | | variable not in all patterns -error[E0408]: variable `d` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:33 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | - ^^^^ pattern doesn't bind `d` - | | - | variable not in all patterns - -error[E0408]: variable `e` is not bound in all patterns - --> $DIR/missing-bindings.rs:45:10 - | -LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; - | ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns - | | - | pattern doesn't bind `e` - error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:61:29 | diff --git a/src/test/ui/proc-macro/nodelim-groups.rs b/src/test/ui/proc-macro/nodelim-groups.rs index db2a879f405..ec301990281 100644 --- a/src/test/ui/proc-macro/nodelim-groups.rs +++ b/src/test/ui/proc-macro/nodelim-groups.rs @@ -3,7 +3,7 @@ // compile-flags: -Z span-debug // edition:2018 // -// Tests the pretty-printing behavior of inserting `NoDelim` groups +// Tests the pretty-printing behavior of inserting `Invisible`-delimited groups #![no_std] // Don't load unnecessary hygiene information from std extern crate std; diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 05ddc09b2d0..66d3102225e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -1,26 +1,35 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:13:5 | -LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + | +++++++++ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:13:5 | -LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + | +++++++++ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:13:5 | -LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + | +++++++++ error: lifetime may not live long enough --> $DIR/regions-close-object-into-object-4.rs:13:5 @@ -51,10 +60,13 @@ LL | Box::new(B(&*v)) as Box<dyn X> error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:13:14 | -LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn i<'a, T, U: 'static>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + | +++++++++ error: aborting due to 6 previous errors diff --git a/src/test/ui/regions/regions-close-object-into-object-5.base.stderr b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr index 8b5a06bab71..1a78079b638 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.base.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr @@ -1,9 +1,6 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:5 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | @@ -12,22 +9,25 @@ note: ...that is required by this bound | LL | struct B<'a, T: 'a>(&'a (A<T> + 'a)); | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:5 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^^^^^^^^^ ...so that the type `B<'_, T>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:14 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^ ...so that the type `T` will meet its required lifetime bounds... | @@ -36,13 +36,14 @@ note: ...that is required by this bound | LL | struct B<'a, T: 'a>(&'a (A<T> + 'a)); | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:14 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | @@ -51,33 +52,43 @@ note: ...that is required by this bound | LL | struct B<'a, T: 'a>(&'a (A<T> + 'a)); | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:16 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^ ...so that the reference type `&dyn A<T>` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:16 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^ ...so that the type `(dyn A<T> + 'static)` is not borrowed for too long + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:16 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^ ...so that the type `(dyn A<T> + 'static)` is not borrowed for too long + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error: aborting due to 7 previous errors diff --git a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr index f4e3809e916..cb06326130e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr @@ -1,29 +1,35 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:5 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:5 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:5 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-5.rs:21:5 @@ -37,11 +43,13 @@ LL | Box::new(B(&*v)) as Box<dyn X> error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-object-into-object-5.rs:21:14 | -LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! LL | Box::new(B(&*v)) as Box<dyn X> | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn f<'a, T: 'static, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> { + | +++++++++ error: aborting due to 5 previous errors diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr index 41dc03e86dd..d8f77ad85c9 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr @@ -1,18 +1,24 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:15:5 | -LL | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { - | -- help: consider adding an explicit lifetime bound...: `A: 'static +` LL | Box::new(v) as Box<dyn SomeTrait + 'static> | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn make_object1<A: SomeTrait + 'static>(v: A) -> Box<dyn SomeTrait + 'static> { + | +++++++++ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:24:5 | -LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> { - | -- help: consider adding an explicit lifetime bound...: `A: 'b +` LL | Box::new(v) as Box<dyn SomeTrait + 'b> | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn make_object3<'a, 'b, A: SomeTrait + 'a + 'b>(v: A) -> Box<dyn SomeTrait + 'b> { + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr index 41dc03e86dd..d8f77ad85c9 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr @@ -1,18 +1,24 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:15:5 | -LL | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { - | -- help: consider adding an explicit lifetime bound...: `A: 'static +` LL | Box::new(v) as Box<dyn SomeTrait + 'static> | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn make_object1<A: SomeTrait + 'static>(v: A) -> Box<dyn SomeTrait + 'static> { + | +++++++++ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:24:5 | -LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> { - | -- help: consider adding an explicit lifetime bound...: `A: 'b +` LL | Box::new(v) as Box<dyn SomeTrait + 'b> | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn make_object3<'a, 'b, A: SomeTrait + 'a + 'b>(v: A) -> Box<dyn SomeTrait + 'b> { + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-close-param-into-object.base.stderr b/src/test/ui/regions/regions-close-param-into-object.base.stderr index 7e135c65450..79a5d34dea8 100644 --- a/src/test/ui/regions/regions-close-param-into-object.base.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.base.stderr @@ -1,38 +1,46 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:10:5 | -LL | fn p1<T>(v: T) -> Box<dyn X + 'static> - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | where T : X + 'static + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:16:5 | -LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static> - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `Box<T>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn p2<T: 'static>(v: Box<T>) -> Box<dyn X + 'static> + | +++++++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:22:5 | -LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | where T : X + 'a + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:28:5 | -LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `Box<T>` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn p4<'a,T: 'a>(v: Box<T>) -> Box<dyn X + 'a> + | ++++ error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-close-param-into-object.nll.stderr b/src/test/ui/regions/regions-close-param-into-object.nll.stderr index 3fbc1022631..6ee12d5b82c 100644 --- a/src/test/ui/regions/regions-close-param-into-object.nll.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.nll.stderr @@ -1,38 +1,46 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:10:5 | -LL | fn p1<T>(v: T) -> Box<dyn X + 'static> - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | where T : X + 'static + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:16:5 | -LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static> - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn p2<T: 'static>(v: Box<T>) -> Box<dyn X + 'static> + | +++++++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:22:5 | -LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | where T : X + 'a + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:28:5 | -LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a> - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn p4<'a,T: 'a>(v: Box<T>) -> Box<dyn X + 'a> + | ++++ error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.rs b/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.rs index f464cab7554..7c2e1aeeea6 100644 --- a/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.rs +++ b/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.rs @@ -9,7 +9,7 @@ // 'a : 'b fn test<'a,'b>(x: &'a i32) -> &'b i32 - where 'a: 'static + where 'a: 'static //~ WARN unnecessary lifetime parameter `'a` { x } diff --git a/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.stderr b/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.stderr new file mode 100644 index 00000000000..70ed418d5cb --- /dev/null +++ b/src/test/ui/regions/regions-free-region-outlives-static-outlives-free-region.stderr @@ -0,0 +1,10 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/regions-free-region-outlives-static-outlives-free-region.rs:12:11 + | +LL | where 'a: 'static + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +warning: 1 warning emitted + diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr index ef68674a18f..85ced4b5241 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr @@ -1,11 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:10 | -LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) - | -- help: consider adding an explicit lifetime bound...: `T: 'x +` -LL | { LL | wf::<&'x T>(); | ^^^^^ ...so that the reference type `&'x T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | fn func<'x, T:Trait1<'x> + 'x>(t: &'x T::Foo) + | ++++ error: aborting due to previous error diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr index 6d63de6d6bd..1a428eb25d7 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr @@ -1,11 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:5 | -LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) - | -- help: consider adding an explicit lifetime bound...: `T: 'x +` -LL | { LL | wf::<&'x T>(); | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn func<'x, T:Trait1<'x> + 'x>(t: &'x T::Foo) + | ++++ error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr index 6a7e8ba1347..658740f3f87 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr @@ -1,8 +1,6 @@ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:37:5 | -LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { - | - help: consider adding an explicit lifetime bound...: `A: 'a` LL | check_bound(x, a) | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... | @@ -11,12 +9,14 @@ note: ...that is required by this bound | LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn bar1<'a,A: 'a>(x: Inv<'a>, a: A) { + | ++++ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:41:5 | -LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { - | -- help: consider adding an explicit lifetime bound...: `A: 'a +` LL | check_bound(x, a) | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... | @@ -25,6 +25,10 @@ note: ...that is required by this bound | LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn bar2<'a,'b,A:Is<'b> + 'a>(x: Inv<'a>, y: Inv<'b>, a: A) { + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr index 4aa4b468eaa..5cc2d20c2e0 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr @@ -1,18 +1,24 @@ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:37:5 | -LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { - | - help: consider adding an explicit lifetime bound...: `A: 'a` LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn bar1<'a,A: 'a>(x: Inv<'a>, a: A) { + | ++++ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-infer-bound-from-trait.rs:41:5 | -LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { - | -- help: consider adding an explicit lifetime bound...: `A: 'a +` LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn bar2<'a,'b,A:Is<'b> + 'a>(x: Inv<'a>, y: Inv<'b>, a: A) { + | ++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-static-bound-rpass.rs b/src/test/ui/regions/regions-static-bound-rpass.rs index c91c6f87493..25232b455b6 100644 --- a/src/test/ui/regions/regions-static-bound-rpass.rs +++ b/src/test/ui/regions/regions-static-bound-rpass.rs @@ -1,10 +1,17 @@ // run-pass + fn invariant_id<'a,'b>(t: &'b mut &'static ()) -> &'b mut &'a () where 'a: 'static { t } +//~^ WARN unnecessary lifetime parameter `'a` + fn static_id<'a>(t: &'a ()) -> &'static () where 'a: 'static { t } +//~^ WARN unnecessary lifetime parameter `'a` + fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } +//~^ WARN unnecessary lifetime parameter `'b` + fn ref_id<'a>(t: &'a ()) -> &'a () where 'static: 'a { t } static UNIT: () = (); diff --git a/src/test/ui/regions/regions-static-bound-rpass.stderr b/src/test/ui/regions/regions-static-bound-rpass.stderr new file mode 100644 index 00000000000..9355a409d50 --- /dev/null +++ b/src/test/ui/regions/regions-static-bound-rpass.stderr @@ -0,0 +1,26 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/regions-static-bound-rpass.rs:4:11 + | +LL | where 'a: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +warning: unnecessary lifetime parameter `'a` + --> $DIR/regions-static-bound-rpass.rs:8:11 + | +LL | where 'a: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +warning: unnecessary lifetime parameter `'b` + --> $DIR/regions-static-bound-rpass.rs:12:19 + | +LL | where 'a: 'b, 'b: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'b` + +warning: 3 warnings emitted + diff --git a/src/test/ui/regions/regions-static-bound.base.stderr b/src/test/ui/regions/regions-static-bound.base.stderr index b37ce1e76bd..6b8120444d0 100644 --- a/src/test/ui/regions/regions-static-bound.base.stderr +++ b/src/test/ui/regions/regions-static-bound.base.stderr @@ -1,18 +1,34 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/regions-static-bound.rs:6:11 + | +LL | where 'a: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +warning: unnecessary lifetime parameter `'b` + --> $DIR/regions-static-bound.rs:10:19 + | +LL | where 'a: 'b, 'b: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'b` + error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:14:5 | LL | t | ^ | = note: ...the reference is valid for the static lifetime... note: ...but the borrowed content is only valid for the lifetime `'a` as defined here - --> $DIR/regions-static-bound.rs:9:24 + --> $DIR/regions-static-bound.rs:13:24 | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | ^^ error[E0759]: `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:16:5 + --> $DIR/regions-static-bound.rs:20:5 | LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... @@ -20,13 +36,13 @@ LL | static_id(&u); | ^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:16:5 + --> $DIR/regions-static-bound.rs:20:5 | LL | static_id(&u); | ^^^^^^^^^ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:19:5 + --> $DIR/regions-static-bound.rs:23:5 | LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... @@ -35,12 +51,12 @@ LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:19:5 + --> $DIR/regions-static-bound.rs:23:5 | LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 3 previous errors; 2 warnings emitted Some errors have detailed explanations: E0312, E0759. For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index d228c42f995..68e36f3aeea 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -1,5 +1,21 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/regions-static-bound.rs:6:11 + | +LL | where 'a: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +warning: unnecessary lifetime parameter `'b` + --> $DIR/regions-static-bound.rs:10:19 + | +LL | where 'a: 'b, 'b: 'static { t } + | ^^ + | + = help: you can use the `'static` lifetime directly, in place of `'b` + error: lifetime may not live long enough - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:14:5 | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here @@ -7,7 +23,7 @@ LL | t | ^ returning this value requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:16:5 + --> $DIR/regions-static-bound.rs:20:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'1` @@ -20,7 +36,7 @@ LL | static_id(&u); | argument requires that `'1` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:19:5 + --> $DIR/regions-static-bound.rs:23:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'2` @@ -33,6 +49,6 @@ LL | static_id_indirect(&v); | `v` escapes the function body here | argument requires that `'2` must outlive `'static` -error: aborting due to 3 previous errors +error: aborting due to 3 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/regions/regions-static-bound.rs b/src/test/ui/regions/regions-static-bound.rs index 058b717c95d..1eed7e71745 100644 --- a/src/test/ui/regions/regions-static-bound.rs +++ b/src/test/ui/regions/regions-static-bound.rs @@ -4,8 +4,12 @@ fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t } +//~^ WARN unnecessary lifetime parameter `'a` + fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } +//~^ WARN unnecessary lifetime parameter `'b` + fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { t //[base]~^ ERROR E0312 diff --git a/src/test/ui/repeat-expr/infer.rs b/src/test/ui/repeat-expr/infer.rs new file mode 100644 index 00000000000..8197713b97e --- /dev/null +++ b/src/test/ui/repeat-expr/infer.rs @@ -0,0 +1,16 @@ +// check-pass + +#[derive(Clone, Default)] +struct MaybeCopy<T>(T); + +impl Copy for MaybeCopy<u8> {} + +fn is_copy<T: Copy>(x: T) { + println!("{}", std::any::type_name::<T>()); +} + +fn main() { + is_copy(MaybeCopy::default()); + [MaybeCopy::default(); 13]; + // didn't work, because `Copy` was only checked in the mir +} diff --git a/src/test/ui/repeat-expr-in-static.rs b/src/test/ui/repeat-expr/repeat-expr-in-static.rs index 0b895379330..0b895379330 100644 --- a/src/test/ui/repeat-expr-in-static.rs +++ b/src/test/ui/repeat-expr/repeat-expr-in-static.rs diff --git a/src/test/ui/repeat-to-run-dtor-twice.rs b/src/test/ui/repeat-expr/repeat-to-run-dtor-twice.rs index 0cd8eceefc5..0cd8eceefc5 100644 --- a/src/test/ui/repeat-to-run-dtor-twice.rs +++ b/src/test/ui/repeat-expr/repeat-to-run-dtor-twice.rs diff --git a/src/test/ui/repeat-to-run-dtor-twice.stderr b/src/test/ui/repeat-expr/repeat-to-run-dtor-twice.stderr index 904413712cd..36b93616375 100644 --- a/src/test/ui/repeat-to-run-dtor-twice.stderr +++ b/src/test/ui/repeat-expr/repeat-to-run-dtor-twice.stderr @@ -1,10 +1,10 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied - --> $DIR/repeat-to-run-dtor-twice.rs:17:13 + --> $DIR/repeat-to-run-dtor-twice.rs:17:15 | LL | let _ = [ a; 5 ]; - | ^^^^^^^^ the trait `Copy` is not implemented for `Foo` + | ^ the trait `Copy` is not implemented for `Foo` | - = note: the `Copy` trait is required because the repeated element will be copied + = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Foo` with `#[derive(Copy)]` | LL | #[derive(Copy)] diff --git a/src/test/ui/repeat_count.rs b/src/test/ui/repeat-expr/repeat_count.rs index 96abff4ab41..96abff4ab41 100644 --- a/src/test/ui/repeat_count.rs +++ b/src/test/ui/repeat-expr/repeat_count.rs diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat-expr/repeat_count.stderr index 59bcd954a1f..59bcd954a1f 100644 --- a/src/test/ui/repeat_count.stderr +++ b/src/test/ui/repeat-expr/repeat_count.stderr diff --git a/src/test/ui/resolve/resolve-inconsistent-names.rs b/src/test/ui/resolve/resolve-inconsistent-names.rs index b9202f556d1..989d2d45230 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.rs +++ b/src/test/ui/resolve/resolve-inconsistent-names.rs @@ -2,9 +2,9 @@ enum E { A, B, c } -mod m { +pub mod m { const CONST1: usize = 10; - const Const2: usize = 20; + pub const Const2: usize = 20; } fn main() { @@ -22,15 +22,14 @@ fn main() { //~| ERROR variable `B` is bound inconsistently //~| ERROR mismatched types //~| ERROR variable `c` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::A` + //~| HELP if you meant to match on unit variant `E::A`, use the full path in the pattern } let z = (10, 20); match z { (CONST1, _) | (_, Const2) => () //~^ ERROR variable `CONST1` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::CONST1` //~| ERROR variable `Const2` is not bound in all patterns - //~| HELP consider making the path in the pattern qualified: `?::Const2` + //~| HELP if you meant to match on constant `m::Const2`, use the full path in the pattern } } diff --git a/src/test/ui/resolve/resolve-inconsistent-names.stderr b/src/test/ui/resolve/resolve-inconsistent-names.stderr index 70e9c2e5bf5..9de191f7d32 100644 --- a/src/test/ui/resolve/resolve-inconsistent-names.stderr +++ b/src/test/ui/resolve/resolve-inconsistent-names.stderr @@ -23,11 +23,10 @@ LL | (A, B) | (ref B, c) | (c, A) => () | | pattern doesn't bind `A` | variable not in all patterns | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::A` - --> $DIR/resolve-inconsistent-names.rs:19:10 +help: if you meant to match on unit variant `E::A`, use the full path in the pattern | -LL | (A, B) | (ref B, c) | (c, A) => () - | ^ +LL | (E::A, B) | (ref B, c) | (c, A) => () + | ~~~~ error[E0408]: variable `B` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:31 @@ -63,11 +62,11 @@ LL | (CONST1, _) | (_, Const2) => () | | | variable not in all patterns | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::CONST1` - --> $DIR/resolve-inconsistent-names.rs:30:10 +note: you might have meant to match on constant `m::CONST1`, which exists but is inaccessible + --> $DIR/resolve-inconsistent-names.rs:6:5 | -LL | (CONST1, _) | (_, Const2) => () - | ^^^^^^ +LL | const CONST1: usize = 10; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not accessible error[E0408]: variable `Const2` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:30:9 @@ -77,11 +76,10 @@ LL | (CONST1, _) | (_, Const2) => () | | | pattern doesn't bind `Const2` | -help: if you meant to match on a variant or a `const` item, consider making the path in the pattern qualified: `?::Const2` - --> $DIR/resolve-inconsistent-names.rs:30:27 +help: if you meant to match on constant `m::Const2`, use the full path in the pattern | -LL | (CONST1, _) | (_, Const2) => () - | ^^^^^^ +LL | (CONST1, _) | (_, m::Const2) => () + | ~~~~~~~~~ error[E0308]: mismatched types --> $DIR/resolve-inconsistent-names.rs:19:19 diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr index 1f387a042e6..950ffd6c89b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -1,8 +1,6 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/dont-infer-static.rs:8:10 | -LL | struct Foo<U> { - | - help: consider adding an explicit lifetime bound...: `U: 'static` LL | bar: Bar<U> | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds... | @@ -11,6 +9,10 @@ note: ...that is required by this bound | LL | struct Bar<T: 'static> { | ^^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | struct Foo<U: 'static> { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr index 553a3e71c16..2c660b28500 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr @@ -1,27 +1,35 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-enum-not-wf.rs:17:18 | -LL | enum Ref1<'a, T> { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | Ref1Variant1(RequireOutlives<'a, T>), | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum Ref1<'a, T: 'a> { + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-enum-not-wf.rs:22:25 | -LL | enum Ref2<'a, T> { - | - help: consider adding an explicit lifetime bound...: `T: 'a` -LL | Ref2Variant1, LL | Ref2Variant2(isize, RequireOutlives<'a, T>), | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum Ref2<'a, T: 'a> { + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-enum-not-wf.rs:35:23 | -LL | enum RefDouble<'a, 'b, T> { - | - help: consider adding an explicit lifetime bound...: `T: 'b` LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum RefDouble<'a, 'b, T: 'b> { + | ++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr index f8861262991..34ff1362cf3 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -1,16 +1,17 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-struct-not-wf.rs:13:16 | -LL | impl<'a, T> Trait<'a, T> for usize { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a T; | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for usize { + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-struct-not-wf.rs:21:16 | -LL | impl<'a, T> Trait<'a, T> for u32 { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = RefOk<'a, T>; | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | @@ -19,6 +20,10 @@ note: ...that is required by this bound | LL | struct RefOk<'a, T:'a> { | ^^ +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for u32 { + | ++++ error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references --> $DIR/regions-struct-not-wf.rs:25:16 diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr index b06ebf70477..057146e7cb0 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:69 @@ -15,6 +20,11 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58 diff --git a/src/test/ui/self/elision/lt-ref-self.nll.stderr b/src/test/ui/self/elision/lt-ref-self.nll.stderr index 1934207527b..2e26c703b65 100644 --- a/src/test/ui/self/elision/lt-ref-self.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:23:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:29:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:35:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:41:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:47:9 @@ -57,6 +82,11 @@ LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self.nll.stderr b/src/test/ui/self/elision/ref-mut-self.nll.stderr index f1f4d341b2b..fd4ecae3cfe 100644 --- a/src/test/ui/self/elision/ref-mut-self.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&mut self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:23:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:29:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:35:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:41:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a mut Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:47:9 @@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a mut Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct.nll.stderr b/src/test/ui/self/elision/ref-mut-struct.nll.stderr index de7eb02d7a7..ede790c0611 100644 --- a/src/test/ui/self/elision/ref-mut-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:21:9 @@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:27:9 @@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:33:9 @@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a mut Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:39:9 @@ -47,6 +67,11 @@ LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Struct<'a>(self: Box<Pin<&'a mut Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self.nll.stderr b/src/test/ui/self/elision/ref-self.nll.stderr index f2b7b0ad019..c0efc35fa6c 100644 --- a/src/test/ui/self/elision/ref-self.nll.stderr +++ b/src/test/ui/self/elision/ref-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:33:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:39:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:45:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:51:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:57:9 @@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:63:9 @@ -67,6 +97,11 @@ LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 { + | ++++ ++ ++ error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct.nll.stderr b/src/test/ui/self/elision/ref-struct.nll.stderr index 70453b0ddfc..226923f59ff 100644 --- a/src/test/ui/self/elision/ref-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-struct.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:21:9 @@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:27:9 @@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:33:9 @@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:39:9 @@ -47,6 +67,11 @@ LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_Struct<'a>(self: Box<Pin<&'a Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/span/issue-39698.stderr b/src/test/ui/span/issue-39698.stderr index 445df90d395..25c35fd5479 100644 --- a/src/test/ui/span/issue-39698.stderr +++ b/src/test/ui/span/issue-39698.stderr @@ -1,3 +1,13 @@ +error[E0408]: variable `d` is not bound in all patterns + --> $DIR/issue-39698.rs:10:37 + | +LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` + | | | | + | | | pattern doesn't bind `d` + | | variable not in all patterns + | variable not in all patterns + error[E0408]: variable `a` is not bound in all patterns --> $DIR/issue-39698.rs:10:23 | @@ -28,16 +38,6 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | pattern doesn't bind `c` | pattern doesn't bind `c` -error[E0408]: variable `d` is not bound in all patterns - --> $DIR/issue-39698.rs:10:37 - | -LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } - | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` - | | | | - | | | pattern doesn't bind `d` - | | variable not in all patterns - | variable not in all patterns - error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0408`. diff --git a/src/test/ui/static/static-lifetime-bound.stderr b/src/test/ui/static/static-lifetime-bound.stderr index 79d9506619e..ef07a89315f 100644 --- a/src/test/ui/static/static-lifetime-bound.stderr +++ b/src/test/ui/static/static-lifetime-bound.stderr @@ -2,7 +2,7 @@ warning: unnecessary lifetime parameter `'a` --> $DIR/static-lifetime-bound.rs:1:6 | LL | fn f<'a: 'static>(_: &'a i32) {} - | ^^^^^^^^^^^ + | ^^ | = help: you can use the `'static` lifetime directly, in place of `'a` diff --git a/src/test/ui/suggestions/bound-suggestions.fixed b/src/test/ui/suggestions/bound-suggestions.fixed index 31fdd2b67e2..17a019c6984 100644 --- a/src/test/ui/suggestions/bound-suggestions.fixed +++ b/src/test/ui/suggestions/bound-suggestions.fixed @@ -35,7 +35,7 @@ fn test_one_bound_where<X>(x: X) where X: Sized + std::fmt::Debug { } #[allow(dead_code)] -fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug { +fn test_many_bounds_where<X>(x: X) where X: Sized + std::fmt::Debug, X: Sized { println!("{:?}", x); //~^ ERROR doesn't implement } diff --git a/src/test/ui/suggestions/bound-suggestions.stderr b/src/test/ui/suggestions/bound-suggestions.stderr index 04f233a1e87..e5e19444d24 100644 --- a/src/test/ui/suggestions/bound-suggestions.stderr +++ b/src/test/ui/suggestions/bound-suggestions.stderr @@ -65,10 +65,10 @@ LL | println!("{:?}", x); | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider further restricting type parameter `X` +help: consider further restricting this bound | -LL | fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug { - | ++++++++++++++++++++ +LL | fn test_many_bounds_where<X>(x: X) where X: Sized + std::fmt::Debug, X: Sized { + | +++++++++++++++++ error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/bound-suggestions.rs:44:46 diff --git a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.rs b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.rs index 5a17c108ccc..cd3741356f4 100644 --- a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.rs +++ b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.rs @@ -8,16 +8,12 @@ impl Bar for Qux {} fn foo() -> impl Bar { //~^ ERROR the trait bound `(): Bar` is not satisfied - //~| ERROR the trait bound `(): Bar` is not satisfied - //~| HELP the following other types implement trait `Bar`: 5; //~^ HELP remove this semicolon } fn bar() -> impl Bar { //~^ ERROR the trait bound `(): Bar` is not satisfied - //~| ERROR the trait bound `(): Bar` is not satisfied - //~| HELP the following other types implement trait `Bar`: //~| HELP the following other types implement trait `Bar`: ""; } diff --git a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index 43f8b7c66f0..e74c2c4214f 100644 --- a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -3,31 +3,14 @@ error[E0277]: the trait bound `(): Bar` is not satisfied | LL | fn foo() -> impl Bar { | ^^^^^^^^ the trait `Bar` is not implemented for `()` -... +LL | LL | 5; | -- help: remove this semicolon | | | this expression has type `{integer}`, which implements `Bar` error[E0277]: the trait bound `(): Bar` is not satisfied - --> $DIR/impl-trait-return-trailing-semicolon.rs:9:22 - | -LL | fn foo() -> impl Bar { - | ______________________^ -LL | | -LL | | -LL | | -LL | | 5; -LL | | -LL | | } - | |_^ the trait `Bar` is not implemented for `()` - | - = help: the following other types implement trait `Bar`: - Qux - i32 - -error[E0277]: the trait bound `(): Bar` is not satisfied - --> $DIR/impl-trait-return-trailing-semicolon.rs:17:13 + --> $DIR/impl-trait-return-trailing-semicolon.rs:15:13 | LL | fn bar() -> impl Bar { | ^^^^^^^^ the trait `Bar` is not implemented for `()` @@ -36,23 +19,6 @@ LL | fn bar() -> impl Bar { Qux i32 -error[E0277]: the trait bound `(): Bar` is not satisfied - --> $DIR/impl-trait-return-trailing-semicolon.rs:17:22 - | -LL | fn bar() -> impl Bar { - | ______________________^ -LL | | -LL | | -LL | | -LL | | -LL | | ""; -LL | | } - | |_^ the trait `Bar` is not implemented for `()` - | - = help: the following other types implement trait `Bar`: - Qux - i32 - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr b/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr index 6255df06efb..8ec7b7bf496 100644 --- a/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr +++ b/src/test/ui/suggestions/impl-trait-with-missing-trait-bounds-in-arg.stderr @@ -8,7 +8,7 @@ LL | foo.hello(); help: the following trait defines an item `hello`, perhaps you need to restrict type parameter `impl Foo` with it: | LL | fn test(foo: impl Foo + Bar) { - | ~~~~~~~~~~~~~~ + | +++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/issue-21673.stderr b/src/test/ui/suggestions/issue-21673.stderr index eda29f876d8..0a4aaa61bc7 100644 --- a/src/test/ui/suggestions/issue-21673.stderr +++ b/src/test/ui/suggestions/issue-21673.stderr @@ -7,8 +7,8 @@ LL | x.method() = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it: | -LL | fn call_method<T: Foo + std::fmt::Debug>(x: &T) { - | ~~~~~~~~ +LL | fn call_method<T: std::fmt::Debug + Foo>(x: &T) { + | +++++ error[E0599]: no method named `method` found for type parameter `T` in the current scope --> $DIR/issue-21673.rs:10:7 @@ -20,7 +20,7 @@ LL | x.method() help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it: | LL | fn call_method_2<T: Foo>(x: T) { - | ~~~~~~ + | +++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/issue-81098.rs b/src/test/ui/suggestions/issue-81098.rs index 7ca7380a7be..a601b5866f4 100644 --- a/src/test/ui/suggestions/issue-81098.rs +++ b/src/test/ui/suggestions/issue-81098.rs @@ -1,14 +1,12 @@ // Don't suggest removing a semicolon if the last statement isn't an expression with semicolon // (#81098) fn wat() -> impl core::fmt::Display { //~ ERROR: `()` doesn't implement `std::fmt::Display` - //~^ ERROR: `()` doesn't implement `std::fmt::Display` fn why() {} } // Do it if the last statement is an expression with semicolon // (#54771) fn ok() -> impl core::fmt::Display { //~ ERROR: `()` doesn't implement `std::fmt::Display` - //~^ ERROR: `()` doesn't implement `std::fmt::Display` 1; } diff --git a/src/test/ui/suggestions/issue-81098.stderr b/src/test/ui/suggestions/issue-81098.stderr index 8665f2e70a8..4dc47a20282 100644 --- a/src/test/ui/suggestions/issue-81098.stderr +++ b/src/test/ui/suggestions/issue-81098.stderr @@ -8,24 +8,10 @@ LL | fn wat() -> impl core::fmt::Display { = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-81098.rs:3:37 - | -LL | fn wat() -> impl core::fmt::Display { - | _____________________________________^ -LL | | -LL | | fn why() {} -LL | | } - | |_^ `()` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - -error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-81098.rs:10:12 + --> $DIR/issue-81098.rs:9:12 | LL | fn ok() -> impl core::fmt::Display { | ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter -LL | LL | 1; | -- help: remove this semicolon | | @@ -34,19 +20,6 @@ LL | 1; = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead -error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-81098.rs:10:36 - | -LL | fn ok() -> impl core::fmt::Display { - | ____________________________________^ -LL | | -LL | | 1; -LL | | } - | |_^ `()` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr index d38d66c0885..0212c2d712c 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.nll.stderr @@ -1,8 +1,6 @@ error[E0311]: the parameter type `T` may not live long enough --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 | -LL | fn func<T: Test>(foo: &Foo, t: T) { - | -- help: consider adding an explicit lifetime bound...: `T: 'a +` LL | / foo.bar(move |_| { LL | | LL | | t.test(); @@ -22,6 +20,10 @@ LL | | LL | | t.test(); LL | | }); | |______^ +help: consider adding an explicit lifetime bound... + | +LL | fn func<T: Test + 'a>(foo: &Foo, t: T) { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr index adb928aa8a3..5d195e5ff32 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr @@ -1,8 +1,6 @@ error[E0311]: the parameter type `T` may not live long enough --> $DIR/missing-lifetimes-in-signature-2.rs:20:9 | -LL | fn func<T: Test>(foo: &Foo, t: T) { - | -- help: consider adding an explicit lifetime bound...: `T: 'a +` LL | foo.bar(move |_| { | ^^^ | @@ -21,6 +19,10 @@ note: ...that is required by this bound | LL | F: 'a, | ^^ +help: consider adding an explicit lifetime bound... + | +LL | fn func<T: Test + 'a>(foo: &Foo, t: T) { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr index 4a18e0a4f8b..24eac64d334 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.nll.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:38:11 + --> $DIR/missing-lifetimes-in-signature.rs:37:11 | LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -24,11 +24,8 @@ LL | fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:32:5 + --> $DIR/missing-lifetimes-in-signature.rs:31:5 | -LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | - help: consider adding an explicit lifetime bound...: `G: 'a` -... LL | / move || { LL | | *dest = g.get(); LL | | } @@ -40,87 +37,94 @@ note: the parameter type `G` must be valid for the anonymous lifetime defined he LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:32:5 + --> $DIR/missing-lifetimes-in-signature.rs:31:5 | LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ +help: consider adding an explicit lifetime bound... + | +LL | G: Get<T> + 'a, + | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:55:5 + --> $DIR/missing-lifetimes-in-signature.rs:53:5 | -LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | -- help: consider adding an explicit lifetime bound...: `G: 'b +` -... LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:49:34 + --> $DIR/missing-lifetimes-in-signature.rs:48:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:55:5 + --> $DIR/missing-lifetimes-in-signature.rs:53:5 | LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ +help: consider adding an explicit lifetime bound... + | +LL | fn qux<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:65:9 + --> $DIR/missing-lifetimes-in-signature.rs:62:9 | -LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | -- help: consider adding an explicit lifetime bound...: `G: 'c +` -... LL | / move || { LL | | *dest = g.get(); LL | | } | |_________^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:62:47 + --> $DIR/missing-lifetimes-in-signature.rs:60:47 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:65:9 + --> $DIR/missing-lifetimes-in-signature.rs:62:9 | LL | / move || { LL | | *dest = g.get(); LL | | } | |_________^ +help: consider adding an explicit lifetime bound... + | +LL | fn qux<'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { + | ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:77:5 + --> $DIR/missing-lifetimes-in-signature.rs:74:5 | -LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a - | -- help: consider adding an explicit lifetime bound...: `G: 'b +` -... LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:72:34 + --> $DIR/missing-lifetimes-in-signature.rs:69:34 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ^^^^^^ note: ...so that the type `G` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:77:5 + --> $DIR/missing-lifetimes-in-signature.rs:74:5 | LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ +help: consider adding an explicit lifetime bound... + | +LL | fn bat<'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a + | ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:77:5 + --> $DIR/missing-lifetimes-in-signature.rs:74:5 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` @@ -131,15 +135,17 @@ LL | | } | |_____^ lifetime `'a` required error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:89:5 + --> $DIR/missing-lifetimes-in-signature.rs:85:5 | -LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | - help: consider adding an explicit lifetime bound...: `G: 'a` -... LL | / move || { LL | | *dest = g.get(); LL | | } | |_____^ ...so that the type `G` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | G: Get<T> + 'a, + | ++++ error: aborting due to 8 previous errors diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs index 647b343fe06..0a3e6b48163 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.rs @@ -28,7 +28,6 @@ fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ where G: Get<T>, { - //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } @@ -51,7 +50,6 @@ fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ where G: Get<T>, { - //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } @@ -61,7 +59,6 @@ where impl<'a> Foo { fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { //~^ ERROR the parameter type `G` may not live long enough - //~| ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } @@ -85,7 +82,6 @@ fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a where G: Get<T>, { - //~^ ERROR the parameter type `G` may not live long enough move || { *dest = g.get(); } diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 6d538dfd609..ae9a020a099 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/missing-lifetimes-in-signature.rs:38:11 + --> $DIR/missing-lifetimes-in-signature.rs:37:11 | LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | - ^^ undeclared lifetime @@ -34,172 +34,63 @@ note: the parameter type `G` must be valid for the anonymous lifetime defined he | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:32:5: 34:6]` will meet its required lifetime bounds +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:31:5: 33:6]` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature.rs:26:37 | LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ help: consider introducing an explicit lifetime bound | -LL | fn bar<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a - | ~~~~~ ++++ - -error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:30:1 - | -LL | / { -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_^ - | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:26:26 - | -LL | fn bar<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:32:5: 34:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:30:1 - | -LL | / { -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_^ -help: consider introducing an explicit lifetime bound - | -LL ~ fn bar<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ +LL ~ fn bar<'a, G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a LL | LL | where -LL | G: Get<T>, -LL | { -LL | - ... +LL ~ G: Get<T> + 'a, + | error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:49:45 + --> $DIR/missing-lifetimes-in-signature.rs:48:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:49:34 + --> $DIR/missing-lifetimes-in-signature.rs:48:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:55:5: 57:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:49:45 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:53:5: 55:6]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:48:45 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ | ^^^^^^^^^^^^^^^^^^ help: consider introducing an explicit lifetime bound | -LL | fn qux<'b, 'a, G: 'b + 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'b - | +++ ~~~~~~~ ++++ - -error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:53:1 - | -LL | / { -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_^ - | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:49:34 - | -LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:55:5: 57:6]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:53:1 - | -LL | / { -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_^ -help: consider introducing an explicit lifetime bound - | -LL ~ fn qux<'b, 'a, G: 'b + 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ -LL | -LL | where -LL | G: Get<T>, -LL | { -LL | - ... +LL | fn qux<'b, 'a, G: 'a + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'b + | +++ ++++ ++++ error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:62:58 + --> $DIR/missing-lifetimes-in-signature.rs:60:58 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ | note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:62:47 + --> $DIR/missing-lifetimes-in-signature.rs:60:47 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:65:9: 67:10]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:62:58 +note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:62:9: 64:10]` will meet its required lifetime bounds + --> $DIR/missing-lifetimes-in-signature.rs:60:58 | LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { | ^^^^^^^^^^^^^^^^^^ help: consider introducing an explicit lifetime bound | -LL | fn qux<'c, 'b, G: 'c + Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'c { - | +++ ~~~~~~~ ++++ - -error[E0311]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:62:77 - | -LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | _____________________________________________________________________________^ -LL | | -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_____^ - | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature.rs:62:47 - | -LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | ^^^^^^ -note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:65:9: 67:10]` will meet its required lifetime bounds - --> $DIR/missing-lifetimes-in-signature.rs:62:77 - | -LL | fn qux<'b, G: Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | _____________________________________________________________________________^ -LL | | -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_____^ -help: consider introducing an explicit lifetime bound - | -LL ~ fn qux<'c, 'b, G: 'c + Get<T> + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { -LL | -LL | -LL | move || { -LL | *dest = g.get(); -LL | } - ... +LL | fn qux<'c, 'b, G: Get<T> + 'b + 'c, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'c { + | +++ ++++ ++++ error[E0621]: explicit lifetime required in the type of `dest` - --> $DIR/missing-lifetimes-in-signature.rs:72:45 + --> $DIR/missing-lifetimes-in-signature.rs:69:45 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | ------ ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required @@ -207,28 +98,17 @@ LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a | help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T` error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:83:44 + --> $DIR/missing-lifetimes-in-signature.rs:80:44 | LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | - ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:89:5: 91:6]` will meet its required lifetime bounds - | | - | help: consider adding an explicit lifetime bound...: `G: 'a` - -error[E0309]: the parameter type `G` may not live long enough - --> $DIR/missing-lifetimes-in-signature.rs:87:1 + | ^^^^^^^^^^^^^^^^^^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:85:5: 87:6]` will meet its required lifetime bounds | -LL | fn bak<'a, G, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a - | - help: consider adding an explicit lifetime bound...: `G: 'a` -... -LL | / { -LL | | -LL | | move || { -LL | | *dest = g.get(); -LL | | } -LL | | } - | |_^ ...so that the type `[closure@$DIR/missing-lifetimes-in-signature.rs:89:5: 91:6]` will meet its required lifetime bounds +help: consider adding an explicit lifetime bound... + | +LL | G: Get<T> + 'a, + | ++++ -error: aborting due to 11 previous errors +error: aborting due to 7 previous errors Some errors have detailed explanations: E0261, E0309, E0621, E0700. For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/suggestions/restrict-type-argument.stderr b/src/test/ui/suggestions/restrict-type-argument.stderr index 551a7c5060f..01c2de79864 100644 --- a/src/test/ui/suggestions/restrict-type-argument.stderr +++ b/src/test/ui/suggestions/restrict-type-argument.stderr @@ -85,8 +85,8 @@ LL | fn is_send<T: Send>(val: T) {} | ^^^^ required by this bound in `is_send` help: consider further restricting this bound | -LL | fn use_bound_and_where<S: Sync>(val: S) where S: std::fmt::Debug + std::marker::Send { - | +++++++++++++++++++ +LL | fn use_bound_and_where<S: Sync + std::marker::Send>(val: S) where S: std::fmt::Debug { + | +++++++++++++++++++ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:28:13 diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr index 72354eaaee1..cf912f4aac2 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.nll.stderr @@ -1,11 +1,13 @@ error[E0310]: the parameter type `impl Debug` may not live long enough --> $DIR/suggest-impl-trait-lifetime.rs:7:5 | -LL | fn foo(d: impl Debug) { - | ---------- help: consider adding an explicit lifetime bound...: `impl Debug + 'static` -LL | LL | bar(d); | ^^^^^^ ...so that the type `impl Debug` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn foo(d: impl Debug + 'static) { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr index e4a247993c2..4a99c3a14d7 100644 --- a/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr +++ b/src/test/ui/suggestions/suggest-impl-trait-lifetime.stderr @@ -1,9 +1,6 @@ error[E0310]: the parameter type `impl Debug` may not live long enough --> $DIR/suggest-impl-trait-lifetime.rs:7:5 | -LL | fn foo(d: impl Debug) { - | ---------- help: consider adding an explicit lifetime bound...: `impl Debug + 'static` -LL | LL | bar(d); | ^^^ ...so that the type `impl Debug` will meet its required lifetime bounds... | @@ -12,6 +9,10 @@ note: ...that is required by this bound | LL | fn bar(d: impl Debug + 'static) { | ^^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | fn foo(d: impl Debug + 'static) { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/symbol-names/x86-stdcall.rs b/src/test/ui/symbol-names/x86-stdcall.rs new file mode 100644 index 00000000000..9948488c0e9 --- /dev/null +++ b/src/test/ui/symbol-names/x86-stdcall.rs @@ -0,0 +1,13 @@ +// build-pass +// only-x86-windows +#![crate_type = "cdylib"] +#![feature(abi_vectorcall)] + +#[no_mangle] +extern "stdcall" fn foo(_: bool) {} + +#[no_mangle] +extern "fastcall" fn bar(_: u8) {} + +#[no_mangle] +extern "vectorcall" fn baz(_: u16) {} diff --git a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs new file mode 100644 index 00000000000..9a444be500c --- /dev/null +++ b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs @@ -0,0 +1,20 @@ +struct Thing<X>(X); + +trait Method<T> { + fn method(self, _: i32) -> T; +} + +impl<X> Method<i32> for Thing<X> { + fn method(self, _: i32) -> i32 { 0 } +} + +impl<X> Method<u32> for Thing<X> { + fn method(self, _: i32) -> u32 { 0 } +} + +fn main() { + let thing = Thing(true); + thing.method(42); + //~^ ERROR type annotations needed + //~| ERROR type annotations needed +} diff --git a/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr new file mode 100644 index 00000000000..0e52420ec43 --- /dev/null +++ b/src/test/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr @@ -0,0 +1,37 @@ +error[E0282]: type annotations needed + --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 + | +LL | thing.method(42); + | ------^^^^^^---- + | | | + | | cannot infer type for type parameter `T` declared on the trait `Method` + | this method call resolves to `T` + +error[E0283]: type annotations needed + --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 + | +LL | thing.method(42); + | ------^^^^^^---- + | | | + | | cannot infer type for type parameter `T` declared on the trait `Method` + | this method call resolves to `T` + | +note: multiple `impl`s satisfying `Thing<bool>: Method<_>` found + --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1 + | +LL | impl<X> Method<i32> for Thing<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl<X> Method<u32> for Thing<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: use the fully qualified path for the potential candidates + | +LL | <Thing<_> as Method<i32>>::method(thing, 42); + | ++++++++++++++++++++++++++++++++++ ~ +LL | <Thing<_> as Method<u32>>::method(thing, 42); + | ++++++++++++++++++++++++++++++++++ ~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0283. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/traits/issue-65284-suggest-generic-trait-bound.stderr b/src/test/ui/traits/issue-65284-suggest-generic-trait-bound.stderr index cb1128fe5c6..35d41c62667 100644 --- a/src/test/ui/traits/issue-65284-suggest-generic-trait-bound.stderr +++ b/src/test/ui/traits/issue-65284-suggest-generic-trait-bound.stderr @@ -7,8 +7,8 @@ LL | t.foo() = help: items from traits can only be used if the type parameter is bounded by the trait help: the following trait defines an item `foo`, perhaps you need to restrict type parameter `T` with it: | -LL | fn do_stuff<T: Foo + Bar>(t : T) { - | ~~~~~~~~ +LL | fn do_stuff<T : Bar + Foo>(t : T) { + | +++++ error: aborting due to previous error diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr index 413225d45a6..63c1cb3791e 100644 --- a/src/test/ui/traits/issue-77982.stderr +++ b/src/test/ui/traits/issue-77982.stderr @@ -37,13 +37,13 @@ LL | opts.get(opt.as_ref()); help: use the fully qualified path for the potential candidates | LL | opts.get(<String as AsRef<OsStr>>::as_ref(opt)); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++++++++++++++++++++++++ ~ LL | opts.get(<String as AsRef<Path>>::as_ref(opt)); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++++++++++++++++++++ ~ LL | opts.get(<String as AsRef<[u8]>>::as_ref(opt)); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ++++++++++++++++++++++++++++++++ ~ LL | opts.get(<String as AsRef<str>>::as_ref(opt)); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | +++++++++++++++++++++++++++++++ ~ and 4 other candidates error[E0283]: type annotations needed diff --git a/src/test/ui/traits/issue-95898.stderr b/src/test/ui/traits/issue-95898.stderr index d7d47905396..0a58ad4b663 100644 --- a/src/test/ui/traits/issue-95898.stderr +++ b/src/test/ui/traits/issue-95898.stderr @@ -8,7 +8,7 @@ LL | t.clone(); help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `T` with it: | LL | fn foo<T: Clone>(t: T) { - | ~~~~~~~~ + | +++++ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr index d87ef2ec79c..920eef11da4 100644 --- a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr +++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr @@ -2,7 +2,7 @@ warning: unnecessary lifetime parameter `'a` --> $DIR/bounds-are-checked.rs:8:6 | LL | fn f<'a: 'static>(t: &'a str) -> X<'a> { - | ^^^^^^^^^^^ + | ^^ | = help: you can use the `'static` lifetime directly, in place of `'a` diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.base.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.base.stderr index a3b410c2cfb..593fb8af32f 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.base.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.base.stderr @@ -19,10 +19,13 @@ LL | type WrongGeneric<T> = impl 'static; error[E0310]: the parameter type `T` may not live long enough --> $DIR/generic_type_does_not_live_long_enough.rs:18:5 | -LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` LL | t | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn wrong_generic<T: 'static>(t: T) -> WrongGeneric<T> { + | +++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr index a3b410c2cfb..593fb8af32f 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr @@ -19,10 +19,13 @@ LL | type WrongGeneric<T> = impl 'static; error[E0310]: the parameter type `T` may not live long enough --> $DIR/generic_type_does_not_live_long_enough.rs:18:5 | -LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` LL | t | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | fn wrong_generic<T: 'static>(t: T) -> WrongGeneric<T> { + | +++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs index 314e5362a8f..82248971692 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs @@ -11,7 +11,6 @@ impl Foo<()> for () { } fn foo() -> impl Foo<FooX> { //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied - //~| ERROR: the trait bound `(): Foo<FooX>` is not satisfied // FIXME(type-alias-impl-trait): We could probably make this work. () } diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr index 0df2b57d373..f98da9f7f92 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr @@ -6,20 +6,6 @@ LL | fn foo() -> impl Foo<FooX> { | = help: the trait `Foo<()>` is implemented for `()` -error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied - --> $DIR/nested-tait-inference.rs:12:28 - | -LL | fn foo() -> impl Foo<FooX> { - | ____________________________^ -LL | | -LL | | -LL | | // FIXME(type-alias-impl-trait): We could probably make this work. -LL | | () -LL | | } - | |_^ the trait `Foo<FooX>` is not implemented for `()` - | - = help: the trait `Foo<()>` is implemented for `()` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs index 4dc30d9257b..0d7f5bad25f 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs @@ -12,7 +12,6 @@ impl Foo<u32> for () {} fn foo() -> impl Foo<FooX> { //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied - //~| ERROR: the trait bound `(): Foo<FooX>` is not satisfied () } diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index 264e8024fac..54f571ad3e3 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -8,21 +8,6 @@ LL | fn foo() -> impl Foo<FooX> { <() as Foo<()>> <() as Foo<u32>> -error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied - --> $DIR/nested-tait-inference2.rs:13:28 - | -LL | fn foo() -> impl Foo<FooX> { - | ____________________________^ -LL | | -LL | | -LL | | () -LL | | } - | |_^ the trait `Foo<FooX>` is not implemented for `()` - | - = help: the following other types implement trait `Foo<A>`: - <() as Foo<()>> - <() as Foo<u32>> - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr index 8e10242cb13..a4dece320ec 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ~~ ~~ error: aborting due to previous error diff --git a/src/test/ui/unused-crate-deps/deny-attr.rs b/src/test/ui/unused-crate-deps/deny-attr.rs new file mode 100644 index 00000000000..e9ab18ff63f --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-attr.rs @@ -0,0 +1,9 @@ +// Check for unused crate dep, no path + +// edition:2018 +// aux-crate:bar=bar.rs + +#![deny(unused_crate_dependencies)] +//~^ ERROR external crate `bar` unused in + +fn main() {} diff --git a/src/test/ui/unused-crate-deps/deny-attr.stderr b/src/test/ui/unused-crate-deps/deny-attr.stderr new file mode 100644 index 00000000000..93694f6827f --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-attr.stderr @@ -0,0 +1,14 @@ +error: external crate `bar` unused in `deny_attr`: remove the dependency or add `use bar as _;` + --> $DIR/deny-attr.rs:6:1 + | +LL | #![deny(unused_crate_dependencies)] + | ^ + | +note: the lint level is defined here + --> $DIR/deny-attr.rs:6:9 + | +LL | #![deny(unused_crate_dependencies)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.rs b/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.rs new file mode 100644 index 00000000000..fd9a61d6caa --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.rs @@ -0,0 +1,8 @@ +// Check for unused crate dep, json event, deny but we're not reporting that in exit status + +// edition:2018 +// check-pass +// compile-flags: -Dunused-crate-dependencies -Zunstable-options --json unused-externs-silent --error-format=json +// aux-crate:bar=bar.rs + +fn main() {} diff --git a/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.stderr b/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.stderr new file mode 100644 index 00000000000..595619f3a8a --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline-json-silent.stderr @@ -0,0 +1 @@ +{"lint_level":"deny","unused_extern_names":["bar"]} diff --git a/src/test/ui/unused-crate-deps/deny-cmdline-json.rs b/src/test/ui/unused-crate-deps/deny-cmdline-json.rs new file mode 100644 index 00000000000..2b369dee5a0 --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline-json.rs @@ -0,0 +1,7 @@ +// Check for unused crate dep, json event, deny, expect compile failure + +// edition:2018 +// compile-flags: -Dunused-crate-dependencies -Zunstable-options --json unused-externs --error-format=json +// aux-crate:bar=bar.rs + +fn main() {} diff --git a/src/test/ui/unused-crate-deps/deny-cmdline-json.stderr b/src/test/ui/unused-crate-deps/deny-cmdline-json.stderr new file mode 100644 index 00000000000..595619f3a8a --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline-json.stderr @@ -0,0 +1 @@ +{"lint_level":"deny","unused_extern_names":["bar"]} diff --git a/src/test/ui/unused-crate-deps/deny-cmdline.rs b/src/test/ui/unused-crate-deps/deny-cmdline.rs new file mode 100644 index 00000000000..69e28b3319a --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline.rs @@ -0,0 +1,8 @@ +// Check for unused crate dep, deny, expect failure + +// edition:2018 +// compile-flags: -Dunused-crate-dependencies +// aux-crate:bar=bar.rs + +fn main() {} +//~^ ERROR external crate `bar` unused in diff --git a/src/test/ui/unused-crate-deps/deny-cmdline.stderr b/src/test/ui/unused-crate-deps/deny-cmdline.stderr new file mode 100644 index 00000000000..0951dc670fe --- /dev/null +++ b/src/test/ui/unused-crate-deps/deny-cmdline.stderr @@ -0,0 +1,10 @@ +error: external crate `bar` unused in `deny_cmdline`: remove the dependency or add `use bar as _;` + --> $DIR/deny-cmdline.rs:7:1 + | +LL | fn main() {} + | ^ + | + = note: requested on the command line with `-D unused-crate-dependencies` + +error: aborting due to previous error + diff --git a/src/test/ui/unused-crate-deps/warn-cmdline-json.rs b/src/test/ui/unused-crate-deps/warn-cmdline-json.rs new file mode 100644 index 00000000000..4826c0062d0 --- /dev/null +++ b/src/test/ui/unused-crate-deps/warn-cmdline-json.rs @@ -0,0 +1,8 @@ +// Check for unused crate dep, warn, json event, expect pass + +// edition:2018 +// check-pass +// compile-flags: -Wunused-crate-dependencies -Zunstable-options --json unused-externs --error-format=json +// aux-crate:bar=bar.rs + +fn main() {} diff --git a/src/test/ui/unused-crate-deps/warn-cmdline-json.stderr b/src/test/ui/unused-crate-deps/warn-cmdline-json.stderr new file mode 100644 index 00000000000..98dbd763927 --- /dev/null +++ b/src/test/ui/unused-crate-deps/warn-cmdline-json.stderr @@ -0,0 +1 @@ +{"lint_level":"warn","unused_extern_names":["bar"]} diff --git a/src/test/ui/wf/wf-impl-associated-type-region.stderr b/src/test/ui/wf/wf-impl-associated-type-region.stderr index 3f324190b7b..b9d4857a3ef 100644 --- a/src/test/ui/wf/wf-impl-associated-type-region.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-region.stderr @@ -1,10 +1,13 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/wf-impl-associated-type-region.rs:10:16 | -LL | impl<'a, T> Foo<'a> for T { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Bar = &'a T; | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Foo<'a> for T { + | ++++ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-fn-type-static.stderr b/src/test/ui/wf/wf-in-fn-type-static.stderr index 44cacf4ef4d..73fbb9ca670 100644 --- a/src/test/ui/wf/wf-in-fn-type-static.stderr +++ b/src/test/ui/wf/wf-in-fn-type-static.stderr @@ -1,20 +1,24 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/wf-in-fn-type-static.rs:13:8 | -LL | struct Foo<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // needs T: 'static LL | x: fn() -> &'static T | ^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | struct Foo<T: 'static> { + | +++++++++ error[E0310]: the parameter type `T` may not live long enough --> $DIR/wf-in-fn-type-static.rs:18:8 | -LL | struct Bar<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // needs T: Copy LL | x: fn(&'static T) | ^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | struct Bar<T: 'static> { + | +++++++++ error: aborting due to 2 previous errors diff --git a/src/test/ui/wf/wf-in-obj-type-static.stderr b/src/test/ui/wf/wf-in-obj-type-static.stderr index c50a6bb6e4d..c3ad42dd5d5 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.stderr +++ b/src/test/ui/wf/wf-in-obj-type-static.stderr @@ -1,11 +1,13 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/wf-in-obj-type-static.rs:14:8 | -LL | struct Foo<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // needs T: 'static LL | x: dyn Object<&'static T> | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the reference type `&'static T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | struct Foo<T: 'static> { + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 68c1e9091d7..4d4d8b2ab4d 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,18 +1,24 @@ error[E0309]: the parameter type `T` may not live long enough --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:16 | -LL | impl<'a, T> Trait<'a, T> for usize { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a fn(T); | ^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for usize { + | ++++ error[E0309]: the parameter type `T` may not live long enough --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:16 | -LL | impl<'a, T> Trait<'a, T> for u32 { - | - help: consider adding an explicit lifetime bound...: `T: 'a` LL | type Out = &'a dyn Baz<T>; | ^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for u32 { + | ++++ error: aborting due to 2 previous errors |
