give a hint which feature is missing
This commit is contained in:
parent
822762c966
commit
f235b6f9c6
@ -89,12 +89,15 @@ fn status_in_item(&self, _ccx: &ConstCx<'_, 'tcx>) -> Status {
|
||||
}
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
|
||||
ccx.dcx().create_err(errors::ConditionallyConstCall {
|
||||
ccx.tcx.sess.create_feature_err(
|
||||
errors::ConditionallyConstCall {
|
||||
span,
|
||||
def_path_str: ccx.tcx.def_path_str_with_args(self.callee, self.args),
|
||||
def_descr: ccx.tcx.def_descr(self.callee),
|
||||
kind: ccx.const_kind(),
|
||||
})
|
||||
},
|
||||
sym::const_trait_impl,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,15 +420,8 @@ fn status_in_item(&self, _: &ConstCx<'_, 'tcx>) -> Status {
|
||||
|
||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
|
||||
let msg = format!("{:#}s are not allowed in {}s", self.0, ccx.const_kind());
|
||||
if let hir::CoroutineKind::Desugared(
|
||||
hir::CoroutineDesugaring::Async,
|
||||
hir::CoroutineSource::Block,
|
||||
) = self.0
|
||||
{
|
||||
ccx.tcx.sess.create_feature_err(
|
||||
errors::UnallowedOpInConstContext { span, msg },
|
||||
sym::const_async_blocks,
|
||||
)
|
||||
if let Status::Unstable { gate, .. } = self.status_in_item(ccx) {
|
||||
ccx.tcx.sess.create_feature_err(errors::UnallowedOpInConstContext { span, msg }, gate)
|
||||
} else {
|
||||
ccx.dcx().create_err(errors::UnallowedOpInConstContext { span, msg })
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ pub fn feature_warn_issue(
|
||||
}
|
||||
|
||||
/// Adds the diagnostics for a feature to an existing error.
|
||||
/// Must be a language feature!
|
||||
pub fn add_feature_diagnostics<G: EmissionGuarantee>(
|
||||
err: &mut Diag<'_, G>,
|
||||
sess: &Session,
|
||||
|
@ -300,6 +300,7 @@ pub fn is_test_crate(&self) -> bool {
|
||||
self.opts.test
|
||||
}
|
||||
|
||||
/// `feature` must be a language feature.
|
||||
#[track_caller]
|
||||
pub fn create_feature_err<'a>(&'a self, err: impl Diagnostic<'a>, feature: Symbol) -> Diag<'a> {
|
||||
let mut err = self.dcx().create_err(err);
|
||||
|
@ -1,8 +1,13 @@
|
||||
error: cannot call conditionally-const method `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions
|
||||
error[E0658]: cannot call conditionally-const method `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions
|
||||
--> $DIR/cross-crate.rs:22:5
|
||||
|
|
||||
LL | Const.func();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,14 +1,23 @@
|
||||
error: cannot call conditionally-const method `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions
|
||||
error[E0658]: cannot call conditionally-const method `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions
|
||||
--> $DIR/cross-crate.rs:19:5
|
||||
|
|
||||
LL | NonConst.func();
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: cannot call conditionally-const method `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions
|
||||
error[E0658]: cannot call conditionally-const method `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions
|
||||
--> $DIR/cross-crate.rs:22:5
|
||||
|
|
||||
LL | Const.func();
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -1,8 +1,13 @@
|
||||
error: cannot call conditionally-const associated function `<staged_api::Unstable as staged_api::MyTrait>::func` in constant functions
|
||||
error[E0658]: cannot call conditionally-const associated function `<staged_api::Unstable as staged_api::MyTrait>::func` in constant functions
|
||||
--> $DIR/staged-api-user-crate.rs:12:5
|
||||
|
|
||||
LL | Unstable::func();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
Loading…
Reference in New Issue
Block a user