Auto merge of #152308 - JonathanBrouwer:rollup-3QU52Xc, r=JonathanBrouwer

Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#151745 (Remove a couple of unnecessary flags and env vars in bootstrap)
 - rust-lang/rust#152217 (Convert to inline diagnostics in `rustc_lint`)
 - rust-lang/rust#152056 (RwLock: refine documentation to emphasize non-reentrancy guarantees)
 - rust-lang/rust#152261 (Introduce helper `ty::Generics::has_own_self`)
 - rust-lang/rust#152288 (Allow only a single accepter per attribute)
 - rust-lang/rust#152292 (Minor change for readability)
 - rust-lang/rust#152300 (Port `rustc_regions` to the new attribute parser)
This commit is contained in:
bors 2026-02-07 22:18:38 +00:00
commit c69e1a04db
77 changed files with 1603 additions and 5710 deletions

View file

@ -3888,19 +3888,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "rustc_fluent_macro"
version = "0.0.0"
dependencies = [
"annotate-snippets 0.11.5",
"fluent-bundle",
"fluent-syntax",
"proc-macro2",
"quote",
"syn 2.0.110",
"unic-langid",
]
[[package]]
name = "rustc_fs_util"
version = "0.0.0"
@ -4143,7 +4130,6 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_fluent_macro",
"rustc_hir",
"rustc_index",
"rustc_infer",

View file

