2020-08-27 20:00:21 +10:00
|
|
|
// check-fail
|
2022-09-18 11:45:41 -04:00
|
|
|
// Tests error conditions for specifying diagnostics using #[derive(DiagnosticHandler)]
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-06-29 09:21:44 +01:00
|
|
|
// normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
|
2022-08-31 14:46:51 +00:00
|
|
|
// normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC"
|
2021-06-07 17:08:13 +02:00
|
|
|
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
|
2022-09-18 11:45:41 -04:00
|
|
|
// changing the output of this test. Since DiagnosticHandler is strictly internal to the compiler
|
2021-06-07 17:08:13 +02:00
|
|
|
// the test is just ignored on stable and beta:
|
|
|
|
// ignore-beta
|
|
|
|
// ignore-stable
|
|
|
|
|
2020-08-27 20:00:21 +10:00
|
|
|
#![feature(rustc_private)]
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
extern crate rustc_span;
|
|
|
|
use rustc_span::symbol::Ident;
|
2022-03-30 09:45:36 +01:00
|
|
|
use rustc_span::Span;
|
2020-08-27 20:00:21 +10:00
|
|
|
|
|
|
|
extern crate rustc_macros;
|
2022-09-18 11:45:41 -04:00
|
|
|
use rustc_macros::{DiagnosticHandler, LintDiagnostic, SessionSubdiagnostic};
|
2020-08-27 20:00:21 +10:00
|
|
|
|
|
|
|
extern crate rustc_middle;
|
|
|
|
use rustc_middle::ty::Ty;
|
|
|
|
|
|
|
|
extern crate rustc_errors;
|
2022-07-11 17:15:31 +01:00
|
|
|
use rustc_errors::{Applicability, MultiSpan};
|
2020-08-27 20:00:21 +10:00
|
|
|
|
|
|
|
extern crate rustc_session;
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct Hello {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 08:35:17 +01:00
|
|
|
struct HelloWarn {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-09-18 11:45:41 -04:00
|
|
|
//~^ ERROR `#[derive(DiagnosticHandler)]` can only be used on structs
|
|
|
|
enum DiagnosticHandlerOnEnum {
|
2020-08-27 20:00:21 +10:00
|
|
|
Foo,
|
|
|
|
Bar,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
#[diag = "E0123"]
|
|
|
|
//~^ ERROR `#[diag = ...]` is not a valid attribute
|
2022-03-31 08:35:17 +01:00
|
|
|
struct WrongStructAttrStyle {}
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-04-27 04:06:13 +01:00
|
|
|
//~^ ERROR `#[nonsense(...)]` is not a valid attribute
|
2022-08-19 15:02:10 +02:00
|
|
|
//~^^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
//~^^^ ERROR cannot find attribute `nonsense` in this scope
|
|
|
|
struct InvalidStructAttr {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag("E0123")]
|
|
|
|
//~^ ERROR `#[diag("...")]` is not a valid attribute
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidLitNestedAttr {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(nonsense, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent`
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidNestedStructAttr {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(nonsense("foo"), code = "E0123", slug = "foo")]
|
|
|
|
//~^ ERROR `#[diag(nonsense(...))]` is not a valid attribute
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidNestedStructAttr1 {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(nonsense = "...", code = "E0123", slug = "foo")]
|
|
|
|
//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidNestedStructAttr2 {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(nonsense = 4, code = "E0123", slug = "foo")]
|
|
|
|
//~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidNestedStructAttr3 {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")]
|
|
|
|
//~^ ERROR `#[diag(slug = ...)]` is not a valid attribute
|
2022-06-23 14:51:44 +01:00
|
|
|
struct InvalidNestedStructAttr4 {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct WrongPlaceField {
|
2022-03-31 13:10:13 +01:00
|
|
|
#[suggestion = "bar"]
|
2022-04-27 04:06:13 +01:00
|
|
|
//~^ ERROR `#[suggestion = ...]` is not a valid attribute
|
2020-08-27 20:00:21 +10:00
|
|
|
sp: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
|
2022-04-27 04:28:21 +01:00
|
|
|
//~^ ERROR specified multiple times
|
|
|
|
//~^^ ERROR specified multiple times
|
2022-08-19 15:40:48 +02:00
|
|
|
struct DiagSpecifiedTwice {}
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")]
|
2022-04-27 04:28:21 +01:00
|
|
|
//~^ ERROR specified multiple times
|
2022-03-31 08:35:17 +01:00
|
|
|
struct CodeSpecifiedTwice {}
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")]
|
|
|
|
//~^ ERROR `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute
|
2022-03-31 08:35:17 +01:00
|
|
|
struct SlugSpecifiedTwice {}
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:02:10 +02:00
|
|
|
struct KindNotProvided {} //~ ERROR diagnostic slug not specified
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(code = "E0456")]
|
2022-06-23 14:51:44 +01:00
|
|
|
//~^ ERROR diagnostic slug not specified
|
2022-03-31 08:35:17 +01:00
|
|
|
struct SlugNotProvided {}
|
2020-08-27 20:00:21 +10:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound)]
|
2022-03-31 08:35:17 +01:00
|
|
|
struct CodeNotProvided {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 08:35:17 +01:00
|
|
|
struct MessageWrongType {
|
2022-03-31 08:50:45 +01:00
|
|
|
#[primary_span]
|
2022-07-11 17:15:31 +01:00
|
|
|
//~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
2022-03-31 08:35:17 +01:00
|
|
|
foo: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 08:35:17 +01:00
|
|
|
struct InvalidPathFieldAttr {
|
|
|
|
#[nonsense]
|
2022-04-27 04:06:13 +01:00
|
|
|
//~^ ERROR `#[nonsense]` is not a valid attribute
|
2022-03-31 08:35:17 +01:00
|
|
|
//~^^ ERROR cannot find attribute `nonsense` in this scope
|
|
|
|
foo: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorWithField {
|
|
|
|
name: String,
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2022-03-30 10:04:03 +01:00
|
|
|
span: Span,
|
2020-08-27 20:00:21 +10:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorWithMessageAppliedToField {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2022-07-11 17:15:31 +01:00
|
|
|
//~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
2020-08-27 20:00:21 +10:00
|
|
|
name: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorWithNonexistentField {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "{name}")]
|
2022-03-31 08:35:17 +01:00
|
|
|
//~^ ERROR `name` doesn't refer to a field on this type
|
2022-03-31 10:24:46 +01:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 20:00:21 +10:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2020-08-27 20:00:21 +10:00
|
|
|
//~^ ERROR invalid format string: expected `'}'`
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorMissingClosingBrace {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "{name")]
|
2022-03-31 10:24:46 +01:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 20:00:21 +10:00
|
|
|
name: String,
|
2022-03-30 09:45:36 +01:00
|
|
|
val: usize,
|
2020-08-27 20:00:21 +10:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2020-08-27 20:00:21 +10:00
|
|
|
//~^ ERROR invalid format string: unmatched `}`
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorMissingOpeningBrace {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "name}")]
|
2022-03-31 10:24:46 +01:00
|
|
|
suggestion: (Span, Applicability),
|
2020-08-27 20:00:21 +10:00
|
|
|
name: String,
|
2022-03-30 09:45:36 +01:00
|
|
|
val: usize,
|
2020-08-27 20:00:21 +10:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct LabelOnSpan {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2022-03-30 10:04:03 +01:00
|
|
|
sp: Span,
|
2020-08-27 20:00:21 +10:00
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct LabelOnNonSpan {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2022-07-11 17:15:31 +01:00
|
|
|
//~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
|
2020-08-27 20:00:21 +10:00
|
|
|
id: u32,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct Suggest {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is the suggested code")]
|
|
|
|
#[suggestion_short(typeck::suggestion, code = "This is the suggested code")]
|
|
|
|
#[suggestion_hidden(typeck::suggestion, code = "This is the suggested code")]
|
|
|
|
#[suggestion_verbose(typeck::suggestion, code = "This is the suggested code")]
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithoutCode {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion)]
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithBadKey {
|
2022-03-31 13:10:13 +01:00
|
|
|
#[suggestion(nonsense = "bar")]
|
2022-04-27 04:06:13 +01:00
|
|
|
//~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithShorthandMsg {
|
2022-03-31 13:10:13 +01:00
|
|
|
#[suggestion(msg = "bar")]
|
2022-04-27 04:06:13 +01:00
|
|
|
//~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithoutMsg {
|
2022-03-31 13:10:13 +01:00
|
|
|
#[suggestion(code = "bar")]
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithTypesSwapped {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is suggested code")]
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Applicability, Span),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithWrongTypeApplicabilityOnly {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is suggested code")]
|
2020-08-27 20:00:21 +10:00
|
|
|
//~^ ERROR wrong field type for suggestion
|
|
|
|
suggestion: Applicability,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-30 10:04:03 +01:00
|
|
|
struct SuggestWithSpanOnly {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is suggested code")]
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithDuplicateSpanAndApplicability {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is suggested code")]
|
2022-03-30 10:04:03 +01:00
|
|
|
//~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one `Span`
|
2020-08-27 20:00:21 +10:00
|
|
|
suggestion: (Span, Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct SuggestWithDuplicateApplicabilityAndSpan {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "This is suggested code")]
|
2020-08-27 20:00:21 +10:00
|
|
|
//~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one
|
|
|
|
suggestion: (Applicability, Applicability, Span),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct WrongKindOfAnnotation {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label = "bar"]
|
|
|
|
//~^ ERROR `#[label = ...]` is not a valid attribute
|
2020-08-27 20:00:21 +10:00
|
|
|
z: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct OptionsInErrors {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2020-08-27 20:00:21 +10:00
|
|
|
label: Option<Span>,
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion)]
|
2020-08-27 20:00:21 +10:00
|
|
|
opt_sugg: Option<(Span, Applicability)>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct MoveOutOfBorrowError<'tcx> {
|
|
|
|
name: Ident,
|
|
|
|
ty: Ty<'tcx>,
|
2022-03-31 08:50:45 +01:00
|
|
|
#[primary_span]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2020-08-27 20:00:21 +10:00
|
|
|
span: Span,
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2020-08-27 20:00:21 +10:00
|
|
|
other_span: Span,
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "{name}.clone()")]
|
2020-08-27 20:00:21 +10:00
|
|
|
opt_sugg: Option<(Span, Applicability)>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2020-08-27 20:00:21 +10:00
|
|
|
struct ErrorWithLifetime<'a> {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[label(typeck::label)]
|
2022-03-31 10:24:46 +01:00
|
|
|
span: Span,
|
|
|
|
name: &'a str,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 10:24:46 +01:00
|
|
|
struct ErrorWithDefaultLabelAttr<'a> {
|
|
|
|
#[label]
|
2020-08-27 20:00:21 +10:00
|
|
|
span: Span,
|
|
|
|
name: &'a str,
|
|
|
|
}
|
2022-03-31 09:02:31 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-05-07 07:26:03 +01:00
|
|
|
//~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 09:02:31 +01:00
|
|
|
struct ArgFieldWithoutSkip {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
other: Hello,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 09:02:31 +01:00
|
|
|
struct ArgFieldWithSkip {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
// `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
|
|
|
|
// not for `#[skip_arg]`.
|
|
|
|
#[skip_arg]
|
|
|
|
other: Hello,
|
|
|
|
}
|
2022-03-31 12:10:00 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithSpannedNote {
|
|
|
|
#[note]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithSpannedNoteCustom {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[note(typeck::note)]
|
2022-03-31 12:10:00 +01:00
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
#[note]
|
|
|
|
struct ErrorWithNote {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[note(typeck::note)]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithNoteCustom {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithSpannedHelp {
|
|
|
|
#[help]
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithSpannedHelpCustom {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[help(typeck::help)]
|
2022-03-31 12:10:00 +01:00
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
#[help]
|
|
|
|
struct ErrorWithHelp {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[help(typeck::help)]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithHelpCustom {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-03-31 12:10:00 +01:00
|
|
|
#[help]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithHelpWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[help(typeck::help)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithHelpCustomWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-03-31 12:10:00 +01:00
|
|
|
#[note]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithNoteWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-06-23 14:51:44 +01:00
|
|
|
#[note(typeck::note)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-03-31 12:10:00 +01:00
|
|
|
struct ErrorWithNoteCustomWrongOrder {
|
|
|
|
val: String,
|
|
|
|
}
|
2022-04-27 05:43:36 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-04-27 05:43:36 +01:00
|
|
|
struct ApplicabilityInBoth {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")]
|
2022-04-27 05:43:36 +01:00
|
|
|
//~^ ERROR applicability cannot be set in both the field and attribute
|
|
|
|
suggestion: (Span, Applicability),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-04-27 05:43:36 +01:00
|
|
|
struct InvalidApplicability {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "...", applicability = "batman")]
|
2022-04-27 05:43:36 +01:00
|
|
|
//~^ ERROR invalid applicability
|
|
|
|
suggestion: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-04-27 05:43:36 +01:00
|
|
|
struct ValidApplicability {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")]
|
2022-04-27 05:43:36 +01:00
|
|
|
suggestion: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-04-27 05:43:36 +01:00
|
|
|
struct NoApplicability {
|
2022-06-23 14:51:44 +01:00
|
|
|
#[suggestion(typeck::suggestion, code = "...")]
|
2022-04-27 05:43:36 +01:00
|
|
|
suggestion: Span,
|
|
|
|
}
|
2022-04-27 05:59:48 +01:00
|
|
|
|
|
|
|
#[derive(SessionSubdiagnostic)]
|
2022-06-23 16:12:52 +01:00
|
|
|
#[note(parser::add_paren)]
|
2022-04-27 05:59:48 +01:00
|
|
|
struct Note;
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound)]
|
2022-04-27 05:59:48 +01:00
|
|
|
struct Subdiagnostic {
|
|
|
|
#[subdiagnostic]
|
|
|
|
note: Note,
|
|
|
|
}
|
2022-05-06 03:43:30 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-05-06 03:43:30 +01:00
|
|
|
struct VecField {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
spans: Vec<Span>,
|
|
|
|
}
|
2022-05-07 06:02:11 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-05-07 06:02:11 +01:00
|
|
|
struct UnitField {
|
|
|
|
#[primary_span]
|
|
|
|
spans: Span,
|
|
|
|
#[help]
|
|
|
|
foo: (),
|
2022-06-23 14:51:44 +01:00
|
|
|
#[help(typeck::help)]
|
2022-05-07 06:02:11 +01:00
|
|
|
bar: (),
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-05-07 06:02:11 +01:00
|
|
|
struct OptUnitField {
|
|
|
|
#[primary_span]
|
|
|
|
spans: Span,
|
|
|
|
#[help]
|
|
|
|
foo: Option<()>,
|
2022-06-23 14:51:44 +01:00
|
|
|
#[help(typeck::help)]
|
2022-05-07 06:02:11 +01:00
|
|
|
bar: Option<()>,
|
|
|
|
}
|
2022-06-23 14:51:44 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
struct LabelWithTrailingPath {
|
|
|
|
#[label(typeck::label, foo)]
|
|
|
|
//~^ ERROR `#[label(...)]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
struct LabelWithTrailingNameValue {
|
|
|
|
#[label(typeck::label, foo = "...")]
|
|
|
|
//~^ ERROR `#[label(...)]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-06-23 14:51:44 +01:00
|
|
|
struct LabelWithTrailingList {
|
|
|
|
#[label(typeck::label, foo("..."))]
|
|
|
|
//~^ ERROR `#[label(...)]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
}
|
2022-06-30 08:57:45 +01:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound)]
|
2022-06-30 08:57:45 +01:00
|
|
|
struct LintsGood {
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound)]
|
2022-08-19 15:04:34 +02:00
|
|
|
struct PrimarySpanOnLint {
|
|
|
|
#[primary_span]
|
|
|
|
//~^ ERROR `#[primary_span]` is not a valid attribute
|
|
|
|
span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-07-11 17:15:31 +01:00
|
|
|
struct ErrorWithMultiSpan {
|
|
|
|
#[primary_span]
|
|
|
|
span: MultiSpan,
|
|
|
|
}
|
2022-07-11 18:46:24 +01:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
2022-08-24 17:57:10 +02:00
|
|
|
#[warning]
|
2022-07-11 18:46:24 +01:00
|
|
|
struct ErrorWithWarn {
|
|
|
|
val: String,
|
|
|
|
}
|
2022-08-19 15:40:48 +02:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
//~^ ERROR `#[error(...)]` is not a valid attribute
|
|
|
|
//~| ERROR diagnostic slug not specified
|
|
|
|
//~| ERROR cannot find attribute `error` in this scope
|
|
|
|
struct ErrorAttribute {}
|
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-24 17:57:10 +02:00
|
|
|
#[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
//~^ ERROR `#[warn_(...)]` is not a valid attribute
|
2022-08-19 15:40:48 +02:00
|
|
|
//~| ERROR diagnostic slug not specified
|
2022-08-24 17:57:10 +02:00
|
|
|
//~| ERROR cannot find attribute `warn_` in this scope
|
|
|
|
struct WarnAttribute {}
|
2022-08-19 15:40:48 +02:00
|
|
|
|
2022-09-18 11:45:41 -04:00
|
|
|
#[derive(DiagnosticHandler)]
|
2022-08-19 15:40:48 +02:00
|
|
|
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
//~^ ERROR `#[lint(...)]` is not a valid attribute
|
|
|
|
//~| ERROR diagnostic slug not specified
|
|
|
|
//~| ERROR cannot find attribute `lint` in this scope
|
|
|
|
struct LintAttributeOnSessionDiag {}
|
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
|
|
|
|
//~^ ERROR `#[lint(...)]` is not a valid attribute
|
|
|
|
//~| ERROR diagnostic slug not specified
|
|
|
|
//~| ERROR cannot find attribute `lint` in this scope
|
|
|
|
struct LintAttributeOnLintDiag {}
|