From 61f33bfd2940ea55559b253a66c42937a17d3c87 Mon Sep 17 00:00:00 2001 From: Julian Knodt Date: Thu, 31 Dec 2020 01:58:27 +0100 Subject: first pass at default values for const generics - Adds optional default values to const generic parameters in the AST and HIR - Parses these optional default values - Adds a `const_generics_defaults` feature gate --- src/librustdoc/clean/mod.rs | 3 ++- src/tools/clippy/clippy_lints/src/utils/ast_utils.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f4eb1924e6f..022161164d1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -607,11 +607,12 @@ impl Clean for hir::GenericParam<'_> { synthetic, }, ), - hir::GenericParamKind::Const { ref ty } => ( + hir::GenericParamKind::Const { ref ty, default: _ } => ( self.name.ident().name, GenericParamDefKind::Const { did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(), ty: ty.clean(cx), + // FIXME(const_generics_defaults): add `default` field here to the docs }, ), }; diff --git a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs index f0267e4c792..940573e4caa 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs @@ -407,6 +407,10 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool { } } +pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool { + eq_expr(&l.value, &r.value) +} + pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool { matches!( (l, r), @@ -497,7 +501,8 @@ pub fn eq_generic_param(l: &GenericParam, r: &GenericParam) -> bool { && match (&l.kind, &r.kind) { (Lifetime, Lifetime) => true, (Type { default: l }, Type { default: r }) => both(l, r, |l, r| eq_ty(l, r)), - (Const { ty: l, kw_span: _ }, Const { ty: r, kw_span: _ }) => eq_ty(l, r), + (Const { ty: lt, kw_span: _ , default: ld}, Const { ty: rt, kw_span: _, default: rd }) => + eq_ty(lt, rt) && both(ld, rd, |ld, rd| eq_anon_const(ld, rd)), _ => false, } && over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r)) -- cgit 1.4.1-3-g733a5 From 64244b22014995cffb41c231953b7c9e0b0bdb66 Mon Sep 17 00:00:00 2001 From: Rémy Rakic Date: Thu, 31 Dec 2020 02:03:15 +0100 Subject: add test for the `const_generics_defaults` feature gate --- .../feature-gate-const_generics_defaults.rs | 7 +++++++ .../feature-gate-const_generics_defaults.stderr | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs create mode 100644 src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr (limited to 'src') diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs new file mode 100644 index 00000000000..90959e7a365 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs @@ -0,0 +1,7 @@ +struct A; +//~^ ERROR default values for const generic parameters are unstable + +fn foo() {} +//~^ ERROR default values for const generic parameters are unstable + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr new file mode 100644 index 00000000000..00d564772d2 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr @@ -0,0 +1,18 @@ +error: default values for const generic parameters are unstable + --> $DIR/feature-gate-const_generics_defaults.rs:1:27 + | +LL | struct A; + | ^ + | + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable + +error: default values for const generic parameters are unstable + --> $DIR/feature-gate-const_generics_defaults.rs:4:22 + | +LL | fn foo() {} + | ^ + | + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5 From 907ba75eb0b063c1da72703642e5710b91868dc8 Mon Sep 17 00:00:00 2001 From: Rémy Rakic Date: Thu, 31 Dec 2020 02:04:52 +0100 Subject: update `min_const_generics` tests using default values for const params The `const_generics_defaults` now handles them, and they correctly parse, so we can update these tests expecting a parser error . --- .../const-generics/min_const_generics/default_function_param.rs | 2 +- .../min_const_generics/default_function_param.stderr | 8 +++++--- .../ui/const-generics/min_const_generics/default_trait_param.rs | 2 +- .../const-generics/min_const_generics/default_trait_param.stderr | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs index d7918a73ab8..425c5eb9e7c 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs @@ -1,4 +1,4 @@ fn foo() {} - //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` +//~^ ERROR default values for const generic parameters are unstable fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr index 8eb796d9bb7..3d2fac78d7c 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,8 +1,10 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` - --> $DIR/default_function_param.rs:1:26 +error: default values for const generic parameters are unstable + --> $DIR/default_function_param.rs:1:28 | LL | fn foo() {} - | ^ expected one of 7 possible tokens + | ^ + | + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs index c8003ad5d44..c6d91ef97a0 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs @@ -1,4 +1,4 @@ trait Foo {} - //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` +//~^ ERROR default values for const generic parameters are unstable fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr index 6d112ef1de0..b727fdd807b 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr @@ -1,8 +1,10 @@ -error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=` - --> $DIR/default_trait_param.rs:1:28 +error: default values for const generic parameters are unstable + --> $DIR/default_trait_param.rs:1:30 | LL | trait Foo {} - | ^ expected one of 7 possible tokens + | ^^^^ + | + = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error -- cgit 1.4.1-3-g733a5 From 1fc3c4c16dde2a6cb4f565435d131b8c57bc1295 Mon Sep 17 00:00:00 2001 From: Rémy Rakic Date: Thu, 31 Dec 2020 02:50:23 +0100 Subject: adjust const generics defaults FIXMEs to the new feature gate --- compiler/rustc_ast_passes/src/ast_validation.rs | 2 +- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 2 +- compiler/rustc_middle/src/ty/print/mod.rs | 2 +- compiler/rustc_passes/src/stability.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 2 +- compiler/rustc_typeck/src/astconv/generics.rs | 2 +- compiler/rustc_typeck/src/astconv/mod.rs | 2 +- compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 2 +- compiler/rustc_typeck/src/check/wfcheck.rs | 2 +- compiler/rustc_typeck/src/collect.rs | 2 +- src/librustdoc/clean/mod.rs | 4 ++-- src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index fd080fa5992..6ac212af68e 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -774,7 +774,7 @@ fn validate_generic_param_order( } GenericParamKind::Type { default: None } => (), GenericParamKind::Lifetime => (), - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) GenericParamKind::Const { ty: _, kw_span: _, default: _ } => (), } first = false; diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 777107ed863..14a56119f21 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -958,7 +958,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ty::GenericParamDefKind::Type { has_default, .. } => { Some((param.def_id, has_default)) } - ty::GenericParamDefKind::Const => None, // FIXME(const_generics:defaults) + ty::GenericParamDefKind::Const => None, // FIXME(const_generics_defaults) }) .peekable(); let has_default = { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 4dfe3e84877..ac6ceafaba8 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1834,7 +1834,7 @@ impl EncodeContext<'a, 'tcx> { EntryKind::ConstParam, true, ); - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) } } } diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index c79e06b7fdd..77f16688937 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -203,7 +203,7 @@ pub trait Printer<'tcx>: Sized { self.tcx().type_of(param.def_id).subst(self.tcx(), substs), ) } - ty::GenericParamDefKind::Const => false, // FIXME(const_generics:defaults) + ty::GenericParamDefKind::Const => false, // FIXME(const_generics_defaults) } }) .count(); diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 3c2462aab26..def2a501cf4 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -443,7 +443,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) { let kind = match &p.kind { - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) hir::GenericParamKind::Type { default, .. } if default.is_some() => { AnnotationKind::Container } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ca30d90e6ad..0de732b2cf9 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -214,7 +214,7 @@ enum ResolutionError<'a> { /// Error E0530: `X` bindings cannot shadow `Y`s. BindingShadowsSomethingUnacceptable(&'static str, Symbol, &'a NameBinding<'a>), /// Error E0128: type parameters with a default cannot use forward-declared identifiers. - ForwardDeclaredTyParam, // FIXME(const_generics:defaults) + ForwardDeclaredTyParam, // FIXME(const_generics_defaults) /// ERROR E0770: the type of const parameters must not depend on other generic parameters. ParamInTyOfConstParam(Symbol), /// constant values inside of type parameter defaults must not depend on generic parameters. diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 0feac036f00..a3a2b8967c6 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -387,7 +387,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { defaults.types += has_default as usize } GenericParamDefKind::Const => { - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) } }; } diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 38d33e55866..9a2210e4f0e 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -486,7 +486,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } GenericParamDefKind::Const => { let ty = tcx.at(self.span).type_of(param.def_id); - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) if infer_args { // No const parameters were provided, we can infer all. self.astconv.ct_infer(ty, Some(param), self.span).into() diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 2a8b77da44f..7126b624059 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -1376,7 +1376,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } GenericParamDefKind::Const => { - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) // No const parameters were provided, we have to infer them. self.fcx.var_for_def(self.span, param) } diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 18c63cb433d..ab41ff372e2 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -785,7 +785,7 @@ fn check_where_clauses<'tcx, 'fcx>( } GenericParamDefKind::Const => { - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) fcx.tcx.mk_param_from_def(param) } } diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 3e40f5ba28a..2ebb1a3be4e 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -228,7 +228,7 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { hir::GenericParamKind::Const { .. } => { let def_id = self.tcx.hir().local_def_id(param.hir_id); self.tcx.ensure().type_of(def_id); - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) } } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 022161164d1..2f430842f9d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -612,7 +612,7 @@ impl Clean for hir::GenericParam<'_> { GenericParamDefKind::Const { did: cx.tcx.hir().local_def_id(self.hir_id).to_def_id(), ty: ty.clean(cx), - // FIXME(const_generics_defaults): add `default` field here to the docs + // FIXME(const_generics_defaults): add `default` field here for docs }, ), }; @@ -1386,7 +1386,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &DocContext<'_>) -> Type { if let Some(ct) = const_ { ct_substs.insert(const_param_def_id.to_def_id(), ct.clean(cx)); } - // FIXME(const_generics:defaults) + // FIXME(const_generics_defaults) indices.consts += 1; } } diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs index 845c6111b59..a85e2a2f2c4 100644 --- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs +++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs @@ -7,7 +7,7 @@ struct Foo()]>(T, U); //[full]~^ ERROR constant values inside of type parameter defaults //[min]~^^ ERROR generic parameters may not be used in const operations -// FIXME(const_generics:defaults): We still don't know how to we deal with type defaults. +// FIXME(const_generics_defaults): We still don't know how to deal with type defaults. struct Bar(T); //~^ ERROR constant values inside of type parameter defaults //~| ERROR type parameters with a default -- cgit 1.4.1-3-g733a5 From 942b7ce2c14b1c4fde5b9f27aa5bef39e0b990d5 Mon Sep 17 00:00:00 2001 From: Rémy Rakic Date: Thu, 31 Dec 2020 18:32:06 +0100 Subject: make `const_generics_defaults` use the unstable syntax mechanism This is important to not accidentally stabilize the parsing of the syntax while it still is experimental and not formally accepted --- compiler/rustc_ast_passes/src/ast_validation.rs | 14 -------------- compiler/rustc_ast_passes/src/feature_gate.rs | 4 ++++ compiler/rustc_parse/src/parser/generics.rs | 17 ++++++++++++++--- .../min_const_generics/default_function_param.rs | 2 +- .../min_const_generics/default_function_param.stderr | 8 +++++--- .../min_const_generics/default_trait_param.rs | 2 +- .../min_const_generics/default_trait_param.stderr | 8 +++++--- .../feature-gate-const_generics_defaults.rs | 8 +++++--- .../feature-gate-const_generics_defaults.stderr | 17 ++++++++++------- 9 files changed, 45 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 6ac212af68e..e172f9d71ff 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -1166,20 +1166,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } } } - if !self.session.features_untracked().const_generics_defaults { - if let GenericParamKind::Const { default: Some(ref default), .. } = param.kind { - let mut err = self.err_handler().struct_span_err( - default.value.span, - "default values for const generic parameters are unstable", - ); - err.help( - "add `#![feature(const_generics_defaults)]` \ - to the crate attributes to enable", - ); - err.emit(); - break; - } - } } validate_generic_param_order( diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 6a9d6d2ed12..435f32535b6 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -619,6 +619,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) { extended_key_value_attributes, "arbitrary expressions in key-value attributes are unstable" ); + gate_all!( + const_generics_defaults, + "default values for const generic parameters are experimental" + ); if sess.parse_sess.span_diagnostic.err_count() == 0 { // Errors for `destructuring_assignment` can get quite noisy, especially where `_` is // involved, so we only emit errors where there are no other parsing errors. diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index ff84dba4177..42a13376863 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -5,7 +5,7 @@ use rustc_ast::{ self as ast, Attribute, GenericBounds, GenericParam, GenericParamKind, WhereClause, }; use rustc_errors::PResult; -use rustc_span::symbol::kw; +use rustc_span::symbol::{kw, sym}; impl<'a> Parser<'a> { /// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. @@ -56,8 +56,19 @@ impl<'a> Parser<'a> { self.expect(&token::Colon)?; let ty = self.parse_ty()?; - // Parse optional const generics default value. - let default = if self.eat(&token::Eq) { Some(self.parse_const_arg()?) } else { None }; + // Parse optional const generics default value, taking care of feature gating the spans + // with the unstable syntax mechanism. + let default = if self.eat(&token::Eq) { + // The gated span goes from the `=` to the end of the const argument that follows (and + // which could be a block expression). + let start = self.prev_token.span; + let const_arg = self.parse_const_arg()?; + let span = start.to(const_arg.value.span); + self.sess.gated_spans.gate(sym::const_generics_defaults, span); + Some(const_arg) + } else { + None + }; Ok(GenericParam { ident, diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs index 425c5eb9e7c..5b0a42a4556 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs @@ -1,4 +1,4 @@ fn foo() {} -//~^ ERROR default values for const generic parameters are unstable +//~^ ERROR default values for const generic parameters are experimental fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr index 3d2fac78d7c..31b5ad5123e 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,10 +1,12 @@ -error: default values for const generic parameters are unstable - --> $DIR/default_function_param.rs:1:28 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/default_function_param.rs:1:26 | LL | fn foo() {} - | ^ + | ^^^ | + = note: see issue #44580 for more information = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs index c6d91ef97a0..14bac473ed9 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs @@ -1,4 +1,4 @@ trait Foo {} -//~^ ERROR default values for const generic parameters are unstable +//~^ ERROR default values for const generic parameters are experimental fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr index b727fdd807b..5617b35ad01 100644 --- a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr @@ -1,10 +1,12 @@ -error: default values for const generic parameters are unstable - --> $DIR/default_trait_param.rs:1:30 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/default_trait_param.rs:1:28 | LL | trait Foo {} - | ^^^^ + | ^^^^^^ | + = note: see issue #44580 for more information = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs index 90959e7a365..5b5ccc88873 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.rs @@ -1,7 +1,9 @@ +#[cfg(FALSE)] struct A; -//~^ ERROR default values for const generic parameters are unstable +//~^ ERROR default values for const generic parameters are experimental -fn foo() {} -//~^ ERROR default values for const generic parameters are unstable +#[cfg(FALSE)] +fn foo() {} +//~^ ERROR default values for const generic parameters are experimental fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr index 00d564772d2..e2b48d793fd 100644 --- a/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_generics_defaults.stderr @@ -1,18 +1,21 @@ -error: default values for const generic parameters are unstable - --> $DIR/feature-gate-const_generics_defaults.rs:1:27 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/feature-gate-const_generics_defaults.rs:2:25 | LL | struct A; - | ^ + | ^^^ | + = note: see issue #44580 for more information = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable -error: default values for const generic parameters are unstable - --> $DIR/feature-gate-const_generics_defaults.rs:4:22 +error[E0658]: default values for const generic parameters are experimental + --> $DIR/feature-gate-const_generics_defaults.rs:6:22 | -LL | fn foo() {} - | ^ +LL | fn foo() {} + | ^^^^^^^ | + = note: see issue #44580 for more information = help: add `#![feature(const_generics_defaults)]` to the crate attributes to enable error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0658`. -- cgit 1.4.1-3-g733a5