diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 96d083bb94f3c..bcff2ae512909 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -16,7 +16,7 @@ use crate::require_c_abi_if_c_variadic; use rustc_ast::TraitObjectSyntax; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{ - struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, + struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; @@ -30,7 +30,7 @@ use rustc_middle::ty::{self, Const, DefIdTree, EarlyBinder, Ty, TyCtxt, TypeFold use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS}; use rustc_span::edition::Edition; use rustc_span::lev_distance::find_best_match_for_name; -use rustc_span::symbol::{Ident, Symbol}; +use rustc_span::symbol::{kw, Ident, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::abi; use rustc_trait_selection::traits; @@ -653,7 +653,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { span, item_def_id, item_segment ); if tcx.generics_of(item_def_id).params.is_empty() { - self.prohibit_generics(slice::from_ref(item_segment)); + self.prohibit_generics(slice::from_ref(item_segment).iter(), |_| {}); parent_substs } else { @@ -681,7 +681,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_ref: &hir::TraitRef<'_>, self_ty: Ty<'tcx>, ) -> ty::TraitRef<'tcx> { - self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1); + self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1.iter(), |_| {}); self.ast_path_to_mono_trait_ref( trait_ref.path.span, @@ -784,7 +784,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let args = trait_segment.args(); let infer_args = trait_segment.infer_args; - self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1); + self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1.iter(), |_| {}); self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, false); self.instantiate_poly_trait_ref_inner( @@ -1776,12 +1776,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { hir_ref_id: hir::HirId, span: Span, qself_ty: Ty<'tcx>, - qself_res: Res, + qself: &hir::Ty<'_>, assoc_segment: &hir::PathSegment<'_>, permit_variants: bool, ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> { let tcx = self.tcx(); let assoc_ident = assoc_segment.ident; + let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = qself.kind { + path.res + } else { + Res::Err + }; debug!("associated_path_to_ty: {:?}::{}", qself_ty, assoc_ident); @@ -1796,7 +1801,87 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { if let Some(variant_def) = variant_def { if permit_variants { tcx.check_stability(variant_def.def_id, Some(hir_ref_id), span, None); - self.prohibit_generics(slice::from_ref(assoc_segment)); + self.prohibit_generics(slice::from_ref(assoc_segment).iter(), |err| { + err.note("enum variants can't have type parameters"); + let type_name = tcx.item_name(adt_def.did()); + let msg = format!( + "you might have meant to specity type parameters on enum \ + `{type_name}`" + ); + let Some(args) = assoc_segment.args else { return; }; + // Get the span of the generics args *including* the leading `::`. + let args_span = assoc_segment.ident.span.shrink_to_hi().to(args.span_ext); + if tcx.generics_of(adt_def.did()).count() == 0 { + // FIXME(estebank): we could also verify that the arguments being + // work for the `enum`, instead of just looking if it takes *any*. + err.span_suggestion_verbose( + args_span, + &format!("{type_name} doesn't have generic parameters"), + String::new(), + Applicability::MachineApplicable, + ); + return; + } + let Ok(snippet) = tcx.sess.source_map().span_to_snippet(args_span) else { + err.note(&msg); + return; + }; + let (qself_sugg_span, is_self) = if let hir::TyKind::Path( + hir::QPath::Resolved(_, ref path) + ) = qself.kind { + // If the path segment already has type params, we want to overwrite + // them. + match &path.segments[..] { + // `segment` is the previous to last element on the path, + // which would normally be the `enum` itself, while the last + // `_` `PathSegment` corresponds to the variant. + [.., hir::PathSegment { + ident, + args, + res: Some(Res::Def(DefKind::Enum, _)), + .. + }, _] => ( + // We need to include the `::` in `Type::Variant::` + // to point the span to `::`, not just ``. + ident.span.shrink_to_hi().to(args.map_or( + ident.span.shrink_to_hi(), + |a| a.span_ext)), + false, + ), + [segment] => ( + // We need to include the `::` in `Type::Variant::` + // to point the span to `::`, not just ``. + segment.ident.span.shrink_to_hi().to(segment.args.map_or( + segment.ident.span.shrink_to_hi(), + |a| a.span_ext)), + kw::SelfUpper == segment.ident.name, + ), + _ => { + err.note(&msg); + return; + } + } + } else { + err.note(&msg); + return; + }; + let suggestion = vec![ + if is_self { + // Account for people writing `Self::Variant::`, where + // `Self` is the enum, and suggest replacing `Self` with the + // appropriate type: `Type::::Variant`. + (qself.span, format!("{type_name}{snippet}")) + } else { + (qself_sugg_span, snippet) + }, + (args_span, String::new()), + ]; + err.multipart_suggestion_verbose( + &msg, + suggestion, + Applicability::MaybeIncorrect, + ); + }); return Ok((qself_ty, DefKind::Variant, variant_def.def_id)); } else { variant_resolution = Some(variant_def.def_id); @@ -2017,69 +2102,112 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { self.normalize_ty(span, tcx.mk_projection(item_def_id, item_substs)) } - pub fn prohibit_generics<'a, T: IntoIterator>>( + pub fn prohibit_generics<'a>( &self, - segments: T, + segments: impl Iterator> + Clone, + extend: impl Fn(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>), ) -> bool { - let mut has_err = false; - for segment in segments { - let (mut err_for_lt, mut err_for_ty, mut err_for_ct) = (false, false, false); - for arg in segment.args().args { - let (span, kind) = match arg { - hir::GenericArg::Lifetime(lt) => { - if err_for_lt { - continue; - } - err_for_lt = true; - has_err = true; - (lt.span, "lifetime") - } - hir::GenericArg::Type(ty) => { - if err_for_ty { - continue; - } - err_for_ty = true; - has_err = true; - (ty.span, "type") - } - hir::GenericArg::Const(ct) => { - if err_for_ct { - continue; - } - err_for_ct = true; - has_err = true; - (ct.span, "const") - } - hir::GenericArg::Infer(inf) => { - if err_for_ty { - continue; - } - has_err = true; - err_for_ty = true; - (inf.span, "generic") + let args = segments.clone().flat_map(|segment| segment.args().args); + let types_and_spans: Vec<_> = segments + .clone() + .flat_map(|segment| { + segment.res.and_then(|res| { + if segment.args().args.is_empty() { + None + } else { + Some(( + match res { + Res::PrimTy(ty) => format!("{} `{}`", res.descr(), ty.name()), + Res::Def(_, def_id) + if let Some(name) = self.tcx().opt_item_name(def_id) => { + format!("{} `{name}`", res.descr()) + } + Res::Err => "this type".to_string(), + _ => res.descr().to_string(), + }, + segment.ident.span, + )) } - }; - let mut err = struct_span_err!( - self.tcx().sess, - span, - E0109, - "{} arguments are not allowed for this type", - kind, - ); - err.span_label(span, format!("{} argument not allowed", kind)); - err.emit(); - if err_for_lt && err_for_ty && err_for_ct { - break; - } + }) + }) + .collect(); + let this_type = match &types_and_spans[..] { + [.., _, (last, _)] => format!( + "{} and {last}", + types_and_spans[..types_and_spans.len() - 1] + .iter() + .map(|(x, _)| x.as_str()) + .intersperse(&", ") + .collect::() + ), + [(only, _)] => only.to_string(), + [] => "this type".to_string(), + }; + + let (lt, ty, ct, inf) = + args.clone().fold((false, false, false, false), |(lt, ty, ct, inf), arg| match arg { + hir::GenericArg::Lifetime(_) => (true, ty, ct, inf), + hir::GenericArg::Type(_) => (lt, true, ct, inf), + hir::GenericArg::Const(_) => (lt, ty, true, inf), + hir::GenericArg::Infer(_) => (lt, ty, ct, true), + }); + let mut emitted = false; + if lt || ty || ct || inf { + let arg_spans: Vec = args.map(|arg| arg.span()).collect(); + + let mut kinds = Vec::with_capacity(4); + if lt { + kinds.push("lifetime"); + } + if ty { + kinds.push("type"); + } + if ct { + kinds.push("const"); } + if inf { + kinds.push("generic"); + } + let (kind, s) = match kinds[..] { + [.., _, last] => ( + format!( + "{} and {last}", + kinds[..kinds.len() - 1] + .iter() + .map(|&x| x) + .intersperse(", ") + .collect::() + ), + "s", + ), + [only] => (format!("{only}"), ""), + [] => unreachable!(), + }; + let last_span = *arg_spans.last().unwrap(); + let span: MultiSpan = arg_spans.into(); + let mut err = struct_span_err!( + self.tcx().sess, + span, + E0109, + "{kind} arguments are not allowed on {this_type}", + ); + err.span_label(last_span, format!("{kind} argument{s} not allowed")); + for (_, span) in types_and_spans { + err.span_label(span, "not allowed on this"); + } + extend(&mut err); + err.emit(); + emitted = true; + } + for segment in segments { // Only emit the first error to avoid overloading the user with error messages. if let [binding, ..] = segment.args().bindings { - has_err = true; Self::prohibit_assoc_ty_binding(self.tcx(), binding.span); + return true; } } - has_err + emitted } // FIXME(eddyb, varkor) handle type paths here too, not just value ones. @@ -2229,7 +2357,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // Check for desugared `impl Trait`. assert!(ty::is_impl_trait_defn(tcx, did).is_none()); let item_segment = path.segments.split_last().unwrap(); - self.prohibit_generics(item_segment.1); + self.prohibit_generics(item_segment.1.iter(), |err| { + err.note("`impl Trait` types can't have type parameters"); + }); let substs = self.ast_path_substs_for_ty(span, did, item_segment.0); self.normalize_ty(span, tcx.mk_opaque(did, substs)) } @@ -2242,7 +2372,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { did, ) => { assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments.split_last().unwrap().1); + self.prohibit_generics(path.segments.split_last().unwrap().1.iter(), |_| {}); self.ast_path_to_ty(span, did, path.segments.last().unwrap()) } Res::Def(kind @ DefKind::Variant, def_id) if permit_variants => { @@ -2254,18 +2384,26 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { self.def_ids_for_value_path_segments(path.segments, None, kind, def_id); let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect(); - self.prohibit_generics(path.segments.iter().enumerate().filter_map( - |(index, seg)| { + self.prohibit_generics( + path.segments.iter().enumerate().filter_map(|(index, seg)| { if !generic_segs.contains(&index) { Some(seg) } else { None } + }), + |err| { + err.note("enum variants can't have type parameters"); }, - )); + ); let PathSeg(def_id, index) = path_segs.last().unwrap(); self.ast_path_to_ty(span, *def_id, &path.segments[*index]) } Res::Def(DefKind::TyParam, def_id) => { assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments); + self.prohibit_generics(path.segments.iter(), |err| { + if let Some(span) = tcx.def_ident_span(def_id) { + let name = tcx.item_name(def_id); + err.span_note(span, &format!("type parameter `{name}` defined here")); + } + }); let def_id = def_id.expect_local(); let item_def_id = tcx.hir().ty_param_owner(def_id); @@ -2276,15 +2414,81 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { Res::SelfTy { trait_: Some(_), alias_to: None } => { // `Self` in trait or type alias. assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments); + self.prohibit_generics(path.segments.iter(), |err| { + if let [hir::PathSegment { args: Some(args), ident, .. }] = &path.segments[..] { + err.span_suggestion_verbose( + ident.span.shrink_to_hi().to(args.span_ext), + "the `Self` type doesn't accept type parameters", + String::new(), + Applicability::MaybeIncorrect, + ); + } + }); tcx.types.self_param } Res::SelfTy { trait_: _, alias_to: Some((def_id, forbid_generic)) } => { // `Self` in impl (we know the concrete type). assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments); // Try to evaluate any array length constants. let ty = tcx.at(span).type_of(def_id); + let span_of_impl = tcx.span_of_impl(def_id); + self.prohibit_generics(path.segments.iter(), |err| { + let def_id = match *ty.kind() { + ty::Adt(self_def, _) => self_def.did(), + _ => return, + }; + + let type_name = tcx.item_name(def_id); + let span_of_ty = tcx.def_ident_span(def_id); + let generics = tcx.generics_of(def_id).count(); + + let msg = format!("`Self` is of type `{ty}`"); + if let (Ok(i_sp), Some(t_sp)) = (span_of_impl, span_of_ty) { + let i_sp = tcx.sess.source_map().guess_head_span(i_sp); + let mut span: MultiSpan = vec![t_sp].into(); + span.push_span_label( + i_sp, + &format!("`Self` is on type `{type_name}` in this `impl`"), + ); + let mut postfix = ""; + if generics == 0 { + postfix = ", which doesn't have generic parameters"; + } + span.push_span_label( + t_sp, + &format!("`Self` corresponds to this type{postfix}"), + ); + err.span_note(span, &msg); + } else { + err.note(&msg); + } + for segment in path.segments { + if let Some(args) = segment.args && segment.ident.name == kw::SelfUpper { + if generics == 0 { + // FIXME(estebank): we could also verify that the arguments being + // work for the `enum`, instead of just looking if it takes *any*. + err.span_suggestion_verbose( + segment.ident.span.shrink_to_hi().to(args.span_ext), + "the `Self` type doesn't accept type parameters", + String::new(), + Applicability::MachineApplicable, + ); + return; + } else { + err.span_suggestion_verbose( + segment.ident.span, + format!( + "the `Self` type doesn't accept type parameters, use the \ + concrete type's name `{type_name}` instead if you want to \ + specify its type parameters" + ), + type_name.to_string(), + Applicability::MaybeIncorrect, + ); + } + } + } + }); // HACK(min_const_generics): Forbid generic `Self` types // here as we can't easily do that during nameres. // @@ -2324,7 +2528,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } Res::Def(DefKind::AssocTy, def_id) => { debug_assert!(path.segments.len() >= 2); - self.prohibit_generics(&path.segments[..path.segments.len() - 2]); + self.prohibit_generics(path.segments[..path.segments.len() - 2].iter(), |_| {}); self.qpath_to_ty( span, opt_self_ty, @@ -2335,7 +2539,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } Res::PrimTy(prim_ty) => { assert_eq!(opt_self_ty, None); - self.prohibit_generics(path.segments); + self.prohibit_generics(path.segments.iter(), |err| { + let name = prim_ty.name_str(); + for segment in path.segments { + if let Some(args) = segment.args { + err.span_suggestion_verbose( + segment.ident.span.shrink_to_hi().to(args.span_ext), + &format!("primitive type `{name}` doesn't have generic parameters"), + String::new(), + Applicability::MaybeIncorrect, + ); + } + } + }); match prim_ty { hir::PrimTy::Bool => tcx.types.bool, hir::PrimTy::Char => tcx.types.char, @@ -2426,13 +2642,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { debug!(?qself, ?segment); let ty = self.ast_ty_to_ty_inner(qself, false, true); - - let res = if let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = qself.kind { - path.res - } else { - Res::Err - }; - self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, res, segment, false) + self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, qself, segment, false) .map(|(ty, _, _)| ty) .unwrap_or_else(|_| tcx.ty_error()) } diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index ac2dc6522adc2..c28c041e78dff 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -1228,6 +1228,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None } }), + |_| {}, ); if let Res::Local(hid) = res { diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs index 34cc02f180b40..83afbfa54b1dd 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/checks.rs @@ -1564,13 +1564,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { QPath::TypeRelative(ref qself, ref segment) => { let ty = self.to_ty(qself); - let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.kind { - path.res - } else { - Res::Err - }; let result = >::associated_path_to_ty( - self, hir_id, path_span, ty, res, segment, true, + self, hir_id, path_span, ty, qself, segment, true, ); let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error()); let result = result.map(|(_, kind, def_id)| (kind, def_id)); diff --git a/src/test/ui/derives/issue-97343.rs b/src/test/ui/derives/issue-97343.rs index adec6c7a5c5a3..6f0e4d55aeb04 100644 --- a/src/test/ui/derives/issue-97343.rs +++ b/src/test/ui/derives/issue-97343.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; #[derive(Debug)] -pub struct Irrelevant { //~ ERROR type arguments are not allowed for this type +pub struct Irrelevant { //~ ERROR type arguments are not allowed on type parameter irrelevant: Irrelevant, } diff --git a/src/test/ui/derives/issue-97343.stderr b/src/test/ui/derives/issue-97343.stderr index eedd54f1e9f0c..ac797a8f50152 100644 --- a/src/test/ui/derives/issue-97343.stderr +++ b/src/test/ui/derives/issue-97343.stderr @@ -1,11 +1,19 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on type parameter `Irrelevant` --> $DIR/issue-97343.rs:4:23 | LL | #[derive(Debug)] - | ----- in this derive macro expansion + | ----- + | | + | not allowed on this + | in this derive macro expansion LL | pub struct Irrelevant { | ^^^^^^^^^^ type argument not allowed | +note: type parameter `Irrelevant` defined here + --> $DIR/issue-97343.rs:4:23 + | +LL | pub struct Irrelevant { + | ^^^^^^^^^^ = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr index 577e286fcc6ce..e0e437e18ae8c 100644 --- a/src/test/ui/error-codes/E0109.stderr +++ b/src/test/ui/error-codes/E0109.stderr @@ -1,8 +1,16 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/E0109.rs:1:14 | LL | type X = u32; - | ^^^ type argument not allowed + | --- ^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `u32` doesn't have generic parameters + | +LL - type X = u32; +LL + type X = u32; + | error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr index b022131808738..15e1b959193fa 100644 --- a/src/test/ui/error-codes/E0110.stderr +++ b/src/test/ui/error-codes/E0110.stderr @@ -1,8 +1,16 @@ -error[E0109]: lifetime arguments are not allowed for this type +error[E0109]: lifetime arguments are not allowed on this type --> $DIR/E0110.rs:1:14 | LL | type X = u32<'static>; - | ^^^^^^^ lifetime argument not allowed + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `u32` doesn't have generic parameters + | +LL - type X = u32<'static>; +LL + type X = u32; + | error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22706.rs b/src/test/ui/issues/issue-22706.rs index 28e8a72280481..bb8a58d3d2ecc 100644 --- a/src/test/ui/issues/issue-22706.rs +++ b/src/test/ui/issues/issue-22706.rs @@ -1,3 +1,3 @@ fn is_copy::Copy>() {} -//~^ ERROR type arguments are not allowed for this type [E0109] +//~^ ERROR type arguments are not allowed on module `marker` [E0109] fn main() {} diff --git a/src/test/ui/issues/issue-22706.stderr b/src/test/ui/issues/issue-22706.stderr index c5929397f6501..66911f081d76c 100644 --- a/src/test/ui/issues/issue-22706.stderr +++ b/src/test/ui/issues/issue-22706.stderr @@ -1,8 +1,10 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on module `marker` --> $DIR/issue-22706.rs:1:29 | LL | fn is_copy::Copy>() {} - | ^^^ type argument not allowed + | ------ ^^^ type argument not allowed + | | + | not allowed on this error: aborting due to previous error diff --git a/src/test/ui/issues/issue-57924.rs b/src/test/ui/issues/issue-57924.rs index dc2942225e3de..8846912a8ff79 100644 --- a/src/test/ui/issues/issue-57924.rs +++ b/src/test/ui/issues/issue-57924.rs @@ -3,7 +3,7 @@ pub struct Gcm(E); impl Gcm { pub fn crash(e: E) -> Self { Self::(e) - //~^ ERROR type arguments are not allowed for this type + //~^ ERROR type arguments are not allowed on self constructor } } diff --git a/src/test/ui/issues/issue-57924.stderr b/src/test/ui/issues/issue-57924.stderr index 2f184b1aae171..211b0dde48c2e 100644 --- a/src/test/ui/issues/issue-57924.stderr +++ b/src/test/ui/issues/issue-57924.stderr @@ -1,8 +1,10 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self constructor --> $DIR/issue-57924.rs:5:16 | LL | Self::(e) - | ^ type argument not allowed + | ---- ^ type argument not allowed + | | + | not allowed on this error: aborting due to previous error diff --git a/src/test/ui/issues/issue-60989.rs b/src/test/ui/issues/issue-60989.rs index 6dae1e1347b7a..29db3fdb47104 100644 --- a/src/test/ui/issues/issue-60989.rs +++ b/src/test/ui/issues/issue-60989.rs @@ -10,9 +10,9 @@ impl From for B { fn main() { let c1 = (); c1::<()>; - //~^ ERROR type arguments are not allowed for this type + //~^ ERROR type arguments are not allowed on local variable let c1 = A {}; c1::>; - //~^ ERROR type arguments are not allowed for this type + //~^ ERROR type arguments are not allowed on local variable } diff --git a/src/test/ui/issues/issue-60989.stderr b/src/test/ui/issues/issue-60989.stderr index 5d2d9e83c9b9c..9076f4f9385ba 100644 --- a/src/test/ui/issues/issue-60989.stderr +++ b/src/test/ui/issues/issue-60989.stderr @@ -1,14 +1,18 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on local variable --> $DIR/issue-60989.rs:12:10 | LL | c1::<()>; - | ^^ type argument not allowed + | -- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on local variable --> $DIR/issue-60989.rs:16:10 | LL | c1::>; - | ^^^^^^^^^^^ type argument not allowed + | -- ^^^^^^^^^^^ type argument not allowed + | | + | not allowed on this error: aborting due to 2 previous errors diff --git a/src/test/ui/mod-subitem-as-enum-variant.rs b/src/test/ui/mod-subitem-as-enum-variant.rs index 9328d1a9045e5..959024c46f4ff 100644 --- a/src/test/ui/mod-subitem-as-enum-variant.rs +++ b/src/test/ui/mod-subitem-as-enum-variant.rs @@ -5,5 +5,5 @@ mod Mod { fn main() { Mod::FakeVariant::(0); Mod::::FakeVariant(0); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on module `Mod` [E0109] } diff --git a/src/test/ui/mod-subitem-as-enum-variant.stderr b/src/test/ui/mod-subitem-as-enum-variant.stderr index d6815c91e5e9e..15da1d155a337 100644 --- a/src/test/ui/mod-subitem-as-enum-variant.stderr +++ b/src/test/ui/mod-subitem-as-enum-variant.stderr @@ -1,8 +1,10 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on module `Mod` --> $DIR/mod-subitem-as-enum-variant.rs:7:11 | LL | Mod::::FakeVariant(0); - | ^^^ type argument not allowed + | --- ^^^ type argument not allowed + | | + | not allowed on this error: aborting due to previous error diff --git a/src/test/ui/structs/struct-path-associated-type.rs b/src/test/ui/structs/struct-path-associated-type.rs index e44a203b7832a..f88572f8419c0 100644 --- a/src/test/ui/structs/struct-path-associated-type.rs +++ b/src/test/ui/structs/struct-path-associated-type.rs @@ -13,7 +13,7 @@ fn f() { //~^ ERROR expected struct, variant or union type, found associated type let z = T::A:: {}; //~^ ERROR expected struct, variant or union type, found associated type - //~| ERROR type arguments are not allowed for this type + //~| ERROR type arguments are not allowed on this type match S { T::A {} => {} //~^ ERROR expected struct, variant or union type, found associated type @@ -22,7 +22,7 @@ fn f() { fn g>() { let s = T::A {}; // OK - let z = T::A:: {}; //~ ERROR type arguments are not allowed for this type + let z = T::A:: {}; //~ ERROR type arguments are not allowed on this type match S { T::A {} => {} // OK } diff --git a/src/test/ui/structs/struct-path-associated-type.stderr b/src/test/ui/structs/struct-path-associated-type.stderr index 0b1b6a5e3af28..7424ceecbe3b6 100644 --- a/src/test/ui/structs/struct-path-associated-type.stderr +++ b/src/test/ui/structs/struct-path-associated-type.stderr @@ -4,11 +4,13 @@ error[E0071]: expected struct, variant or union type, found associated type LL | let s = T::A {}; | ^^^^ not a struct -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/struct-path-associated-type.rs:14:20 | LL | let z = T::A:: {}; - | ^^ type argument not allowed + | - ^^ type argument not allowed + | | + | not allowed on this error[E0071]: expected struct, variant or union type, found associated type --> $DIR/struct-path-associated-type.rs:14:13 @@ -22,11 +24,13 @@ error[E0071]: expected struct, variant or union type, found associated type LL | T::A {} => {} | ^^^^ not a struct -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/struct-path-associated-type.rs:25:20 | LL | let z = T::A:: {}; - | ^^ type argument not allowed + | - ^^ type argument not allowed + | | + | not allowed on this error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:32:13 diff --git a/src/test/ui/structs/struct-path-self.rs b/src/test/ui/structs/struct-path-self.rs index c938ce8dad98d..6e529c7ed2b70 100644 --- a/src/test/ui/structs/struct-path-self.rs +++ b/src/test/ui/structs/struct-path-self.rs @@ -6,7 +6,7 @@ trait Tr { //~^ ERROR expected struct, variant or union type, found type parameter let z = Self:: {}; //~^ ERROR expected struct, variant or union type, found type parameter - //~| ERROR type arguments are not allowed for this type + //~| ERROR type arguments are not allowed on self type match s { Self { .. } => {} //~^ ERROR expected struct, variant or union type, found type parameter @@ -17,7 +17,7 @@ trait Tr { impl Tr for S { fn f() { let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type arguments are not allowed for this type + let z = Self:: {}; //~ ERROR type arguments are not allowed on self type match s { Self { .. } => {} // OK } @@ -27,7 +27,7 @@ impl Tr for S { impl S { fn g() { let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type arguments are not allowed for this type + let z = Self:: {}; //~ ERROR type arguments are not allowed on self type match s { Self { .. } => {} // OK } diff --git a/src/test/ui/structs/struct-path-self.stderr b/src/test/ui/structs/struct-path-self.stderr index 693ed35cbc9c6..cccdd7b0f023f 100644 --- a/src/test/ui/structs/struct-path-self.stderr +++ b/src/test/ui/structs/struct-path-self.stderr @@ -4,11 +4,19 @@ error[E0071]: expected struct, variant or union type, found type parameter `Self LL | let s = Self {}; | ^^^^ not a struct -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/struct-path-self.rs:7:24 | LL | let z = Self:: {}; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +help: the `Self` type doesn't accept type parameters + | +LL - let z = Self:: {}; +LL + let z = Self {}; + | error[E0071]: expected struct, variant or union type, found type parameter `Self` --> $DIR/struct-path-self.rs:7:17 @@ -22,17 +30,49 @@ error[E0071]: expected struct, variant or union type, found type parameter `Self LL | Self { .. } => {} | ^^^^ not a struct -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/struct-path-self.rs:20:24 | LL | let z = Self:: {}; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `S` + --> $DIR/struct-path-self.rs:1:8 + | +LL | struct S; + | ^ `Self` corresponds to this type, which doesn't have generic parameters +... +LL | impl Tr for S { + | ------------- `Self` is on type `S` in this `impl` +help: the `Self` type doesn't accept type parameters + | +LL - let z = Self:: {}; +LL + let z = Self {}; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/struct-path-self.rs:30:24 | LL | let z = Self:: {}; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `S` + --> $DIR/struct-path-self.rs:1:8 + | +LL | struct S; + | ^ `Self` corresponds to this type, which doesn't have generic parameters +... +LL | impl S { + | ------ `Self` is on type `S` in this `impl` +help: the `Self` type doesn't accept type parameters + | +LL - let z = Self:: {}; +LL + let z = Self {}; + | error: aborting due to 6 previous errors diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs index 6bc4f528faaf9..e6f45036f8514 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs @@ -13,38 +13,38 @@ impl Enum { Self::TSVariant(()); //~^ ERROR mismatched types [E0308] Self::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Self::<()>::TSVariant(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] //~| ERROR mismatched types [E0308] Self::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] - //~| ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] + //~| ERROR type arguments are not allowed on this type [E0109] } fn s_variant() { Self::SVariant { v: () }; //~^ ERROR mismatched types [E0308] Self::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] //~| ERROR mismatched types [E0308] Self::<()>::SVariant { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] //~| ERROR mismatched types [E0308] Self::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] - //~| ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] + //~| ERROR type arguments are not allowed on this type [E0109] //~| ERROR mismatched types [E0308] } fn u_variant() { Self::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Self::<()>::UVariant; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] Self::<()>::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] - //~| ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on self type [E0109] + //~| ERROR type arguments are not allowed on this type [E0109] } } @@ -52,54 +52,54 @@ fn main() { // Tuple struct variant Enum::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::<()>::TSVariant(()); //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] AliasFixed::<()>::TSVariant::<()>(()); - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] // Struct variant Enum::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::<()>::SVariant { v: () }; //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] AliasFixed::<()>::SVariant::<()> { v: () }; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] // Unit variant Enum::<()>::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] Alias::<()>::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] AliasFixed::<()>::UVariant; //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] AliasFixed::<()>::UVariant::<()>; - //~^ ERROR type arguments are not allowed for this type [E0109] + //~^ ERROR type arguments are not allowed on this type [E0109] //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107] } diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr index 115ecb013766d..3e60ab108a82f 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr @@ -17,17 +17,34 @@ note: tuple variant defined here LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } | ^^^^^^^^^ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:15:27 | LL | Self::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:17:16 | LL | Self::<()>::TSVariant(()); - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::TSVariant(()); + | ~~~~ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:17:31 @@ -48,17 +65,34 @@ note: tuple variant defined here LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } | ^^^^^^^^^ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:20:16 | LL | Self::<()>::TSVariant::<()>(()); - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::TSVariant::<()>(()); + | ~~~~ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:20:33 | LL | Self::<()>::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:26:29 @@ -72,11 +106,20 @@ LL | Self::SVariant { v: () }; = note: expected type parameter `T` found unit type `()` -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:28:26 | LL | Self::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - Self::SVariant::<()> { v: () }; +LL + Enum::<()>::SVariant { v: () }; + | error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:28:35 @@ -90,11 +133,26 @@ LL | Self::SVariant::<()> { v: () }; = note: expected type parameter `T` found unit type `()` -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:31:16 | LL | Self::<()>::SVariant { v: () }; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::SVariant { v: () }; + | ~~~~ error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:31:35 @@ -108,17 +166,41 @@ LL | Self::<()>::SVariant { v: () }; = note: expected type parameter `T` found unit type `()` -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:34:16 | LL | Self::<()>::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::SVariant::<()> { v: () }; + | ~~~~ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:34:32 | LL | Self::<()>::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - Self::<()>::SVariant::<()> { v: () }; +LL + Enum::<()>::SVariant { v: () }; + | error[E0308]: mismatched types --> $DIR/enum-variant-generic-args.rs:34:41 @@ -132,53 +214,95 @@ LL | Self::<()>::SVariant::<()> { v: () }; = note: expected type parameter `T` found unit type `()` -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:41:26 | LL | Self::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:43:16 | LL | Self::<()>::UVariant; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::UVariant; + | ~~~~ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on self type --> $DIR/enum-variant-generic-args.rs:45:16 | LL | Self::<()>::UVariant::<()>; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this + | +note: `Self` is of type `Enum` + --> $DIR/enum-variant-generic-args.rs:7:6 + | +LL | enum Enum { TSVariant(T), SVariant { v: T }, UVariant } + | ^^^^ `Self` corresponds to this type +... +LL | impl Enum { + | --------------- `Self` is on type `Enum` in this `impl` +help: the `Self` type doesn't accept type parameters, use the concrete type's name `Enum` instead if you want to specify its type parameters + | +LL | Enum::<()>::UVariant::<()>; + | ~~~~ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:45:32 | LL | Self::<()>::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:54:29 | LL | Enum::<()>::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:57:24 | LL | Alias::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:59:30 | LL | Alias::<()>::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:62:29 | LL | AliasFixed::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied --> $DIR/enum-variant-generic-args.rs:64:5 @@ -208,35 +332,68 @@ note: type alias defined here, with 0 generic parameters LL | type AliasFixed = Enum<()>; | ^^^^^^^^^^ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:66:35 | LL | AliasFixed::<()>::TSVariant::<()>(()); - | ^^ type argument not allowed + | --------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:72:28 | LL | Enum::<()>::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:75:23 | LL | Alias::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - Alias::SVariant::<()> { v: () }; +LL + Alias::<()>::SVariant { v: () }; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:77:29 | LL | Alias::<()>::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - Alias::<()>::SVariant::<()> { v: () }; +LL + Alias::<()>::SVariant { v: () }; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:80:28 | LL | AliasFixed::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - AliasFixed::SVariant::<()> { v: () }; +LL + AliasFixed::<()>::SVariant { v: () }; + | error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied --> $DIR/enum-variant-generic-args.rs:82:5 @@ -266,35 +423,52 @@ note: type alias defined here, with 0 generic parameters LL | type AliasFixed = Enum<()>; | ^^^^^^^^^^ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:84:34 | LL | AliasFixed::<()>::SVariant::<()> { v: () }; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this + | + = note: enum variants can't have type parameters +help: you might have meant to specity type parameters on enum `Enum` + | +LL - AliasFixed::<()>::SVariant::<()> { v: () }; +LL + AliasFixed::<()>::SVariant { v: () }; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:90:28 | LL | Enum::<()>::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:93:23 | LL | Alias::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:95:29 | LL | Alias::<()>::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:98:28 | LL | AliasFixed::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied --> $DIR/enum-variant-generic-args.rs:100:5 @@ -324,11 +498,13 @@ note: type alias defined here, with 0 generic parameters LL | type AliasFixed = Enum<()>; | ^^^^^^^^^^ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/enum-variant-generic-args.rs:102:34 | LL | AliasFixed::<()>::UVariant::<()>; - | ^^ type argument not allowed + | -------- ^^ type argument not allowed + | | + | not allowed on this error: aborting due to 39 previous errors diff --git a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.rs b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.rs index c1153fa4dc7b4..872ece0c0f99e 100644 --- a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.rs +++ b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.rs @@ -10,5 +10,5 @@ fn main() { let _ = Option::::None; // OK let _ = Option::None::; // OK (Lint in future!) let _ = Alias::::None; // OK - let _ = Alias::None::; //~ ERROR type arguments are not allowed for this type + let _ = Alias::None::; //~ ERROR type arguments are not allowed on this type } diff --git a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr index a1064d6925111..474548a14a9a6 100644 --- a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr +++ b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr @@ -1,8 +1,10 @@ -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/no-type-application-on-aliased-enum-variant.rs:13:27 | LL | let _ = Alias::None::; - | ^^ type argument not allowed + | ---- ^^ type argument not allowed + | | + | not allowed on this error: aborting due to previous error diff --git a/src/test/ui/type/issue-91268.rs b/src/test/ui/type/issue-91268.rs index fd2733c1c545e..01ed9ea9e231f 100644 --- a/src/test/ui/type/issue-91268.rs +++ b/src/test/ui/type/issue-91268.rs @@ -1,7 +1,7 @@ // error-pattern: this file contains an unclosed delimiter // error-pattern: cannot find type `ţ` in this scope // error-pattern: parenthesized type parameters may only be used with a `Fn` trait -// error-pattern: type arguments are not allowed for this type +// error-pattern: type arguments are not allowed on this type // error-pattern: mismatched types // ignore-tidy-trailing-newlines // `ţ` must be the last character in this file, it cannot be followed by a newline diff --git a/src/test/ui/type/issue-91268.stderr b/src/test/ui/type/issue-91268.stderr index 2fe6ba6248c8d..199fd6a23f755 100644 --- a/src/test/ui/type/issue-91268.stderr +++ b/src/test/ui/type/issue-91268.stderr @@ -30,11 +30,19 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait LL | 0: u8(ţ | ^^^^ only `Fn` traits may use parentheses -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/issue-91268.rs:9:11 | LL | 0: u8(ţ - | ^ type argument not allowed + | -- ^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `u8` doesn't have generic parameters + | +LL - 0: u8(ţ +LL + 0: u8 + | error[E0308]: mismatched types --> $DIR/issue-91268.rs:9:5 diff --git a/src/test/ui/typeck/prim-with-args.fixed b/src/test/ui/typeck/prim-with-args.fixed new file mode 100644 index 0000000000000..1c5fd7508676a --- /dev/null +++ b/src/test/ui/typeck/prim-with-args.fixed @@ -0,0 +1,28 @@ +// run-rustfix +fn main() { + +let _x: isize; //~ ERROR type arguments are not allowed on this type +let _x: i8; //~ ERROR type arguments are not allowed on this type +let _x: i16; //~ ERROR type arguments are not allowed on this type +let _x: i32; //~ ERROR type arguments are not allowed on this type +let _x: i64; //~ ERROR type arguments are not allowed on this type +let _x: usize; //~ ERROR type arguments are not allowed on this type +let _x: u8; //~ ERROR type arguments are not allowed on this type +let _x: u16; //~ ERROR type arguments are not allowed on this type +let _x: u32; //~ ERROR type arguments are not allowed on this type +let _x: u64; //~ ERROR type arguments are not allowed on this type +let _x: char; //~ ERROR type arguments are not allowed on this type + +let _x: isize; //~ ERROR lifetime arguments are not allowed on this type +let _x: i8; //~ ERROR lifetime arguments are not allowed on this type +let _x: i16; //~ ERROR lifetime arguments are not allowed on this type +let _x: i32; //~ ERROR lifetime arguments are not allowed on this type +let _x: i64; //~ ERROR lifetime arguments are not allowed on this type +let _x: usize; //~ ERROR lifetime arguments are not allowed on this type +let _x: u8; //~ ERROR lifetime arguments are not allowed on this type +let _x: u16; //~ ERROR lifetime arguments are not allowed on this type +let _x: u32; //~ ERROR lifetime arguments are not allowed on this type +let _x: u64; //~ ERROR lifetime arguments are not allowed on this type +let _x: char; //~ ERROR lifetime arguments are not allowed on this type + +} diff --git a/src/test/ui/typeck/prim-with-args.rs b/src/test/ui/typeck/prim-with-args.rs index e5beaca6abb8c..b05d6c1cb4e4a 100644 --- a/src/test/ui/typeck/prim-with-args.rs +++ b/src/test/ui/typeck/prim-with-args.rs @@ -1,27 +1,28 @@ +// run-rustfix fn main() { -let x: isize; //~ ERROR type arguments are not allowed for this type -let x: i8; //~ ERROR type arguments are not allowed for this type -let x: i16; //~ ERROR type arguments are not allowed for this type -let x: i32; //~ ERROR type arguments are not allowed for this type -let x: i64; //~ ERROR type arguments are not allowed for this type -let x: usize; //~ ERROR type arguments are not allowed for this type -let x: u8; //~ ERROR type arguments are not allowed for this type -let x: u16; //~ ERROR type arguments are not allowed for this type -let x: u32; //~ ERROR type arguments are not allowed for this type -let x: u64; //~ ERROR type arguments are not allowed for this type -let x: char; //~ ERROR type arguments are not allowed for this type +let _x: isize; //~ ERROR type arguments are not allowed on this type +let _x: i8; //~ ERROR type arguments are not allowed on this type +let _x: i16; //~ ERROR type arguments are not allowed on this type +let _x: i32; //~ ERROR type arguments are not allowed on this type +let _x: i64; //~ ERROR type arguments are not allowed on this type +let _x: usize; //~ ERROR type arguments are not allowed on this type +let _x: u8; //~ ERROR type arguments are not allowed on this type +let _x: u16; //~ ERROR type arguments are not allowed on this type +let _x: u32; //~ ERROR type arguments are not allowed on this type +let _x: u64; //~ ERROR type arguments are not allowed on this type +let _x: char; //~ ERROR type arguments are not allowed on this type -let x: isize<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: i8<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: i16<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: i32<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: i64<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: usize<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: u8<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: u16<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: u32<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: u64<'static>; //~ ERROR lifetime arguments are not allowed for this type -let x: char<'static>; //~ ERROR lifetime arguments are not allowed for this type +let _x: isize<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: i8<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: i16<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: i32<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: i64<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: usize<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: u8<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: u16<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: u32<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: u64<'static>; //~ ERROR lifetime arguments are not allowed on this type +let _x: char<'static>; //~ ERROR lifetime arguments are not allowed on this type } diff --git a/src/test/ui/typeck/prim-with-args.stderr b/src/test/ui/typeck/prim-with-args.stderr index 4bde981e7f2d4..7e7bc580b3b95 100644 --- a/src/test/ui/typeck/prim-with-args.stderr +++ b/src/test/ui/typeck/prim-with-args.stderr @@ -1,134 +1,310 @@ -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:3:14 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:4:15 | -LL | let x: isize; - | ^^^^^ type argument not allowed - -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:4:11 +LL | let _x: isize; + | ----- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `isize` doesn't have generic parameters | -LL | let x: i8; - | ^^^^^ type argument not allowed +LL - let _x: isize; +LL + let _x: isize; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/prim-with-args.rs:5:12 | -LL | let x: i16; - | ^^^^^ type argument not allowed +LL | let _x: i8; + | -- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `i8` doesn't have generic parameters + | +LL - let _x: i8; +LL + let _x: i8; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:6:12 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:6:13 + | +LL | let _x: i16; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `i16` doesn't have generic parameters | -LL | let x: i32; - | ^^^^^ type argument not allowed +LL - let _x: i16; +LL + let _x: i16; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:7:12 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:7:13 | -LL | let x: i64; - | ^^^^^ type argument not allowed +LL | let _x: i32; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `i32` doesn't have generic parameters + | +LL - let _x: i32; +LL + let _x: i32; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:8:14 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:8:13 + | +LL | let _x: i64; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this | -LL | let x: usize; - | ^^^^^ type argument not allowed +help: primitive type `i64` doesn't have generic parameters + | +LL - let _x: i64; +LL + let _x: i64; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:9:11 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:9:15 + | +LL | let _x: usize; + | ----- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `usize` doesn't have generic parameters | -LL | let x: u8; - | ^^^^^ type argument not allowed +LL - let _x: usize; +LL + let _x: usize; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/prim-with-args.rs:10:12 | -LL | let x: u16; - | ^^^^^ type argument not allowed +LL | let _x: u8; + | -- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `u8` doesn't have generic parameters + | +LL - let _x: u8; +LL + let _x: u8; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:11:12 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:11:13 + | +LL | let _x: u16; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this | -LL | let x: u32; - | ^^^^^ type argument not allowed +help: primitive type `u16` doesn't have generic parameters + | +LL - let _x: u16; +LL + let _x: u16; + | -error[E0109]: type arguments are not allowed for this type - --> $DIR/prim-with-args.rs:12:12 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:12:13 + | +LL | let _x: u32; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `u32` doesn't have generic parameters | -LL | let x: u64; - | ^^^^^ type argument not allowed +LL - let _x: u32; +LL + let _x: u32; + | -error[E0109]: type arguments are not allowed for this type +error[E0109]: type arguments are not allowed on this type --> $DIR/prim-with-args.rs:13:13 | -LL | let x: char; - | ^^^^^ type argument not allowed +LL | let _x: u64; + | --- ^^^^^ type argument not allowed + | | + | not allowed on this + | +help: primitive type `u64` doesn't have generic parameters + | +LL - let _x: u64; +LL + let _x: u64; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:15:14 +error[E0109]: type arguments are not allowed on this type + --> $DIR/prim-with-args.rs:14:14 + | +LL | let _x: char; + | ---- ^^^^^ type argument not allowed + | | + | not allowed on this | -LL | let x: isize<'static>; - | ^^^^^^^ lifetime argument not allowed +help: primitive type `char` doesn't have generic parameters + | +LL - let _x: char; +LL + let _x: char; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:16:11 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:16:15 + | +LL | let _x: isize<'static>; + | ----- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this | -LL | let x: i8<'static>; - | ^^^^^^^ lifetime argument not allowed +help: primitive type `isize` doesn't have generic parameters + | +LL - let _x: isize<'static>; +LL + let _x: isize; + | -error[E0109]: lifetime arguments are not allowed for this type +error[E0109]: lifetime arguments are not allowed on this type --> $DIR/prim-with-args.rs:17:12 | -LL | let x: i16<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: i8<'static>; + | -- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `i8` doesn't have generic parameters + | +LL - let _x: i8<'static>; +LL + let _x: i8; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:18:12 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:18:13 | -LL | let x: i32<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: i16<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `i16` doesn't have generic parameters + | +LL - let _x: i16<'static>; +LL + let _x: i16; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:19:12 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:19:13 + | +LL | let _x: i32<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this | -LL | let x: i64<'static>; - | ^^^^^^^ lifetime argument not allowed +help: primitive type `i32` doesn't have generic parameters + | +LL - let _x: i32<'static>; +LL + let _x: i32; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:20:14 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:20:13 + | +LL | let _x: i64<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `i64` doesn't have generic parameters | -LL | let x: usize<'static>; - | ^^^^^^^ lifetime argument not allowed +LL - let _x: i64<'static>; +LL + let _x: i64; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:21:11 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:21:15 | -LL | let x: u8<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: usize<'static>; + | ----- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `usize` doesn't have generic parameters + | +LL - let _x: usize<'static>; +LL + let _x: usize; + | -error[E0109]: lifetime arguments are not allowed for this type +error[E0109]: lifetime arguments are not allowed on this type --> $DIR/prim-with-args.rs:22:12 | -LL | let x: u16<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: u8<'static>; + | -- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `u8` doesn't have generic parameters + | +LL - let _x: u8<'static>; +LL + let _x: u8; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:23:12 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:23:13 + | +LL | let _x: u16<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `u16` doesn't have generic parameters | -LL | let x: u32<'static>; - | ^^^^^^^ lifetime argument not allowed +LL - let _x: u16<'static>; +LL + let _x: u16; + | -error[E0109]: lifetime arguments are not allowed for this type - --> $DIR/prim-with-args.rs:24:12 +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:24:13 | -LL | let x: u64<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: u32<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `u32` doesn't have generic parameters + | +LL - let _x: u32<'static>; +LL + let _x: u32; + | -error[E0109]: lifetime arguments are not allowed for this type +error[E0109]: lifetime arguments are not allowed on this type --> $DIR/prim-with-args.rs:25:13 | -LL | let x: char<'static>; - | ^^^^^^^ lifetime argument not allowed +LL | let _x: u64<'static>; + | --- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `u64` doesn't have generic parameters + | +LL - let _x: u64<'static>; +LL + let _x: u64; + | + +error[E0109]: lifetime arguments are not allowed on this type + --> $DIR/prim-with-args.rs:26:14 + | +LL | let _x: char<'static>; + | ---- ^^^^^^^ lifetime argument not allowed + | | + | not allowed on this + | +help: primitive type `char` doesn't have generic parameters + | +LL - let _x: char<'static>; +LL + let _x: char; + | error: aborting due to 22 previous errors diff --git a/src/test/ui/usize-generic-argument-parent.rs b/src/test/ui/usize-generic-argument-parent.rs index 46b06e2b3662a..6d17ba9b5b261 100644 --- a/src/test/ui/usize-generic-argument-parent.rs +++ b/src/test/ui/usize-generic-argument-parent.rs @@ -1,5 +1,5 @@ fn foo() { - let x: usize; //~ ERROR const arguments are not allowed for this type + let x: usize; //~ ERROR const arguments are not allowed on this type } fn main() {} diff --git a/src/test/ui/usize-generic-argument-parent.stderr b/src/test/ui/usize-generic-argument-parent.stderr index f1eae3b500840..c657f0faa0b98 100644 --- a/src/test/ui/usize-generic-argument-parent.stderr +++ b/src/test/ui/usize-generic-argument-parent.stderr @@ -1,8 +1,16 @@ -error[E0109]: const arguments are not allowed for this type +error[E0109]: const arguments are not allowed on this type --> $DIR/usize-generic-argument-parent.rs:2:18 | LL | let x: usize; - | ^^^ const argument not allowed + | ----- ^^^ const argument not allowed + | | + | not allowed on this + | +help: primitive type `usize` doesn't have generic parameters + | +LL - let x: usize; +LL + let x: usize; + | error: aborting due to previous error