Skip to content

Commit 0fcfb10

Browse files
authored
Rollup merge of rust-lang#84705 - lcnr:const_generics-rec, r=joshtriplett
make feature recommendations optional this is what we're already doing for other feature gates, so it's better to be consistent
2 parents 3dc03e4 + da6261e commit 0fcfb10

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,13 @@ impl<'a> Resolver<'a> {
487487
name
488488
));
489489
}
490-
err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions");
490+
491+
if self.session.is_nightly_build() {
492+
err.help(
493+
"use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \
494+
to allow generic const expressions"
495+
);
496+
}
491497

492498
err
493499
}

compiler/rustc_typeck/src/check/wfcheck.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
315315
),
316316
)
317317
} else {
318-
tcx.sess
319-
.struct_span_err(
320-
hir_ty.span,
321-
&format!(
322-
"{} is forbidden as the type of a const generic parameter",
323-
unsupported_type
324-
),
325-
)
326-
.note("the only supported types are integers, `bool` and `char`")
327-
.help("more complex types are supported with `#![feature(const_generics)]`")
328-
.emit()
318+
let mut err = tcx.sess.struct_span_err(
319+
hir_ty.span,
320+
&format!(
321+
"{} is forbidden as the type of a const generic parameter",
322+
unsupported_type
323+
),
324+
);
325+
err.note("the only supported types are integers, `bool` and `char`");
326+
if tcx.sess.is_nightly_build() {
327+
err.help(
328+
"more complex types are supported with `#![feature(const_generics)]`",
329+
);
330+
}
331+
err.emit()
329332
}
330333
};
331334

0 commit comments

Comments
 (0)