"rustc_attr",
"rustc_data_structures",
"rustc_errors",
+ "rustc_feature",
"rustc_graphviz",
"rustc_hir",
"rustc_hir_pretty",
rustc_lint = { path = "../rustc_lint" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_type_ir = { path = "../rustc_type_ir" }
+rustc_feature = { path = "../rustc_feature" }
if !is_implemented_here {
match tcx.eval_default_body_stability(trait_item_id, full_impl_span) {
- EvalResult::Deny { feature, reason, issue, is_soft, .. } => {
- default_body_is_unstable(
- tcx,
- full_impl_span,
- trait_item_id,
- feature,
- reason,
- issue,
- is_soft,
- )
- }
+ EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable(
+ tcx,
+ full_impl_span,
+ trait_item_id,
+ feature,
+ reason,
+ issue,
+ ),
// Unmarked default bodies are considered stable (at least for now).
EvalResult::Allow | EvalResult::Unmarked => {}
pub use fn_ctxt::*;
use hir::def::CtorOf;
pub use inherited::{Inherited, InheritedBuilder};
-use rustc_middle::middle::stability::report_unstable;
use crate::astconv::AstConv;
use crate::check::gather_locals::GatherLocalsVisitor;
fn default_body_is_unstable(
tcx: TyCtxt<'_>,
impl_span: Span,
- _item_did: DefId,
+ item_did: DefId,
feature: Symbol,
reason: Option<Symbol>,
issue: Option<NonZeroU32>,
- is_soft: bool,
) {
- let soft_handler = |lint, span, msg: &_| {
- tcx.struct_span_lint_hir(lint, hir::CRATE_HIR_ID, span, |lint| {
- lint.build(msg).emit();
- })
+ let missing_item_name = &tcx.associated_item(item_did).name;
+ let use_of_unstable_library_feature_note = match reason {
+ Some(r) => format!("use of unstable library feature '{feature}': {r}"),
+ None => format!("use of unstable library feature '{feature}'"),
};
- report_unstable(tcx.sess, feature, reason, issue, None, is_soft, impl_span, soft_handler)
+ let mut err = struct_span_err!(
+ tcx.sess,
+ impl_span,
+ E0046,
+ "not all trait items implemented, missing: `{missing_item_name}`",
+ );
+ err.note(format!("default implementation of `{missing_item_name}` is unstable"));
+ err.note(use_of_unstable_library_feature_note);
+ rustc_session::parse::add_feature_diagnostics_for_issue(
+ &mut err,
+ &tcx.sess.parse_sess,
+ feature,
+ rustc_feature::GateIssue::Library(issue),
+ );
+ err.emit();
}
/// Re-sugar `ty::GenericPredicates` in a way suitable to be used in structured suggestions.
struct Type;
impl JustTrait for Type {}
-//~^ ERROR use of unstable library feature 'fun_default_body'
-//~| ERROR use of unstable library feature 'constant_default_body'
+//~^ ERROR not all trait items implemented, missing: `CONSTANT` [E0046]
+//~| ERROR not all trait items implemented, missing: `fun` [E0046]
impl Equal for Type {
- //~^ ERROR use of unstable library feature 'eq_default_body'
+ //~^ ERROR not all trait items implemented, missing: `eq` [E0046]
fn neq(&self, other: &Self) -> bool {
false
}
-error[E0658]: use of unstable library feature 'constant_default_body'
+error[E0046]: not all trait items implemented, missing: `CONSTANT`
--> $DIR/default-body-stability-err.rs:10:1
|
LL | impl JustTrait for Type {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
+ = note: default implementation of `CONSTANT` is unstable
+ = note: use of unstable library feature 'constant_default_body'
= help: add `#![feature(constant_default_body)]` to the crate attributes to enable
-error[E0658]: use of unstable library feature 'fun_default_body'
+error[E0046]: not all trait items implemented, missing: `fun`
--> $DIR/default-body-stability-err.rs:10:1
|
LL | impl JustTrait for Type {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
+ = note: default implementation of `fun` is unstable
+ = note: use of unstable library feature 'fun_default_body'
= help: add `#![feature(fun_default_body)]` to the crate attributes to enable
-error[E0658]: use of unstable library feature 'eq_default_body'
+error[E0046]: not all trait items implemented, missing: `eq`
--> $DIR/default-body-stability-err.rs:14:1
|
LL | / impl Equal for Type {
LL | | }
| |_^
|
+ = note: default implementation of `eq` is unstable
+ = note: use of unstable library feature 'eq_default_body'
= help: add `#![feature(eq_default_body)]` to the crate attributes to enable
error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0046`.