@ -219,6 +219,22 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcLintQueryInstabilityParser {
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintQueryInstability;
}
pub(crate) struct RustcRegionsParser;
impl<S: Stage> NoArgsAttributeParser<S> for RustcRegionsParser {
const PATH: &[Symbol] = &[sym::rustc_regions];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
Allow(Target::Fn),
Allow(Target::Method(MethodKind::Inherent)),
Allow(Target::Method(MethodKind::Trait { body: false })),
Allow(Target::Method(MethodKind::Trait { body: true })),
Allow(Target::Method(MethodKind::TraitImpl)),
]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcRegions;
}
pub(crate) struct RustcLintUntrackedQueryInformationParser;
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintUntrackedQueryInformationParser {

View file

@ -1,5 +1,6 @@
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::collections::btree_map::Entry;
use std::ops::{Deref, DerefMut};
use std::sync::LazyLock;
@ -61,7 +62,7 @@ use crate::target_checking::AllowedTargets;
type GroupType<S> = LazyLock<GroupTypeInner<S>>;
pub(super) struct GroupTypeInner<S: Stage> {
pub(super) accepters: BTreeMap<&'static [Symbol], Vec<GroupTypeInnerAccept<S>>>,
pub(super) accepters: BTreeMap<&'static [Symbol], GroupTypeInnerAccept<S>>,
}
pub(super) struct GroupTypeInnerAccept<S: Stage> {
@ -101,7 +102,7 @@ macro_rules! attribute_parsers {
@[$stage: ty] pub(crate) static $name: ident = [$($names: ty),* $(,)?];
) => {
pub(crate) static $name: GroupType<$stage> = LazyLock::new(|| {
let mut accepters = BTreeMap::<_, Vec<GroupTypeInnerAccept<$stage>>>::new();
let mut accepters = BTreeMap::<_, GroupTypeInnerAccept<$stage>>::new();
$(
{
thread_local! {
@ -109,19 +110,24 @@ macro_rules! attribute_parsers {
};
for (path, template, accept_fn) in <$names>::ATTRIBUTES {
accepters.entry(*path).or_default().push(GroupTypeInnerAccept {
template: *template,
accept_fn: Box::new(|cx, args| {
STATE_OBJECT.with_borrow_mut(|s| {
accept_fn(s, cx, args)
})
}),
allowed_targets: <$names as crate::attributes::AttributeParser<$stage>>::ALLOWED_TARGETS,
finalizer: Box::new(|cx| {
let state = STATE_OBJECT.take();
state.finalize(cx)
}),
});
match accepters.entry(*path) {
Entry::Vacant(e) => {
e.insert(GroupTypeInnerAccept {
template: *template,
accept_fn: Box::new(|cx, args| {
STATE_OBJECT.with_borrow_mut(|s| {
accept_fn(s, cx, args)
})
}),
allowed_targets: <$names as crate::attributes::AttributeParser<$stage>>::ALLOWED_TARGETS,
finalizer: Box::new(|cx| {
let state = STATE_OBJECT.take();
state.finalize(cx)
})
});
}
Entry::Occupied(_) => panic!("Attribute {path:?} has multiple accepters"),
}
}
}
)*
@ -278,6 +284,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
Single<WithoutArgs<RustcPreserveUbChecksParser>>,
Single<WithoutArgs<RustcReallocatorParser>>,
Single<WithoutArgs<RustcRegionsParser>>,
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
Single<WithoutArgs<RustcVarianceOfOpaquesParser>>,
Single<WithoutArgs<RustcVarianceParser>>,

View file

@ -327,7 +327,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
let parts =
n.item.path.segments.iter().map(|seg| seg.ident.name).collect::<Vec<_>>();
if let Some(accepts) = S::parsers().accepters.get(parts.as_slice()) {
if let Some(accept) = S::parsers().accepters.get(parts.as_slice()) {
let Some(args) = ArgParser::from_attr_args(
args,
&parts,
@ -368,28 +368,26 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
continue;
}
for accept in accepts {
let mut cx: AcceptContext<'_, 'sess, S> = AcceptContext {
shared: SharedContext {
cx: self,
target_span,
target,
emit_lint: &mut emit_lint,
},
attr_span,
inner_span: lower_span(n.item.span()),
attr_style: attr.style,
parsed_description: ParsedDescription::Attribute,
template: &accept.template,
attr_path: attr_path.clone(),
};
let mut cx: AcceptContext<'_, 'sess, S> = AcceptContext {
shared: SharedContext {
cx: self,
target_span,
target,
emit_lint: &mut emit_lint,
},
attr_span,
inner_span: lower_span(n.item.span()),
attr_style: attr.style,
parsed_description: ParsedDescription::Attribute,
template: &accept.template,
attr_path: attr_path.clone(),
};
(accept.accept_fn)(&mut cx, &args);
finalizers.push(&accept.finalizer);
(accept.accept_fn)(&mut cx, &args);
finalizers.push(&accept.finalizer);
if !matches!(cx.stage.should_emit(), ShouldEmit::Nothing) {
Self::check_target(&accept.allowed_targets, target, &mut cx);
}
if !matches!(cx.stage.should_emit(), ShouldEmit::Nothing) {
Self::check_target(&accept.allowed_targets, target, &mut cx);
}
} else {
// If we're here, we must be compiling a tool attribute... Or someone

View file

@ -7,6 +7,8 @@ use std::str::FromStr;
use polonius_engine::{Algorithm, AllFacts, Output};
use rustc_data_structures::frozen::Frozen;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::find_attr;
use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::PrettyPrintMirOptions;
use rustc_middle::mir::{Body, MirDumper, PassWhere, Promoted};
@ -15,7 +17,6 @@ use rustc_middle::ty::{self, TyCtxt};
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_session::config::MirIncludeSpans;
use rustc_span::sym;
use tracing::{debug, instrument};
use crate::borrow_set::BorrowSet;
@ -295,7 +296,7 @@ pub(super) fn dump_annotation<'tcx, 'infcx>(
) {
let tcx = infcx.tcx;
let base_def_id = tcx.typeck_root_def_id(body.source.def_id());
if !tcx.has_attr(base_def_id, sym::rustc_regions) {
if !find_attr!(tcx.get_all_attrs(base_def_id), AttributeKind::RustcRegions) {
return;
}

View file

@ -111,11 +111,7 @@ pub fn default_translator() -> Translator {
Translator::with_fallback_bundle(DEFAULT_LOCALE_RESOURCES.to_vec(), false)
}
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
// tidy-alphabetical-start
rustc_lint::DEFAULT_LOCALE_RESOURCE,
// tidy-alphabetical-end
];
pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[];
/// Exit status code used for successful compilation and help output.
pub const EXIT_SUCCESS: i32 = 0;

View file

@ -1,18 +0,0 @@
[package]
name = "rustc_fluent_macro"
version = "0.0.0"
edition = "2024"
[lib]
proc-macro = true
[dependencies]
# tidy-alphabetical-start
annotate-snippets = "0.11"
fluent-bundle = "0.16"
fluent-syntax = "0.12"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
unic-langid = { version = "0.9.0", features = ["macros"] }
# tidy-alphabetical-end

View file

@ -1,315 +0,0 @@
use std::collections::{HashMap, HashSet};
use std::fs::read_to_string;
use std::path::{Path, PathBuf};
use annotate_snippets::{Renderer, Snippet};
use fluent_bundle::{FluentBundle, FluentError, FluentResource};
use fluent_syntax::ast::{
Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement,
};
use fluent_syntax::parser::ParserError;
use proc_macro::tracked::path;
use proc_macro::{Diagnostic, Level, Span};
use proc_macro2::TokenStream;
use quote::quote;
use syn::{Ident, LitStr, parse_macro_input};
use unic_langid::langid;
/// Helper function for returning an absolute path for macro-invocation relative file paths.
///
/// If the input is already absolute, then the input is returned. If the input is not absolute,
/// then it is appended to the directory containing the source file with this macro invocation.
fn invocation_relative_path_to_absolute(span: Span, path: &str) -> PathBuf {
let path = Path::new(path);
if path.is_absolute() {
path.to_path_buf()
} else {
// `/a/b/c/foo/bar.rs` contains the current macro invocation
let mut source_file_path = span.local_file().unwrap();
// `/a/b/c/foo/`
source_file_path.pop();
// `/a/b/c/foo/../locales/en-US/example.ftl`
source_file_path.push(path);
source_file_path
}
}
/// Final tokens.
fn finish(body: TokenStream, resource: TokenStream) -> proc_macro::TokenStream {
quote! {
/// Raw content of Fluent resource for this crate, generated by `fluent_messages` macro,
/// imported by `rustc_driver` to include all crates' resources in one bundle.
pub static DEFAULT_LOCALE_RESOURCE: &'static str = #resource;
#[allow(non_upper_case_globals)]
#[doc(hidden)]
/// Auto-generated constants for type-checked references to Fluent messages.
pub(crate) mod fluent_generated {
#body
/// Constants expected to exist by the diagnostic derive macros to use as default Fluent
/// identifiers for different subdiagnostic kinds.
pub mod _subdiag {
/// Default for `#[help]`
pub const help: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
/// Default for `#[note]`
pub const note: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
/// Default for `#[warn]`
pub const warn: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
/// Default for `#[label]`
pub const label: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
/// Default for `#[suggestion]`
pub const suggestion: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
}
}
}
.into()
}
/// Tokens to be returned when the macro cannot proceed.
fn failed(crate_name: &Ident) -> proc_macro::TokenStream {
finish(quote! { pub mod #crate_name {} }, quote! { "" })
}
/// See [rustc_fluent_macro::fluent_messages].
pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let crate_name = std::env::var("CARGO_CRATE_NAME")
// If `CARGO_CRATE_NAME` is missing, then we're probably running in a test, so use
// `no_crate`.
.unwrap_or_else(|_| "no_crate".to_string())
.replace("rustc_", "");
// Cannot iterate over individual messages in a bundle, so do that using the
// `FluentResource` instead. Construct a bundle anyway to find out if there are conflicting
// messages in the resources.
let mut bundle = FluentBundle::new(vec![langid!("en-US")]);
// Set of Fluent attribute names already output, to avoid duplicate type errors - any given
// constant created for a given attribute is the same.
let mut previous_attrs = HashSet::new();
let resource_str = parse_macro_input!(input as LitStr);
let resource_span = resource_str.span().unwrap();
let relative_ftl_path = resource_str.value();
let absolute_ftl_path = invocation_relative_path_to_absolute(resource_span, &relative_ftl_path);
let crate_name = Ident::new(&crate_name, resource_str.span());
path(absolute_ftl_path.to_str().unwrap());
let resource_contents = match read_to_string(absolute_ftl_path) {
Ok(resource_contents) => resource_contents,
Err(e) => {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("could not open Fluent resource: {e}"),
)
.emit();
return failed(&crate_name);
}
};
let mut bad = false;
for esc in ["\\n", "\\\"", "\\'"] {
for _ in resource_contents.matches(esc) {
bad = true;
Diagnostic::spanned(resource_span, Level::Error, format!("invalid escape `{esc}` in Fluent resource"))
.note("Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)")
.emit();
}
}
if bad {
return failed(&crate_name);
}
let resource = match FluentResource::try_new(resource_contents) {
Ok(resource) => resource,
Err((this, errs)) => {
Diagnostic::spanned(resource_span, Level::Error, "could not parse Fluent resource")
.help("see additional errors emitted")
.emit();
for ParserError { pos, slice: _, kind } in errs {
let mut err = kind.to_string();
// Entirely unnecessary string modification so that the error message starts
// with a lowercase as rustc errors do.
err.replace_range(0..1, &err.chars().next().unwrap().to_lowercase().to_string());
let message = annotate_snippets::Level::Error.title(&err).snippet(
Snippet::source(this.source())
.origin(&relative_ftl_path)
.fold(true)
.annotation(annotate_snippets::Level::Error.span(pos.start..pos.end - 1)),
);
let renderer = Renderer::plain();
eprintln!("{}\n", renderer.render(message));
}
return failed(&crate_name);
}
};
let mut constants = TokenStream::new();
let mut previous_defns = HashMap::new();
let mut message_refs = Vec::new();
for entry in resource.entries() {
if let Entry::Message(msg) = entry {
let Message { id: Identifier { name }, attributes, value, .. } = msg;
let _ = previous_defns.entry(name.to_string()).or_insert(resource_span);
if name.contains('-') {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("name `{name}` contains a '-' character"),
)
.help("replace any '-'s with '_'s")
.emit();
}
if let Some(Pattern { elements }) = value {
for elt in elements {
if let PatternElement::Placeable {
expression:
Expression::Inline(InlineExpression::MessageReference { id, .. }),
} = elt
{
message_refs.push((id.name, *name));
}
}
}
// `typeck_foo_bar` => `foo_bar` (in `typeck.ftl`)
// `const_eval_baz` => `baz` (in `const_eval.ftl`)
// `const-eval-hyphen-having` => `hyphen_having` (in `const_eval.ftl`)
// The last case we error about above, but we want to fall back gracefully
// so that only the error is being emitted and not also one about the macro
// failing.
let crate_prefix = format!("{crate_name}_");
let snake_name = name.replace('-', "_");
if !snake_name.starts_with(&crate_prefix) {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("name `{name}` does not start with the crate name"),
)
.help(format!(
"prepend `{crate_prefix}` to the slug name: `{crate_prefix}{snake_name}`"
))
.emit();
};
let snake_name = Ident::new(&snake_name, resource_str.span());
if !previous_attrs.insert(snake_name.clone()) {
continue;
}
let docstr =
format!("Constant referring to Fluent message `{name}` from `{crate_name}`");
constants.extend(quote! {
#[doc = #docstr]
pub const #snake_name: rustc_errors::DiagMessage =
rustc_errors::DiagMessage::FluentIdentifier(
std::borrow::Cow::Borrowed(#name),
None
);
});
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
let snake_name = Ident::new(
&format!("{crate_prefix}{}", attr_name.replace('-', "_")),
resource_str.span(),
);
if !previous_attrs.insert(snake_name.clone()) {
continue;
}
if attr_name.contains('-') {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("attribute `{attr_name}` contains a '-' character"),
)
.help("replace any '-'s with '_'s")
.emit();
}
let msg = format!(
"Constant referring to Fluent message `{name}.{attr_name}` from `{crate_name}`"
);
constants.extend(quote! {
#[doc = #msg]
pub const #snake_name: rustc_errors::SubdiagMessage =
rustc_errors::SubdiagMessage::FluentAttr(std::borrow::Cow::Borrowed(#attr_name));
});
}
// Record variables referenced by these messages so we can produce
// tests in the derive diagnostics to validate them.
let ident = quote::format_ident!("{snake_name}_refs");
let vrefs = variable_references(msg);
constants.extend(quote! {
#[cfg(test)]
pub const #ident: &[&str] = &[#(#vrefs),*];
})
}
}
for (mref, name) in message_refs.into_iter() {
if !previous_defns.contains_key(mref) {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("referenced message `{mref}` does not exist (in message `{name}`)"),
)
.help(format!("you may have meant to use a variable reference (`{{${mref}}}`)"))
.emit();
}
}
if let Err(errs) = bundle.add_resource(resource) {
for e in errs {
match e {
FluentError::Overriding { kind, id } => {
Diagnostic::spanned(
resource_span,
Level::Error,
format!("overrides existing {kind}: `{id}`"),
)
.emit();
}
FluentError::ResolverError(_) | FluentError::ParserError(_) => unreachable!(),
}
}
}
finish(constants, quote! { include_str!(#relative_ftl_path) })
}
fn variable_references<'a>(msg: &Message<&'a str>) -> Vec<&'a str> {
let mut refs = vec![];
if let Some(Pattern { elements }) = &msg.value {
for elt in elements {
if let PatternElement::Placeable {
expression: Expression::Inline(InlineExpression::VariableReference { id }),
} = elt
{
refs.push(id.name);
}
}
}
for attr in &msg.attributes {
for elt in &attr.value.elements {
if let PatternElement::Placeable {
expression: Expression::Inline(InlineExpression::VariableReference { id }),
} = elt
{
refs.push(id.name);
}
}
}
refs
}

View file

@ -1,67 +0,0 @@
// tidy-alphabetical-start
#![allow(rustc::default_hash_types)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_tracked_path)]
// tidy-alphabetical-end
use proc_macro::TokenStream;
mod fluent;
/// Implements the `fluent_messages` macro, which performs compile-time validation of the
/// compiler's Fluent resources (i.e. that the resources parse and don't multiply define the same
/// messages) and generates constants that make using those messages in diagnostics more ergonomic.
///
/// For example, given the following invocation of the macro..
///
/// ```ignore (rust)
/// fluent_messages! { "./typeck.ftl" }
/// ```
/// ..where `typeck.ftl` has the following contents..
///
/// ```fluent
/// typeck_field_multiply_specified_in_initializer =
/// field `{$ident}` specified more than once
/// .label = used more than once
/// .label_previous_use = first use of `{$ident}`
/// ```
/// ...then the macro parse the Fluent resource, emitting a diagnostic if it fails to do so, and
/// will generate the following code:
///
/// ```ignore (rust)
/// pub static DEFAULT_LOCALE_RESOURCE: &'static [&'static str] = include_str!("./typeck.ftl");
///
/// mod fluent_generated {
/// mod typeck {
/// pub const field_multiply_specified_in_initializer: DiagMessage =
/// DiagMessage::fluent("typeck_field_multiply_specified_in_initializer");
/// pub const field_multiply_specified_in_initializer_label_previous_use: DiagMessage =
/// DiagMessage::fluent_attr(
/// "typeck_field_multiply_specified_in_initializer",
/// "previous_use_label"
/// );
/// }
/// }
/// ```
/// When emitting a diagnostic, the generated constants can be used as follows:
///
/// ```ignore (rust)
/// let mut err = sess.struct_span_err(
/// span,
/// fluent::typeck::field_multiply_specified_in_initializer
/// );
/// err.span_default_label(span);
/// err.span_label(
/// previous_use_span,
/// fluent::typeck::field_multiply_specified_in_initializer_label_previous_use
/// );
/// err.emit();
/// ```
///
/// Note: any crate using this macro must also have a dependency on
/// `rustc_errors`, because the generated code refers to things from that
/// crate.
#[proc_macro]
pub fn fluent_messages(input: TokenStream) -> TokenStream {
fluent::fluent_messages(input)
}

View file

@ -1204,6 +1204,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_reallocator]`
RustcReallocator,
/// Represents `#[rustc_regions]`
RustcRegions,
/// Represents `#[rustc_scalable_vector(N)]`
RustcScalableVector {
/// The base multiple of lanes that are in a scalable vector, if provided. `element_count`

View file

@ -146,6 +146,7 @@ impl AttributeKind {
RustcPreserveUbChecks => No,
RustcPubTransparent(..) => Yes,
RustcReallocator => No,
RustcRegions => No,
RustcScalableVector { .. } => Yes,
RustcShouldNotBeCalledOnConstItems(..) => Yes,
RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate

View file

@ -393,8 +393,7 @@ pub fn check_generic_arg_count_for_call(
IsMethodCall::Yes => GenericArgPosition::MethodCall,
IsMethodCall::No => GenericArgPosition::Value,
};
let has_self = generics.parent.is_none() && generics.has_self;
check_generic_arg_count(cx, def_id, seg, generics, gen_pos, has_self)
check_generic_arg_count(cx, def_id, seg, generics, gen_pos, generics.has_own_self())
}
/// Checks that the correct number of generic arguments have been provided.

View file

@ -14,7 +14,6 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" }

File diff suppressed because it is too large Load diff

View file

@ -108,16 +108,18 @@ impl<'tcx> LateLintPass<'tcx> for AsyncClosureUsage {
}
#[derive(LintDiagnostic)]
#[diag(lint_closure_returning_async_block)]
#[diag("closure returning async block can be made into an async closure")]
struct ClosureReturningAsyncBlock {
#[label]
#[label(
"this async block can be removed, and the closure can be turned into an async closure"
)]
async_decl_span: Span,
#[subdiagnostic]
sugg: AsyncClosureSugg,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(lint_suggestion, applicability = "maybe-incorrect")]
#[multipart_suggestion("turn this into an async closure", applicability = "maybe-incorrect")]
struct AsyncClosureSugg {
#[suggestion_part(code = "")]
deletion_span: Span,

View file

@ -22,7 +22,7 @@ use rustc_ast::visit::{FnCtxt, FnKind};
use rustc_ast::{self as ast, *};
use rustc_ast_pretty::pprust::expr_to_string;
use rustc_attr_parsing::AttributeParser;
use rustc_errors::{Applicability, LintDiagnostic};
use rustc_errors::{Applicability, LintDiagnostic, inline_fluent};
use rustc_feature::GateIssue;
use rustc_hir as hir;
use rustc_hir::attrs::{AttributeKind, DocAttribute};
@ -61,10 +61,7 @@ use crate::lints::{
BuiltinUnreachablePub, BuiltinUnsafe, BuiltinUnstableFeatures, BuiltinUnusedDocComment,
BuiltinUnusedDocCommentSub, BuiltinWhileTrue, InvalidAsmLabel,
};
use crate::{
EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext,
fluent_generated as fluent,
};
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext};
declare_lint! {
/// The `while_true` lint detects `while true { }`.
///
@ -2655,8 +2652,12 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
let conjured_ty = cx.typeck_results().expr_ty(expr);
if let Some(err) = with_no_trimmed_paths!(ty_find_init_error(cx, conjured_ty, init)) {
let msg = match init {
InitKind::Zeroed => fluent::lint_builtin_unpermitted_type_init_zeroed,
InitKind::Uninit => fluent::lint_builtin_unpermitted_type_init_uninit,
InitKind::Zeroed => {
inline_fluent!("the type `{$ty}` does not permit zero-initialization")
}
InitKind::Uninit => {
inline_fluent!("the type `{$ty}` does not permit being left uninitialized")
}
};
let sub = BuiltinUnpermittedTypeInitSub { err };
cx.emit_span_lint(

View file

@ -1,17 +1,15 @@
use rustc_errors::codes::*;
use rustc_errors::{Diag, EmissionGuarantee, Subdiagnostic};
use rustc_errors::{Diag, EmissionGuarantee, Subdiagnostic, inline_fluent};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_session::lint::Level;
use rustc_span::{Span, Symbol};
use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(lint_overruled_attribute, code = E0453)]
#[diag("{$lint_level}({$lint_source}) incompatible with previous forbid", code = E0453)]
pub(crate) struct OverruledAttribute<'a> {
#[primary_span]
pub span: Span,
#[label]
#[label("overruled by previous forbid")]
pub overruled: Span,
pub lint_level: &'a str,
pub lint_source: Symbol,
@ -29,24 +27,24 @@ impl Subdiagnostic for OverruledAttributeSub {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
match self {
OverruledAttributeSub::DefaultSource { id } => {
diag.note(fluent::lint_default_source);
diag.note(inline_fluent!("`forbid` lint level is the default for {$id}"));
diag.arg("id", id);
}
OverruledAttributeSub::NodeSource { span, reason } => {
diag.span_label(span, fluent::lint_node_source);
diag.span_label(span, inline_fluent!("`forbid` level set here"));
if let Some(rationale) = reason {
diag.note(rationale.to_string());
}
}
OverruledAttributeSub::CommandLineSource => {
diag.note(fluent::lint_command_line_source);
diag.note(inline_fluent!("`forbid` lint level was set on command line"));
}
}
}
}
#[derive(Diagnostic)]
#[diag(lint_malformed_attribute, code = E0452)]
#[diag("malformed lint attribute input", code = E0452)]
pub(crate) struct MalformedAttribute {
#[primary_span]
pub span: Span,
@ -56,50 +54,55 @@ pub(crate) struct MalformedAttribute {
#[derive(Subdiagnostic)]
pub(crate) enum MalformedAttributeSub {
#[label(lint_bad_attribute_argument)]
#[label("bad attribute argument")]
BadAttributeArgument(#[primary_span] Span),
#[label(lint_reason_must_be_string_literal)]
#[label("reason must be a string literal")]
ReasonMustBeStringLiteral(#[primary_span] Span),
#[label(lint_reason_must_come_last)]
#[label("reason in lint attribute must come last")]
ReasonMustComeLast(#[primary_span] Span),
}
#[derive(Diagnostic)]
#[diag(lint_unknown_tool_in_scoped_lint, code = E0710)]
#[diag("unknown tool name `{$tool_name}` found in scoped lint: `{$tool_name}::{$lint_name}`", code = E0710)]
pub(crate) struct UnknownToolInScopedLint {
#[primary_span]
pub span: Option<Span>,
pub tool_name: Symbol,
pub lint_name: String,
#[help]
#[help("add `#![register_tool({$tool_name})]` to the crate root")]
pub is_nightly_build: bool,
}
#[derive(Diagnostic)]
#[diag(lint_builtin_ellipsis_inclusive_range_patterns, code = E0783)]
#[diag("`...` range patterns are deprecated", code = E0783)]
pub(crate) struct BuiltinEllipsisInclusiveRangePatterns {
#[primary_span]
pub span: Span,
#[suggestion(style = "short", code = "{replace}", applicability = "machine-applicable")]
#[suggestion(
"use `..=` for an inclusive range",
style = "short",
code = "{replace}",
applicability = "machine-applicable"
)]
pub suggestion: Span,
pub replace: String,
}
#[derive(Subdiagnostic)]
#[note(lint_requested_level)]
#[note("requested on the command line with `{$level} {$lint_name}`")]
pub(crate) struct RequestedLevel<'a> {
pub level: Level,
pub lint_name: &'a str,
}
#[derive(Diagnostic)]
#[diag(lint_unsupported_group, code = E0602)]
#[diag("`{$lint_group}` lint group is not supported with ´--force-warn´", code = E0602)]
pub(crate) struct UnsupportedGroup {
pub lint_group: String,
}
#[derive(Diagnostic)]
#[diag(lint_check_name_unknown_tool, code = E0602)]
#[diag("unknown lint tool: `{$tool_name}`", code = E0602)]
pub(crate) struct CheckNameUnknownTool<'a> {
pub tool_name: Symbol,
#[subdiagnostic]

View file

@ -3,7 +3,9 @@ use std::ops::ControlFlow;
use hir::intravisit::{self, Visitor};
use rustc_ast::Recovered;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic, SuggestionStyle};
use rustc_errors::{
Applicability, Diag, EmissionGuarantee, Subdiagnostic, SuggestionStyle, inline_fluent,
};
use rustc_hir::{self as hir, HirIdSet};
use rustc_macros::{LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::adjustment::Adjust;
@ -303,13 +305,15 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope {
}
#[derive(LintDiagnostic)]
#[diag(lint_if_let_rescope)]
#[diag("`if let` assigns a shorter lifetime since Edition 2024")]
struct IfLetRescopeLint {
#[subdiagnostic]
destructors: Vec<DestructorLabel>,
#[label]
#[label(
"this value has a significant drop implementation which may observe a major change in drop order and requires your discretion"
)]
significant_droppers: Vec<Span>,
#[help]
#[help("the value is now dropped here in Edition 2024")]
lifetime_ends: Vec<Span>,
#[subdiagnostic]
rewrite: Option<IfLetRescopeRewrite>,
@ -352,7 +356,9 @@ impl Subdiagnostic for IfLetRescopeRewrite {
.chain(repeat_n('}', closing_brackets.count))
.collect(),
));
let msg = diag.eagerly_translate(crate::fluent_generated::lint_suggestion);
let msg = diag.eagerly_translate(inline_fluent!(
"a `match` with a single arm can preserve the drop order up to Edition 2021"
));
diag.multipart_suggestion_with_style(
msg,
suggestions,
@ -363,7 +369,12 @@ impl Subdiagnostic for IfLetRescopeRewrite {
}
#[derive(Subdiagnostic)]
#[note(lint_if_let_dtor)]
#[note(
"{$dtor_kind ->
[dyn] value may invoke a custom destructor because it contains a trait object
*[concrete] value invokes this custom destructor
}"
)]
struct DestructorLabel {
#[primary_span]
span: Span,

View file

@ -3,7 +3,7 @@ use std::cell::LazyCell;
use rustc_data_structures::debug_assert_matches;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{LintDiagnostic, Subdiagnostic};
use rustc_errors::{LintDiagnostic, Subdiagnostic, inline_fluent};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
@ -28,7 +28,7 @@ use rustc_trait_selection::errors::{
use rustc_trait_selection::regions::OutlivesEnvironmentBuildExt;
use rustc_trait_selection::traits::ObligationCtxt;
use crate::{LateContext, LateLintPass, fluent_generated as fluent};
use crate::{LateContext, LateLintPass};
declare_lint! {
/// The `impl_trait_overcaptures` lint warns against cases where lifetime
@ -435,11 +435,23 @@ struct ImplTraitOvercapturesLint<'tcx> {
impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
diag.primary_message(fluent::lint_impl_trait_overcaptures);
diag.primary_message(inline_fluent!(
"`{$self_ty}` will capture more lifetimes than possibly intended in edition 2024"
));
diag.arg("self_ty", self.self_ty.to_string())
.arg("num_captured", self.num_captured)
.span_note(self.uncaptured_spans, fluent::lint_note)
.note(fluent::lint_note2);
.span_note(
self.uncaptured_spans,
inline_fluent!(
"specifically, {$num_captured ->
[one] this lifetime is
*[other] these lifetimes are
} in scope but not mentioned in the type's bounds"
),
)
.note(inline_fluent!(
"all lifetimes in scope will be captured by `impl Trait`s in edition 2024"
));
if let Some(suggestion) = self.suggestion {
suggestion.add_to_diag(diag);
}
@ -447,9 +459,9 @@ impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
}
#[derive(LintDiagnostic)]
#[diag(lint_impl_trait_redundant_captures)]
#[diag("all possible in-scope parameters are already captured, so `use<...>` syntax is redundant")]
struct ImplTraitRedundantCapturesLint {
#[suggestion(lint_suggestion, code = "", applicability = "machine-applicable")]
#[suggestion("remove the `use<...>` syntax", code = "", applicability = "machine-applicable")]
capturing_span: Span,
}

View file

@ -2,7 +2,7 @@ use rustc_ast::attr::AttributeExt;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
use rustc_errors::{Diag, LintDiagnostic, MultiSpan, inline_fluent};
use rustc_feature::{Features, GateIssue};
use rustc_hir::HirId;
use rustc_hir::intravisit::{self, Visitor};
@ -31,7 +31,6 @@ use crate::errors::{
CheckNameUnknownTool, MalformedAttribute, MalformedAttributeSub, OverruledAttribute,
OverruledAttributeSub, RequestedLevel, UnknownToolInScopedLint, UnsupportedGroup,
};
use crate::fluent_generated as fluent;
use crate::late::unerased_lint_store;
use crate::lints::{
DeprecatedLintName, DeprecatedLintNameFromCommandLine, IgnoredUnlessCrateSpecified,
@ -942,9 +941,9 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
let lint = builtin::UNKNOWN_LINTS;
let level = self.lint_level(builtin::UNKNOWN_LINTS);
lint_level(self.sess, lint, level, Some(span.into()), |lint| {
lint.primary_message(fluent::lint_unknown_gated_lint);
lint.primary_message(inline_fluent!("unknown lint: `{$name}`"));
lint.arg("name", lint_id.lint.name_lower());
lint.note(fluent::lint_note);
lint.note(inline_fluent!("the `{$name}` lint is unstable"));
rustc_session::parse::add_feature_diagnostics_for_issue(
lint,
&self.sess,

View file

@ -139,8 +139,6 @@ pub use rustc_errors::BufferedEarlyLint;
pub use rustc_session::lint::Level::{self, *};
pub use rustc_session::lint::{FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub fn provide(providers: &mut Providers) {
levels::provide(providers);
expect::provide(providers);

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
use rustc_ast as ast;
use rustc_errors::Applicability;
use rustc_errors::{Applicability, inline_fluent};
use rustc_hir::{self as hir, LangItem};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::{bug, ty};
@ -10,7 +10,7 @@ use rustc_span::{InnerSpan, Span, Symbol, hygiene, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused};
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
use crate::{LateContext, LateLintPass, LintContext};
declare_lint! {
/// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first
@ -121,20 +121,20 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
}
cx.span_lint(NON_FMT_PANICS, arg_span, |lint| {
lint.primary_message(fluent::lint_non_fmt_panic);
lint.primary_message(inline_fluent!("panic message is not a string literal"));
lint.arg("name", symbol);
lint.note(fluent::lint_note);
lint.note(fluent::lint_more_info_note);
lint.note(inline_fluent!("this usage of `{$name}!()` is deprecated; it will be a hard error in Rust 2021"));
lint.note(inline_fluent!("for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html>"));
if !is_arg_inside_call(arg_span, span) {
// No clue where this argument is coming from.
return;
}
if arg_macro.is_some_and(|id| cx.tcx.is_diagnostic_item(sym::format_macro, id)) {
// A case of `panic!(format!(..))`.
lint.note(fluent::lint_supports_fmt_note);
lint.note(inline_fluent!("the `{$name}!()` macro supports formatting, so there's no need for the `format!()` macro here"));
if let Some((open, close, _)) = find_delimiters(cx, arg_span) {
lint.multipart_suggestion(
fluent::lint_supports_fmt_suggestion,
inline_fluent!("remove the `format!(..)` macro call"),
vec![
(arg_span.until(open.shrink_to_hi()), "".into()),
(close.until(arg_span.shrink_to_hi()), "".into()),
@ -178,7 +178,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
if suggest_display {
lint.span_suggestion_verbose(
arg_span.shrink_to_lo(),
fluent::lint_display_suggestion,
inline_fluent!(r#"add a "{"{"}{"}"}" format string to `Display` the message"#),
"\"{}\", ",
fmt_applicability,
);
@ -186,7 +186,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
lint.arg("ty", ty);
lint.span_suggestion_verbose(
arg_span.shrink_to_lo(),
fluent::lint_debug_suggestion,
inline_fluent!(r#"add a "{"{"}:?{"}"}" format string to use the `Debug` implementation of `{$ty}`"#),
"\"{:?}\", ",
fmt_applicability,
);
@ -196,7 +196,10 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
if let Some((open, close, del)) = find_delimiters(cx, span) {
lint.arg("already_suggested", suggest_display || suggest_debug);
lint.multipart_suggestion(
fluent::lint_panic_suggestion,
inline_fluent!("{$already_suggested ->
[true] or use
*[false] use
} std::panic::panic_any instead"),
if del == '(' {
vec![(span.until(open), "std::panic::panic_any".into())]
} else {

View file

@ -1,4 +1,4 @@
use rustc_errors::MultiSpan;
use rustc_errors::{MultiSpan, inline_fluent};
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{self, Visitor, VisitorExt};
@ -9,7 +9,7 @@ use rustc_span::def_id::{DefId, LOCAL_CRATE};
use rustc_span::{ExpnKind, Span, kw};
use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag};
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
use crate::{LateContext, LateLintPass, LintContext};
declare_lint! {
/// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]`
@ -210,7 +210,12 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
if !doctest {
ms.push_span_label(
cx.tcx.def_span(parent),
fluent::lint_non_local_definitions_impl_move_help,
inline_fluent!(
"move the `impl` block outside of this {$body_kind_descr} {$depth ->
[one] `{$body_name}`
*[other] `{$body_name}` and up {$depth} bodies
}"
),
);
}

View file

@ -202,11 +202,11 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
}
#[derive(LintDiagnostic)]
#[diag(lint_opaque_hidden_inferred_bound)]
#[diag("opaque type `{$ty}` does not satisfy its associated type bounds")]
struct OpaqueHiddenInferredBoundLint<'tcx> {
ty: Ty<'tcx>,
proj_ty: Ty<'tcx>,
#[label(lint_specifically)]
#[label("this associated type bound is unsatisfied for `{$proj_ty}`")]
assoc_pred_span: Span,
#[subdiagnostic]
add_bound: Option<AddBound<'tcx>>,
@ -214,7 +214,7 @@ struct OpaqueHiddenInferredBoundLint<'tcx> {
#[derive(Subdiagnostic)]
#[suggestion(
lint_opaque_hidden_inferred_bound_sugg,
"add this bound",
style = "verbose",
applicability = "machine-applicable",
code = " + {trait_ref}"

View file

@ -369,8 +369,10 @@ fn check_unnecessary_transmute<'tcx>(
}
#[derive(LintDiagnostic)]
#[diag(lint_undefined_transmute)]
#[note]
#[note(lint_note2)]
#[help]
#[diag("pointers cannot be transmuted to integers during const eval")]
#[note("at compile-time, pointers do not have an integer value")]
#[note(
"avoiding this restriction via `union` or raw pointers leads to compile-time undefined behavior"
)]
#[help("for more information, see https://doc.rust-lang.org/std/mem/fn.transmute.html")]
pub(crate) struct UndefinedTransmuteLint;

View file

@ -4,7 +4,7 @@ use std::ops::ControlFlow;
use bitflags::bitflags;
use rustc_abi::VariantIdx;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::DiagMessage;
use rustc_errors::{DiagMessage, inline_fluent};
use rustc_hir::def::CtorKind;
use rustc_hir::intravisit::VisitorExt;
use rustc_hir::{self as hir, AmbigArg};
@ -21,7 +21,7 @@ use tracing::debug;
use super::repr_nullable_ptr;
use crate::lints::{ImproperCTypes, UsesPowerAlignment};
use crate::{LateContext, LateLintPass, LintContext, fluent_generated as fluent};
use crate::{LateContext, LateLintPass, LintContext};
declare_lint! {
/// The `improper_ctypes` lint detects incorrect use of types in foreign
@ -158,12 +158,12 @@ pub(crate) fn check_non_exhaustive_variant(
// with an enum like `#[repr(u8)] enum Enum { A(DataA), B(DataB), }`
// but exempt enums with unit ctors like C's (e.g. from rust-bindgen)
if variant_has_complex_ctor(variant) {
return ControlFlow::Break(fluent::lint_improper_ctypes_non_exhaustive);
return ControlFlow::Break(inline_fluent!("this enum is non-exhaustive"));
}
}
if variant.field_list_has_applicable_non_exhaustive() {
return ControlFlow::Break(fluent::lint_improper_ctypes_non_exhaustive_variant);
return ControlFlow::Break(inline_fluent!("this enum has non-exhaustive variants"));
}
ControlFlow::Continue(())
@ -424,7 +424,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
if all_phantom {
FfiPhantom(ty)
} else if transparent_with_all_zst_fields {
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_struct_zst, help: None }
FfiUnsafe {
ty,
reason: inline_fluent!("this struct contains only zero-sized fields"),
help: None,
}
} else {
FfiSafe
}
@ -460,7 +464,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} else {
return FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_box,
reason: inline_fluent!("box cannot be represented as a single pointer"),
help: None,
};
}
@ -476,8 +480,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
{
return FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_cstr_reason,
help: Some(fluent::lint_improper_ctypes_cstr_help),
reason: inline_fluent!(
"`CStr`/`CString` do not have a guaranteed layout"
),
help: Some(inline_fluent!(
"consider passing a `*const std::ffi::c_char` instead, and use `CStr::as_ptr()`"
)),
};
}
@ -485,14 +493,18 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
return FfiUnsafe {
ty,
reason: if def.is_struct() {
fluent::lint_improper_ctypes_struct_layout_reason
inline_fluent!("this struct has unspecified layout")
} else {
fluent::lint_improper_ctypes_union_layout_reason
inline_fluent!("this union has unspecified layout")
},
help: if def.is_struct() {
Some(fluent::lint_improper_ctypes_struct_layout_help)
Some(inline_fluent!(
"consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct"
))
} else {
Some(fluent::lint_improper_ctypes_union_layout_help)
Some(inline_fluent!(
"consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this union"
))
},
};
}
@ -501,9 +513,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
return FfiUnsafe {
ty,
reason: if def.is_struct() {
fluent::lint_improper_ctypes_struct_non_exhaustive
inline_fluent!("this struct is non-exhaustive")
} else {
fluent::lint_improper_ctypes_union_non_exhaustive
inline_fluent!("this union is non-exhaustive")
},
help: None,
};
@ -513,14 +525,14 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
return FfiUnsafe {
ty,
reason: if def.is_struct() {
fluent::lint_improper_ctypes_struct_fieldless_reason
inline_fluent!("this struct has no fields")
} else {
fluent::lint_improper_ctypes_union_fieldless_reason
inline_fluent!("this union has no fields")
},
help: if def.is_struct() {
Some(fluent::lint_improper_ctypes_struct_fieldless_help)
Some(inline_fluent!("consider adding a member to this struct"))
} else {
Some(fluent::lint_improper_ctypes_union_fieldless_help)
Some(inline_fluent!("consider adding a member to this union"))
},
};
}
@ -545,8 +557,10 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
return FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_enum_repr_reason,
help: Some(fluent::lint_improper_ctypes_enum_repr_help),
reason: inline_fluent!("enum has no representation hint"),
help: Some(inline_fluent!(
"consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum"
)),
};
}
@ -572,8 +586,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
ty::Char => FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_char_reason,
help: Some(fluent::lint_improper_ctypes_char_help),
reason: inline_fluent!("the `char` type has no C equivalent"),
help: Some(inline_fluent!("consider using `u32` or `libc::wchar_t` instead")),
},
// It's just extra invariants on the type that you need to uphold,
@ -585,24 +599,26 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
ty::Slice(_) => FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_slice_reason,
help: Some(fluent::lint_improper_ctypes_slice_help),
reason: inline_fluent!("slices have no C equivalent"),
help: Some(inline_fluent!("consider using a raw pointer instead")),
},
ty::Dynamic(..) => {
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_dyn, help: None }
}
ty::Dynamic(..) => FfiUnsafe {
ty,
reason: inline_fluent!("trait objects have no C equivalent"),
help: None,
},
ty::Str => FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_str_reason,
help: Some(fluent::lint_improper_ctypes_str_help),
reason: inline_fluent!("string slices have no C equivalent"),
help: Some(inline_fluent!("consider using `*const u8` and a length instead")),
},
ty::Tuple(..) => FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_tuple_reason,
help: Some(fluent::lint_improper_ctypes_tuple_help),
reason: inline_fluent!("tuples have unspecified layout"),
help: Some(inline_fluent!("consider using a struct instead")),
},
ty::RawPtr(ty, _) | ty::Ref(_, ty, _)
@ -632,8 +648,12 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
if sig.abi().is_rustic_abi() {
return FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_fnptr_reason,
help: Some(fluent::lint_improper_ctypes_fnptr_help),
reason: inline_fluent!(
"this function pointer has Rust-specific calling convention"
),
help: Some(inline_fluent!(
"consider using an `extern fn(...) -> ...` function pointer instead"
)),
};
}
@ -657,9 +677,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
// While opaque types are checked for earlier, if a projection in a struct field
// normalizes to an opaque type, then it will reach this branch.
ty::Alias(ty::Opaque, ..) => {
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_opaque, help: None }
}
ty::Alias(ty::Opaque, ..) => FfiUnsafe {
ty,
reason: inline_fluent!("opaque types have no C equivalent"),
help: None,
},
// `extern "C" fn` functions can have type parameters, which may or may not be FFI-safe,
// so they are currently ignored for the purposes of this lint.
@ -669,9 +691,13 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
FfiSafe
}
ty::UnsafeBinder(_) => {
FfiUnsafe { ty, reason: fluent::lint_improper_ctypes_unsafe_binder, help: None }
}
ty::UnsafeBinder(_) => FfiUnsafe {
ty,
reason: inline_fluent!(
"unsafe binders are incompatible with foreign function interfaces"
),
help: None,
},
ty::Param(..)
| ty::Alias(ty::Projection | ty::Inherent | ty::Free, ..)
@ -715,7 +741,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
{
Some(FfiResult::FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_opaque,
reason: inline_fluent!("opaque types have no C equivalent"),
help: None,
})
} else {
@ -728,8 +754,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
if let ty::Array(..) = ty.kind() {
Some(FfiResult::FfiUnsafe {
ty,
reason: fluent::lint_improper_ctypes_array_reason,
help: Some(fluent::lint_improper_ctypes_array_help),
reason: inline_fluent!("passing raw arrays by value is not FFI-safe"),
help: Some(inline_fluent!("consider passing a pointer to the array")),
})
} else {
None
@ -908,7 +934,7 @@ impl<'tcx> ImproperCTypesLint {
cx,
ty,
sp,
fluent::lint_improper_ctypes_only_phantomdata,
inline_fluent!("composed only of `PhantomData`"),
None,
fn_mode,
);

View file

@ -284,7 +284,7 @@ impl<'tcx> Generics {
args: &'a [ty::GenericArg<'tcx>],
) -> &'a [ty::GenericArg<'tcx>] {
let mut own_params = self.parent_count..self.count();
if self.has_self && self.parent.is_none() {
if self.has_own_self() {
own_params.start = 1;
}
@ -316,7 +316,7 @@ impl<'tcx> Generics {
args: &'tcx [ty::GenericArg<'tcx>],
) -> &'tcx [ty::GenericArg<'tcx>] {
let own = &args[self.parent_count..][..self.own_params.len()];
if self.has_self && self.parent.is_none() { &own[1..] } else { own }
if self.has_own_self() { &own[1..] } else { own }
}
/// Returns true if a concrete type is specified after a default type.
@ -350,6 +350,10 @@ impl<'tcx> Generics {
pub fn is_own_empty(&'tcx self) -> bool {
self.own_params.is_empty()
}
pub fn has_own_self(&'tcx self) -> bool {
self.has_self && self.parent.is_none()
}
}
/// Bounds on generics.

