Skip to content

Commit

Permalink
make feature recommendations optional
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Apr 29, 2021
1 parent 814a560 commit da6261e
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 da6261e

Please sign in to comment.