Skip to content

Commit

Permalink
Rollup merge of rust-lang#84705 - lcnr:const_generics-rec, r=joshtrip…
Browse files Browse the repository at this point in the history
…lett

make feature recommendations optional

this is what we're already doing for other feature gates, so it's better to be consistent
  • Loading branch information
jackh726 committed Apr 29, 2021
2 parents 9148cc7 + da6261e commit 862e48c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ impl<'a> Resolver<'a> {
name
));
}
err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions");

if self.session.is_nightly_build() {
err.help(
"use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \
to allow generic const expressions"
);
}

err
}
Expand Down
25 changes: 14 additions & 11 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
),
)
} else {
tcx.sess
.struct_span_err(
hir_ty.span,
&format!(
"{} is forbidden as the type of a const generic parameter",
unsupported_type
),
)
.note("the only supported types are integers, `bool` and `char`")
.help("more complex types are supported with `#![feature(const_generics)]`")
.emit()
let mut err = tcx.sess.struct_span_err(
hir_ty.span,
&format!(
"{} is forbidden as the type of a const generic parameter",
unsupported_type
),
);
err.note("the only supported types are integers, `bool` and `char`");
if tcx.sess.is_nightly_build() {
err.help(
"more complex types are supported with `#![feature(const_generics)]`",
);
}
err.emit()
}
};

Expand Down

0 comments on commit 862e48c

Please sign in to comment.