View file

@ -337,6 +337,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)
| AttributeKind::RustcPreserveUbChecks
| AttributeKind::RustcReallocator
| AttributeKind::RustcRegions
| AttributeKind::RustcScalableVector { .. }
| AttributeKind::RustcShouldNotBeCalledOnConstItems(..)
| AttributeKind::RustcSimdMonomorphizeLaneLimit(..)
@ -401,7 +402,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::rustc_never_type_options
| sym::rustc_autodiff
| sym::rustc_capture_analysis
| sym::rustc_regions
| sym::rustc_strict_coherence
| sym::rustc_mir
| sym::rustc_outlives

View file

@ -1263,7 +1263,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
.iter()
.position(|&arg| self.generic_arg_contains_target(arg))
{
if generics.parent.is_none() && generics.has_self {
if generics.has_own_self() {
argument_index += 1;
}
let args = self.tecx.resolve_vars_if_possible(args);

View file

@ -411,9 +411,8 @@ impl str {
fn map_uppercase_sigma(from: &str, i: usize) -> char {
// See https://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992
// for the definition of `Final_Sigma`.
debug_assert!('Σ'.len_utf8() == 2);
let is_word_final = case_ignorable_then_cased(from[..i].chars().rev())
&& !case_ignorable_then_cased(from[i + 2..].chars());
&& !case_ignorable_then_cased(from[i + const { 'Σ'.len_utf8() }..].chars());
if is_word_final { 'ς' } else { 'σ' }
}

View file

@ -56,24 +56,36 @@ use crate::sys::sync as sys;
/// # Examples
///
/// ```
/// use std::sync::RwLock;
/// use std::sync::{Arc, RwLock};
/// use std::thread;
/// use std::time::Duration;
///
/// let lock = RwLock::new(5);
/// let data = Arc::new(RwLock::new(5));
///
/// // many reader locks can be held at once
/// {
/// let r1 = lock.read().unwrap();
/// let r2 = lock.read().unwrap();
/// assert_eq!(*r1, 5);
/// assert_eq!(*r2, 5);
/// } // read locks are dropped at this point
/// // Multiple readers can access in parallel.
/// for i in 0..3 {
/// let lock_clone = Arc::clone(&data);
///
/// // only one write lock may be held, however
/// {
/// let mut w = lock.write().unwrap();
/// *w += 1;
/// assert_eq!(*w, 6);
/// } // write lock is dropped here
/// thread::spawn(move || {
/// let value = lock_clone.read().unwrap();
///
/// println!("Reader {}: Read value {}, now holding lock...", i, *value);
///
/// // Simulating a long read operation
/// thread::sleep(Duration::from_secs(1));
///
/// println!("Reader {}: Dropping lock.", i);
/// // Read lock unlocked when going out of scope.
/// });
/// }
///
/// thread::sleep(Duration::from_millis(100)); // Wait for readers to start
///
/// // While all readers can proceed, a call to .write() has to wait for
// // current active reader locks.
/// let mut writable_data = data.write().unwrap();
/// println!("Writer proceeds...");
/// *writable_data += 1;
/// ```
///
/// [`Mutex`]: super::Mutex
@ -370,7 +382,8 @@ impl<T: ?Sized> RwLock<T> {
///
/// # Panics
///
/// This function might panic when called if the lock is already held by the current thread.
/// This function might panic when called if the lock is already held by the current thread
/// in read or write mode.
///
/// # Examples
///
@ -467,7 +480,8 @@ impl<T: ?Sized> RwLock<T> {
///
/// # Panics
///
/// This function might panic when called if the lock is already held by the current thread.
/// This function might panic when called if the lock is already held by the current thread
/// in read or write mode.
///
/// # Examples
///

View file

@ -1378,6 +1378,9 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
}
}
// The host this new compiler will *run* on.
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
if builder.config.rust_verify_llvm_ir {
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
}

View file

@ -331,10 +331,6 @@ impl Cargo {
self.rustflags.arg("-Clink-arg=-gz");
}
// Ignore linker warnings for now. These are complicated to fix and don't affect the build.
// FIXME: we should really investigate these...
self.rustflags.arg("-Alinker-messages");
// Throughout the build Cargo can execute a number of build scripts
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
// obtained previously to those build scripts.
@ -1256,13 +1252,7 @@ impl Builder<'_> {
// when compiling the standard library, since this might be linked into the final outputs
// produced by rustc. Since this mitigation is only available on Windows, only enable it
// for the standard library in case the compiler is run on a non-Windows platform.
// This is not needed for stage 0 artifacts because these will only be used for building
// the stage 1 compiler.
if cfg!(windows)
&& mode == Mode::Std
&& self.config.control_flow_guard
&& compiler.stage >= 1
{
if cfg!(windows) && mode == Mode::Std && self.config.control_flow_guard {
rustflags.arg("-Ccontrol-flow-guard");
}
@ -1270,9 +1260,7 @@ impl Builder<'_> {
// standard library, since this might be linked into the final outputs produced by rustc.
// Since this mitigation is only available on Windows, only enable it for the standard
// library in case the compiler is run on a non-Windows platform.
// This is not needed for stage 0 artifacts because these will only be used for building
// the stage 1 compiler.
if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard && compiler.stage >= 1 {
if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard {
rustflags.arg("-Zehcont-guard");
}
@ -1289,52 +1277,13 @@ impl Builder<'_> {
rustdocflags.arg("--crate-version").arg(&rust_version);
// Environment variables *required* throughout the build
//
// FIXME: should update code to not require this env var
// The host this new compiler will *run* on.
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
// The host this new compiler is being *built* on.
cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);
// Set this for all builds to make sure doc builds also get it.
cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel);
// This one's a bit tricky. As of the time of this writing the compiler
// links to the `winapi` crate on crates.io. This crate provides raw
// bindings to Windows system functions, sort of like libc does for
// Unix. This crate also, however, provides "import libraries" for the
// MinGW targets. There's an import library per dll in the windows
// distribution which is what's linked to. These custom import libraries
// are used because the winapi crate can reference Windows functions not
// present in the MinGW import libraries.
//
// For example MinGW may ship libdbghelp.a, but it may not have
// references to all the functions in the dbghelp dll. Instead the
// custom import library for dbghelp in the winapi crates has all this
// information.
//
// Unfortunately for us though the import libraries are linked by
// default via `-ldylib=winapi_foo`. That is, they're linked with the
// `dylib` type with a `winapi_` prefix (so the winapi ones don't
// conflict with the system MinGW ones). This consequently means that
// the binaries we ship of things like rustc_codegen_llvm (aka the rustc_codegen_llvm
// DLL) when linked against *again*, for example with procedural macros
// or plugins, will trigger the propagation logic of `-ldylib`, passing
// `-lwinapi_foo` to the linker again. This isn't actually available in
// our distribution, however, so the link fails.
//
// To solve this problem we tell winapi to not use its bundled import
// libraries. This means that it will link to the system MinGW import
// libraries by default, and the `-ldylib=foo` directives will still get
// passed to the final linker, but they'll look like `-lfoo` which can
// be resolved because MinGW has the import library. The downside is we
// don't get newer functions from Windows, but we don't use any of them
// anyway.
if !mode.is_tool() {
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
}
// verbose cargo output is very noisy, so only enable it with -vv
for _ in 0..self.verbosity.saturating_sub(1) {
cargo.arg("--verbose");

View file

@ -44,7 +44,6 @@ expression: bench
- Set({bench::compiler/rustc_errors})
- Set({bench::compiler/rustc_expand})
- Set({bench::compiler/rustc_feature})
- Set({bench::compiler/rustc_fluent_macro})
- Set({bench::compiler/rustc_fs_util})
- Set({bench::compiler/rustc_graphviz})
- Set({bench::compiler/rustc_hashes})

View file

@ -26,7 +26,6 @@ expression: build compiler
- Set({build::compiler/rustc_errors})
- Set({build::compiler/rustc_expand})
- Set({build::compiler/rustc_feature})
- Set({build::compiler/rustc_fluent_macro})
- Set({build::compiler/rustc_fs_util})
- Set({build::compiler/rustc_graphviz})
- Set({build::compiler/rustc_hashes})

View file

@ -28,7 +28,6 @@ expression: check
- Set({check::compiler/rustc_errors})
- Set({check::compiler/rustc_expand})
- Set({check::compiler/rustc_feature})
- Set({check::compiler/rustc_fluent_macro})
- Set({check::compiler/rustc_fs_util})
- Set({check::compiler/rustc_graphviz})
- Set({check::compiler/rustc_hashes})

View file

@ -28,7 +28,6 @@ expression: check compiler
- Set({check::compiler/rustc_errors})
- Set({check::compiler/rustc_expand})
- Set({check::compiler/rustc_feature})
- Set({check::compiler/rustc_fluent_macro})
- Set({check::compiler/rustc_fs_util})
- Set({check::compiler/rustc_graphviz})
- Set({check::compiler/rustc_hashes})

View file

@ -28,7 +28,6 @@ expression: check compiletest --include-default-paths
- Set({check::compiler/rustc_errors})
- Set({check::compiler/rustc_expand})
- Set({check::compiler/rustc_feature})
- Set({check::compiler/rustc_fluent_macro})
- Set({check::compiler/rustc_fs_util})
- Set({check::compiler/rustc_graphviz})
- Set({check::compiler/rustc_hashes})

View file

@ -43,7 +43,6 @@ expression: clippy
- Set({clippy::compiler/rustc_errors})
- Set({clippy::compiler/rustc_expand})
- Set({clippy::compiler/rustc_feature})
- Set({clippy::compiler/rustc_fluent_macro})
- Set({clippy::compiler/rustc_fs_util})
- Set({clippy::compiler/rustc_graphviz})
- Set({clippy::compiler/rustc_hashes})

View file

@ -28,7 +28,6 @@ expression: fix
- Set({fix::compiler/rustc_errors})
- Set({fix::compiler/rustc_expand})
- Set({fix::compiler/rustc_feature})
- Set({fix::compiler/rustc_fluent_macro})
- Set({fix::compiler/rustc_fs_util})
- Set({fix::compiler/rustc_graphviz})
- Set({fix::compiler/rustc_hashes})

View file

@ -94,7 +94,6 @@ expression: test
- Set({test::compiler/rustc_errors})
- Set({test::compiler/rustc_expand})
- Set({test::compiler/rustc_feature})
- Set({test::compiler/rustc_fluent_macro})
- Set({test::compiler/rustc_fs_util})
- Set({test::compiler/rustc_graphviz})
- Set({test::compiler/rustc_hashes})

View file

@ -93,7 +93,6 @@ expression: test --skip=coverage
- Set({test::compiler/rustc_errors})
- Set({test::compiler/rustc_expand})
- Set({test::compiler/rustc_feature})
- Set({test::compiler/rustc_fluent_macro})
- Set({test::compiler/rustc_fs_util})
- Set({test::compiler/rustc_graphviz})
- Set({test::compiler/rustc_hashes})

View file

@ -1,6 +1,5 @@
---
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
assertion_line: 68
expression: test --skip=tests
---
[Test] test::Tidy
@ -58,7 +57,6 @@ expression: test --skip=tests
- Set({test::compiler/rustc_errors})
- Set({test::compiler/rustc_expand})
- Set({test::compiler/rustc_feature})
- Set({test::compiler/rustc_fluent_macro})
- Set({test::compiler/rustc_fs_util})
- Set({test::compiler/rustc_graphviz})
- Set({test::compiler/rustc_hashes})

View file

@ -1,6 +1,5 @@
---
source: src/bootstrap/src/core/builder/cli_paths/tests.rs
assertion_line: 68
expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest
---
[Test] test::Tidy
@ -38,7 +37,6 @@ expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=lib
- Set({test::compiler/rustc_errors})
- Set({test::compiler/rustc_expand})
- Set({test::compiler/rustc_feature})
- Set({test::compiler/rustc_fluent_macro})
- Set({test::compiler/rustc_fs_util})
- Set({test::compiler/rustc_graphviz})
- Set({test::compiler/rustc_hashes})

View file

@ -1815,7 +1815,7 @@ mod snapshot {
insta::assert_snapshot!(
ctx.config("check")
.path("compiler")
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (75 crates)");
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (74 crates)");
}
#[test]
@ -1841,7 +1841,7 @@ mod snapshot {
ctx.config("check")
.path("compiler")
.stage(1)
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (75 crates)");
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (74 crates)");
}
#[test]
@ -1855,7 +1855,7 @@ mod snapshot {
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[check] rustc 1 <host> -> rustc 2 <host> (75 crates)
[check] rustc 1 <host> -> rustc 2 <host> (74 crates)
");
}
@ -1871,7 +1871,7 @@ mod snapshot {
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[check] rustc 1 <host> -> std 1 <target1>
[check] rustc 1 <host> -> rustc 2 <target1> (75 crates)
[check] rustc 1 <host> -> rustc 2 <target1> (74 crates)
[check] rustc 1 <host> -> rustc 2 <target1>
[check] rustc 1 <host> -> Rustdoc 2 <target1>
[check] rustc 1 <host> -> rustc_codegen_cranelift 2 <target1>
@ -1967,7 +1967,7 @@ mod snapshot {
ctx.config("check")
.paths(&["library", "compiler"])
.args(&args)
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (75 crates)");
.render_steps(), @"[check] rustc 0 <host> -> rustc 1 <host> (74 crates)");
}
#[test]

View file

@ -3,8 +3,6 @@
/// See <https://github.com/rust-lang/rust/issues/134863>
pub static CRATES: &[&str] = &[
// tidy-alphabetical-start
"annotate-snippets",
"anstyle",
"askama_derive",
"askama_parser",
"basic-toml",
@ -59,7 +57,6 @@ pub static CRATES: &[&str] = &[
"unic-langid-impl",
"unic-langid-macros",
"unicode-ident",
"unicode-width",
"version_check",
"wasm-bindgen-macro-support",
"wasm-bindgen-shared",

View file

@ -105,7 +105,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
// to align the arguments and parameters for the iteration below and to enable us to correctly
// instantiate the generic parameter default later.
let generics = cx.tcx.generics_of(owner);
let args = if !has_self && generics.parent.is_none() && generics.has_self {
let args = if !has_self && generics.has_own_self() {
has_self = true;
[cx.tcx.types.trait_object_dummy_self.into()]
.into_iter()

View file

@ -1 +0,0 @@
a_b_key = Value

View file

@ -1 +0,0 @@
a_b_key = Value

View file

@ -1,3 +0,0 @@
no_crate_a_b_key = Value
no_crate_a_b_key = Another Value

View file

@ -1 +0,0 @@
no_crate_bad_escape = don't use \n, \', or \"

View file

@ -1,2 +0,0 @@
no_crate_some_slug = hi
.label-has-hyphens = test

View file

@ -1,11 +0,0 @@
no_crate_foo = foo
# This file tests error reporting for
# fluent files with many lines.
# The error message should point to the correct line number
# and include no more context than necessary.
no_crate_bar =
no_crate_baz =
baz

View file

@ -1,2 +0,0 @@
with-hyphens = 1234
no-crate_foo = abcd

View file

@ -1 +0,0 @@
no_crate_missing_message_ref = {message}

View file

@ -1 +0,0 @@
no_crate_missing_message =

View file

@ -1 +0,0 @@
no_crate_this-slug-has-hyphens = hi

View file

@ -1,87 +0,0 @@
//@ normalize-stderr: "could not open Fluent resource:.*" -> "could not open Fluent resource: os-specific message"
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
/// Copy of the relevant `DiagMessage` variant constructed by `fluent_messages` as it
/// expects `crate::DiagMessage` to exist.
pub enum DiagMessage {
FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
}
/// Copy of the relevant `SubdiagMessage` variant constructed by `fluent_messages` as it
/// expects `crate::SubdiagMessage` to exist.
pub enum SubdiagMessage {
FluentAttr(std::borrow::Cow<'static, str>),
}
mod missing_absolute {
rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" }
//~^ ERROR could not open Fluent resource
}
mod missing_relative {
rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" }
//~^ ERROR could not open Fluent resource
}
mod missing_message {
rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" }
//~^ ERROR could not parse Fluent resource
}
mod duplicate {
rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" }
//~^ ERROR overrides existing message: `no_crate_a_b_key`
}
mod slug_with_hyphens {
rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" }
//~^ ERROR name `no_crate_this-slug-has-hyphens` contains a '-' character
}
mod label_with_hyphens {
rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" }
//~^ ERROR attribute `label-has-hyphens` contains a '-' character
}
mod valid {
rustc_fluent_macro::fluent_messages! { "./valid.ftl" }
mod test_generated {
use super::{fluent_generated::no_crate_key, DEFAULT_LOCALE_RESOURCE};
}
}
mod missing_crate_name {
rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" }
//~^ ERROR name `no-crate_foo` contains a '-' character
//~| ERROR name `with-hyphens` contains a '-' character
//~| ERROR name `with-hyphens` does not start with the crate name
mod test_generated {
use super::{
fluent_generated::{no_crate_foo, with_hyphens},
DEFAULT_LOCALE_RESOURCE,
};
}
}
mod missing_message_ref {
rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" }
//~^ ERROR referenced message `message` does not exist
}
mod bad_escape {
rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" }
//~^ ERROR invalid escape `\n`
//~| ERROR invalid escape `\"`
//~| ERROR invalid escape `\'`
}
mod many_lines {
rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" }
//~^ ERROR could not parse Fluent resource
}

View file

@ -1,122 +0,0 @@
error: could not open Fluent resource: os-specific message
--> $DIR/test.rs:21:44
|
LL | rustc_fluent_macro::fluent_messages! { "/definitely_does_not_exist.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: could not open Fluent resource: os-specific message
--> $DIR/test.rs:26:44
|
LL | rustc_fluent_macro::fluent_messages! { "../definitely_does_not_exist.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: could not parse Fluent resource
--> $DIR/test.rs:31:44
|
LL | rustc_fluent_macro::fluent_messages! { "./missing-message.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: see additional errors emitted
error: expected a message field for "no_crate_missing_message"
--> ./missing-message.ftl:1:1
|
1 | no_crate_missing_message =
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
error: overrides existing message: `no_crate_a_b_key`
--> $DIR/test.rs:36:44
|
LL | rustc_fluent_macro::fluent_messages! { "./duplicate.ftl" }
| ^^^^^^^^^^^^^^^^^
error: name `no_crate_this-slug-has-hyphens` contains a '-' character
--> $DIR/test.rs:41:44
|
LL | rustc_fluent_macro::fluent_messages! { "./slug-with-hyphens.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s
error: attribute `label-has-hyphens` contains a '-' character
--> $DIR/test.rs:46:44
|
LL | rustc_fluent_macro::fluent_messages! { "./label-with-hyphens.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s
error: name `with-hyphens` contains a '-' character
--> $DIR/test.rs:59:44
|
LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s
error: name `with-hyphens` does not start with the crate name
--> $DIR/test.rs:59:44
|
LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: prepend `no_crate_` to the slug name: `no_crate_with_hyphens`
error: name `no-crate_foo` contains a '-' character
--> $DIR/test.rs:59:44
|
LL | rustc_fluent_macro::fluent_messages! { "./missing-crate-name.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: replace any '-'s with '_'s
error: referenced message `message` does not exist (in message `no_crate_missing_message_ref`)
--> $DIR/test.rs:73:44
|
LL | rustc_fluent_macro::fluent_messages! { "./missing-message-ref.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: you may have meant to use a variable reference (`{$message}`)
error: invalid escape `\n` in Fluent resource
--> $DIR/test.rs:78:44
|
LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: invalid escape `\"` in Fluent resource
--> $DIR/test.rs:78:44
|
LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: invalid escape `\'` in Fluent resource
--> $DIR/test.rs:78:44
|
LL | rustc_fluent_macro::fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: could not parse Fluent resource
--> $DIR/test.rs:85:44
|
LL | rustc_fluent_macro::fluent_messages! { "./many-lines.ftl" }
| ^^^^^^^^^^^^^^^^^^
|
= help: see additional errors emitted
error: expected a message field for "no_crate_bar"
--> ./many-lines.ftl:8:1
|
8 | no_crate_bar =
| ^^^^^^^^^^^^^^
|
error: aborting due to 14 previous errors

View file

@ -1 +0,0 @@
no_crate_key = Valid!

View file

@ -14,7 +14,6 @@
#![crate_type = "lib"]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;
@ -24,12 +23,10 @@ use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
struct NotIntoDiagArg;
#[derive(Diagnostic)]
#[diag(no_crate_example)]
#[diag("example message")]
struct Test {
#[primary_span]
span: Span,
@ -39,7 +36,7 @@ struct Test {
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
#[label("example message")]
struct SubTest {
#[primary_span]
span: Span,

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive-doc-comment-field.rs:37:10
--> $DIR/diagnostic-derive-doc-comment-field.rs:34:10
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
@ -8,7 +8,7 @@ LL | arg: NotIntoDiagArg,
| ^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
--> $DIR/diagnostic-derive-doc-comment-field.rs:29:1
--> $DIR/diagnostic-derive-doc-comment-field.rs:26:1
|
LL | struct NotIntoDiagArg;
| ^^^^^^^^^^^^^^^^^^^^^
@ -21,7 +21,7 @@ note: required by a bound in `Diag::<'a, G>::arg`
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive-doc-comment-field.rs:47:10
--> $DIR/diagnostic-derive-doc-comment-field.rs:44:10
|
LL | #[derive(Subdiagnostic)]
| ------------- required by a bound introduced by this call
@ -30,7 +30,7 @@ LL | arg: NotIntoDiagArg,
| ^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `NotIntoDiagArg`
--> $DIR/diagnostic-derive-doc-comment-field.rs:29:1
--> $DIR/diagnostic-derive-doc-comment-field.rs:26:1
|
LL | struct NotIntoDiagArg;
| ^^^^^^^^^^^^^^^^^^^^^

View file

@ -19,7 +19,6 @@ extern crate rustc_span;
use rustc_span::symbol::Ident;
use rustc_span::Span;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};

View file

@ -1,11 +1,11 @@
error: derive(Diagnostic): unsupported type attribute for diagnostic derive enum
--> $DIR/diagnostic-derive-inline.rs:45:1
--> $DIR/diagnostic-derive-inline.rs:44:1
|
LL | #[diag("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:48:5
--> $DIR/diagnostic-derive-inline.rs:47:5
|
LL | Foo,
| ^^^
@ -13,7 +13,7 @@ LL | Foo,
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:50:5
--> $DIR/diagnostic-derive-inline.rs:49:5
|
LL | Bar,
| ^^^
@ -21,19 +21,19 @@ LL | Bar,
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: expected parentheses: #[diag(...)]
--> $DIR/diagnostic-derive-inline.rs:56:8
--> $DIR/diagnostic-derive-inline.rs:55:8
|
LL | #[diag = "E0123"]
| ^
error: derive(Diagnostic): `#[nonsense(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:61:1
--> $DIR/diagnostic-derive-inline.rs:60:1
|
LL | #[nonsense("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:61:1
--> $DIR/diagnostic-derive-inline.rs:60:1
|
LL | #[nonsense("this is an example message", code = E0123)]
| ^
@ -41,7 +41,7 @@ LL | #[nonsense("this is an example message", code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:68:1
--> $DIR/diagnostic-derive-inline.rs:67:1
|
LL | #[diag(code = E0123)]
| ^
@ -49,7 +49,7 @@ LL | #[diag(code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:73:1
--> $DIR/diagnostic-derive-inline.rs:72:1
|
LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
| ^
@ -57,7 +57,7 @@ LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:78:1
--> $DIR/diagnostic-derive-inline.rs:77:1
|
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
| ^
@ -65,7 +65,7 @@ LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:83:1
--> $DIR/diagnostic-derive-inline.rs:82:1
|
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
| ^
@ -73,7 +73,7 @@ LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): unknown argument
--> $DIR/diagnostic-derive-inline.rs:88:52
--> $DIR/diagnostic-derive-inline.rs:87:52
|
LL | #[diag("this is an example message", code = E0123, slug = "foo")]
| ^^^^
@ -81,43 +81,43 @@ LL | #[diag("this is an example message", code = E0123, slug = "foo")]
= note: only the `code` parameter is valid after the slug
error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:95:5
--> $DIR/diagnostic-derive-inline.rs:94:5
|
LL | #[suggestion = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:102:38
--> $DIR/diagnostic-derive-inline.rs:101:38
|
LL | #[diag("this is an example message", code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:101:38
--> $DIR/diagnostic-derive-inline.rs:100:38
|
LL | #[diag("this is an example message", code = E0123)]
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:107:52
--> $DIR/diagnostic-derive-inline.rs:106:52
|
LL | #[diag("this is an example message", code = E0123, code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:107:38
--> $DIR/diagnostic-derive-inline.rs:106:38
|
LL | #[diag("this is an example message", code = E0123, code = E0456)]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be the first argument
--> $DIR/diagnostic-derive-inline.rs:112:38
--> $DIR/diagnostic-derive-inline.rs:111:38
|
LL | #[diag("this is an example message", no_crate::example, code = E0123)]
| ^^^^^^^^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:117:1
--> $DIR/diagnostic-derive-inline.rs:116:1
|
LL | struct KindNotProvided {}
| ^^^^^^
@ -125,7 +125,7 @@ LL | struct KindNotProvided {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:120:1
--> $DIR/diagnostic-derive-inline.rs:119:1
|
LL | #[diag(code = E0123)]
| ^
@ -133,31 +133,31 @@ LL | #[diag(code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive-inline.rs:131:5
--> $DIR/diagnostic-derive-inline.rs:130:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): `#[nonsense]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:139:5
--> $DIR/diagnostic-derive-inline.rs:138:5
|
LL | #[nonsense]
| ^
error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive-inline.rs:156:5
--> $DIR/diagnostic-derive-inline.rs:155:5
|
LL | #[label("with a label")]
| ^
error: derive(Diagnostic): `name` doesn't refer to a field on this type
--> $DIR/diagnostic-derive-inline.rs:164:46
--> $DIR/diagnostic-derive-inline.rs:163:46
|
LL | #[suggestion("with a suggestion", code = "{name}")]
| ^^^^^^^^
error: invalid format string: expected `}` but string was terminated
--> $DIR/diagnostic-derive-inline.rs:169:10
--> $DIR/diagnostic-derive-inline.rs:168:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ expected `}` in format string
@ -166,7 +166,7 @@ LL | #[derive(Diagnostic)]
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid format string: unmatched `}` found
--> $DIR/diagnostic-derive-inline.rs:179:10
--> $DIR/diagnostic-derive-inline.rs:178:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ unmatched `}` in format string
@ -175,19 +175,19 @@ LL | #[derive(Diagnostic)]
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive-inline.rs:199:5
--> $DIR/diagnostic-derive-inline.rs:198:5
|
LL | #[label("with a label")]
| ^
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive-inline.rs:218:5
--> $DIR/diagnostic-derive-inline.rs:217:5
|
LL | #[suggestion("with a suggestion")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive-inline.rs:226:39
--> $DIR/diagnostic-derive-inline.rs:225:39
|
LL | #[suggestion("with a suggestion", nonsense = "bar")]
| ^^^^^^^^
@ -195,13 +195,13 @@ LL | #[suggestion("with a suggestion", nonsense = "bar")]
= help: only `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive-inline.rs:226:5
--> $DIR/diagnostic-derive-inline.rs:225:5
|
LL | #[suggestion("with a suggestion", nonsense = "bar")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive-inline.rs:235:39
--> $DIR/diagnostic-derive-inline.rs:234:39
|
LL | #[suggestion("with a suggestion", msg = "bar")]
| ^^^
@ -209,13 +209,13 @@ LL | #[suggestion("with a suggestion", msg = "bar")]
= help: only `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive-inline.rs:235:5
--> $DIR/diagnostic-derive-inline.rs:234:5
|
LL | #[suggestion("with a suggestion", msg = "bar")]
| ^
error: derive(Diagnostic): wrong field type for suggestion
--> $DIR/diagnostic-derive-inline.rs:258:5
--> $DIR/diagnostic-derive-inline.rs:257:5
|
LL | #[suggestion("with a suggestion", code = "This is suggested code")]
| ^
@ -223,79 +223,79 @@ LL | #[suggestion("with a suggestion", code = "This is suggested code")]
= help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:274:24
--> $DIR/diagnostic-derive-inline.rs:273:24
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:274:18
--> $DIR/diagnostic-derive-inline.rs:273:18
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:282:33
--> $DIR/diagnostic-derive-inline.rs:281:33
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:282:18
--> $DIR/diagnostic-derive-inline.rs:281:18
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:289:5
--> $DIR/diagnostic-derive-inline.rs:288:5
|
LL | #[label = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:390:5
--> $DIR/diagnostic-derive-inline.rs:389:5
|
LL | #[suggestion("with a suggestion", code = "...", applicability = "maybe-incorrect")]
| ^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:392:24
--> $DIR/diagnostic-derive-inline.rs:391:24
|
LL | suggestion: (Span, Applicability),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): invalid applicability
--> $DIR/diagnostic-derive-inline.rs:398:69
--> $DIR/diagnostic-derive-inline.rs:397:69
|
LL | #[suggestion("with a suggestion", code = "...", applicability = "batman")]
| ^^^^^^^^
error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()`
--> $DIR/diagnostic-derive-inline.rs:461:5
--> $DIR/diagnostic-derive-inline.rs:460:5
|
LL | #[help("with a help")]
| ^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/diagnostic-derive-inline.rs:470:29
--> $DIR/diagnostic-derive-inline.rs:469:29
|
LL | #[label("with a label", foo)]
| ^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/diagnostic-derive-inline.rs:478:29
--> $DIR/diagnostic-derive-inline.rs:477:29
|
LL | #[label("with a label", foo = "...")]
| ^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/diagnostic-derive-inline.rs:486:29
--> $DIR/diagnostic-derive-inline.rs:485:29
|
LL | #[label("with a label", foo("..."))]
| ^^^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:498:5
--> $DIR/diagnostic-derive-inline.rs:497:5
|
LL | #[primary_span]
| ^
@ -303,13 +303,13 @@ LL | #[primary_span]
= help: the `primary_span` field attribute is not valid for lint diagnostics
error: derive(Diagnostic): `#[error(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:518:1
--> $DIR/diagnostic-derive-inline.rs:517:1
|
LL | #[error("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:518:1
--> $DIR/diagnostic-derive-inline.rs:517:1
|
LL | #[error("this is an example message", code = E0123)]
| ^
@ -317,13 +317,13 @@ LL | #[error("this is an example message", code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:525:1
--> $DIR/diagnostic-derive-inline.rs:524:1
|
LL | #[warn_("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:525:1
--> $DIR/diagnostic-derive-inline.rs:524:1
|
LL | #[warn_("this is an example message", code = E0123)]
| ^
@ -331,13 +331,13 @@ LL | #[warn_("this is an example message", code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:532:1
--> $DIR/diagnostic-derive-inline.rs:531:1
|
LL | #[lint("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:532:1
--> $DIR/diagnostic-derive-inline.rs:531:1
|
LL | #[lint("this is an example message", code = E0123)]
| ^
@ -345,13 +345,13 @@ LL | #[lint("this is an example message", code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:539:1
--> $DIR/diagnostic-derive-inline.rs:538:1
|
LL | #[lint("this is an example message", code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive-inline.rs:539:1
--> $DIR/diagnostic-derive-inline.rs:538:1
|
LL | #[lint("this is an example message", code = E0123)]
| ^
@ -359,19 +359,19 @@ LL | #[lint("this is an example message", code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive-inline.rs:548:53
--> $DIR/diagnostic-derive-inline.rs:547:53
|
LL | #[suggestion("with a suggestion", code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive-inline.rs:548:39
--> $DIR/diagnostic-derive-inline.rs:547:39
|
LL | #[suggestion("with a suggestion", code = "...", code = ",,,")]
| ^^^^
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive-inline.rs:557:24
--> $DIR/diagnostic-derive-inline.rs:556:24
|
LL | suggestion: (Span, usize),
| ^^^^^
@ -379,7 +379,7 @@ LL | suggestion: (Span, usize),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive-inline.rs:565:17
--> $DIR/diagnostic-derive-inline.rs:564:17
|
LL | suggestion: (Span,),
| ^^^^^^^
@ -387,13 +387,13 @@ LL | suggestion: (Span,),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive-inline.rs:572:5
--> $DIR/diagnostic-derive-inline.rs:571:5
|
LL | #[suggestion("with a suggestion")]
| ^
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:579:1
--> $DIR/diagnostic-derive-inline.rs:578:1
|
LL | #[multipart_suggestion("with a suggestion")]
| ^
@ -401,7 +401,7 @@ LL | #[multipart_suggestion("with a suggestion")]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:582:1
--> $DIR/diagnostic-derive-inline.rs:581:1
|
LL | #[multipart_suggestion()]
| ^
@ -409,7 +409,7 @@ LL | #[multipart_suggestion()]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:586:5
--> $DIR/diagnostic-derive-inline.rs:585:5
|
LL | #[multipart_suggestion("with a suggestion")]
| ^
@ -417,7 +417,7 @@ LL | #[multipart_suggestion("with a suggestion")]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:594:1
--> $DIR/diagnostic-derive-inline.rs:593:1
|
LL | #[suggestion("with a suggestion", code = "...")]
| ^
@ -425,7 +425,7 @@ LL | #[suggestion("with a suggestion", code = "...")]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[label]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:603:1
--> $DIR/diagnostic-derive-inline.rs:602:1
|
LL | #[label]
| ^
@ -433,73 +433,73 @@ LL | #[label]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:637:5
--> $DIR/diagnostic-derive-inline.rs:636:5
|
LL | #[subdiagnostic(bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:645:5
--> $DIR/diagnostic-derive-inline.rs:644:5
|
LL | #[subdiagnostic = "bad"]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:653:5
--> $DIR/diagnostic-derive-inline.rs:652:5
|
LL | #[subdiagnostic(bad, bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:661:5
--> $DIR/diagnostic-derive-inline.rs:660:5
|
LL | #[subdiagnostic("bad")]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:669:5
--> $DIR/diagnostic-derive-inline.rs:668:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:677:5
--> $DIR/diagnostic-derive-inline.rs:676:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:698:5
--> $DIR/diagnostic-derive-inline.rs:697:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): expected at least one string literal for `code(...)`
--> $DIR/diagnostic-derive-inline.rs:729:44
--> $DIR/diagnostic-derive-inline.rs:728:44
|
LL | #[suggestion("with a suggestion", code())]
| ^
error: derive(Diagnostic): `code(...)` must contain only string literals
--> $DIR/diagnostic-derive-inline.rs:737:44
--> $DIR/diagnostic-derive-inline.rs:736:44
|
LL | #[suggestion("with a suggestion", code(foo))]
| ^^^
error: unexpected token, expected `)`
--> $DIR/diagnostic-derive-inline.rs:737:44
--> $DIR/diagnostic-derive-inline.rs:736:44
|
LL | #[suggestion("with a suggestion", code(foo))]
| ^^^
error: expected string literal
--> $DIR/diagnostic-derive-inline.rs:746:46
--> $DIR/diagnostic-derive-inline.rs:745:46
|
LL | #[suggestion("with a suggestion", code = 3)]
| ^
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive-inline.rs:761:5
--> $DIR/diagnostic-derive-inline.rs:760:5
|
LL | #[suggestion("with a suggestion", code = "")]
| ^
@ -509,7 +509,7 @@ LL | #[suggestion("with a suggestion", code = "")]
= help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]`
error: derive(Diagnostic): Variable `nosub` not found in diagnostic
--> $DIR/diagnostic-derive-inline.rs:773:8
--> $DIR/diagnostic-derive-inline.rs:772:8
|
LL | #[diag("does not exist: {$nosub}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -517,19 +517,19 @@ LL | #[diag("does not exist: {$nosub}")]
= help: Available fields: "sub"
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive-inline.rs:61:3
--> $DIR/diagnostic-derive-inline.rs:60:3
|
LL | #[nonsense("this is an example message", code = E0123)]
| ^^^^^^^^
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive-inline.rs:139:7
--> $DIR/diagnostic-derive-inline.rs:138:7
|
LL | #[nonsense]
| ^^^^^^^^
error: cannot find attribute `error` in this scope
--> $DIR/diagnostic-derive-inline.rs:518:3
--> $DIR/diagnostic-derive-inline.rs:517:3
|
LL | #[error("this is an example message", code = E0123)]
| ^^^^^
@ -541,7 +541,7 @@ LL | struct ErrorAttribute {}
|
error: cannot find attribute `warn_` in this scope
--> $DIR/diagnostic-derive-inline.rs:525:3
--> $DIR/diagnostic-derive-inline.rs:524:3
|
LL | #[warn_("this is an example message", code = E0123)]
| ^^^^^
@ -553,7 +553,7 @@ LL + #[warn("this is an example message", code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive-inline.rs:532:3
--> $DIR/diagnostic-derive-inline.rs:531:3
|
LL | #[lint("this is an example message", code = E0123)]
| ^^^^
@ -565,7 +565,7 @@ LL + #[link("this is an example message", code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive-inline.rs:539:3
--> $DIR/diagnostic-derive-inline.rs:538:3
|
LL | #[lint("this is an example message", code = E0123)]
| ^^^^
@ -577,7 +577,7 @@ LL + #[link("this is an example message", code = E0123)]
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive-inline.rs:579:3
--> $DIR/diagnostic-derive-inline.rs:578:3
|
LL | #[multipart_suggestion("with a suggestion")]
| ^^^^^^^^^^^^^^^^^^^^
@ -589,7 +589,7 @@ LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive-inline.rs:582:3
--> $DIR/diagnostic-derive-inline.rs:581:3
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^
@ -601,7 +601,7 @@ LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive-inline.rs:586:7
--> $DIR/diagnostic-derive-inline.rs:585:7
|
LL | #[multipart_suggestion("with a suggestion")]
| ^^^^^^^^^^^^^^^^^^^^
@ -609,7 +609,7 @@ LL | #[multipart_suggestion("with a suggestion")]
= note: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute
error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive-inline.rs:330:12
--> $DIR/diagnostic-derive-inline.rs:329:12
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
@ -618,7 +618,7 @@ LL | other: Hello,
| ^^^^^ unsatisfied trait bound
|
help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `Hello`
--> $DIR/diagnostic-derive-inline.rs:42:1
--> $DIR/diagnostic-derive-inline.rs:41:1
|
LL | struct Hello {}
| ^^^^^^^^^^^^

View file

@ -1,827 +0,0 @@
//@ check-fail
// Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
//@ normalize-stderr: "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
//@ normalize-stderr: "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC"
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
// changing the output of this test. Since Diagnostic is strictly internal to the compiler
// the test is just ignored on stable and beta:
//@ ignore-stage1
//@ ignore-beta
//@ ignore-stable
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_span;
use rustc_span::symbol::Ident;
use rustc_span::Span;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
extern crate rustc_middle;
use rustc_middle::ty::Ty;
extern crate rustc_errors;
use rustc_errors::{Applicability, DiagMessage, ErrCode, MultiSpan, SubdiagMessage};
extern crate rustc_session;
extern crate core;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
// E0123 and E0456 are no longer used, so we define our own constants here just for this test.
const E0123: ErrCode = ErrCode::from_u32(0123);
const E0456: ErrCode = ErrCode::from_u32(0456);
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct Hello {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct HelloWarn {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
//~^ ERROR unsupported type attribute for diagnostic derive enum
enum DiagnosticOnEnum {
Foo,
//~^ ERROR diagnostic slug not specified
Bar,
//~^ ERROR diagnostic slug not specified
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[diag = "E0123"]
//~^ ERROR expected parentheses: #[diag(...)]
struct WrongStructAttrStyle {}
#[derive(Diagnostic)]
#[nonsense(no_crate_example, code = E0123)]
//~^ ERROR `#[nonsense(...)]` is not a valid attribute
//~^^ ERROR diagnostic slug not specified
//~^^^ ERROR cannot find attribute `nonsense` in this scope
struct InvalidStructAttr {}
#[derive(Diagnostic)]
#[diag(code = E0123)]
//~^ ERROR diagnostic slug not specified
struct InvalidLitNestedAttr {}
#[derive(Diagnostic)]
#[diag(nonsense, code = E0123)]
//~^ ERROR cannot find value `nonsense` in module `crate::fluent_generated`
struct InvalidNestedStructAttr {}
#[derive(Diagnostic)]
#[diag(nonsense("foo"), code = E0123, slug = "foo")]
//~^ ERROR derive(Diagnostic): diagnostic slug not specified
struct InvalidNestedStructAttr1 {}
#[derive(Diagnostic)]
#[diag(nonsense = "...", code = E0123, slug = "foo")]
//~^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr2 {}
#[derive(Diagnostic)]
#[diag(nonsense = 4, code = E0123, slug = "foo")]
//~^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr3 {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123, slug = "foo")]
//~^ ERROR unknown argument
struct InvalidNestedStructAttr4 {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct WrongPlaceField {
#[suggestion = "bar"]
//~^ ERROR `#[suggestion = ...]` is not a valid attribute
sp: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[diag(no_crate_example, code = E0456)]
//~^ ERROR specified multiple times
struct DiagSpecifiedTwice {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123, code = E0456)]
//~^ ERROR specified multiple times
struct CodeSpecifiedTwice {}
#[derive(Diagnostic)]
#[diag(no_crate_example, no_crate::example, code = E0123)]
//~^ ERROR diagnostic slug must be the first argument
struct SlugSpecifiedTwice {}
#[derive(Diagnostic)]
struct KindNotProvided {} //~ ERROR diagnostic slug not specified
#[derive(Diagnostic)]
#[diag(code = E0123)]
//~^ ERROR diagnostic slug not specified
struct SlugNotProvided {}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct CodeNotProvided {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct MessageWrongType {
#[primary_span]
//~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
foo: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct InvalidPathFieldAttr {
#[nonsense]
//~^ ERROR `#[nonsense]` is not a valid attribute
//~^^ ERROR cannot find attribute `nonsense` in this scope
foo: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithField {
name: String,
#[label(no_crate_label)]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithMessageAppliedToField {
#[label(no_crate_label)]
//~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
name: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithNonexistentField {
#[suggestion(no_crate_suggestion, code = "{name}")]
//~^ ERROR `name` doesn't refer to a field on this type
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
//~^ ERROR invalid format string: expected `}`
#[diag(no_crate_example, code = E0123)]
struct ErrorMissingClosingBrace {
#[suggestion(no_crate_suggestion, code = "{name")]
suggestion: (Span, Applicability),
name: String,
val: usize,
}
#[derive(Diagnostic)]
//~^ ERROR invalid format string: unmatched `}`
#[diag(no_crate_example, code = E0123)]
struct ErrorMissingOpeningBrace {
#[suggestion(no_crate_suggestion, code = "name}")]
suggestion: (Span, Applicability),
name: String,
val: usize,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct LabelOnSpan {
#[label(no_crate_label)]
sp: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct LabelOnNonSpan {
#[label(no_crate_label)]
//~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
id: u32,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct Suggest {
#[suggestion(no_crate_suggestion, code = "This is the suggested code")]
#[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "normal")]
#[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "short")]
#[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "hidden")]
#[suggestion(no_crate_suggestion, code = "This is the suggested code", style = "verbose")]
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithoutCode {
#[suggestion(no_crate_suggestion)]
//~^ ERROR suggestion without `code = "..."`
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithBadKey {
#[suggestion(nonsense = "bar")]
//~^ ERROR invalid nested attribute
//~| ERROR suggestion without `code = "..."`
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithShorthandMsg {
#[suggestion(msg = "bar")]
//~^ ERROR invalid nested attribute
//~| ERROR suggestion without `code = "..."`
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithoutMsg {
#[suggestion(code = "bar")]
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithTypesSwapped {
#[suggestion(no_crate_suggestion, code = "This is suggested code")]
suggestion: (Applicability, Span),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithWrongTypeApplicabilityOnly {
#[suggestion(no_crate_suggestion, code = "This is suggested code")]
//~^ ERROR wrong field type for suggestion
suggestion: Applicability,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithSpanOnly {
#[suggestion(no_crate_suggestion, code = "This is suggested code")]
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithDuplicateSpanAndApplicability {
#[suggestion(no_crate_suggestion, code = "This is suggested code")]
suggestion: (Span, Span, Applicability),
//~^ ERROR specified multiple times
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct SuggestWithDuplicateApplicabilityAndSpan {
#[suggestion(no_crate_suggestion, code = "This is suggested code")]
suggestion: (Applicability, Applicability, Span),
//~^ ERROR specified multiple times
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct WrongKindOfAnnotation {
#[label = "bar"]
//~^ ERROR `#[label = ...]` is not a valid attribute
z: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct OptionsInErrors {
#[label(no_crate_label)]
label: Option<Span>,
#[suggestion(no_crate_suggestion, code = "...")]
opt_sugg: Option<(Span, Applicability)>,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct MoveOutOfBorrowError<'tcx> {
name: Ident,
ty: Ty<'tcx>,
#[primary_span]
#[label(no_crate_label)]
span: Span,
#[label(no_crate_label)]
other_span: Span,
#[suggestion(no_crate_suggestion, code = "{name}.clone()")]
opt_sugg: Option<(Span, Applicability)>,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithLifetime<'a> {
#[label(no_crate_label)]
span: Span,
name: &'a str,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithDefaultLabelAttr<'a> {
#[label]
span: Span,
name: &'a str,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ArgFieldWithoutSkip {
#[primary_span]
span: Span,
other: Hello,
//~^ ERROR the trait bound `Hello: IntoDiagArg` is not satisfied
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ArgFieldWithSkip {
#[primary_span]
span: Span,
// `Hello` does not implement `IntoDiagArg` so this would result in an error if
// not for `#[skip_arg]`.
#[skip_arg]
other: Hello,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithSpannedNote {
#[note]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithSpannedNoteCustom {
#[note(no_crate_note)]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[note]
struct ErrorWithNote {
val: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[note(no_crate_note)]
struct ErrorWithNoteCustom {
val: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithSpannedHelp {
#[help]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithSpannedHelpCustom {
#[help(no_crate_help)]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[help]
struct ErrorWithHelp {
val: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[help(no_crate_help)]
struct ErrorWithHelpCustom {
val: String,
}
#[derive(Diagnostic)]
#[help]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithHelpWrongOrder {
val: String,
}
#[derive(Diagnostic)]
#[help(no_crate_help)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithHelpCustomWrongOrder {
val: String,
}
#[derive(Diagnostic)]
#[note]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithNoteWrongOrder {
val: String,
}
#[derive(Diagnostic)]
#[note(no_crate_note)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithNoteCustomWrongOrder {
val: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ApplicabilityInBoth {
#[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")]
//~^ ERROR specified multiple times
suggestion: (Span, Applicability),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct InvalidApplicability {
#[suggestion(no_crate_suggestion, code = "...", applicability = "batman")]
//~^ ERROR invalid applicability
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ValidApplicability {
#[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")]
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct NoApplicability {
#[suggestion(no_crate_suggestion, code = "...")]
suggestion: Span,
}
#[derive(Subdiagnostic)]
#[note(no_crate_example)]
struct Note;
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct Subdiagnostic {
#[subdiagnostic]
note: Note,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct VecField {
#[primary_span]
#[label]
spans: Vec<Span>,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct UnitField {
#[primary_span]
spans: Span,
#[help]
foo: (),
#[help(no_crate_help)]
bar: (),
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct OptUnitField {
#[primary_span]
spans: Span,
#[help]
foo: Option<()>,
#[help(no_crate_help)]
bar: Option<()>,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct BoolField {
#[primary_span]
spans: Span,
#[help]
foo: bool,
#[help(no_crate_help)]
//~^ ERROR the `#[help(...)]` attribute can only be applied to fields of type
// only allow plain 'bool' fields
bar: Option<bool>,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct LabelWithTrailingPath {
#[label(no_crate_label, foo)]
//~^ ERROR a diagnostic slug must be the first argument to the attribute
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct LabelWithTrailingNameValue {
#[label(no_crate_label, foo = "...")]
//~^ ERROR no nested attribute expected here
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct LabelWithTrailingList {
#[label(no_crate_label, foo("..."))]
//~^ ERROR no nested attribute expected here
span: Span,
}
#[derive(LintDiagnostic)]
#[diag(no_crate_example)]
struct LintsGood {}
#[derive(LintDiagnostic)]
#[diag(no_crate_example)]
struct PrimarySpanOnLint {
#[primary_span]
//~^ ERROR `#[primary_span]` is not a valid attribute
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct ErrorWithMultiSpan {
#[primary_span]
span: MultiSpan,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[warning]
struct ErrorWithWarn {
val: String,
}
#[derive(Diagnostic)]
#[error(no_crate_example, code = E0123)]
//~^ ERROR `#[error(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified
//~| ERROR cannot find attribute `error` in this scope
struct ErrorAttribute {}
#[derive(Diagnostic)]
#[warn_(no_crate_example, code = E0123)]
//~^ ERROR `#[warn_(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified
//~| ERROR cannot find attribute `warn_` in this scope
struct WarnAttribute {}
#[derive(Diagnostic)]
#[lint(no_crate_example, 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(no_crate_example, code = E0123)]
//~^ ERROR `#[lint(...)]` is not a valid attribute
//~| ERROR diagnostic slug not specified
//~| ERROR cannot find attribute `lint` in this scope
struct LintAttributeOnLintDiag {}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct DuplicatedSuggestionCode {
#[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
//~^ ERROR specified multiple times
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct InvalidTypeInSuggestionTuple {
#[suggestion(no_crate_suggestion, code = "...")]
suggestion: (Span, usize),
//~^ ERROR wrong types for suggestion
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct MissingApplicabilityInSuggestionTuple {
#[suggestion(no_crate_suggestion, code = "...")]
suggestion: (Span,),
//~^ ERROR wrong types for suggestion
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct MissingCodeInSuggestion {
#[suggestion(no_crate_suggestion)]
//~^ ERROR suggestion without `code = "..."`
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[multipart_suggestion(no_crate_suggestion)]
//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
//~| ERROR cannot find attribute `multipart_suggestion` in this scope
#[multipart_suggestion()]
//~^ ERROR cannot find attribute `multipart_suggestion` in this scope
//~| ERROR `#[multipart_suggestion(...)]` is not a valid attribute
struct MultipartSuggestion {
#[multipart_suggestion(no_crate_suggestion)]
//~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
//~| ERROR cannot find attribute `multipart_suggestion` in this scope
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[suggestion(no_crate_suggestion, code = "...")]
//~^ ERROR `#[suggestion(...)]` is not a valid attribute
struct SuggestionOnStruct {
#[primary_span]
suggestion: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
#[label]
//~^ ERROR `#[label]` is not a valid attribute
struct LabelOnStruct {
#[primary_span]
suggestion: Span,
}
#[derive(Diagnostic)]
enum ExampleEnum {
#[diag(no_crate_example)]
Foo {
#[primary_span]
sp: Span,
#[note]
note_sp: Span,
},
#[diag(no_crate_example)]
Bar {
#[primary_span]
sp: Span,
},
#[diag(no_crate_example)]
Baz,
}
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct RawIdentDiagnosticArg {
pub r#type: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticBad {
#[subdiagnostic(bad)]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
note: Note,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticBadStr {
#[subdiagnostic = "bad"]
//~^ ERROR `#[subdiagnostic = ...]` is not a valid attribute
note: Note,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticBadTwice {
#[subdiagnostic(bad, bad)]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
note: Note,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticBadLitStr {
#[subdiagnostic("bad")]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
note: Note,
}
#[derive(LintDiagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticEagerLint {
#[subdiagnostic(eager)]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
note: Note,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticEagerFormerlyCorrect {
#[subdiagnostic(eager)]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
note: Note,
}
// Check that formatting of `correct` in suggestion doesn't move the binding for that field, making
// the `arg` call a compile error; and that isn't worked around by moving the `arg` call
// after the `span_suggestion` call - which breaks eager translation.
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, applicability = "machine-applicable", code = "{correct}")]
pub(crate) struct SubdiagnosticWithSuggestion {
#[primary_span]
span: Span,
invalid: String,
correct: String,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SubdiagnosticEagerSuggestion {
#[subdiagnostic(eager)]
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
sub: SubdiagnosticWithSuggestion,
}
/// with a doc comment on the type..
#[derive(Diagnostic)]
#[diag(no_crate_example, code = E0123)]
struct WithDocComment {
/// ..and the field
#[primary_span]
span: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionsGood {
#[suggestion(code("foo", "bar"))]
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionsSingleItem {
#[suggestion(code("foo"))]
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionsNoItem {
#[suggestion(code())]
//~^ ERROR expected at least one string literal for `code(...)`
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionsInvalidItem {
#[suggestion(code(foo))]
//~^ ERROR `code(...)` must contain only string literals
//~| ERROR unexpected token, expected `)`
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionsInvalidLiteral {
#[suggestion(code = 3)]
//~^ ERROR expected string literal
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionStyleGood {
#[suggestion(code = "", style = "hidden")]
sub: Span,
}
#[derive(Diagnostic)]
#[diag(no_crate_example)]
struct SuggestionOnVec {
#[suggestion(no_crate_suggestion, code = "")]
//~^ ERROR `#[suggestion(...)]` is not a valid attribute
sub: Vec<Span>,
}

View file

@ -1,634 +0,0 @@
error: derive(Diagnostic): unsupported type attribute for diagnostic derive enum
--> $DIR/diagnostic-derive.rs:49:1
|
LL | #[diag(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:52:5
|
LL | Foo,
| ^^^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:54:5
|
LL | Bar,
| ^^^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: expected parentheses: #[diag(...)]
--> $DIR/diagnostic-derive.rs:60:8
|
LL | #[diag = "E0123"]
| ^
error: derive(Diagnostic): `#[nonsense(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:65:1
|
LL | #[nonsense(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:65:1
|
LL | #[nonsense(no_crate_example, code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:72:1
|
LL | #[diag(code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:82:1
|
LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:87:1
|
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:92:1
|
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): unknown argument
--> $DIR/diagnostic-derive.rs:97:40
|
LL | #[diag(no_crate_example, code = E0123, slug = "foo")]
| ^^^^
|
= note: only the `code` parameter is valid after the slug
error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:104:5
|
LL | #[suggestion = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:111:26
|
LL | #[diag(no_crate_example, code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:110:26
|
LL | #[diag(no_crate_example, code = E0123)]
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:116:40
|
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:116:26
|
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be the first argument
--> $DIR/diagnostic-derive.rs:121:26
|
LL | #[diag(no_crate_example, no_crate::example, code = E0123)]
| ^^^^^^^^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:126:1
|
LL | struct KindNotProvided {}
| ^^^^^^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:129:1
|
LL | #[diag(code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:140:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): `#[nonsense]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:148:5
|
LL | #[nonsense]
| ^
error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:165:5
|
LL | #[label(no_crate_label)]
| ^
error: derive(Diagnostic): `name` doesn't refer to a field on this type
--> $DIR/diagnostic-derive.rs:173:46
|
LL | #[suggestion(no_crate_suggestion, code = "{name}")]
| ^^^^^^^^
error: invalid format string: expected `}` but string was terminated
--> $DIR/diagnostic-derive.rs:178:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ expected `}` in format string
|
= note: if you intended to print `{`, you can escape it using `{{`
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid format string: unmatched `}` found
--> $DIR/diagnostic-derive.rs:188:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:208:5
|
LL | #[label(no_crate_label)]
| ^
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:227:5
|
LL | #[suggestion(no_crate_suggestion)]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive.rs:235:18
|
LL | #[suggestion(nonsense = "bar")]
| ^^^^^^^^
|
= help: only `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:235:5
|
LL | #[suggestion(nonsense = "bar")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive.rs:244:18
|
LL | #[suggestion(msg = "bar")]
| ^^^
|
= help: only `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:244:5
|
LL | #[suggestion(msg = "bar")]
| ^
error: derive(Diagnostic): wrong field type for suggestion
--> $DIR/diagnostic-derive.rs:267:5
|
LL | #[suggestion(no_crate_suggestion, code = "This is suggested code")]
| ^
|
= help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:283:24
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:283:18
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:291:33
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:291:18
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:298:5
|
LL | #[label = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:449:5
|
LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")]
| ^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:451:24
|
LL | suggestion: (Span, Applicability),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): invalid applicability
--> $DIR/diagnostic-derive.rs:457:69
|
LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")]
| ^^^^^^^^
error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()`
--> $DIR/diagnostic-derive.rs:524:5
|
LL | #[help(no_crate_help)]
| ^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/diagnostic-derive.rs:533:29
|
LL | #[label(no_crate_label, foo)]
| ^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/diagnostic-derive.rs:541:29
|
LL | #[label(no_crate_label, foo = "...")]
| ^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/diagnostic-derive.rs:549:29
|
LL | #[label(no_crate_label, foo("..."))]
| ^^^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:561:5
|
LL | #[primary_span]
| ^
|
= help: the `primary_span` field attribute is not valid for lint diagnostics
error: derive(Diagnostic): `#[error(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:581:1
|
LL | #[error(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:581:1
|
LL | #[error(no_crate_example, code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:588:1
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:588:1
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:595:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:595:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:602:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:602:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:611:53
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:611:39
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive.rs:620:24
|
LL | suggestion: (Span, usize),
| ^^^^^
|
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive.rs:628:17
|
LL | suggestion: (Span,),
| ^^^^^^^
|
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:635:5
|
LL | #[suggestion(no_crate_suggestion)]
| ^
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:642:1
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^
|
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:645:1
|
LL | #[multipart_suggestion()]
| ^
|
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:649:5
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^
|
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:657:1
|
LL | #[suggestion(no_crate_suggestion, code = "...")]
| ^
|
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[label]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:666:1
|
LL | #[label]
| ^
|
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:700:5
|
LL | #[subdiagnostic(bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:708:5
|
LL | #[subdiagnostic = "bad"]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:716:5
|
LL | #[subdiagnostic(bad, bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:724:5
|
LL | #[subdiagnostic("bad")]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:732:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:740:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:761:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): expected at least one string literal for `code(...)`
--> $DIR/diagnostic-derive.rs:792:23
|
LL | #[suggestion(code())]
| ^
error: derive(Diagnostic): `code(...)` must contain only string literals
--> $DIR/diagnostic-derive.rs:800:23
|
LL | #[suggestion(code(foo))]
| ^^^
error: unexpected token, expected `)`
--> $DIR/diagnostic-derive.rs:800:23
|
LL | #[suggestion(code(foo))]
| ^^^
error: expected string literal
--> $DIR/diagnostic-derive.rs:809:25
|
LL | #[suggestion(code = 3)]
| ^
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:824:5
|
LL | #[suggestion(no_crate_suggestion, code = "")]
| ^
|
= note: `#[suggestion(...)]` applied to `Vec` field is ambiguous
= help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]`
= help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]`
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive.rs:65:3
|
LL | #[nonsense(no_crate_example, code = E0123)]
| ^^^^^^^^
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive.rs:148:7
|
LL | #[nonsense]
| ^^^^^^^^
error: cannot find attribute `error` in this scope
--> $DIR/diagnostic-derive.rs:581:3
|
LL | #[error(no_crate_example, code = E0123)]
| ^^^^^
|
help: `error` is an attribute that can be used by the derive macro `Error`, you might be missing a `derive` attribute
|
LL + #[derive(Error)]
LL | struct ErrorAttribute {}
|
error: cannot find attribute `warn_` in this scope
--> $DIR/diagnostic-derive.rs:588:3
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^^^^^
|
help: a built-in attribute with a similar name exists
|
LL - #[warn_(no_crate_example, code = E0123)]
LL + #[warn(no_crate_example, code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:595:3
|
LL | #[lint(no_crate_example, code = E0123)]
| ^^^^
|
help: a built-in attribute with a similar name exists
|
LL - #[lint(no_crate_example, code = E0123)]
LL + #[link(no_crate_example, code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:602:3
|
LL | #[lint(no_crate_example, code = E0123)]
| ^^^^
|
help: a built-in attribute with a similar name exists
|
LL - #[lint(no_crate_example, code = E0123)]
LL + #[link(no_crate_example, code = E0123)]
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:642:3
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
|
help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute
|
LL + #[derive(Subdiagnostic)]
LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:645:3
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^
|
help: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute
|
LL + #[derive(Subdiagnostic)]
LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:649:7
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `multipart_suggestion` is an attribute that can be used by the derive macro `Subdiagnostic`, you might be missing a `derive` attribute
error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated`
--> $DIR/diagnostic-derive.rs:77:8
|
LL | #[diag(nonsense, code = E0123)]
| ^^^^^^^^ not found in `crate::fluent_generated`
error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive.rs:347:12
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
...
LL | other: Hello,
| ^^^^^ unsatisfied trait bound
|
help: the nightly-only, unstable trait `IntoDiagArg` is not implemented for `Hello`
--> $DIR/diagnostic-derive.rs:42:1
|
LL | struct Hello {}
| ^^^^^^^^^^^^
= help: normalized in stderr
note: required by a bound in `Diag::<'a, G>::arg`
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
|
= note: in this macro invocation
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 80 previous errors
Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.

View file

@ -1,24 +0,0 @@
//@ rustc-env:CARGO_CRATE_NAME=rustc_dummy
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_span;
use rustc_span::symbol::Ident;
use rustc_span::Span;
extern crate rustc_macros;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
extern crate rustc_middle;
use rustc_middle::ty::Ty;
extern crate rustc_errors;
use rustc_errors::{Applicability, MultiSpan};
extern crate rustc_session;
#[derive(Diagnostic)]
#[diag(compiletest_example, code = E0123)]
//~^ ERROR diagnostic slug and crate name do not match
struct Hello {}

View file

@ -1,11 +0,0 @@
error: derive(Diagnostic): diagnostic slug and crate name do not match
--> $DIR/enforce_slug_naming.rs:22:8
|
LL | #[diag(compiletest_example, code = E0123)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: slug is `compiletest_example` but the crate name is `rustc_dummy`
= help: expected a slug starting with `dummy_...`
error: aborting due to 1 previous error

View file

@ -1,7 +0,0 @@
no_crate_example = this is an example message used in testing
.note = with a note
.help = with a help
.suggestion = with a suggestion
.label = with a label
no_crate_bad_reference = {$r} does not exist

View file

@ -1,20 +0,0 @@
//@ run-fail
//@ compile-flags: --test
// test that messages referencing non-existent fields cause test failures
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_driver;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_errors;
use rustc_macros::Diagnostic;
use rustc_errors::{DiagMessage, SubdiagMessage};
extern crate rustc_session;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
#[derive(Diagnostic)]
#[diag(no_crate_bad_reference)]
struct BadRef;

View file

@ -1,37 +0,0 @@
//@ check-fail
// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)].
// This test is split off from the main `subdiagnostic-derive`,
// because this error is generated post-expansion.
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler
// the test is just ignored on stable and beta:
//@ ignore-stage1
//@ ignore-beta
//@ ignore-stable
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;
extern crate core;
use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
use rustc_macros::Subdiagnostic;
use rustc_span::Span;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
#[derive(Subdiagnostic)]
#[label(slug)]
//~^ ERROR cannot find value `slug` in module `crate::fluent_generated`
//~^^ NOTE not found in `crate::fluent_generated`
struct L {
#[primary_span]
span: Span,
var: String,
}

View file

@ -1,9 +0,0 @@
error[E0425]: cannot find value `slug` in module `crate::fluent_generated`
--> $DIR/subdiagnostic-derive-2.rs:30:9
|
LL | #[label(slug)]
| ^^^^ not found in `crate::fluent_generated`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0425`.

View file

@ -12,7 +12,6 @@
#![crate_type = "lib"]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;

View file

@ -1,143 +1,143 @@
error: derive(Diagnostic): label without `#[primary_span]` field
--> $DIR/subdiagnostic-derive-inline.rs:50:1
--> $DIR/subdiagnostic-derive-inline.rs:49:1
|
LL | #[label("example message")]
| ^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:57:1
--> $DIR/subdiagnostic-derive-inline.rs:56:1
|
LL | #[label]
| ^
error: derive(Diagnostic): `#[foo]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:66:1
--> $DIR/subdiagnostic-derive-inline.rs:65:1
|
LL | #[foo]
| ^
error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:76:1
--> $DIR/subdiagnostic-derive-inline.rs:75:1
|
LL | #[label = "..."]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:85:9
--> $DIR/subdiagnostic-derive-inline.rs:84:9
|
LL | #[label(bug = "...")]
| ^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:85:1
--> $DIR/subdiagnostic-derive-inline.rs:84:1
|
LL | #[label(bug = "...")]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:95:9
--> $DIR/subdiagnostic-derive-inline.rs:94:9
|
LL | #[label(slug = 4)]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:95:1
--> $DIR/subdiagnostic-derive-inline.rs:94:1
|
LL | #[label(slug = 4)]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:105:9
--> $DIR/subdiagnostic-derive-inline.rs:104:9
|
LL | #[label(slug("..."))]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:105:1
--> $DIR/subdiagnostic-derive-inline.rs:104:1
|
LL | #[label(slug("..."))]
| ^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:115:1
--> $DIR/subdiagnostic-derive-inline.rs:114:1
|
LL | #[label()]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:124:28
--> $DIR/subdiagnostic-derive-inline.rs:123:28
|
LL | #[label("example message", code = "...")]
| ^^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:133:28
--> $DIR/subdiagnostic-derive-inline.rs:132:28
|
LL | #[label("example message", applicability = "machine-applicable")]
| ^^^^^^^^^^^^^
error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum
--> $DIR/subdiagnostic-derive-inline.rs:142:1
--> $DIR/subdiagnostic-derive-inline.rs:141:1
|
LL | #[foo]
| ^
error: derive(Diagnostic): `#[bar]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:156:5
--> $DIR/subdiagnostic-derive-inline.rs:155:5
|
LL | #[bar]
| ^
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:168:5
--> $DIR/subdiagnostic-derive-inline.rs:167:5
|
LL | #[bar = "..."]
| ^
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:180:5
--> $DIR/subdiagnostic-derive-inline.rs:179:5
|
LL | #[bar = 4]
| ^
error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:192:5
--> $DIR/subdiagnostic-derive-inline.rs:191:5
|
LL | #[bar("...")]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive-inline.rs:204:13
--> $DIR/subdiagnostic-derive-inline.rs:203:13
|
LL | #[label(code = "...")]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive-inline.rs:204:5
--> $DIR/subdiagnostic-derive-inline.rs:203:5
|
LL | #[label(code = "...")]
| ^
error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive-inline.rs:233:5
--> $DIR/subdiagnostic-derive-inline.rs:232:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): label without `#[primary_span]` field
--> $DIR/subdiagnostic-derive-inline.rs:230:1
--> $DIR/subdiagnostic-derive-inline.rs:229:1
|
LL | #[label("example message")]
| ^
error: derive(Diagnostic): `#[applicability]` is only valid on suggestions
--> $DIR/subdiagnostic-derive-inline.rs:243:5
--> $DIR/subdiagnostic-derive-inline.rs:242:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): `#[bar]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:253:5
--> $DIR/subdiagnostic-derive-inline.rs:252:5
|
LL | #[bar]
| ^
@ -145,13 +145,13 @@ LL | #[bar]
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:264:5
--> $DIR/subdiagnostic-derive-inline.rs:263:5
|
LL | #[bar = "..."]
| ^
error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:275:5
--> $DIR/subdiagnostic-derive-inline.rs:274:5
|
LL | #[bar("...")]
| ^
@ -159,7 +159,7 @@ LL | #[bar("...")]
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: unexpected unsupported untagged union
--> $DIR/subdiagnostic-derive-inline.rs:291:1
--> $DIR/subdiagnostic-derive-inline.rs:290:1
|
LL | / union AC {
LL | |
@ -169,97 +169,97 @@ LL | | }
| |_^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/subdiagnostic-derive-inline.rs:306:28
--> $DIR/subdiagnostic-derive-inline.rs:305:28
|
LL | #[label("example message", no_crate::example)]
| ^^^^^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive-inline.rs:319:5
--> $DIR/subdiagnostic-derive-inline.rs:318:5
|
LL | #[primary_span]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive-inline.rs:316:5
--> $DIR/subdiagnostic-derive-inline.rs:315:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): subdiagnostic kind not specified
--> $DIR/subdiagnostic-derive-inline.rs:325:8
--> $DIR/subdiagnostic-derive-inline.rs:324:8
|
LL | struct AG {
| ^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive-inline.rs:362:47
--> $DIR/subdiagnostic-derive-inline.rs:361:47
|
LL | #[suggestion("example message", code = "...", code = "...")]
| ^^^^
|
note: previously specified here
--> $DIR/subdiagnostic-derive-inline.rs:362:33
--> $DIR/subdiagnostic-derive-inline.rs:361:33
|
LL | #[suggestion("example message", code = "...", code = "...")]
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive-inline.rs:380:5
--> $DIR/subdiagnostic-derive-inline.rs:379:5
|
LL | #[applicability]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive-inline.rs:377:5
--> $DIR/subdiagnostic-derive-inline.rs:376:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): the `#[applicability]` attribute can only be applied to fields of type `Applicability`
--> $DIR/subdiagnostic-derive-inline.rs:390:5
--> $DIR/subdiagnostic-derive-inline.rs:389:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:403:1
--> $DIR/subdiagnostic-derive-inline.rs:402:1
|
LL | #[suggestion("example message")]
| ^
error: derive(Diagnostic): invalid applicability
--> $DIR/subdiagnostic-derive-inline.rs:413:63
--> $DIR/subdiagnostic-derive-inline.rs:412:63
|
LL | #[suggestion("example message", code = "...", applicability = "foo")]
| ^^^^^
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive-inline.rs:431:1
--> $DIR/subdiagnostic-derive-inline.rs:430:1
|
LL | #[suggestion("example message", code = "...")]
| ^
error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum
--> $DIR/subdiagnostic-derive-inline.rs:445:1
--> $DIR/subdiagnostic-derive-inline.rs:444:1
|
LL | #[label]
| ^
error: derive(Diagnostic): `var` doesn't refer to a field on this type
--> $DIR/subdiagnostic-derive-inline.rs:465:40
--> $DIR/subdiagnostic-derive-inline.rs:464:40
|
LL | #[suggestion("example message", code = "{var}", applicability = "machine-applicable")]
| ^^^^^^^
error: derive(Diagnostic): `var` doesn't refer to a field on this type
--> $DIR/subdiagnostic-derive-inline.rs:484:44
--> $DIR/subdiagnostic-derive-inline.rs:483:44
|
LL | #[suggestion("example message", code = "{var}", applicability = "machine-applicable")]
| ^^^^^^^
error: derive(Diagnostic): `#[suggestion_part]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:507:5
--> $DIR/subdiagnostic-derive-inline.rs:506:5
|
LL | #[suggestion_part]
| ^
@ -267,7 +267,7 @@ LL | #[suggestion_part]
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead
error: derive(Diagnostic): `#[suggestion_part(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:510:5
--> $DIR/subdiagnostic-derive-inline.rs:509:5
|
LL | #[suggestion_part(code = "...")]
| ^
@ -275,13 +275,13 @@ LL | #[suggestion_part(code = "...")]
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive-inline.rs:504:1
--> $DIR/subdiagnostic-derive-inline.rs:503:1
|
LL | #[suggestion("example message", code = "...")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/subdiagnostic-derive-inline.rs:519:43
--> $DIR/subdiagnostic-derive-inline.rs:518:43
|
LL | #[multipart_suggestion("example message", code = "...", applicability = "machine-applicable")]
| ^^^^
@ -289,25 +289,25 @@ LL | #[multipart_suggestion("example message", code = "...", applicability = "ma
= help: only `style` and `applicability` are valid nested attributes
error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive-inline.rs:519:1
--> $DIR/subdiagnostic-derive-inline.rs:518:1
|
LL | #[multipart_suggestion("example message", code = "...", applicability = "machine-applicable")]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:529:5
--> $DIR/subdiagnostic-derive-inline.rs:528:5
|
LL | #[suggestion_part]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:537:5
--> $DIR/subdiagnostic-derive-inline.rs:536:5
|
LL | #[suggestion_part()]
| ^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:546:5
--> $DIR/subdiagnostic-derive-inline.rs:545:5
|
LL | #[primary_span]
| ^
@ -315,127 +315,127 @@ LL | #[primary_span]
= help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]`
error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive-inline.rs:543:1
--> $DIR/subdiagnostic-derive-inline.rs:542:1
|
LL | #[multipart_suggestion("example message")]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:554:5
--> $DIR/subdiagnostic-derive-inline.rs:553:5
|
LL | #[suggestion_part]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:557:5
--> $DIR/subdiagnostic-derive-inline.rs:556:5
|
LL | #[suggestion_part()]
| ^
error: derive(Diagnostic): `code` is the only valid nested attribute
--> $DIR/subdiagnostic-derive-inline.rs:560:23
--> $DIR/subdiagnostic-derive-inline.rs:559:23
|
LL | #[suggestion_part(foo = "bar")]
| ^^^
error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive-inline.rs:564:5
--> $DIR/subdiagnostic-derive-inline.rs:563:5
|
LL | #[suggestion_part(code = "...")]
| ^
error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive-inline.rs:567:5
--> $DIR/subdiagnostic-derive-inline.rs:566:5
|
LL | #[suggestion_part()]
| ^
error: expected `,`
--> $DIR/subdiagnostic-derive-inline.rs:560:27
--> $DIR/subdiagnostic-derive-inline.rs:559:27
|
LL | #[suggestion_part(foo = "bar")]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive-inline.rs:575:37
--> $DIR/subdiagnostic-derive-inline.rs:574:37
|
LL | #[suggestion_part(code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
--> $DIR/subdiagnostic-derive-inline.rs:575:23
--> $DIR/subdiagnostic-derive-inline.rs:574:23
|
LL | #[suggestion_part(code = "...", code = ",,,")]
| ^^^^
error: derive(Diagnostic): `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."`
--> $DIR/subdiagnostic-derive-inline.rs:604:5
--> $DIR/subdiagnostic-derive-inline.rs:603:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive-inline.rs:652:28
--> $DIR/subdiagnostic-derive-inline.rs:651:28
|
LL | #[suggestion_part(code("foo"))]
| ^^^^^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive-inline.rs:652:28
--> $DIR/subdiagnostic-derive-inline.rs:651:28
|
LL | #[suggestion_part(code("foo"))]
| ^^^^^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive-inline.rs:662:28
--> $DIR/subdiagnostic-derive-inline.rs:661:28
|
LL | #[suggestion_part(code("foo", "bar"))]
| ^^^^^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive-inline.rs:662:28
--> $DIR/subdiagnostic-derive-inline.rs:661:28
|
LL | #[suggestion_part(code("foo", "bar"))]
| ^^^^^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive-inline.rs:672:28
--> $DIR/subdiagnostic-derive-inline.rs:671:28
|
LL | #[suggestion_part(code(3))]
| ^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive-inline.rs:672:28
--> $DIR/subdiagnostic-derive-inline.rs:671:28
|
LL | #[suggestion_part(code(3))]
| ^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive-inline.rs:682:28
--> $DIR/subdiagnostic-derive-inline.rs:681:28
|
LL | #[suggestion_part(code())]
| ^
error: expected string literal
--> $DIR/subdiagnostic-derive-inline.rs:691:30
--> $DIR/subdiagnostic-derive-inline.rs:690:30
|
LL | #[suggestion_part(code = 3)]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive-inline.rs:733:1
--> $DIR/subdiagnostic-derive-inline.rs:732:1
|
LL | #[suggestion("example message", code = "", style = "hidden", style = "normal")]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive-inline.rs:733:1
--> $DIR/subdiagnostic-derive-inline.rs:732:1
|
LL | #[suggestion("example message", code = "", style = "hidden", style = "normal")]
| ^
error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:742:1
--> $DIR/subdiagnostic-derive-inline.rs:741:1
|
LL | #[suggestion_hidden("example message", code = "")]
| ^
@ -443,7 +443,7 @@ LL | #[suggestion_hidden("example message", code = "")]
= help: Use `#[suggestion(..., style = "hidden")]` instead
error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:750:1
--> $DIR/subdiagnostic-derive-inline.rs:749:1
|
LL | #[suggestion_hidden("example message", code = "", style = "normal")]
| ^
@ -451,7 +451,7 @@ LL | #[suggestion_hidden("example message", code = "", style = "normal")]
= help: Use `#[suggestion(..., style = "hidden")]` instead
error: derive(Diagnostic): invalid suggestion style
--> $DIR/subdiagnostic-derive-inline.rs:758:52
--> $DIR/subdiagnostic-derive-inline.rs:757:52
|
LL | #[suggestion("example message", code = "", style = "foo")]
| ^^^^^
@ -459,25 +459,25 @@ LL | #[suggestion("example message", code = "", style = "foo")]
= help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`
error: expected string literal
--> $DIR/subdiagnostic-derive-inline.rs:766:52
--> $DIR/subdiagnostic-derive-inline.rs:765:52
|
LL | #[suggestion("example message", code = "", style = 42)]
| ^^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/subdiagnostic-derive-inline.rs:774:44
--> $DIR/subdiagnostic-derive-inline.rs:773:44
|
LL | #[suggestion("example message", code = "", style)]
| ^^^^^
error: expected `=`
--> $DIR/subdiagnostic-derive-inline.rs:782:49
--> $DIR/subdiagnostic-derive-inline.rs:781:49
|
LL | #[suggestion("example message", code = "", style("foo"))]
| ^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/subdiagnostic-derive-inline.rs:793:5
--> $DIR/subdiagnostic-derive-inline.rs:792:5
|
LL | #[primary_span]
| ^
@ -486,61 +486,61 @@ LL | #[primary_span]
= help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive-inline.rs:790:1
--> $DIR/subdiagnostic-derive-inline.rs:789:1
|
LL | #[suggestion("example message", code = "")]
| ^
error: cannot find attribute `foo` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:66:3
--> $DIR/subdiagnostic-derive-inline.rs:65:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `foo` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:142:3
--> $DIR/subdiagnostic-derive-inline.rs:141:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:156:7
--> $DIR/subdiagnostic-derive-inline.rs:155:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:168:7
--> $DIR/subdiagnostic-derive-inline.rs:167:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:180:7
--> $DIR/subdiagnostic-derive-inline.rs:179:7
|
LL | #[bar = 4]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:192:7
--> $DIR/subdiagnostic-derive-inline.rs:191:7
|
LL | #[bar("...")]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:253:7
--> $DIR/subdiagnostic-derive-inline.rs:252:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:264:7
--> $DIR/subdiagnostic-derive-inline.rs:263:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive-inline.rs:275:7
--> $DIR/subdiagnostic-derive-inline.rs:274:7
|
LL | #[bar("...")]
| ^^^

View file

@ -1,809 +0,0 @@
//@ check-fail
// Tests error conditions for specifying subdiagnostics using #[derive(Subdiagnostic)]
// The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
// changing the output of this test. Since Subdiagnostic is strictly internal to the compiler
// the test is just ignored on stable and beta:
//@ ignore-stage1
//@ ignore-beta
//@ ignore-stable
#![feature(rustc_private)]
#![crate_type = "lib"]
extern crate rustc_errors;
extern crate rustc_fluent_macro;
extern crate rustc_macros;
extern crate rustc_session;
extern crate rustc_span;
extern crate core;
use rustc_errors::{Applicability, DiagMessage, SubdiagMessage};
use rustc_macros::Subdiagnostic;
use rustc_span::Span;
rustc_fluent_macro::fluent_messages! { "./example.ftl" }
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct A {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
enum B {
#[label(no_crate_example)]
A {
#[primary_span]
span: Span,
var: String,
},
#[label(no_crate_example)]
B {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
//~^ ERROR label without `#[primary_span]` field
struct C {
var: String,
}
#[derive(Subdiagnostic)]
#[label]
//~^ ERROR diagnostic slug must be first argument
struct D {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[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(Subdiagnostic)]
#[label = "..."]
//~^ ERROR `#[label = ...]` is not a valid attribute
struct F {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label(bug = "...")]
//~^ ERROR no nested attribute expected here
//~| ERROR diagnostic slug must be first argument
struct G {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label(slug = 4)]
//~^ ERROR no nested attribute expected here
//~| ERROR diagnostic slug must be first argument
struct J {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label(slug("..."))]
//~^ ERROR no nested attribute expected here
//~| ERROR diagnostic slug must be first argument
struct K {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label()]
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
struct M {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example, code = "...")]
//~^ ERROR no nested attribute expected here
struct N {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example, applicability = "machine-applicable")]
//~^ ERROR no nested attribute expected here
struct O {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[foo]
//~^ ERROR cannot find attribute `foo` in this scope
//~^^ ERROR unsupported type attribute for subdiagnostic enum
enum P {
#[label(no_crate_example)]
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
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(Subdiagnostic)]
enum R {
#[bar = "..."]
//~^ ERROR `#[bar = ...]` is not a valid attribute
//~^^ ERROR cannot find attribute `bar` in this scope
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
enum S {
#[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(Subdiagnostic)]
enum T {
#[bar("...")]
//~^ ERROR `#[bar(...)]` is not a valid attribute
//~^^ ERROR cannot find attribute `bar` in this scope
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
enum U {
#[label(code = "...")]
//~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute
//~| ERROR no nested attribute expected here
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
enum V {
#[label(no_crate_example)]
A {
#[primary_span]
span: Span,
var: String,
},
B {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
//~^ ERROR label without `#[primary_span]` field
struct W {
#[primary_span]
//~^ ERROR the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
span: String,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct X {
#[primary_span]
span: Span,
#[applicability]
//~^ ERROR `#[applicability]` is only valid on suggestions
applicability: Applicability,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
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(Subdiagnostic)]
#[label(no_crate_example)]
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(Subdiagnostic)]
#[label(no_crate_example)]
struct AA {
#[primary_span]
span: Span,
#[bar("...")]
//~^ ERROR `#[bar(...)]` is not a valid attribute
//~^^ ERROR cannot find attribute `bar` in this scope
bar: String,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct AB {
#[primary_span]
span: Span,
#[skip_arg]
z: Z,
}
#[derive(Subdiagnostic)]
union AC {
//~^ ERROR unexpected unsupported untagged union
span: u32,
b: u64,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
#[label(no_crate_example)]
struct AD {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example, no_crate::example)]
//~^ ERROR a diagnostic slug must be the first argument to the attribute
struct AE {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct AF {
#[primary_span]
//~^ NOTE previously specified here
span_a: Span,
#[primary_span]
//~^ ERROR specified multiple times
span_b: Span,
}
#[derive(Subdiagnostic)]
struct AG {
//~^ ERROR subdiagnostic kind not specified
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
struct AH {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
var: String,
}
#[derive(Subdiagnostic)]
enum AI {
#[suggestion(no_crate_example, code = "...")]
A {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
var: String,
},
#[suggestion(no_crate_example, code = "...")]
B {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
var: String,
},
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...", code = "...")]
//~^ ERROR specified multiple times
//~^^ NOTE previously specified here
struct AJ {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
struct AK {
#[primary_span]
span: Span,
#[applicability]
//~^ NOTE previously specified here
applicability_a: Applicability,
#[applicability]
//~^ ERROR specified multiple times
applicability_b: Applicability,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
struct AL {
#[primary_span]
span: Span,
#[applicability]
//~^ ERROR the `#[applicability]` attribute can only be applied to fields of type `Applicability`
applicability: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
struct AM {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example)]
//~^ ERROR suggestion without `code = "..."`
struct AN {
#[primary_span]
span: Span,
#[applicability]
applicability: Applicability,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...", applicability = "foo")]
//~^ ERROR invalid applicability
struct AO {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[help(no_crate_example)]
struct AP {
var: String,
}
#[derive(Subdiagnostic)]
#[note(no_crate_example)]
struct AQ;
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field
struct AR {
var: String,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
struct AS {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[label]
//~^ ERROR unsupported type attribute for subdiagnostic enum
enum AT {
#[label(no_crate_example)]
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
struct AU {
#[primary_span]
span: Span,
var: String,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
//~^ ERROR `var` doesn't refer to a field on this type
struct AV {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
enum AW {
#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
A {
#[primary_span]
span: Span,
var: String,
},
}
#[derive(Subdiagnostic)]
enum AX {
#[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
//~^ ERROR `var` doesn't refer to a field on this type
A {
#[primary_span]
span: Span,
},
}
#[derive(Subdiagnostic)]
#[warning(no_crate_example)]
struct AY {}
#[derive(Subdiagnostic)]
#[warning(no_crate_example)]
struct AZ {
#[primary_span]
span: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "...")]
//~^ ERROR suggestion without `#[primary_span]` field
struct BA {
#[suggestion_part]
//~^ ERROR `#[suggestion_part]` is not a valid attribute
span: Span,
#[suggestion_part(code = "...")]
//~^ ERROR `#[suggestion_part(...)]` is not a valid attribute
span2: Span,
#[applicability]
applicability: Applicability,
var: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
//~| ERROR invalid nested attribute
struct BBa {
var: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BBb {
#[suggestion_part]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
span1: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BBc {
#[suggestion_part()]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
span1: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
//~^ ERROR multipart suggestion without any `#[suggestion_part(...)]` fields
struct BC {
#[primary_span]
//~^ ERROR `#[primary_span]` is not a valid attribute
span: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BD {
#[suggestion_part]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
span1: Span,
#[suggestion_part()]
//~^ ERROR `#[suggestion_part(...)]` attribute without `code = "..."`
span2: Span,
#[suggestion_part(foo = "bar")]
//~^ ERROR `code` is the only valid nested attribute
//~| ERROR expected `,`
span4: Span,
#[suggestion_part(code = "...")]
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
s1: String,
#[suggestion_part()]
//~^ ERROR the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
s2: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BE {
#[suggestion_part(code = "...", code = ",,,")]
//~^ ERROR specified multiple times
//~| NOTE previously specified here
span: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BF {
#[suggestion_part(code = "(")]
first: Span,
#[suggestion_part(code = ")")]
second: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BG {
#[applicability]
appl: Applicability,
#[suggestion_part(code = "(")]
first: Span,
#[suggestion_part(code = ")")]
second: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BH {
#[applicability]
//~^ ERROR `#[applicability]` has no effect
appl: Applicability,
#[suggestion_part(code = "(")]
first: Span,
#[suggestion_part(code = ")")]
second: Span,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example, applicability = "machine-applicable")]
struct BI {
#[suggestion_part(code = "")]
spans: Vec<Span>,
}
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct BJ {
#[primary_span]
span: Span,
r#type: String,
}
/// with a doc comment on the type..
#[derive(Subdiagnostic)]
#[label(no_crate_example)]
struct BK {
/// ..and the field
#[primary_span]
span: Span,
}
/// with a doc comment on the type..
#[derive(Subdiagnostic)]
enum BL {
/// ..and the variant..
#[label(no_crate_example)]
Foo {
/// ..and the field
#[primary_span]
span: Span,
},
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BM {
#[suggestion_part(code("foo"))]
//~^ ERROR expected exactly one string literal for `code = ...`
//~| ERROR unexpected token, expected `)`
span: Span,
r#type: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BN {
#[suggestion_part(code("foo", "bar"))]
//~^ ERROR expected exactly one string literal for `code = ...`
//~| ERROR unexpected token, expected `)`
span: Span,
r#type: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BO {
#[suggestion_part(code(3))]
//~^ ERROR expected exactly one string literal for `code = ...`
//~| ERROR unexpected token, expected `)`
span: Span,
r#type: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BP {
#[suggestion_part(code())]
//~^ ERROR expected exactly one string literal for `code = ...`
span: Span,
r#type: String,
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(no_crate_example)]
struct BQ {
#[suggestion_part(code = 3)]
//~^ ERROR expected string literal
span: Span,
r#type: String,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "")]
struct SuggestionStyleDefault {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "short")]
struct SuggestionStyleShort {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "hidden")]
struct SuggestionStyleHidden {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "verbose")]
struct SuggestionStyleVerbose {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "tool-only")]
struct SuggestionStyleToolOnly {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")]
//~^ ERROR specified multiple times
//~| NOTE previously specified here
struct SuggestionStyleTwice {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion_hidden(no_crate_example, code = "")]
//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
struct SuggestionStyleOldSyntax {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion_hidden(no_crate_example, code = "", style = "normal")]
//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
struct SuggestionStyleOldAndNewSyntax {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = "foo")]
//~^ ERROR invalid suggestion style
struct SuggestionStyleInvalid1 {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style = 42)]
//~^ ERROR expected string literal
struct SuggestionStyleInvalid2 {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style)]
//~^ ERROR a diagnostic slug must be the first argument to the attribute
struct SuggestionStyleInvalid3 {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "", style("foo"))]
//~^ ERROR expected `=`
struct SuggestionStyleInvalid4 {
#[primary_span]
sub: Span,
}
#[derive(Subdiagnostic)]
#[suggestion(no_crate_example, code = "")]
//~^ ERROR suggestion without `#[primary_span]` field
struct PrimarySpanOnVec {
#[primary_span]
//~^ ERROR `#[primary_span]` is not a valid attribute
//~| NOTE there must be exactly one primary span
sub: Vec<Span>,
}
#[derive(Subdiagnostic)]
struct NestedParent {
#[subdiagnostic]
single_sub: A,
#[subdiagnostic]
option_sub: Option<A>,
#[subdiagnostic]
vec_sub: Vec<A>,
}

View file

@ -1,549 +0,0 @@
error: derive(Diagnostic): label without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:52:1
|
LL | #[label(no_crate_example)]
| ^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:59:1
|
LL | #[label]
| ^
error: derive(Diagnostic): `#[foo]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:68:1
|
LL | #[foo]
| ^
error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:78:1
|
LL | #[label = "..."]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:87:9
|
LL | #[label(bug = "...")]
| ^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:87:1
|
LL | #[label(bug = "...")]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:97:9
|
LL | #[label(slug = 4)]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:97:1
|
LL | #[label(slug = 4)]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:107:9
|
LL | #[label(slug("..."))]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:107:1
|
LL | #[label(slug("..."))]
| ^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:117:1
|
LL | #[label()]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:126:27
|
LL | #[label(no_crate_example, code = "...")]
| ^^^^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:135:27
|
LL | #[label(no_crate_example, applicability = "machine-applicable")]
| ^^^^^^^^^^^^^
error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum
--> $DIR/subdiagnostic-derive.rs:144:1
|
LL | #[foo]
| ^
error: derive(Diagnostic): `#[bar]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:158:5
|
LL | #[bar]
| ^
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:170:5
|
LL | #[bar = "..."]
| ^
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:182:5
|
LL | #[bar = 4]
| ^
error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:194:5
|
LL | #[bar("...")]
| ^
error: derive(Diagnostic): no nested attribute expected here
--> $DIR/subdiagnostic-derive.rs:206:13
|
LL | #[label(code = "...")]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be first argument of a `#[label(...)]` attribute
--> $DIR/subdiagnostic-derive.rs:206:5
|
LL | #[label(code = "...")]
| ^
error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive.rs:235:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): label without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:232:1
|
LL | #[label(no_crate_example)]
| ^
error: derive(Diagnostic): `#[applicability]` is only valid on suggestions
--> $DIR/subdiagnostic-derive.rs:245:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): `#[bar]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:255:5
|
LL | #[bar]
| ^
|
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: derive(Diagnostic): `#[bar = ...]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:266:5
|
LL | #[bar = "..."]
| ^
error: derive(Diagnostic): `#[bar(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:277:5
|
LL | #[bar("...")]
| ^
|
= help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes
error: unexpected unsupported untagged union
--> $DIR/subdiagnostic-derive.rs:293:1
|
LL | / union AC {
LL | |
LL | | span: u32,
LL | | b: u64,
LL | | }
| |_^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/subdiagnostic-derive.rs:308:27
|
LL | #[label(no_crate_example, no_crate::example)]
| ^^^^^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive.rs:321:5
|
LL | #[primary_span]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive.rs:318:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): subdiagnostic kind not specified
--> $DIR/subdiagnostic-derive.rs:327:8
|
LL | struct AG {
| ^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive.rs:364:46
|
LL | #[suggestion(no_crate_example, code = "...", code = "...")]
| ^^^^
|
note: previously specified here
--> $DIR/subdiagnostic-derive.rs:364:32
|
LL | #[suggestion(no_crate_example, code = "...", code = "...")]
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive.rs:382:5
|
LL | #[applicability]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive.rs:379:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): the `#[applicability]` attribute can only be applied to fields of type `Applicability`
--> $DIR/subdiagnostic-derive.rs:392:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:405:1
|
LL | #[suggestion(no_crate_example)]
| ^
error: derive(Diagnostic): invalid applicability
--> $DIR/subdiagnostic-derive.rs:415:62
|
LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")]
| ^^^^^
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:433:1
|
LL | #[suggestion(no_crate_example, code = "...")]
| ^
error: derive(Diagnostic): unsupported type attribute for subdiagnostic enum
--> $DIR/subdiagnostic-derive.rs:447:1
|
LL | #[label]
| ^
error: derive(Diagnostic): `var` doesn't refer to a field on this type
--> $DIR/subdiagnostic-derive.rs:467:39
|
LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
| ^^^^^^^
error: derive(Diagnostic): `var` doesn't refer to a field on this type
--> $DIR/subdiagnostic-derive.rs:486:43
|
LL | #[suggestion(no_crate_example, code = "{var}", applicability = "machine-applicable")]
| ^^^^^^^
error: derive(Diagnostic): `#[suggestion_part]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:509:5
|
LL | #[suggestion_part]
| ^
|
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead
error: derive(Diagnostic): `#[suggestion_part(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:512:5
|
LL | #[suggestion_part(code = "...")]
| ^
|
= help: `#[suggestion_part(...)]` is only valid in multipart suggestions
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:506:1
|
LL | #[suggestion(no_crate_example, code = "...")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/subdiagnostic-derive.rs:521:42
|
LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
| ^^^^
|
= help: only `style` and `applicability` are valid nested attributes
error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive.rs:521:1
|
LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:531:5
|
LL | #[suggestion_part]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:539:5
|
LL | #[suggestion_part()]
| ^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:548:5
|
LL | #[primary_span]
| ^
|
= help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]`
error: derive(Diagnostic): multipart suggestion without any `#[suggestion_part(...)]` fields
--> $DIR/subdiagnostic-derive.rs:545:1
|
LL | #[multipart_suggestion(no_crate_example)]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:556:5
|
LL | #[suggestion_part]
| ^
error: derive(Diagnostic): `#[suggestion_part(...)]` attribute without `code = "..."`
--> $DIR/subdiagnostic-derive.rs:559:5
|
LL | #[suggestion_part()]
| ^
error: derive(Diagnostic): `code` is the only valid nested attribute
--> $DIR/subdiagnostic-derive.rs:562:23
|
LL | #[suggestion_part(foo = "bar")]
| ^^^
error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive.rs:566:5
|
LL | #[suggestion_part(code = "...")]
| ^
error: derive(Diagnostic): the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/subdiagnostic-derive.rs:569:5
|
LL | #[suggestion_part()]
| ^
error: expected `,`
--> $DIR/subdiagnostic-derive.rs:562:27
|
LL | #[suggestion_part(foo = "bar")]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive.rs:577:37
|
LL | #[suggestion_part(code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
--> $DIR/subdiagnostic-derive.rs:577:23
|
LL | #[suggestion_part(code = "...", code = ",,,")]
| ^^^^
error: derive(Diagnostic): `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_suggestion]` attributes have a static `applicability = "..."`
--> $DIR/subdiagnostic-derive.rs:606:5
|
LL | #[applicability]
| ^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive.rs:654:28
|
LL | #[suggestion_part(code("foo"))]
| ^^^^^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive.rs:654:28
|
LL | #[suggestion_part(code("foo"))]
| ^^^^^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive.rs:664:28
|
LL | #[suggestion_part(code("foo", "bar"))]
| ^^^^^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive.rs:664:28
|
LL | #[suggestion_part(code("foo", "bar"))]
| ^^^^^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive.rs:674:28
|
LL | #[suggestion_part(code(3))]
| ^
error: unexpected token, expected `)`
--> $DIR/subdiagnostic-derive.rs:674:28
|
LL | #[suggestion_part(code(3))]
| ^
error: derive(Diagnostic): expected exactly one string literal for `code = ...`
--> $DIR/subdiagnostic-derive.rs:684:28
|
LL | #[suggestion_part(code())]
| ^
error: expected string literal
--> $DIR/subdiagnostic-derive.rs:693:30
|
LL | #[suggestion_part(code = 3)]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/subdiagnostic-derive.rs:735:1
|
LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")]
| ^
|
note: previously specified here
--> $DIR/subdiagnostic-derive.rs:735:1
|
LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")]
| ^
error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:744:1
|
LL | #[suggestion_hidden(no_crate_example, code = "")]
| ^
|
= help: Use `#[suggestion(..., style = "hidden")]` instead
error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:752:1
|
LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")]
| ^
|
= help: Use `#[suggestion(..., style = "hidden")]` instead
error: derive(Diagnostic): invalid suggestion style
--> $DIR/subdiagnostic-derive.rs:760:51
|
LL | #[suggestion(no_crate_example, code = "", style = "foo")]
| ^^^^^
|
= help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`
error: expected string literal
--> $DIR/subdiagnostic-derive.rs:768:51
|
LL | #[suggestion(no_crate_example, code = "", style = 42)]
| ^^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/subdiagnostic-derive.rs:776:43
|
LL | #[suggestion(no_crate_example, code = "", style)]
| ^^^^^
error: expected `=`
--> $DIR/subdiagnostic-derive.rs:784:48
|
LL | #[suggestion(no_crate_example, code = "", style("foo"))]
| ^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/subdiagnostic-derive.rs:795:5
|
LL | #[primary_span]
| ^
|
= note: there must be exactly one primary span
= help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead
error: derive(Diagnostic): suggestion without `#[primary_span]` field
--> $DIR/subdiagnostic-derive.rs:792:1
|
LL | #[suggestion(no_crate_example, code = "")]
| ^
error: cannot find attribute `foo` in this scope
--> $DIR/subdiagnostic-derive.rs:68:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `foo` in this scope
--> $DIR/subdiagnostic-derive.rs:144:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:158:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:170:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:182:7
|
LL | #[bar = 4]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:194:7
|
LL | #[bar("...")]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:255:7
|
LL | #[bar]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:266:7
|
LL | #[bar = "..."]
| ^^^
error: cannot find attribute `bar` in this scope
--> $DIR/subdiagnostic-derive.rs:277:7
|
LL | #[bar("...")]
| ^^^
error: aborting due to 82 previous errors