From 7224b0052316766f421ec3ab52e5b1a342219958 Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 5 Jan 2022 11:42:08 +0100 Subject: [PATCH 1/4] change `ct_infer` to a delay_span_bug --- compiler/rustc_middle/src/ty/context.rs | 20 +++++++++++++++++--- compiler/rustc_typeck/src/collect.rs | 6 ++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index dd571e29bf695..8a156a6570c1f 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1209,11 +1209,25 @@ impl<'tcx> TyCtxt<'tcx> { self.mk_ty(Error(DelaySpanBugEmitted(()))) } - /// Like `err` but for constants. + /// Like [`ty_error`] but for constants. #[track_caller] pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> { - self.sess - .delay_span_bug(DUMMY_SP, "ty::ConstKind::Error constructed but no error reported."); + self.const_error_with_message( + ty, + DUMMY_SP, + "ty::ConstKind::Error constructed but no error reported", + ) + } + + /// Like [`ty_error_with_message`] but for constants. + #[track_caller] + pub fn const_error_with_message>( + self, + ty: Ty<'tcx>, + span: S, + msg: &str, + ) -> &'tcx Const<'tcx> { + self.sess.delay_span_bug(span, msg); self.mk_const(ty::Const { val: ty::ConstKind::Error(DelaySpanBugEmitted(())), ty }) } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index e1fef84d9d929..2bd41856098bb 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -386,7 +386,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> { } fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> { - self.tcx().ty_error_with_message(span, "bad_placeholder_type") + self.tcx().ty_error_with_message(span, "bad placeholder type") } fn ct_infer( @@ -395,13 +395,11 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> { _: Option<&ty::GenericParamDef>, span: Span, ) -> &'tcx Const<'tcx> { - bad_placeholder(self.tcx(), "const", vec![span], "generic").emit(); - // Typeck doesn't expect erased regions to be returned from `type_of`. let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match r { ty::ReErased => self.tcx.lifetimes.re_static, _ => r, }); - self.tcx().const_error(ty) + self.tcx().const_error_with_message(ty, span, "bad placeholder constant") } fn projected_ty_from_poly_trait_ref( From a3e378799b78fde29a79b887866e38c86502e79b Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 5 Jan 2022 11:42:45 +0100 Subject: [PATCH 2/4] remove unnecessary fixme --- compiler/rustc_typeck/src/collect/type_of.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 04e887bf7420f..f6b07176767a1 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -19,9 +19,6 @@ use super::{bad_placeholder, is_suggestable_infer_ty}; /// /// This should be called using the query `tcx.opt_const_param_of`. pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { - // FIXME(generic_arg_infer): allow for returning DefIds of inference of - // GenericArg::Infer below. This may require a change where GenericArg::Infer has some flag - // for const or type. use hir::*; let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); From c0aa0faba7467473139fed6e1d8e560afee56e5a Mon Sep 17 00:00:00 2001 From: lcnr Date: Wed, 5 Jan 2022 11:43:21 +0100 Subject: [PATCH 3/4] generic_arg_infer: placeholder in signature err --- compiler/rustc_typeck/src/astconv/mod.rs | 4 +- compiler/rustc_typeck/src/collect.rs | 40 +++--- compiler/rustc_typeck/src/collect/type_of.rs | 2 +- .../generic_arg_infer/array-in-sig.rs | 12 -- .../generic_arg_infer/array-in-sig.stderr | 9 -- .../generic_arg_infer/in-signature.rs | 61 +++++++++ .../generic_arg_infer/in-signature.stderr | 119 +++++++++++++++++ src/test/ui/did_you_mean/bad-assoc-ty.rs | 20 +-- src/test/ui/did_you_mean/bad-assoc-ty.stderr | 20 +-- src/test/ui/error-codes/E0121.stderr | 4 +- src/test/ui/fn/issue-80179.rs | 4 +- src/test/ui/fn/issue-80179.stderr | 4 +- .../issue-69396-const-no-type-in-macro.rs | 2 +- .../issue-69396-const-no-type-in-macro.stderr | 2 +- src/test/ui/self/self-infer.rs | 4 +- src/test/ui/self/self-infer.stderr | 4 +- src/test/ui/suggestions/unnamable-types.rs | 4 +- .../ui/suggestions/unnamable-types.stderr | 4 +- .../ui/type-alias-impl-trait/issue-77179.rs | 2 +- .../type-alias-impl-trait/issue-77179.stderr | 2 +- src/test/ui/typeck/issue-74086.rs | 2 +- src/test/ui/typeck/issue-74086.stderr | 2 +- src/test/ui/typeck/issue-75883.rs | 4 +- src/test/ui/typeck/issue-75883.stderr | 4 +- src/test/ui/typeck/issue-75889.stderr | 4 +- src/test/ui/typeck/issue-80779.rs | 4 +- src/test/ui/typeck/issue-80779.stderr | 4 +- src/test/ui/typeck/issue-81885.rs | 4 +- src/test/ui/typeck/issue-81885.stderr | 4 +- ...-83621-placeholder-static-in-extern.stderr | 2 +- .../ui/typeck/issue-91450-inner-ty-error.rs | 2 +- .../typeck/issue-91450-inner-ty-error.stderr | 2 +- .../ui/typeck/type-placeholder-fn-in-const.rs | 6 +- .../type-placeholder-fn-in-const.stderr | 6 +- .../ui/typeck/typeck_type_placeholder_item.rs | 120 +++++++++--------- .../typeck_type_placeholder_item.stderr | 120 +++++++++--------- .../typeck_type_placeholder_item_help.rs | 12 +- .../typeck_type_placeholder_item_help.stderr | 12 +- 38 files changed, 402 insertions(+), 235 deletions(-) delete mode 100644 src/test/ui/const-generics/generic_arg_infer/array-in-sig.rs delete mode 100644 src/test/ui/const-generics/generic_arg_infer/array-in-sig.stderr create mode 100644 src/test/ui/const-generics/generic_arg_infer/in-signature.rs create mode 100644 src/test/ui/const-generics/generic_arg_infer/in-signature.stderr diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 8226ffbccc431..2f2ee250d4e38 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -6,7 +6,7 @@ mod errors; mod generics; use crate::bounds::Bounds; -use crate::collect::PlaceholderHirTyCollector; +use crate::collect::HirPlaceholderCollector; use crate::errors::{ AmbiguousLifetimeBound, MultipleRelaxedDefaultBounds, TraitObjectDeclaredWithNoTraits, TypeofReservedKeywordUsed, ValueOfAssociatedStructAlreadySpecified, @@ -2469,7 +2469,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { debug!(?bound_vars); // We proactively collect all the inferred type params to emit a single error per fn def. - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); for ty in decl.inputs { visitor.visit_ty(ty); } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 2bd41856098bb..11f2b97f5a18c 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -114,9 +114,9 @@ pub struct ItemCtxt<'tcx> { /////////////////////////////////////////////////////////////////////////// #[derive(Default)] -crate struct PlaceholderHirTyCollector(crate Vec); +crate struct HirPlaceholderCollector(crate Vec); -impl<'v> Visitor<'v> for PlaceholderHirTyCollector { +impl<'v> Visitor<'v> for HirPlaceholderCollector { type Map = intravisit::ErasedMap<'v>; fn nested_visit_map(&mut self) -> NestedVisitorMap { @@ -138,6 +138,12 @@ impl<'v> Visitor<'v> for PlaceholderHirTyCollector { _ => {} } } + fn visit_array_length(&mut self, length: &'v hir::ArrayLen) { + if let &hir::ArrayLen::Infer(_, span) = length { + self.0.push(span); + } + intravisit::walk_array_len(self, length) + } } struct CollectItemTypesVisitor<'tcx> { @@ -182,7 +188,7 @@ crate fn placeholder_type_error<'tcx>( sugg.push((span, format!(", {}", type_name))); } - let mut err = bad_placeholder(tcx, "type", placeholder_types, kind); + let mut err = bad_placeholder(tcx, placeholder_types, kind); // Suggest, but only if it is not a function in const or static if suggest { @@ -240,7 +246,7 @@ fn reject_placeholder_type_signatures_in_item<'tcx>( _ => return, }; - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_item(item); placeholder_type_error( @@ -316,7 +322,6 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { fn bad_placeholder<'tcx>( tcx: TyCtxt<'tcx>, - placeholder_kind: &'static str, mut spans: Vec, kind: &'static str, ) -> rustc_errors::DiagnosticBuilder<'tcx> { @@ -327,8 +332,7 @@ fn bad_placeholder<'tcx>( tcx.sess, spans.clone(), E0121, - "the {} placeholder `_` is not allowed within types on item signatures for {}", - placeholder_kind, + "the placeholder `_` is not allowed within types on item signatures for {}", kind ); for span in spans { @@ -743,7 +747,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { match item.kind { hir::ForeignItemKind::Fn(..) => tcx.ensure().fn_sig(item.def_id), hir::ForeignItemKind::Static(..) => { - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_foreign_item(item); placeholder_type_error( tcx, @@ -826,7 +830,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) { hir::ItemKind::Const(ty, ..) | hir::ItemKind::Static(ty, ..) => { // (#75889): Account for `const C: dyn Fn() -> _ = "";` if let hir::TyKind::TraitObject(..) = ty.kind { - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_item(it); placeholder_type_error( tcx, @@ -862,7 +866,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { hir::TraitItemKind::Const(..) => { tcx.ensure().type_of(trait_item_id.def_id); // Account for `const C: _;`. - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_trait_item(trait_item); placeholder_type_error(tcx, None, &[], visitor.0, false, None, "constant"); } @@ -871,7 +875,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { tcx.ensure().item_bounds(trait_item_id.def_id); tcx.ensure().type_of(trait_item_id.def_id); // Account for `type T = _;`. - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_trait_item(trait_item); placeholder_type_error(tcx, None, &[], visitor.0, false, None, "associated type"); } @@ -880,7 +884,7 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::TraitItemId) { tcx.ensure().item_bounds(trait_item_id.def_id); // #74612: Visit and try to find bad placeholders // even if there is no concrete type. - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_trait_item(trait_item); placeholder_type_error(tcx, None, &[], visitor.0, false, None, "associated type"); @@ -902,7 +906,7 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::ImplItemId) { } hir::ImplItemKind::TyAlias(_) => { // Account for `type T = _;` - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_impl_item(impl_item); placeholder_type_error(tcx, None, &[], visitor.0, false, None, "associated type"); @@ -1735,10 +1739,14 @@ fn are_suggestable_generic_args(generic_args: &[hir::GenericArg<'_>]) -> bool { /// Whether `ty` is a type with `_` placeholders that can be inferred. Used in diagnostics only to /// use inference to provide suggestions for the appropriate type if possible. fn is_suggestable_infer_ty(ty: &hir::Ty<'_>) -> bool { + debug!(?ty); use hir::TyKind::*; match &ty.kind { Infer => true, - Slice(ty) | Array(ty, _) => is_suggestable_infer_ty(ty), + Slice(ty) => is_suggestable_infer_ty(ty), + Array(ty, length) => { + is_suggestable_infer_ty(ty) || matches!(length, hir::ArrayLen::Infer(_, _)) + } Tup(tys) => tys.iter().any(is_suggestable_infer_ty), Ptr(mut_ty) | Rptr(_, mut_ty) => is_suggestable_infer_ty(mut_ty.ty), OpaqueDef(_, generic_args) => are_suggestable_generic_args(generic_args), @@ -1790,9 +1798,9 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { }); let fn_sig = ty::Binder::dummy(fn_sig); - let mut visitor = PlaceholderHirTyCollector::default(); + let mut visitor = HirPlaceholderCollector::default(); visitor.visit_ty(ty); - let mut diag = bad_placeholder(tcx, "type", visitor.0, "return type"); + let mut diag = bad_placeholder(tcx, visitor.0, "return type"); let ret_ty = fn_sig.skip_binder().output(); if !ret_ty.references_error() { if !ret_ty.is_closure() { diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index f6b07176767a1..1a416a6dcc3dc 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -785,7 +785,7 @@ fn infer_placeholder_type<'a>( err.emit(); } None => { - let mut diag = bad_placeholder(tcx, "type", vec![span], kind); + let mut diag = bad_placeholder(tcx, vec![span], kind); if !ty.references_error() { let mut mk_nameable = MakeNameable::new(tcx); diff --git a/src/test/ui/const-generics/generic_arg_infer/array-in-sig.rs b/src/test/ui/const-generics/generic_arg_infer/array-in-sig.rs deleted file mode 100644 index 56b88a426a1a8..0000000000000 --- a/src/test/ui/const-generics/generic_arg_infer/array-in-sig.rs +++ /dev/null @@ -1,12 +0,0 @@ -// To avoid having to `or` gate `_` as an expr. -#![feature(generic_arg_infer)] - -fn foo() -> [u8; _] { - //~^ ERROR the const placeholder `_` is not allowed within types on item signatures for generics - // FIXME(generic_arg_infer): this error message should say in the return type or sth like that. - [0; 3] -} - -fn main() { - foo(); -} diff --git a/src/test/ui/const-generics/generic_arg_infer/array-in-sig.stderr b/src/test/ui/const-generics/generic_arg_infer/array-in-sig.stderr deleted file mode 100644 index eaa12b4192dc6..0000000000000 --- a/src/test/ui/const-generics/generic_arg_infer/array-in-sig.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0121]: the const placeholder `_` is not allowed within types on item signatures for generics - --> $DIR/array-in-sig.rs:4:18 - | -LL | fn foo() -> [u8; _] { - | ^ not allowed in type signatures - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/const-generics/generic_arg_infer/in-signature.rs b/src/test/ui/const-generics/generic_arg_infer/in-signature.rs new file mode 100644 index 0000000000000..1f60b2242411d --- /dev/null +++ b/src/test/ui/const-generics/generic_arg_infer/in-signature.rs @@ -0,0 +1,61 @@ +#![crate_type = "rlib"] +#![feature(generic_arg_infer)] + +struct Foo; +struct Bar(T); + +fn arr_fn() -> [u8; _] { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + [0; 3] +} + +fn ty_fn() -> Bar { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + Bar::(0) +} + +fn ty_fn_mixed() -> Bar<_, _> { + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + Bar::(0) +} + +const ARR_CT: [u8; _] = [0; 3]; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +static ARR_STATIC: [u8; _] = [0; 3]; +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables +const TY_CT: Bar = Bar::(0); +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +static TY_STATIC: Bar = Bar::(0); +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables +const TY_CT_MIXED: Bar<_, _> = Bar::(0); +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +static TY_STATIC_MIXED: Bar<_, _> = Bar::(0); +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables +trait ArrAssocConst { + const ARR: [u8; _]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +} +trait TyAssocConst { + const ARR: Bar; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +} +trait TyAssocConstMixed { + const ARR: Bar<_, _>; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +} + +trait AssocTy { + type Assoc; +} +impl AssocTy for i8 { + type Assoc = [u8; _]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types +} +impl AssocTy for i16 { + type Assoc = Bar; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types +} +impl AssocTy for i32 { + type Assoc = Bar<_, _>; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types +} diff --git a/src/test/ui/const-generics/generic_arg_infer/in-signature.stderr b/src/test/ui/const-generics/generic_arg_infer/in-signature.stderr new file mode 100644 index 0000000000000..7581cf4120ecf --- /dev/null +++ b/src/test/ui/const-generics/generic_arg_infer/in-signature.stderr @@ -0,0 +1,119 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/in-signature.rs:7:21 + | +LL | fn arr_fn() -> [u8; _] { + | -----^- + | | | + | | not allowed in type signatures + | help: replace with the correct return type: `[u8; 3]` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/in-signature.rs:12:24 + | +LL | fn ty_fn() -> Bar { + | ---------^- + | | | + | | not allowed in type signatures + | help: replace with the correct return type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/in-signature.rs:17:25 + | +LL | fn ty_fn_mixed() -> Bar<_, _> { + | ----^--^- + | | | | + | | | not allowed in type signatures + | | not allowed in type signatures + | help: replace with the correct return type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:22:15 + | +LL | const ARR_CT: [u8; _] = [0; 3]; + | ^^^^^^^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables + --> $DIR/in-signature.rs:24:20 + | +LL | static ARR_STATIC: [u8; _] = [0; 3]; + | ^^^^^^^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:26:14 + | +LL | const TY_CT: Bar = Bar::(0); + | ^^^^^^^^^^^ + | | + | not allowed in type signatures + | help: replace with the correct type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables + --> $DIR/in-signature.rs:28:19 + | +LL | static TY_STATIC: Bar = Bar::(0); + | ^^^^^^^^^^^ + | | + | not allowed in type signatures + | help: replace with the correct type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:30:20 + | +LL | const TY_CT_MIXED: Bar<_, _> = Bar::(0); + | ^^^^^^^^^ + | | + | not allowed in type signatures + | help: replace with the correct type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables + --> $DIR/in-signature.rs:32:25 + | +LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::(0); + | ^^^^^^^^^ + | | + | not allowed in type signatures + | help: replace with the correct type: `Bar` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:35:21 + | +LL | const ARR: [u8; _]; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:39:25 + | +LL | const ARR: Bar; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/in-signature.rs:43:20 + | +LL | const ARR: Bar<_, _>; + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/in-signature.rs:51:23 + | +LL | type Assoc = [u8; _]; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/in-signature.rs:55:27 + | +LL | type Assoc = Bar; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/in-signature.rs:59:22 + | +LL | type Assoc = Bar<_, _>; + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.rs b/src/test/ui/did_you_mean/bad-assoc-ty.rs index 609a5b0de6b7e..f787c416c2d63 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.rs +++ b/src/test/ui/did_you_mean/bad-assoc-ty.rs @@ -16,7 +16,7 @@ type D = (u8, u8)::AssocTy; type E = _::AssocTy; //~^ ERROR missing angle brackets in associated item path -//~| ERROR the type placeholder `_` is not allowed within types on item signatures for type aliases +//~| ERROR the placeholder `_` is not allowed within types on item signatures for type aliases type F = &'static (u8)::AssocTy; //~^ ERROR missing angle brackets in associated item path @@ -49,37 +49,37 @@ type I = ty!()::AssocTy; trait K {} fn foo>(x: X) {} -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn bar(_: F) where F: Fn() -> _ {} -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn baz _>(_: F) {} -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions struct L(F) where F: Fn() -> _; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs struct M where F: Fn() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs a: F, } enum N where F: Fn() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for enums +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for enums Foo(F), } union O where F: Fn() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for unions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for unions foo: F, } trait P where F: Fn() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for traits +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for traits } trait Q { fn foo(_: F) where F: Fn() -> _ {} - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } fn main() {} diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 11514a28b2ca5..2326af934d014 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -81,7 +81,7 @@ error[E0223]: ambiguous associated type LL | type D = (u8, u8)::AssocTy; | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(u8, u8) as Trait>::AssocTy` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for type aliases +error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases --> $DIR/bad-assoc-ty.rs:17:10 | LL | type E = _::AssocTy; @@ -136,7 +136,7 @@ error[E0223]: ambiguous associated type LL | type I = ty!()::AssocTy; | ^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/bad-assoc-ty.rs:51:13 | LL | fn foo>(x: X) {} @@ -149,7 +149,7 @@ help: use type parameters instead LL | fn foo, T>(x: X) {} | ~ ~ +++ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/bad-assoc-ty.rs:54:34 | LL | fn bar(_: F) where F: Fn() -> _ {} @@ -160,7 +160,7 @@ help: use type parameters instead LL | fn bar(_: F) where F: Fn() -> T {} | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/bad-assoc-ty.rs:57:19 | LL | fn baz _>(_: F) {} @@ -171,7 +171,7 @@ help: use type parameters instead LL | fn baz T, T>(_: F) {} | ~+++ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/bad-assoc-ty.rs:60:33 | LL | struct L(F) where F: Fn() -> _; @@ -182,7 +182,7 @@ help: use type parameters instead LL | struct L(F) where F: Fn() -> T; | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/bad-assoc-ty.rs:62:30 | LL | struct M where F: Fn() -> _ { @@ -193,7 +193,7 @@ help: use type parameters instead LL | struct M where F: Fn() -> T { | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for enums +error[E0121]: the placeholder `_` is not allowed within types on item signatures for enums --> $DIR/bad-assoc-ty.rs:66:28 | LL | enum N where F: Fn() -> _ { @@ -204,7 +204,7 @@ help: use type parameters instead LL | enum N where F: Fn() -> T { | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for unions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for unions --> $DIR/bad-assoc-ty.rs:71:29 | LL | union O where F: Fn() -> _ { @@ -215,7 +215,7 @@ help: use type parameters instead LL | union O where F: Fn() -> T { | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for traits +error[E0121]: the placeholder `_` is not allowed within types on item signatures for traits --> $DIR/bad-assoc-ty.rs:76:29 | LL | trait P where F: Fn() -> _ { @@ -226,7 +226,7 @@ help: use type parameters instead LL | trait P where F: Fn() -> T { | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/bad-assoc-ty.rs:81:38 | LL | fn foo(_: F) where F: Fn() -> _ {} diff --git a/src/test/ui/error-codes/E0121.stderr b/src/test/ui/error-codes/E0121.stderr index cc0c2df72ea7c..023d7e011bf3a 100644 --- a/src/test/ui/error-codes/E0121.stderr +++ b/src/test/ui/error-codes/E0121.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/E0121.rs:1:13 | LL | fn foo() -> _ { 5 } @@ -7,7 +7,7 @@ LL | fn foo() -> _ { 5 } | not allowed in type signatures | help: replace with the correct return type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/E0121.rs:3:13 | LL | static BAR: _ = "test"; diff --git a/src/test/ui/fn/issue-80179.rs b/src/test/ui/fn/issue-80179.rs index 550974bf77881..fcef6f1b60ecf 100644 --- a/src/test/ui/fn/issue-80179.rs +++ b/src/test/ui/fn/issue-80179.rs @@ -8,7 +8,7 @@ fn returns_i32() -> i32 { } fn returns_fn_ptr() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types [E0121] +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] //~| NOTE not allowed in type signatures //~| HELP replace with the correct return type //~| SUGGESTION fn() -> i32 @@ -16,7 +16,7 @@ fn returns_fn_ptr() -> _ { } fn returns_closure() -> _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types [E0121] +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121] //~| NOTE not allowed in type signatures //~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound //~| NOTE for more information on `Fn` traits and closure types, see diff --git a/src/test/ui/fn/issue-80179.stderr b/src/test/ui/fn/issue-80179.stderr index 96d0f02b01af4..2ca4ae982d96f 100644 --- a/src/test/ui/fn/issue-80179.stderr +++ b/src/test/ui/fn/issue-80179.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-80179.rs:10:24 | LL | fn returns_fn_ptr() -> _ { @@ -7,7 +7,7 @@ LL | fn returns_fn_ptr() -> _ { | not allowed in type signatures | help: replace with the correct return type: `fn() -> i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-80179.rs:18:25 | LL | fn returns_closure() -> _ { diff --git a/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs b/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs index 6880e1a46293f..45a30857413b9 100644 --- a/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs +++ b/src/test/ui/issues/issue-69396-const-no-type-in-macro.rs @@ -4,7 +4,7 @@ macro_rules! suite { const A = "A".$fn(); //~^ ERROR the name `A` is defined multiple times //~| ERROR missing type for `const` item - //~| ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~| ERROR the placeholder `_` is not allowed within types on item signatures for constants )* } } diff --git a/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr index 34c2073db0485..e5ab65169ce3b 100644 --- a/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr +++ b/src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr @@ -30,7 +30,7 @@ LL | | } | = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-69396-const-no-type-in-macro.rs:4:19 | LL | const A = "A".$fn(); diff --git a/src/test/ui/self/self-infer.rs b/src/test/ui/self/self-infer.rs index cc17d8f8e3962..9839b8880e9e1 100644 --- a/src/test/ui/self/self-infer.rs +++ b/src/test/ui/self/self-infer.rs @@ -1,8 +1,8 @@ struct S; impl S { - fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item signatures for functions - fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item signatures for functions + fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions + fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions } fn main() {} diff --git a/src/test/ui/self/self-infer.stderr b/src/test/ui/self/self-infer.stderr index d3bf63efa40d8..4f9e3f21dca52 100644 --- a/src/test/ui/self/self-infer.stderr +++ b/src/test/ui/self/self-infer.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/self-infer.rs:4:16 | LL | fn f(self: _) {} @@ -9,7 +9,7 @@ help: use type parameters instead LL | fn f(self: T) {} | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/self-infer.rs:5:17 | LL | fn g(self: &_) {} diff --git a/src/test/ui/suggestions/unnamable-types.rs b/src/test/ui/suggestions/unnamable-types.rs index 483f9bbb48cc6..f2485041d9ba2 100644 --- a/src/test/ui/suggestions/unnamable-types.rs +++ b/src/test/ui/suggestions/unnamable-types.rs @@ -8,14 +8,14 @@ const A = 5; //~| HELP: provide a type for the constant static B: _ = "abc"; -//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for static variables +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static variables //~| NOTE: not allowed in type signatures //~| HELP: replace with the correct type // FIXME: this should also suggest a function pointer, as the closure is non-capturing const C: _ = || 42; -//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for constants +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for constants //~| NOTE: not allowed in type signatures //~| NOTE: however, the inferred type diff --git a/src/test/ui/suggestions/unnamable-types.stderr b/src/test/ui/suggestions/unnamable-types.stderr index 3a489a6e94313..6127446c83e3b 100644 --- a/src/test/ui/suggestions/unnamable-types.stderr +++ b/src/test/ui/suggestions/unnamable-types.stderr @@ -4,7 +4,7 @@ error: missing type for `const` item LL | const A = 5; | ^ help: provide a type for the constant: `A: i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/unnamable-types.rs:10:11 | LL | static B: _ = "abc"; @@ -13,7 +13,7 @@ LL | static B: _ = "abc"; | not allowed in type signatures | help: replace with the correct type: `&str` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/unnamable-types.rs:17:10 | LL | const C: _ = || 42; diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.rs b/src/test/ui/type-alias-impl-trait/issue-77179.rs index 31c45a2093a04..8d818d4a387a6 100644 --- a/src/test/ui/type-alias-impl-trait/issue-77179.rs +++ b/src/test/ui/type-alias-impl-trait/issue-77179.rs @@ -5,7 +5,7 @@ type Pointer = impl std::ops::Deref; fn test() -> Pointer<_> { - //~^ ERROR: the type placeholder `_` is not allowed within types + //~^ ERROR: the placeholder `_` is not allowed within types Box::new(1) } diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.stderr b/src/test/ui/type-alias-impl-trait/issue-77179.stderr index 593aeeacb83aa..15205ba9b419e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-77179.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-77179.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-77179.rs:7:22 | LL | fn test() -> Pointer<_> { diff --git a/src/test/ui/typeck/issue-74086.rs b/src/test/ui/typeck/issue-74086.rs index 1de9cd8007cff..44ca256b05163 100644 --- a/src/test/ui/typeck/issue-74086.rs +++ b/src/test/ui/typeck/issue-74086.rs @@ -1,4 +1,4 @@ fn main() { static BUG: fn(_) -> u8 = |_| 8; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions [E0121] + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions [E0121] } diff --git a/src/test/ui/typeck/issue-74086.stderr b/src/test/ui/typeck/issue-74086.stderr index ac1752e17dfb9..e7aea33758cb2 100644 --- a/src/test/ui/typeck/issue-74086.stderr +++ b/src/test/ui/typeck/issue-74086.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/issue-74086.rs:2:20 | LL | static BUG: fn(_) -> u8 = |_| 8; diff --git a/src/test/ui/typeck/issue-75883.rs b/src/test/ui/typeck/issue-75883.rs index 0d1534df091fa..885acc48231b2 100644 --- a/src/test/ui/typeck/issue-75883.rs +++ b/src/test/ui/typeck/issue-75883.rs @@ -5,7 +5,7 @@ pub struct UI {} impl UI { pub fn run() -> Result<_> { //~^ ERROR: this enum takes 2 generic arguments but 1 generic argument was supplied - //~| ERROR: the type placeholder `_` is not allowed within types on item signatures for return types + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for return types let mut ui = UI {}; ui.interact(); @@ -14,7 +14,7 @@ impl UI { pub fn interact(&mut self) -> Result<_> { //~^ ERROR: this enum takes 2 generic arguments but 1 generic argument was supplied - //~| ERROR: the type placeholder `_` is not allowed within types on item signatures for return types + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for return types unimplemented!(); } } diff --git a/src/test/ui/typeck/issue-75883.stderr b/src/test/ui/typeck/issue-75883.stderr index 5e42c817e030b..3861e0507f6dd 100644 --- a/src/test/ui/typeck/issue-75883.stderr +++ b/src/test/ui/typeck/issue-75883.stderr @@ -34,13 +34,13 @@ help: add missing generic argument LL | pub fn interact(&mut self) -> Result<_, E> { | +++ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-75883.rs:15:42 | LL | pub fn interact(&mut self) -> Result<_> { | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-75883.rs:6:28 | LL | pub fn run() -> Result<_> { diff --git a/src/test/ui/typeck/issue-75889.stderr b/src/test/ui/typeck/issue-75889.stderr index de4bdf4e6d9de..1438f481ec7e1 100644 --- a/src/test/ui/typeck/issue-75889.stderr +++ b/src/test/ui/typeck/issue-75889.stderr @@ -1,10 +1,10 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items --> $DIR/issue-75889.rs:3:24 | LL | const FOO: dyn Fn() -> _ = ""; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items --> $DIR/issue-75889.rs:4:25 | LL | static BOO: dyn Fn() -> _ = ""; diff --git a/src/test/ui/typeck/issue-80779.rs b/src/test/ui/typeck/issue-80779.rs index 99a93b1863d6e..1624f6b7742b0 100644 --- a/src/test/ui/typeck/issue-80779.rs +++ b/src/test/ui/typeck/issue-80779.rs @@ -3,11 +3,11 @@ pub struct T<'a>(&'a str); pub fn f<'a>(val: T<'a>) -> _ { - //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for return types g(val) } pub fn g(_: T<'static>) -> _ {} -//~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for return types fn main() {} diff --git a/src/test/ui/typeck/issue-80779.stderr b/src/test/ui/typeck/issue-80779.stderr index 5a695fecc29dc..2261ba616545f 100644 --- a/src/test/ui/typeck/issue-80779.stderr +++ b/src/test/ui/typeck/issue-80779.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-80779.rs:10:28 | LL | pub fn g(_: T<'static>) -> _ {} @@ -7,7 +7,7 @@ LL | pub fn g(_: T<'static>) -> _ {} | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-80779.rs:5:29 | LL | pub fn f<'a>(val: T<'a>) -> _ { diff --git a/src/test/ui/typeck/issue-81885.rs b/src/test/ui/typeck/issue-81885.rs index 5117f250fe5ea..8935535fb7eb8 100644 --- a/src/test/ui/typeck/issue-81885.rs +++ b/src/test/ui/typeck/issue-81885.rs @@ -1,8 +1,8 @@ const TEST4: fn() -> _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn main() { const TEST5: fn() -> _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } diff --git a/src/test/ui/typeck/issue-81885.stderr b/src/test/ui/typeck/issue-81885.stderr index 8206156a6180a..3ff4375cd8d3f 100644 --- a/src/test/ui/typeck/issue-81885.stderr +++ b/src/test/ui/typeck/issue-81885.stderr @@ -1,10 +1,10 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/issue-81885.rs:1:22 | LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/issue-81885.rs:5:26 | LL | const TEST5: fn() -> _ = 42; diff --git a/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr index 7c5cf1082be09..9376e8bcf80bc 100644 --- a/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr +++ b/src/test/ui/typeck/issue-83621-placeholder-static-in-extern.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15 | LL | static x: _; diff --git a/src/test/ui/typeck/issue-91450-inner-ty-error.rs b/src/test/ui/typeck/issue-91450-inner-ty-error.rs index 0b942d6d94f84..3c7c990d4e27c 100644 --- a/src/test/ui/typeck/issue-91450-inner-ty-error.rs +++ b/src/test/ui/typeck/issue-91450-inner-ty-error.rs @@ -2,6 +2,6 @@ // This test ensures that the compiler does not suggest `Foo<[type error]>` in diagnostic messages. fn foo() -> Option<_> {} //~ ERROR: [E0308] -//~^ ERROR: the type placeholder `_` is not allowed +//~^ ERROR: the placeholder `_` is not allowed fn main() {} diff --git a/src/test/ui/typeck/issue-91450-inner-ty-error.stderr b/src/test/ui/typeck/issue-91450-inner-ty-error.stderr index 314fe56180368..32f4c8f6fdf82 100644 --- a/src/test/ui/typeck/issue-91450-inner-ty-error.stderr +++ b/src/test/ui/typeck/issue-91450-inner-ty-error.stderr @@ -9,7 +9,7 @@ LL | fn foo() -> Option<_> {} = note: expected enum `Option<_>` found unit type `()` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-91450-inner-ty-error.rs:4:20 | LL | fn foo() -> Option<_> {} diff --git a/src/test/ui/typeck/type-placeholder-fn-in-const.rs b/src/test/ui/typeck/type-placeholder-fn-in-const.rs index f657bea164872..ab2e2d8c53aa3 100644 --- a/src/test/ui/typeck/type-placeholder-fn-in-const.rs +++ b/src/test/ui/typeck/type-placeholder-fn-in-const.rs @@ -2,13 +2,13 @@ struct MyStruct; trait Test { const TEST: fn() -> _; - //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for functions [E0121] - //~| ERROR: the type placeholder `_` is not allowed within types on item signatures for constants [E0121] + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for constants [E0121] } impl Test for MyStruct { const TEST: fn() -> _ = 42; - //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures for functions [E0121] + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] } fn main() {} diff --git a/src/test/ui/typeck/type-placeholder-fn-in-const.stderr b/src/test/ui/typeck/type-placeholder-fn-in-const.stderr index 62f4db8638f3c..e7b2e554a8d42 100644 --- a/src/test/ui/typeck/type-placeholder-fn-in-const.stderr +++ b/src/test/ui/typeck/type-placeholder-fn-in-const.stderr @@ -1,16 +1,16 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/type-placeholder-fn-in-const.rs:4:25 | LL | const TEST: fn() -> _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/type-placeholder-fn-in-const.rs:4:25 | LL | const TEST: fn() -> _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/type-placeholder-fn-in-const.rs:10:25 | LL | const TEST: fn() -> _ = 42; diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.rs b/src/test/ui/typeck/typeck_type_placeholder_item.rs index a3b75543510ae..ca0876be58df9 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.rs +++ b/src/test/ui/typeck/typeck_type_placeholder_item.rs @@ -5,67 +5,67 @@ // inference by using the `_` type placeholder. fn test() -> _ { 5 } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn test2() -> (_, _) { (5, 5) } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types static TEST3: _ = "test"; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables static TEST4: _ = 145; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables static TEST5: (_, _) = (1, 2); -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables fn test6(_: _) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn test6_b(_: _, _: T) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn test6_c(_: _, _: (T, K, L, A, B)) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn test7(x: _) { let _x: usize = x; } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn test8(_f: fn() -> _) { } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions -//~^^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~^^ ERROR the placeholder `_` is not allowed within types on item signatures for functions struct Test9; impl Test9 { fn test9(&self) -> _ { () } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn test10(&self, _x : _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } fn test11(x: &usize) -> &_ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types &x } unsafe fn test12(x: *const usize) -> *const *const _ { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types &x } impl Clone for Test9 { fn clone(&self) -> _ { Test9 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn clone_from(&mut self, other: _) { *self = Test9; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } struct Test10 { a: _, - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs b: (_, _), } @@ -73,94 +73,94 @@ pub fn main() { static A = 42; //~^ ERROR missing type for `static` item static B: _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables static C: Option<_> = Some(42); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables fn fn_test() -> _ { 5 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn fn_test2() -> (_, _) { (5, 5) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types static FN_TEST3: _ = "test"; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables static FN_TEST4: _ = 145; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables static FN_TEST5: (_, _) = (1, 2); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for static variables + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables fn fn_test6(_: _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn fn_test7(x: _) { let _x: usize = x; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn fn_test8(_f: fn() -> _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions - //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^^ ERROR the placeholder `_` is not allowed within types on item signatures for functions struct FnTest9; impl FnTest9 { fn fn_test9(&self) -> _ { () } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn fn_test10(&self, _x : _) { } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } impl Clone for FnTest9 { fn clone(&self) -> _ { FnTest9 } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn clone_from(&mut self, other: _) { *self = FnTest9; } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } struct FnTest10 { a: _, - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for structs + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs b: (_, _), } fn fn_test11(_: _) -> (_, _) { panic!() } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types //~| ERROR type annotations needed fn fn_test12(x: i32) -> (_, _) { (x, x) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn fn_test13(x: _) -> (i32, _) { (x, x) } - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types } trait T { fn method_test1(&self, x: _); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn method_test2(&self, x: _) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn method_test3(&self) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn assoc_fn_test1(x: _); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn assoc_fn_test2(x: _) -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions fn assoc_fn_test3() -> _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions } struct BadStruct<_>(_); //~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs +//~| ERROR the placeholder `_` is not allowed within types on item signatures for structs trait BadTrait<_> {} //~^ ERROR expected identifier, found reserved identifier `_` impl BadTrait<_> for BadStruct<_> {} -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for implementations +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for implementations fn impl_trait() -> impl BadTrait<_> { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for opaque types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for opaque types unimplemented!() } @@ -168,19 +168,19 @@ struct BadStruct1<_, _>(_); //~^ ERROR expected identifier, found reserved identifier `_` //~| ERROR expected identifier, found reserved identifier `_` //~| ERROR the name `_` is already used -//~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs +//~| ERROR the placeholder `_` is not allowed within types on item signatures for structs struct BadStruct2<_, T>(_, T); //~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR the type placeholder `_` is not allowed within types on item signatures for structs +//~| ERROR the placeholder `_` is not allowed within types on item signatures for structs type X = Box<_>; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for type aliases +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for type aliases struct Struct; trait Trait {} impl Trait for Struct {} type Y = impl Trait<_>; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for opaque types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for opaque types fn foo() -> Y { Struct } @@ -188,25 +188,25 @@ fn foo() -> Y { trait Qux { type A; type B = _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types const C: _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const D: _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants // type E: _; // FIXME: make the parser propagate the existence of `B` type F: std::ops::Fn(_); - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types } impl Qux for Struct { type A = _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types type B = _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for associated types + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types const C: _; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants //~| ERROR associated constant in `impl` without body const D: _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants } fn map(_: fn() -> Option<&'static T>) -> Option { @@ -214,9 +214,9 @@ fn map(_: fn() -> Option<&'static T>) -> Option { } fn value() -> Option<&'static _> { -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types Option::<&'static u8>::None } const _: Option<_> = map(value); -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index e1f66afdacc11..c07b96f9a977a 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -44,7 +44,7 @@ LL | struct BadStruct1<_, _>(_); | | | first use of `_` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:7:14 | LL | fn test() -> _ { 5 } @@ -53,7 +53,7 @@ LL | fn test() -> _ { 5 } | not allowed in type signatures | help: replace with the correct return type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:10:16 | LL | fn test2() -> (_, _) { (5, 5) } @@ -63,7 +63,7 @@ LL | fn test2() -> (_, _) { (5, 5) } | |not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:13:15 | LL | static TEST3: _ = "test"; @@ -72,7 +72,7 @@ LL | static TEST3: _ = "test"; | not allowed in type signatures | help: replace with the correct type: `&str` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:16:15 | LL | static TEST4: _ = 145; @@ -81,13 +81,13 @@ LL | static TEST4: _ = 145; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:19:15 | LL | static TEST5: (_, _) = (1, 2); | ^^^^^^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:22:13 | LL | fn test6(_: _) { } @@ -98,7 +98,7 @@ help: use type parameters instead LL | fn test6(_: T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:25:18 | LL | fn test6_b(_: _, _: T) { } @@ -109,7 +109,7 @@ help: use type parameters instead LL | fn test6_b(_: U, _: T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:28:30 | LL | fn test6_c(_: _, _: (T, K, L, A, B)) { } @@ -120,7 +120,7 @@ help: use type parameters instead LL | fn test6_c(_: U, _: (T, K, L, A, B)) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:31:13 | LL | fn test7(x: _) { let _x: usize = x; } @@ -131,7 +131,7 @@ help: use type parameters instead LL | fn test7(x: T) { let _x: usize = x; } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:34:22 | LL | fn test8(_f: fn() -> _) { } @@ -140,7 +140,7 @@ LL | fn test8(_f: fn() -> _) { } | not allowed in type signatures | help: use type parameters instead: `T` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:34:22 | LL | fn test8(_f: fn() -> _) { } @@ -151,7 +151,7 @@ help: use type parameters instead LL | fn test8(_f: fn() -> T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:48:26 | LL | fn test11(x: &usize) -> &_ { @@ -160,7 +160,7 @@ LL | fn test11(x: &usize) -> &_ { | |not allowed in type signatures | help: replace with the correct return type: `&'static &'static usize` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:53:52 | LL | unsafe fn test12(x: *const usize) -> *const *const _ { @@ -169,7 +169,7 @@ LL | unsafe fn test12(x: *const usize) -> *const *const _ { | | not allowed in type signatures | help: replace with the correct return type: `*const *const usize` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/typeck_type_placeholder_item.rs:67:8 | LL | a: _, @@ -194,7 +194,7 @@ error: missing type for `static` item LL | static A = 42; | ^ help: provide a type for the static variable: `A: i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:75:15 | LL | static B: _ = 42; @@ -203,13 +203,13 @@ LL | static B: _ = 42; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:77:15 | LL | static C: Option<_> = Some(42); | ^^^^^^^^^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:79:21 | LL | fn fn_test() -> _ { 5 } @@ -218,7 +218,7 @@ LL | fn fn_test() -> _ { 5 } | not allowed in type signatures | help: replace with the correct return type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:82:23 | LL | fn fn_test2() -> (_, _) { (5, 5) } @@ -228,7 +228,7 @@ LL | fn fn_test2() -> (_, _) { (5, 5) } | |not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:85:22 | LL | static FN_TEST3: _ = "test"; @@ -237,7 +237,7 @@ LL | static FN_TEST3: _ = "test"; | not allowed in type signatures | help: replace with the correct type: `&str` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:88:22 | LL | static FN_TEST4: _ = 145; @@ -246,13 +246,13 @@ LL | static FN_TEST4: _ = 145; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:91:22 | LL | static FN_TEST5: (_, _) = (1, 2); | ^^^^^^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:94:20 | LL | fn fn_test6(_: _) { } @@ -263,7 +263,7 @@ help: use type parameters instead LL | fn fn_test6(_: T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:97:20 | LL | fn fn_test7(x: _) { let _x: usize = x; } @@ -274,7 +274,7 @@ help: use type parameters instead LL | fn fn_test7(x: T) { let _x: usize = x; } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:100:29 | LL | fn fn_test8(_f: fn() -> _) { } @@ -283,7 +283,7 @@ LL | fn fn_test8(_f: fn() -> _) { } | not allowed in type signatures | help: use type parameters instead: `T` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:100:29 | LL | fn fn_test8(_f: fn() -> _) { } @@ -294,7 +294,7 @@ help: use type parameters instead LL | fn fn_test8(_f: fn() -> T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/typeck_type_placeholder_item.rs:123:12 | LL | a: _, @@ -319,7 +319,7 @@ error[E0282]: type annotations needed LL | fn fn_test11(_: _) -> (_, _) { panic!() } | ^ cannot infer type -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:128:28 | LL | fn fn_test11(_: _) -> (_, _) { panic!() } @@ -327,7 +327,7 @@ LL | fn fn_test11(_: _) -> (_, _) { panic!() } | | | not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:132:30 | LL | fn fn_test12(x: i32) -> (_, _) { (x, x) } @@ -337,7 +337,7 @@ LL | fn fn_test12(x: i32) -> (_, _) { (x, x) } | |not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:135:33 | LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } @@ -346,7 +346,7 @@ LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } | | not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/typeck_type_placeholder_item.rs:154:21 | LL | struct BadStruct<_>(_); @@ -357,7 +357,7 @@ help: use type parameters instead LL | struct BadStruct(T); | ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for implementations +error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations --> $DIR/typeck_type_placeholder_item.rs:159:15 | LL | impl BadTrait<_> for BadStruct<_> {} @@ -370,13 +370,13 @@ help: use type parameters instead LL | impl BadTrait for BadStruct {} | +++ ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for opaque types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types --> $DIR/typeck_type_placeholder_item.rs:162:34 | LL | fn impl_trait() -> impl BadTrait<_> { | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/typeck_type_placeholder_item.rs:167:25 | LL | struct BadStruct1<_, _>(_); @@ -387,7 +387,7 @@ help: use type parameters instead LL | struct BadStruct1(T); | ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs --> $DIR/typeck_type_placeholder_item.rs:172:25 | LL | struct BadStruct2<_, T>(_, T); @@ -398,19 +398,19 @@ help: use type parameters instead LL | struct BadStruct2(U, T); | ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for type aliases +error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases --> $DIR/typeck_type_placeholder_item.rs:176:14 | LL | type X = Box<_>; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for opaque types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types --> $DIR/typeck_type_placeholder_item.rs:182:21 | LL | type Y = impl Trait<_>; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:216:31 | LL | fn value() -> Option<&'static _> { @@ -419,7 +419,7 @@ LL | fn value() -> Option<&'static _> { | | not allowed in type signatures | help: replace with the correct return type: `Option<&'static u8>` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item.rs:221:10 | LL | const _: Option<_> = map(value); @@ -428,7 +428,7 @@ LL | const _: Option<_> = map(value); | not allowed in type signatures | help: replace with the correct type: `Option` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:140:31 | LL | fn method_test1(&self, x: _); @@ -439,7 +439,7 @@ help: use type parameters instead LL | fn method_test1(&self, x: T); | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:142:31 | LL | fn method_test2(&self, x: _) -> _; @@ -452,7 +452,7 @@ help: use type parameters instead LL | fn method_test2(&self, x: T) -> T; | +++ ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:144:31 | LL | fn method_test3(&self) -> _; @@ -463,7 +463,7 @@ help: use type parameters instead LL | fn method_test3(&self) -> T; | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:146:26 | LL | fn assoc_fn_test1(x: _); @@ -474,7 +474,7 @@ help: use type parameters instead LL | fn assoc_fn_test1(x: T); | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:148:26 | LL | fn assoc_fn_test2(x: _) -> _; @@ -487,7 +487,7 @@ help: use type parameters instead LL | fn assoc_fn_test2(x: T) -> T; | +++ ~ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:150:28 | LL | fn assoc_fn_test3() -> _; @@ -498,19 +498,19 @@ help: use type parameters instead LL | fn assoc_fn_test3() -> T; | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/typeck_type_placeholder_item.rs:190:14 | LL | type B = _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item.rs:192:14 | LL | const C: _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item.rs:194:14 | LL | const D: _ = 42; @@ -519,13 +519,13 @@ LL | const D: _ = 42; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/typeck_type_placeholder_item.rs:197:26 | LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:41:24 | LL | fn test9(&self) -> _ { () } @@ -534,7 +534,7 @@ LL | fn test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:44:27 | LL | fn test10(&self, _x : _) { } @@ -545,7 +545,7 @@ help: use type parameters instead LL | fn test10(&self, _x : T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:59:24 | LL | fn clone(&self) -> _ { Test9 } @@ -554,7 +554,7 @@ LL | fn clone(&self) -> _ { Test9 } | not allowed in type signatures | help: replace with the correct return type: `Test9` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:62:37 | LL | fn clone_from(&mut self, other: _) { *self = Test9; } @@ -565,7 +565,7 @@ help: use type parameters instead LL | fn clone_from(&mut self, other: T) { *self = Test9; } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:107:31 | LL | fn fn_test9(&self) -> _ { () } @@ -574,7 +574,7 @@ LL | fn fn_test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:110:34 | LL | fn fn_test10(&self, _x : _) { } @@ -585,7 +585,7 @@ help: use type parameters instead LL | fn fn_test10(&self, _x : T) { } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:115:28 | LL | fn clone(&self) -> _ { FnTest9 } @@ -594,7 +594,7 @@ LL | fn clone(&self) -> _ { FnTest9 } | not allowed in type signatures | help: replace with the correct return type: `FnTest9` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:118:41 | LL | fn clone_from(&mut self, other: _) { *self = FnTest9; } @@ -605,25 +605,25 @@ help: use type parameters instead LL | fn clone_from(&mut self, other: T) { *self = FnTest9; } | +++ ~ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/typeck_type_placeholder_item.rs:201:14 | LL | type A = _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/typeck_type_placeholder_item.rs:203:14 | LL | type B = _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item.rs:205:14 | LL | const C: _; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item.rs:208:14 | LL | const D: _ = 42; diff --git a/src/test/ui/typeck/typeck_type_placeholder_item_help.rs b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs index 3af5cf926abf0..53f31b683c1a4 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item_help.rs +++ b/src/test/ui/typeck/typeck_type_placeholder_item_help.rs @@ -2,27 +2,27 @@ // using the `_` type placeholder. fn test1() -> _ { Some(42) } -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for return types +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types const TEST2: _ = 42u32; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const TEST3: _ = Some(42); -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const TEST4: fn() -> _ = 42; -//~^ ERROR the type placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions trait Test5 { const TEST5: _ = 42; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants } struct Test6; impl Test6 { const TEST6: _ = 13; - //~^ ERROR the type placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants } pub fn main() { diff --git a/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr b/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr index 1b56b1033a8c1..e8191832318e5 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -1,4 +1,4 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item_help.rs:4:15 | LL | fn test1() -> _ { Some(42) } @@ -7,7 +7,7 @@ LL | fn test1() -> _ { Some(42) } | not allowed in type signatures | help: replace with the correct return type: `Option` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:7:14 | LL | const TEST2: _ = 42u32; @@ -16,7 +16,7 @@ LL | const TEST2: _ = 42u32; | not allowed in type signatures | help: replace with the correct type: `u32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:10:14 | LL | const TEST3: _ = Some(42); @@ -25,13 +25,13 @@ LL | const TEST3: _ = Some(42); | not allowed in type signatures | help: replace with the correct type: `Option` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item_help.rs:13:22 | LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:17:18 | LL | const TEST5: _ = 42; @@ -40,7 +40,7 @@ LL | const TEST5: _ = 42; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:24:18 | LL | const TEST6: _ = 13; From a3c55ac2e4aed26f59fb659c024c7e31c7ab0524 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 10 Jan 2022 10:59:26 +0100 Subject: [PATCH 4/4] privacy: update `visit_infer` --- compiler/rustc_privacy/src/lib.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 183a5a205ec82..8d6604183c783 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -1250,19 +1250,11 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> { if self.visit(ty).is_break() { return; } + } else { + // We don't do anything for const infers here. } } else { - let local_id = self.tcx.hir().local_def_id(inf.hir_id); - if let Some(did) = self.tcx.opt_const_param_of(local_id) { - if self.visit_def_id(did, "inferred", &"").is_break() { - return; - } - } - - // FIXME see above note for same issue. - if self.visit(rustc_typeck::hir_ty_to_ty(self.tcx, &inf.to_ty())).is_break() { - return; - } + bug!("visit_infer without typeck_results"); } intravisit::walk_inf(self, inf); }