1use rustc_errors::codes::*;2use rustc_errors::{DiagArgFromDisplay, DiagArgValue, DiagSymbolList, IntoDiagArg};3use rustc_macros::{Diagnostic, Subdiagnostic};4use rustc_span::{Ident, Span, Symbol};56#[derive(Diagnostic)]7#[diag("parenthesized type parameters may only be used with a `Fn` trait", code = E0214)]8pub(crate) struct GenericTypeWithParentheses {9 #[primary_span]10 #[label("only `Fn` traits may use parentheses")]11 pub span: Span,12 #[subdiagnostic]13 pub sub: Option<UseAngleBrackets>,14}1516#[derive(Subdiagnostic)]17#[multipart_suggestion("use angle brackets instead", applicability = "maybe-incorrect")]18pub(crate) struct UseAngleBrackets {19 #[suggestion_part(code = "<")]20 pub open_param: Span,21 #[suggestion_part(code = ">")]22 pub close_param: Span,23}2425#[derive(Diagnostic)]26#[diag("invalid ABI: found `{$abi}`", code = E0703)]27#[note("invoke `{$command}` for a full list of supported calling conventions")]28pub(crate) struct InvalidAbi {29 #[primary_span]30 #[label("invalid ABI")]31 pub span: Span,32 pub abi: Symbol,33 pub command: String,34 #[subdiagnostic]35 pub suggestion: Option<InvalidAbiSuggestion>,36}3738#[derive(Diagnostic)]39#[diag("default fields are not supported in tuple structs")]40pub(crate) struct TupleStructWithDefault {41 #[primary_span]42 #[label("default fields are only supported on structs")]43 pub span: Span,44}4546#[derive(Subdiagnostic)]47#[suggestion(48 "there's a similarly named valid ABI `{$suggestion}`",49 code = "\"{suggestion}\"",50 applicability = "maybe-incorrect",51 style = "verbose"52)]53pub(crate) struct InvalidAbiSuggestion {54 #[primary_span]55 pub span: Span,56 pub suggestion: String,57}5859#[derive(Diagnostic)]60#[diag("parenthesized generic arguments cannot be used in associated type constraints")]61pub(crate) struct AssocTyParentheses {62 #[primary_span]63 pub span: Span,64 #[subdiagnostic]65 pub sub: AssocTyParenthesesSub,66}6768#[derive(Subdiagnostic)]69pub(crate) enum AssocTyParenthesesSub {70 #[multipart_suggestion("remove these parentheses")]71 Empty {72 #[suggestion_part(code = "")]73 parentheses_span: Span,74 },75 #[multipart_suggestion("use angle brackets instead")]76 NotEmpty {77 #[suggestion_part(code = "<")]78 open_param: Span,79 #[suggestion_part(code = ">")]80 close_param: Span,81 },82}8384#[derive(Diagnostic)]85#[diag("`impl Trait` is not allowed in {$position}", code = E0562)]86#[note("`impl Trait` is only allowed in arguments and return types of functions and methods")]87pub(crate) struct MisplacedImplTrait<'a> {88 #[primary_span]89 pub span: Span,90 pub position: DiagArgFromDisplay<'a>,91}9293#[derive(Diagnostic)]94#[diag("associated type bounds are not allowed in `dyn` types")]95pub(crate) struct MisplacedAssocTyBinding {96 #[primary_span]97 pub span: Span,98 #[suggestion(99 "use `impl Trait` to introduce a type instead",100 code = " = impl",101 applicability = "maybe-incorrect",102 style = "verbose"103 )]104 pub suggestion: Option<Span>,105}106107#[derive(Diagnostic)]108#[diag("in expressions, `_` can only be used on the left-hand side of an assignment")]109pub(crate) struct UnderscoreExprLhsAssign {110 #[primary_span]111 #[label("`_` not allowed here")]112 pub span: Span,113}114115#[derive(Diagnostic)]116#[diag("`await` is only allowed inside `async` functions and blocks", code = E0728)]117pub(crate) struct AwaitOnlyInAsyncFnAndBlocks {118 #[primary_span]119 #[label("only allowed inside `async` functions and blocks")]120 pub await_kw_span: Span,121 #[label("this is not `async`")]122 pub item_span: Option<Span>,123}124125#[derive(Diagnostic)]126#[diag("a function cannot be both `comptime` and `const`")]127pub(crate) struct ConstComptimeFn {128 #[primary_span]129 #[suggestion("remove the `const`", applicability = "machine-applicable", code = "")]130 #[note("`const` implies the function can be called at runtime, too")]131 pub span: Span,132 #[label("`comptime` because of this")]133 pub attr_span: Span,134}135136#[derive(Diagnostic)]137#[diag("too many parameters for a coroutine (expected 0 or 1 parameters)", code = E0628)]138pub(crate) struct CoroutineTooManyParameters {139 #[primary_span]140 pub fn_decl_span: Span,141}142143#[derive(Diagnostic)]144#[diag("closures cannot be static", code = E0697)]145pub(crate) struct ClosureCannotBeStatic {146 #[primary_span]147 pub fn_decl_span: Span,148}149150#[derive(Diagnostic)]151#[diag("`move(expr)` is only supported in plain closures")]152pub(crate) struct MoveExprOnlyInPlainClosures {153 #[primary_span]154 pub span: Span,155}156157#[derive(Diagnostic)]158#[diag("functional record updates are not allowed in destructuring assignments")]159pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {160 #[primary_span]161 #[suggestion(162 "consider removing the trailing pattern",163 code = "",164 applicability = "machine-applicable"165 )]166 pub span: Span,167}168169#[derive(Diagnostic)]170#[diag("`async` coroutines are not yet supported", code = E0727)]171pub(crate) struct AsyncCoroutinesNotSupported {172 #[primary_span]173 pub span: Span,174}175176#[derive(Diagnostic)]177#[diag("inline assembly is unsupported on this target", code = E0472)]178pub(crate) struct InlineAsmUnsupportedTarget {179 #[primary_span]180 pub span: Span,181}182183#[derive(Diagnostic)]184#[diag("the `att_syntax` option is only supported on x86")]185pub(crate) struct AttSyntaxOnlyX86 {186 #[primary_span]187 pub span: Span,188}189190#[derive(Diagnostic)]191#[diag("`{$prev_name}` ABI specified multiple times")]192pub(crate) struct AbiSpecifiedMultipleTimes {193 #[primary_span]194 pub abi_span: Span,195 pub prev_name: Symbol,196 #[label("previously specified here")]197 pub prev_span: Span,198 #[note("these ABIs are equivalent on the current target")]199 pub equivalent: bool,200}201202#[derive(Diagnostic)]203#[diag("`clobber_abi` is not supported on this target")]204pub(crate) struct ClobberAbiNotSupported {205 #[primary_span]206 pub abi_span: Span,207}208209#[derive(Diagnostic)]210#[note("the following ABIs are supported on this target: {$supported_abis}")]211#[diag("invalid ABI for `clobber_abi`")]212pub(crate) struct InvalidAbiClobberAbi<'a> {213 #[primary_span]214 pub abi_span: Span,215 pub supported_abis: DiagSymbolList<&'a str>,216}217218#[derive(Diagnostic)]219#[diag("invalid register `{$reg}`: {$error}")]220pub(crate) struct InvalidRegister<'a> {221 #[primary_span]222 pub op_span: Span,223 pub reg: Symbol,224 pub error: &'a str,225}226227#[derive(Diagnostic)]228#[note(229 "the following register classes are supported on this target: {$supported_register_classes}"230)]231#[diag("invalid register class `{$reg_class}`: unknown register class")]232pub(crate) struct InvalidRegisterClass {233 #[primary_span]234 pub op_span: Span,235 pub reg_class: Symbol,236 pub supported_register_classes: DiagSymbolList<Symbol>,237}238239#[derive(Diagnostic)]240#[diag("invalid asm template modifier `{$modifier}` for this register class")]241pub(crate) struct InvalidAsmTemplateModifierRegClass {242 #[primary_span]243 #[label("template modifier")]244 pub placeholder_span: Span,245 #[label("argument")]246 pub op_span: Span,247 pub modifier: String,248 #[subdiagnostic]249 pub sub: InvalidAsmTemplateModifierRegClassSub,250}251252#[derive(Subdiagnostic)]253pub(crate) enum InvalidAsmTemplateModifierRegClassSub {254 #[note(255 "the `{$class_name}` register class supports the following template modifiers: {$modifiers}"256 )]257 SupportModifier { class_name: Symbol, modifiers: DiagSymbolList<char> },258 #[note("the `{$class_name}` register class does not support template modifiers")]259 DoesNotSupportModifier { class_name: Symbol },260}261262#[derive(Diagnostic)]263#[diag("asm template modifiers are not allowed for `const` arguments")]264pub(crate) struct InvalidAsmTemplateModifierConst {265 #[primary_span]266 #[label("template modifier")]267 pub placeholder_span: Span,268 #[label("argument")]269 pub op_span: Span,270}271272#[derive(Diagnostic)]273#[diag("asm template modifiers are not allowed for `sym` arguments")]274pub(crate) struct InvalidAsmTemplateModifierSym {275 #[primary_span]276 #[label("template modifier")]277 pub placeholder_span: Span,278 #[label("argument")]279 pub op_span: Span,280}281282#[derive(Diagnostic)]283#[diag("asm template modifiers are not allowed for `label` arguments")]284pub(crate) struct InvalidAsmTemplateModifierLabel {285 #[primary_span]286 #[label("template modifier")]287 pub placeholder_span: Span,288 #[label("argument")]289 pub op_span: Span,290}291292#[derive(Diagnostic)]293#[diag(294 "register class `{$reg_class_name}` can only be used as a clobber, not as an input or output"295)]296pub(crate) struct RegisterClassOnlyClobber {297 #[primary_span]298 pub op_span: Span,299 pub reg_class_name: Symbol,300}301302#[derive(Diagnostic)]303#[diag("register class `{$reg_class_name}` can only be used as a clobber in stable")]304pub(crate) struct RegisterClassOnlyClobberStable {305 #[primary_span]306 pub op_span: Span,307 pub reg_class_name: Symbol,308}309310#[derive(Diagnostic)]311#[diag("register `{$reg1_name}` conflicts with register `{$reg2_name}`")]312pub(crate) struct RegisterConflict<'a> {313 #[primary_span]314 #[label("register `{$reg1_name}`")]315 pub op_span1: Span,316 #[label("register `{$reg2_name}`")]317 pub op_span2: Span,318 pub reg1_name: &'a str,319 pub reg2_name: &'a str,320 #[help("use `lateout` instead of `out` to avoid conflict")]321 pub in_out: Option<Span>,322}323324#[derive(Diagnostic)]325#[help("remove this and bind each tuple field independently")]326#[diag("`{$ident_name} @` is not allowed in a {$ctx}")]327pub(crate) struct SubTupleBinding<'a> {328 #[primary_span]329 #[label("this is only allowed in slice patterns")]330 #[suggestion(331 "if you don't need to use the contents of {$ident}, discard the tuple's remaining fields",332 style = "verbose",333 code = "..",334 applicability = "maybe-incorrect"335 )]336 pub span: Span,337 pub ident: Ident,338 pub ident_name: Symbol,339 pub ctx: &'a str,340}341342#[derive(Diagnostic)]343#[diag("`..` can only be used once per {$ctx} pattern")]344pub(crate) struct ExtraDoubleDot<'a> {345 #[primary_span]346 #[label("can only be used once per {$ctx} pattern")]347 pub span: Span,348 #[label("previously used here")]349 pub prev_span: Span,350 pub ctx: &'a str,351}352353#[derive(Diagnostic)]354#[note("only allowed in tuple, tuple struct, and slice patterns")]355#[diag("`..` patterns are not allowed here")]356pub(crate) struct MisplacedDoubleDot {357 #[primary_span]358 pub span: Span,359}360361#[derive(Diagnostic)]362#[diag("`match` arm with no body")]363pub(crate) struct MatchArmWithNoBody {364 #[primary_span]365 pub span: Span,366 #[suggestion(367 "add a body after the pattern",368 // ignore-tidy-todo369 code = " => todo!(),",370 applicability = "has-placeholders"371 )]372 pub suggestion: Span,373}374375#[derive(Diagnostic)]376#[diag("a never pattern is always unreachable")]377pub(crate) struct NeverPatternWithBody {378 #[primary_span]379 #[label("this will never be executed")]380 #[suggestion("remove this expression", code = "", applicability = "maybe-incorrect")]381 pub span: Span,382}383384#[derive(Diagnostic)]385#[diag("a guard on a never pattern will never be run")]386pub(crate) struct NeverPatternWithGuard {387 #[primary_span]388 #[suggestion("remove this guard", code = "", applicability = "maybe-incorrect")]389 pub span: Span,390}391392#[derive(Diagnostic)]393#[diag("arbitrary expressions aren't allowed in patterns")]394pub(crate) struct ArbitraryExpressionInPattern {395 #[primary_span]396 pub span: Span,397 #[note("the `expr` fragment specifier forces the metavariable's content to be an expression")]398 pub pattern_from_macro_note: bool,399 #[help("use a named `const`-item or an `if`-guard (`x if x == const {\"{ ... }\"}`) instead")]400 pub const_block_in_pattern_help: bool,401}402403#[derive(Diagnostic)]404#[diag("inclusive range with no end")]405pub(crate) struct InclusiveRangeWithNoEnd {406 #[primary_span]407 pub span: Span,408}409410#[derive(Subdiagnostic)]411#[multipart_suggestion(412 "use the right argument notation and remove the return type",413 applicability = "machine-applicable",414 style = "verbose"415)]416/// Given `T: Tr<m() -> Ret>` or `T: Tr<m(Ty) -> Ret>`, suggest `T: Tr<m(..)>`.417pub(crate) struct RTNSuggestion {418 #[suggestion_part(code = "")]419 pub output: Span,420 #[suggestion_part(code = "(..)")]421 pub input: Span,422}423424#[derive(Diagnostic)]425pub(crate) enum BadReturnTypeNotation {426 #[diag("argument types not allowed with return type notation")]427 Inputs {428 #[primary_span]429 #[suggestion(430 "remove the input types",431 code = "(..)",432 applicability = "machine-applicable",433 style = "verbose"434 )]435 span: Span,436 },437 #[diag("return type not allowed with return type notation")]438 Output {439 #[primary_span]440 span: Span,441 #[subdiagnostic]442 suggestion: RTNSuggestion,443 },444 #[diag("return type notation arguments must be elided with `..`")]445 NeedsDots {446 #[primary_span]447 #[suggestion(448 "use the correct syntax by adding `..` to the arguments",449 code = "(..)",450 applicability = "machine-applicable",451 style = "verbose"452 )]453 span: Span,454 },455 #[diag("return type notation not allowed in this position yet")]456 Position {457 #[primary_span]458 span: Span,459 },460}461462#[derive(Diagnostic)]463#[diag("defaults for generic parameters are not allowed in `for<...>` binders")]464pub(crate) struct GenericParamDefaultInBinder {465 #[primary_span]466 pub span: Span,467}468469#[derive(Diagnostic)]470#[diag("`async` bound modifier only allowed on trait, not `{$descr}`")]471pub(crate) struct AsyncBoundNotOnTrait {472 #[primary_span]473 pub span: Span,474 pub descr: &'static str,475}476477#[derive(Diagnostic)]478#[diag("`async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits")]479pub(crate) struct AsyncBoundOnlyForFnTraits {480 #[primary_span]481 pub span: Span,482}483484#[derive(Diagnostic)]485#[diag("`use<...>` precise capturing syntax not allowed in argument-position `impl Trait`")]486pub(crate) struct NoPreciseCapturesOnApit {487 #[primary_span]488 pub span: Span,489}490491#[derive(Diagnostic)]492#[diag("`yield` can only be used in `#[coroutine]` closures, or `gen` blocks")]493pub(crate) struct YieldInClosure {494 #[primary_span]495 pub span: Span,496 #[suggestion(497 "use `#[coroutine]` to make this closure a coroutine",498 code = "#[coroutine] ",499 applicability = "maybe-incorrect",500 style = "verbose"501 )]502 pub suggestion: Option<Span>,503}504505#[derive(Diagnostic)]506#[diag(507 "invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items"508)]509pub(crate) struct InvalidLegacyConstGenericArg {510 #[primary_span]511 pub span: Span,512 #[subdiagnostic]513 pub suggestion: UseConstGenericArg,514}515516#[derive(Subdiagnostic)]517#[multipart_suggestion(518 "try using a const generic argument instead",519 applicability = "maybe-incorrect"520)]521pub(crate) struct UseConstGenericArg {522 #[suggestion_part(code = "::<{const_args}>")]523 pub end_of_fn: Span,524 pub const_args: String,525 pub other_args: String,526 #[suggestion_part(code = "{other_args}")]527 pub call_args: Span,528}529530#[derive(Diagnostic)]531#[diag("unions cannot have default field values")]532pub(crate) struct UnionWithDefault {533 #[primary_span]534 pub span: Span,535}536537#[derive(Diagnostic)]538#[diag("failed to resolve delegation callee")]539pub(crate) struct UnresolvedDelegationCallee {540 #[primary_span]541 pub span: Span,542}543544#[derive(Diagnostic)]545#[diag("encountered a cycle during delegation signature resolution")]546pub(crate) struct CycleInDelegationSignatureResolution {547 #[primary_span]548 pub span: Span,549}550551#[derive(Diagnostic)]552#[diag("delegation's target expression is specified for function with no params")]553pub(crate) struct DelegationBlockSpecifiedWhenNoParams {554 #[primary_span]555 pub span: Span,556}557558#[derive(Diagnostic)]559#[diag("attempted to delete delegation's target expression that contains definitions inside")]560pub(crate) struct DelegationAttemptedBlockWithDefsDeletion {561 #[primary_span]562 pub span: Span,563}564565#[derive(Diagnostic)]566#[diag("wrong infer used: expected {$expected}, found: {$actual}")]567pub(crate) struct DelegationInfersMismatch {568 #[primary_span]569 pub span: Span,570 pub expected: Symbol,571 pub actual: Symbol,572}573574#[derive(Diagnostic)]575#[diag(576 "attempted to lower target expression with definitions more than once while mapping argument"577)]578pub(crate) struct DelegationAttemptedBlockWithDefsRelowering {579 #[primary_span]580 pub span: Span,581}582583/// Whether resolving `impl` or `mut` restriction paths584#[derive(Debug, Clone, Copy)]585pub(crate) enum ResolvingRestrictionKind {586 Impl,587 Mut,588}589590impl IntoDiagArg for ResolvingRestrictionKind {591 fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {592 use std::borrow::Cow;593 match self {594 ResolvingRestrictionKind::Impl => DiagArgValue::Str(Cow::Borrowed("impl")),595 ResolvingRestrictionKind::Mut => DiagArgValue::Str(Cow::Borrowed("mut")),596 }597 }598}599600#[derive(Diagnostic)]601#[diag(602 "{$kind ->603 [impl] trait implementation604 *[mut] field mutation605} can only be restricted to ancestor modules"606)]607pub(crate) struct RestrictionAncestorOnly {608 #[primary_span]609 pub(crate) span: Span,610 pub(crate) kind: ResolvingRestrictionKind,611}
Findings
✓ No findings reported for this file.