1
Fork 0

Fetch less HIR in signature check.

This commit is contained in:
Camille GILLOT 2023-02-12 18:49:54 +00:00
parent e9e12266ce
commit facecf6e1b
11 changed files with 96 additions and 506 deletions

View file

@ -530,46 +530,33 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
} }
DefKind::Fn => {} // entirely within check_item_body DefKind::Fn => {} // entirely within check_item_body
DefKind::Impl { of_trait } => { DefKind::Impl { of_trait } => {
if of_trait { if of_trait && let Some(impl_trait_ref) = tcx.impl_trait_ref(id.owner_id) {
let it = tcx.hir().item(id); check_impl_items_against_trait(
let hir::ItemKind::Impl(impl_) = it.kind else { return }; tcx,
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.owner_id); id.owner_id.def_id,
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.owner_id) { impl_trait_ref.subst_identity(),
check_impl_items_against_trait( );
tcx, check_on_unimplemented(tcx, id);
it.span,
it.owner_id.def_id,
impl_trait_ref.subst_identity(),
&impl_.items,
);
check_on_unimplemented(tcx, it);
}
} }
} }
DefKind::Trait => { DefKind::Trait => {
let it = tcx.hir().item(id); let assoc_items = tcx.associated_items(id.owner_id);
let hir::ItemKind::Trait(_, _, _, _, items) = it.kind else { check_on_unimplemented(tcx, id);
return;
};
check_on_unimplemented(tcx, it);
for item in items.iter() { for assoc_item in assoc_items.in_definition_order() {
let item = tcx.hir().trait_item(item.id); match assoc_item.kind {
match &item.kind { ty::AssocKind::Fn => {
hir::TraitItemKind::Fn(sig, _) => { let abi = tcx.fn_sig(assoc_item.def_id).skip_binder().abi();
let abi = sig.header.abi; fn_maybe_err(tcx, assoc_item.ident(tcx).span, abi);
fn_maybe_err(tcx, item.ident.span, abi);
} }
hir::TraitItemKind::Type(.., Some(default)) => { ty::AssocKind::Type if assoc_item.defaultness(tcx).has_value() => {
let assoc_item = tcx.associated_item(item.owner_id);
let trait_substs = let trait_substs =
InternalSubsts::identity_for_item(tcx, it.owner_id.to_def_id()); InternalSubsts::identity_for_item(tcx, id.owner_id.to_def_id());
let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds( let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
tcx, tcx,
assoc_item, assoc_item,
assoc_item, assoc_item,
default.span, tcx.mk_trait_ref(id.owner_id.to_def_id(), trait_substs),
tcx.mk_trait_ref(it.owner_id.to_def_id(), trait_substs),
); );
} }
_ => {} _ => {}
@ -681,7 +668,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
} }
} }
pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, item: &hir::Item<'_>) { pub(super) fn check_on_unimplemented(tcx: TyCtxt<'_>, item: hir::ItemId) {
// an error would be reported if this fails. // an error would be reported if this fails.
let _ = OnUnimplementedDirective::of_item(tcx, item.owner_id.to_def_id()); let _ = OnUnimplementedDirective::of_item(tcx, item.owner_id.to_def_id());
} }
@ -691,7 +678,7 @@ pub(super) fn check_specialization_validity<'tcx>(
trait_def: &ty::TraitDef, trait_def: &ty::TraitDef,
trait_item: &ty::AssocItem, trait_item: &ty::AssocItem,
impl_id: DefId, impl_id: DefId,
impl_item: &hir::ImplItemRef, impl_item: DefId,
) { ) {
let Ok(ancestors) = trait_def.ancestors(tcx, impl_id) else { return }; let Ok(ancestors) = trait_def.ancestors(tcx, impl_id) else { return };
let mut ancestor_impls = ancestors.skip(1).filter_map(|parent| { let mut ancestor_impls = ancestors.skip(1).filter_map(|parent| {
@ -737,10 +724,8 @@ pub(super) fn check_specialization_validity<'tcx>(
fn check_impl_items_against_trait<'tcx>( fn check_impl_items_against_trait<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
full_impl_span: Span,
impl_id: LocalDefId, impl_id: LocalDefId,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
impl_item_refs: &[hir::ImplItemRef],
) { ) {
// If the trait reference itself is erroneous (so the compilation is going // If the trait reference itself is erroneous (so the compilation is going
// to fail), skip checking the items here -- the `impl_item` table in `tcx` // to fail), skip checking the items here -- the `impl_item` table in `tcx`
@ -749,12 +734,14 @@ fn check_impl_items_against_trait<'tcx>(
return; return;
} }
let impl_item_refs = tcx.associated_item_def_ids(impl_id);
// Negative impls are not expected to have any items // Negative impls are not expected to have any items
match tcx.impl_polarity(impl_id) { match tcx.impl_polarity(impl_id) {
ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {} ty::ImplPolarity::Reservation | ty::ImplPolarity::Positive => {}
ty::ImplPolarity::Negative => { ty::ImplPolarity::Negative => {
if let [first_item_ref, ..] = impl_item_refs { if let [first_item_ref, ..] = impl_item_refs {
let first_item_span = tcx.hir().impl_item(first_item_ref.id).span; let first_item_span = tcx.def_span(first_item_ref);
struct_span_err!( struct_span_err!(
tcx.sess, tcx.sess,
first_item_span, first_item_span,
@ -769,43 +756,27 @@ fn check_impl_items_against_trait<'tcx>(
let trait_def = tcx.trait_def(impl_trait_ref.def_id); let trait_def = tcx.trait_def(impl_trait_ref.def_id);
for impl_item in impl_item_refs { for &impl_item in impl_item_refs {
let ty_impl_item = tcx.associated_item(impl_item.id.owner_id); let ty_impl_item = tcx.associated_item(impl_item);
let ty_trait_item = if let Some(trait_item_id) = ty_impl_item.trait_item_def_id { let ty_trait_item = if let Some(trait_item_id) = ty_impl_item.trait_item_def_id {
tcx.associated_item(trait_item_id) tcx.associated_item(trait_item_id)
} else { } else {
// Checked in `associated_item`. // Checked in `associated_item`.
tcx.sess.delay_span_bug(impl_item.span, "missing associated item in trait"); tcx.sess.delay_span_bug(tcx.def_span(impl_item), "missing associated item in trait");
continue; continue;
}; };
let impl_item_full = tcx.hir().impl_item(impl_item.id); match ty_impl_item.kind {
match impl_item_full.kind { ty::AssocKind::Const => {
hir::ImplItemKind::Const(..) => {
let _ = tcx.compare_impl_const(( let _ = tcx.compare_impl_const((
impl_item.id.owner_id.def_id, impl_item.expect_local(),
ty_impl_item.trait_item_def_id.unwrap(), ty_impl_item.trait_item_def_id.unwrap(),
)); ));
} }
hir::ImplItemKind::Fn(..) => { ty::AssocKind::Fn => {
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id); compare_impl_method(tcx, &ty_impl_item, &ty_trait_item, impl_trait_ref);
compare_impl_method(
tcx,
&ty_impl_item,
&ty_trait_item,
impl_trait_ref,
opt_trait_span,
);
} }
hir::ImplItemKind::Type(impl_ty) => { ty::AssocKind::Type => {
let opt_trait_span = tcx.hir().span_if_local(ty_trait_item.def_id); compare_impl_ty(tcx, &ty_impl_item, &ty_trait_item, impl_trait_ref);
compare_impl_ty(
tcx,
&ty_impl_item,
impl_ty.span,
&ty_trait_item,
impl_trait_ref,
opt_trait_span,
);
} }
} }
@ -840,6 +811,8 @@ fn check_impl_items_against_trait<'tcx>(
.map_or(false, |node_item| !node_item.defining_node.is_from_trait()); .map_or(false, |node_item| !node_item.defining_node.is_from_trait());
if !is_implemented_here { if !is_implemented_here {
let full_impl_span =
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
match tcx.eval_default_body_stability(trait_item_id, full_impl_span) { match tcx.eval_default_body_stability(trait_item_id, full_impl_span) {
EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable( EvalResult::Deny { feature, reason, issue, .. } => default_body_is_unstable(
tcx, tcx,
@ -866,6 +839,8 @@ fn check_impl_items_against_trait<'tcx>(
} }
if !missing_items.is_empty() { if !missing_items.is_empty() {
let full_impl_span =
tcx.hir().span_with_body(tcx.hir().local_def_id_to_hir_id(impl_id));
missing_items_err(tcx, tcx.def_span(impl_id), &missing_items, full_impl_span); missing_items_err(tcx, tcx.def_span(impl_id), &missing_items, full_impl_span);
} }

View file

@ -33,7 +33,6 @@ use std::iter;
/// # Parameters /// # Parameters
/// ///
/// - `impl_m`: type of the method we are checking /// - `impl_m`: type of the method we are checking
/// - `impl_m_span`: span to use for reporting errors
/// - `trait_m`: the method in the trait /// - `trait_m`: the method in the trait
/// - `impl_trait_ref`: the TraitRef corresponding to the trait implementation /// - `impl_trait_ref`: the TraitRef corresponding to the trait implementation
pub(super) fn compare_impl_method<'tcx>( pub(super) fn compare_impl_method<'tcx>(
@ -41,23 +40,19 @@ pub(super) fn compare_impl_method<'tcx>(
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
trait_item_span: Option<Span>,
) { ) {
debug!("compare_impl_method(impl_trait_ref={:?})", impl_trait_ref); debug!("compare_impl_method(impl_trait_ref={:?})", impl_trait_ref);
let impl_m_span = tcx.def_span(impl_m.def_id);
let _: Result<_, ErrorGuaranteed> = try { let _: Result<_, ErrorGuaranteed> = try {
compare_self_type(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref)?; compare_self_type(tcx, impl_m, trait_m, impl_trait_ref)?;
compare_number_of_generics(tcx, impl_m, trait_m, trait_item_span, false)?; compare_number_of_generics(tcx, impl_m, trait_m, false)?;
compare_generic_param_kinds(tcx, impl_m, trait_m, false)?; compare_generic_param_kinds(tcx, impl_m, trait_m, false)?;
compare_number_of_method_arguments(tcx, impl_m, impl_m_span, trait_m, trait_item_span)?; compare_number_of_method_arguments(tcx, impl_m, trait_m)?;
compare_synthetic_generics(tcx, impl_m, trait_m)?; compare_synthetic_generics(tcx, impl_m, trait_m)?;
compare_asyncness(tcx, impl_m, impl_m_span, trait_m, trait_item_span)?; compare_asyncness(tcx, impl_m, trait_m)?;
compare_method_predicate_entailment( compare_method_predicate_entailment(
tcx, tcx,
impl_m, impl_m,
impl_m_span,
trait_m, trait_m,
impl_trait_ref, impl_trait_ref,
CheckImpliedWfMode::Check, CheckImpliedWfMode::Check,
@ -131,11 +126,10 @@ pub(super) fn compare_impl_method<'tcx>(
/// ///
/// Finally we register each of these predicates as an obligation and check that /// Finally we register each of these predicates as an obligation and check that
/// they hold. /// they hold.
#[instrument(level = "debug", skip(tcx, impl_m_span, impl_trait_ref))] #[instrument(level = "debug", skip(tcx, impl_trait_ref))]
fn compare_method_predicate_entailment<'tcx>( fn compare_method_predicate_entailment<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
check_implied_wf: CheckImpliedWfMode, check_implied_wf: CheckImpliedWfMode,
@ -148,6 +142,7 @@ fn compare_method_predicate_entailment<'tcx>(
// FIXME(@lcnr): remove that after removing `cause.body_id` from // FIXME(@lcnr): remove that after removing `cause.body_id` from
// obligations. // obligations.
let impl_m_def_id = impl_m.def_id.expect_local(); let impl_m_def_id = impl_m.def_id.expect_local();
let impl_m_span = tcx.def_span(impl_m_def_id);
let cause = ObligationCause::new( let cause = ObligationCause::new(
impl_m_span, impl_m_span,
impl_m_def_id, impl_m_def_id,
@ -315,7 +310,6 @@ fn compare_method_predicate_entailment<'tcx>(
return compare_method_predicate_entailment( return compare_method_predicate_entailment(
tcx, tcx,
impl_m, impl_m,
impl_m_span,
trait_m, trait_m,
impl_trait_ref, impl_trait_ref,
CheckImpliedWfMode::Skip, CheckImpliedWfMode::Skip,
@ -353,7 +347,6 @@ fn compare_method_predicate_entailment<'tcx>(
return compare_method_predicate_entailment( return compare_method_predicate_entailment(
tcx, tcx,
impl_m, impl_m,
impl_m_span,
trait_m, trait_m,
impl_trait_ref, impl_trait_ref,
CheckImpliedWfMode::Skip, CheckImpliedWfMode::Skip,
@ -535,9 +528,7 @@ enum CheckImpliedWfMode {
fn compare_asyncness<'tcx>( fn compare_asyncness<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_item_span: Option<Span>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
if tcx.asyncness(trait_m.def_id) == hir::IsAsync::Async { if tcx.asyncness(trait_m.def_id) == hir::IsAsync::Async {
match tcx.fn_sig(impl_m.def_id).skip_binder().skip_binder().output().kind() { match tcx.fn_sig(impl_m.def_id).skip_binder().skip_binder().output().kind() {
@ -549,9 +540,9 @@ fn compare_asyncness<'tcx>(
} }
_ => { _ => {
return Err(tcx.sess.emit_err(crate::errors::AsyncTraitImplShouldBeAsync { return Err(tcx.sess.emit_err(crate::errors::AsyncTraitImplShouldBeAsync {
span: impl_m_span, span: tcx.def_span(impl_m.def_id),
method_name: trait_m.name, method_name: trait_m.name,
trait_item_span, trait_item_span: tcx.hir().span_if_local(trait_m.def_id),
})); }));
} }
}; };
@ -606,7 +597,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
// First, check a few of the same things as `compare_impl_method`, // First, check a few of the same things as `compare_impl_method`,
// just so we don't ICE during substitution later. // just so we don't ICE during substitution later.
compare_number_of_generics(tcx, impl_m, trait_m, tcx.hir().span_if_local(impl_m.def_id), true)?; compare_number_of_generics(tcx, impl_m, trait_m, true)?;
compare_generic_param_kinds(tcx, impl_m, trait_m, true)?; compare_generic_param_kinds(tcx, impl_m, trait_m, true)?;
check_region_bounds_on_impl_item(tcx, impl_m, trait_m, true)?; check_region_bounds_on_impl_item(tcx, impl_m, trait_m, true)?;
@ -1094,7 +1085,6 @@ fn extract_spans_for_error_reporting<'tcx>(
fn compare_self_type<'tcx>( fn compare_self_type<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
@ -1130,6 +1120,7 @@ fn compare_self_type<'tcx>(
(false, true) => { (false, true) => {
let self_descr = self_string(impl_m); let self_descr = self_string(impl_m);
let impl_m_span = tcx.def_span(impl_m.def_id);
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
impl_m_span, impl_m_span,
@ -1149,6 +1140,7 @@ fn compare_self_type<'tcx>(
(true, false) => { (true, false) => {
let self_descr = self_string(trait_m); let self_descr = self_string(trait_m);
let impl_m_span = tcx.def_span(impl_m.def_id);
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
impl_m_span, impl_m_span,
@ -1196,7 +1188,6 @@ fn compare_number_of_generics<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_: &ty::AssocItem, impl_: &ty::AssocItem,
trait_: &ty::AssocItem, trait_: &ty::AssocItem,
trait_span: Option<Span>,
delay: bool, delay: bool,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
let trait_own_counts = tcx.generics_of(trait_.def_id).own_counts(); let trait_own_counts = tcx.generics_of(trait_.def_id).own_counts();
@ -1256,6 +1247,7 @@ fn compare_number_of_generics<'tcx>(
.collect(); .collect();
(Some(arg_spans), impl_trait_spans) (Some(arg_spans), impl_trait_spans)
} else { } else {
let trait_span = tcx.hir().span_if_local(trait_.def_id);
(trait_span.map(|s| vec![s]), vec![]) (trait_span.map(|s| vec![s]), vec![])
}; };
@ -1338,9 +1330,7 @@ fn compare_number_of_generics<'tcx>(
fn compare_number_of_method_arguments<'tcx>( fn compare_number_of_method_arguments<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_item_span: Option<Span>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
let impl_m_fty = tcx.fn_sig(impl_m.def_id); let impl_m_fty = tcx.fn_sig(impl_m.def_id);
let trait_m_fty = tcx.fn_sig(trait_m.def_id); let trait_m_fty = tcx.fn_sig(trait_m.def_id);
@ -1362,7 +1352,7 @@ fn compare_number_of_method_arguments<'tcx>(
} }
}) })
}) })
.or(trait_item_span); .or_else(|| tcx.hir().span_if_local(trait_m.def_id));
let (impl_m_sig, _) = &tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).expect_fn(); let (impl_m_sig, _) = &tcx.hir().expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
let pos = impl_number_args.saturating_sub(1); let pos = impl_number_args.saturating_sub(1);
@ -1377,7 +1367,7 @@ fn compare_number_of_method_arguments<'tcx>(
arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo()) arg.span.with_lo(impl_m_sig.decl.inputs[0].span.lo())
} }
}) })
.unwrap_or(impl_m_span); .unwrap_or_else(|| tcx.def_span(impl_m.def_id));
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
@ -1747,22 +1737,16 @@ pub(super) fn compare_impl_const_raw(
pub(super) fn compare_impl_ty<'tcx>( pub(super) fn compare_impl_ty<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_ty: &ty::AssocItem, impl_ty: &ty::AssocItem,
impl_ty_span: Span,
trait_ty: &ty::AssocItem, trait_ty: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
trait_item_span: Option<Span>,
) { ) {
debug!("compare_impl_type(impl_trait_ref={:?})", impl_trait_ref); debug!("compare_impl_type(impl_trait_ref={:?})", impl_trait_ref);
let _: Result<(), ErrorGuaranteed> = try { let _: Result<(), ErrorGuaranteed> = try {
compare_number_of_generics(tcx, impl_ty, trait_ty, trait_item_span, false)?; compare_number_of_generics(tcx, impl_ty, trait_ty, false)?;
compare_generic_param_kinds(tcx, impl_ty, trait_ty, false)?; compare_generic_param_kinds(tcx, impl_ty, trait_ty, false)?;
compare_type_predicate_entailment(tcx, impl_ty, trait_ty, impl_trait_ref)?;
let sp = tcx.def_span(impl_ty.def_id); check_type_bounds(tcx, trait_ty, impl_ty, impl_trait_ref)?;
compare_type_predicate_entailment(tcx, impl_ty, sp, trait_ty, impl_trait_ref)?;
check_type_bounds(tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref)?;
}; };
} }
@ -1771,7 +1755,6 @@ pub(super) fn compare_impl_ty<'tcx>(
fn compare_type_predicate_entailment<'tcx>( fn compare_type_predicate_entailment<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_ty: &ty::AssocItem, impl_ty: &ty::AssocItem,
impl_ty_span: Span,
trait_ty: &ty::AssocItem, trait_ty: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
@ -1808,6 +1791,7 @@ fn compare_type_predicate_entailment<'tcx>(
debug!("compare_type_predicate_entailment: bounds={:?}", hybrid_preds); debug!("compare_type_predicate_entailment: bounds={:?}", hybrid_preds);
let impl_ty_span = tcx.def_span(impl_ty_def_id);
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id); let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_def_id);
let param_env = ty::ParamEnv::new( let param_env = ty::ParamEnv::new(
tcx.intern_predicates(&hybrid_preds.predicates), tcx.intern_predicates(&hybrid_preds.predicates),
@ -1873,7 +1857,6 @@ pub(super) fn check_type_bounds<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_ty: &ty::AssocItem, trait_ty: &ty::AssocItem,
impl_ty: &ty::AssocItem, impl_ty: &ty::AssocItem,
impl_ty_span: Span,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
// Given // Given
@ -2009,8 +1992,15 @@ pub(super) fn check_type_bounds<'tcx>(
let infcx = tcx.infer_ctxt().build(); let infcx = tcx.infer_ctxt().build();
let ocx = ObligationCtxt::new(&infcx); let ocx = ObligationCtxt::new(&infcx);
let assumed_wf_types = let impl_ty_span = match tcx.hir().get_by_def_id(impl_ty_def_id) {
ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty.def_id.expect_local()); hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Type(_, Some(ty)),
..
}) => ty.span,
hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Type(ty), .. }) => ty.span,
_ => bug!(),
};
let assumed_wf_types = ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty_def_id);
let normalize_cause = ObligationCause::new( let normalize_cause = ObligationCause::new(
impl_ty_span, impl_ty_span,

View file

@ -75,7 +75,6 @@ pub use check::check_abi;
use check::check_mod_item_types; use check::check_mod_item_types;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder}; use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
use rustc_index::bit_set::BitSet; use rustc_index::bit_set::BitSet;
@ -169,27 +168,24 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
} }
} }
fn report_forbidden_specialization( fn report_forbidden_specialization(tcx: TyCtxt<'_>, impl_item: DefId, parent_impl: DefId) {
tcx: TyCtxt<'_>, let span = tcx.def_span(impl_item);
impl_item: &hir::ImplItemRef, let ident = tcx.item_name(impl_item);
parent_impl: DefId,
) {
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
impl_item.span, span,
E0520, E0520,
"`{}` specializes an item from a parent `impl`, but \ "`{}` specializes an item from a parent `impl`, but that item is not marked `default`",
that item is not marked `default`", ident,
impl_item.ident
); );
err.span_label(impl_item.span, format!("cannot specialize default item `{}`", impl_item.ident)); err.span_label(span, format!("cannot specialize default item `{}`", ident));
match tcx.span_of_impl(parent_impl) { match tcx.span_of_impl(parent_impl) {
Ok(span) => { Ok(span) => {
err.span_label(span, "parent `impl` is here"); err.span_label(span, "parent `impl` is here");
err.note(&format!( err.note(&format!(
"to specialize, `{}` in the parent `impl` must be marked `default`", "to specialize, `{}` in the parent `impl` must be marked `default`",
impl_item.ident ident
)); ));
} }
Err(cname) => { Err(cname) => {

View file

@ -3,38 +3,17 @@
use std::ops::Index; use std::ops::Index;
pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
//~^ ERROR
//~^^ ERROR
//~^^^ ERROR
let _ = s; let _ = s;
} }
pub trait SVec: Index< pub trait SVec: Index<
<Self as SVec>::Item, <Self as SVec>::Item,
//~^ ERROR
//~^^ ERROR
//~^^^ ERROR
//~^^^^ ERROR
Output = <Index<<Self as SVec>::Item, Output = <Index<<Self as SVec>::Item,
//~^ ERROR
//~^^ ERROR
//~^^^ ERROR
//~^^^^ ERROR
Output = <Self as SVec>::Item> as SVec>::Item, Output = <Self as SVec>::Item> as SVec>::Item,
//~^ ERROR
//~^^ ERROR
//~^^^ ERROR
//~^^^^ ERROR
//~^^^^^ ERROR
//~^^^^^^ ERROR
//~^^^^^^^ ERROR
//~^^^^^^^^ ERROR
> { > {
type Item<'a, T>; type Item<'a, T>;
fn len(&self) -> <Self as SVec>::Item; fn len(&self) -> <Self as SVec>::Item;
//~^ ERROR //~^ ERROR
//~^^ ERROR //~^^ ERROR
//~^^^ ERROR
//~^^^^ ERROR
} }

View file

@ -1,328 +1,11 @@
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21 --> $DIR/issue-105742.rs:16:38
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:5:40
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) {
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:5:40
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) {
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:13:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:18:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:23:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0038]: the trait `SVec` cannot be made into an object
--> $DIR/issue-105742.rs:5:31
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-105742.rs:12:17
|
LL | pub trait SVec: Index<
| ____________----__^
| | |
| | this trait cannot be made into an object...
LL | | <Self as SVec>::Item,
LL | |
LL | |
... |
LL | |/ Output = <Index<<Self as SVec>::Item,
LL | ||
LL | ||
LL | ||
LL | ||
LL | || Output = <Self as SVec>::Item> as SVec>::Item,
| ||_________________________________________________^ ...because it uses `Self` as a type parameter
... |
LL | |
LL | | > {
| |__^ ...because it uses `Self` as a type parameter
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:35:38
| |
LL | fn len(&self) -> <Self as SVec>::Item; LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 lifetime argument | ^^^^ expected 1 lifetime argument
| |
note: associated type defined here, with 1 lifetime parameter: `'a` note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10 --> $DIR/issue-105742.rs:14:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ -- | ^^^^ --
@ -332,13 +15,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ++++ | ++++
error[E0107]: missing generics for associated type `SVec::Item` error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/issue-105742.rs:35:38 --> $DIR/issue-105742.rs:16:38
| |
LL | fn len(&self) -> <Self as SVec>::Item; LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 generic argument | ^^^^ expected 1 generic argument
| |
note: associated type defined here, with 1 generic parameter: `T` note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10 --> $DIR/issue-105742.rs:14:10
| |
LL | type Item<'a, T>; LL | type Item<'a, T>;
| ^^^^ - | ^^^^ -
@ -347,39 +30,6 @@ help: add missing generic argument
LL | fn len(&self) -> <Self as SVec>::Item<T>; LL | fn len(&self) -> <Self as SVec>::Item<T>;
| +++ | +++
error[E0107]: missing generics for associated type `SVec::Item` error: aborting due to 2 previous errors
--> $DIR/issue-105742.rs:35:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ --
help: add missing lifetime argument
|
LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ++++
error[E0107]: missing generics for associated type `SVec::Item` For more information about this error, try `rustc --explain E0107`.
--> $DIR/issue-105742.rs:35:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/issue-105742.rs:33:10
|
LL | type Item<'a, T>;
| ^^^^ -
help: add missing generic argument
|
LL | fn len(&self) -> <Self as SVec>::Item<T>;
| +++
error: aborting due to 23 previous errors
Some errors have detailed explanations: E0038, E0107.
For more information about an error, try `rustc --explain E0038`.

View file

@ -15,7 +15,7 @@ LL | impl<T: Clone> SpaceLlama for T {
| ------------------------------- parent `impl` is here | ------------------------------- parent `impl` is here
... ...
LL | default fn fly(&self) {} LL | default fn fly(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `fly` | ^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `fly`
| |
= note: to specialize, `fly` in the parent `impl` must be marked `default` = note: to specialize, `fly` in the parent `impl` must be marked `default`

View file

@ -15,7 +15,7 @@ LL | impl<T> Foo for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `foo` | ^^^^^^^^^^^^^ cannot specialize default item `foo`
| |
= note: to specialize, `foo` in the parent `impl` must be marked `default` = note: to specialize, `foo` in the parent `impl` must be marked `default`
@ -26,7 +26,7 @@ LL | impl<T> Foo for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | fn bar(&self) {} LL | fn bar(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `bar` | ^^^^^^^^^^^^^ cannot specialize default item `bar`
| |
= note: to specialize, `bar` in the parent `impl` must be marked `default` = note: to specialize, `bar` in the parent `impl` must be marked `default`
@ -37,7 +37,7 @@ LL | impl<T> Bar for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | type T = (); LL | type T = ();
| ^^^^^^^^^^^^ cannot specialize default item `T` | ^^^^^^ cannot specialize default item `T`
| |
= note: to specialize, `T` in the parent `impl` must be marked `default` = note: to specialize, `T` in the parent `impl` must be marked `default`
@ -48,7 +48,7 @@ LL | impl<T: Clone> Baz for T {
| ------------------------ parent `impl` is here | ------------------------ parent `impl` is here
... ...
LL | fn baz(&self) {} LL | fn baz(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `baz` | ^^^^^^^^^^^^^ cannot specialize default item `baz`
| |
= note: to specialize, `baz` in the parent `impl` must be marked `default` = note: to specialize, `baz` in the parent `impl` must be marked `default`
@ -59,7 +59,7 @@ LL | impl<T: Clone> Redundant for T {
| ------------------------------ parent `impl` is here | ------------------------------ parent `impl` is here
... ...
LL | fn redundant(&self) {} LL | fn redundant(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant` | ^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant`
| |
= note: to specialize, `redundant` in the parent `impl` must be marked `default` = note: to specialize, `redundant` in the parent `impl` must be marked `default`

View file

@ -12,7 +12,7 @@ error[E0520]: `foo` specializes an item from a parent `impl`, but that item is n
--> $DIR/issue-50452-fail.rs:10:5 --> $DIR/issue-50452-fail.rs:10:5
| |
LL | fn foo() {} LL | fn foo() {}
| ^^^^^^^^^^^ cannot specialize default item `foo` | ^^^^^^^^ cannot specialize default item `foo`
... ...
LL | impl<T> Foo for T { LL | impl<T> Foo for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here

View file

@ -15,7 +15,7 @@ LL | impl<T> Foo for Box<T> {
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | type Ty = Vec<()>; LL | type Ty = Vec<()>;
| ^^^^^^^^^^^^^^^^^^ cannot specialize default item `Ty` | ^^^^^^^ cannot specialize default item `Ty`
| |
= note: to specialize, `Ty` in the parent `impl` must be marked `default` = note: to specialize, `Ty` in the parent `impl` must be marked `default`
@ -26,7 +26,7 @@ LL | impl<T> Foo for Box<T> {
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | const CONST: u8 = 42; LL | const CONST: u8 = 42;
| ^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `CONST` | ^^^^^^^^^^^^^^^ cannot specialize default item `CONST`
| |
= note: to specialize, `CONST` in the parent `impl` must be marked `default` = note: to specialize, `CONST` in the parent `impl` must be marked `default`
@ -37,7 +37,7 @@ LL | impl<T> Foo for Box<T> {
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | fn foo(&self) -> bool { true } LL | fn foo(&self) -> bool { true }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo` | ^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
| |
= note: to specialize, `foo` in the parent `impl` must be marked `default` = note: to specialize, `foo` in the parent `impl` must be marked `default`
@ -48,7 +48,7 @@ LL | impl<T> Foo for Vec<T> {}
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | type Ty = Vec<()>; LL | type Ty = Vec<()>;
| ^^^^^^^^^^^^^^^^^^ cannot specialize default item `Ty` | ^^^^^^^ cannot specialize default item `Ty`
| |
= note: to specialize, `Ty` in the parent `impl` must be marked `default` = note: to specialize, `Ty` in the parent `impl` must be marked `default`
@ -59,7 +59,7 @@ LL | impl<T> Foo for Vec<T> {}
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | const CONST: u8 = 42; LL | const CONST: u8 = 42;
| ^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `CONST` | ^^^^^^^^^^^^^^^ cannot specialize default item `CONST`
| |
= note: to specialize, `CONST` in the parent `impl` must be marked `default` = note: to specialize, `CONST` in the parent `impl` must be marked `default`
@ -70,7 +70,7 @@ LL | impl<T> Foo for Vec<T> {}
| ---------------------- parent `impl` is here | ---------------------- parent `impl` is here
... ...
LL | fn foo(&self) -> bool { true } LL | fn foo(&self) -> bool { true }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo` | ^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
| |
= note: to specialize, `foo` in the parent `impl` must be marked `default` = note: to specialize, `foo` in the parent `impl` must be marked `default`

View file

@ -15,7 +15,7 @@ LL | impl<T> Foo for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | fn foo(&self) {} LL | fn foo(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `foo` | ^^^^^^^^^^^^^ cannot specialize default item `foo`
| |
= note: to specialize, `foo` in the parent `impl` must be marked `default` = note: to specialize, `foo` in the parent `impl` must be marked `default`
@ -26,7 +26,7 @@ LL | impl<T> Foo for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | fn bar(&self) {} LL | fn bar(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `bar` | ^^^^^^^^^^^^^ cannot specialize default item `bar`
| |
= note: to specialize, `bar` in the parent `impl` must be marked `default` = note: to specialize, `bar` in the parent `impl` must be marked `default`
@ -37,7 +37,7 @@ LL | impl<T> Bar for T {
| ----------------- parent `impl` is here | ----------------- parent `impl` is here
... ...
LL | type T = (); LL | type T = ();
| ^^^^^^^^^^^^ cannot specialize default item `T` | ^^^^^^ cannot specialize default item `T`
| |
= note: to specialize, `T` in the parent `impl` must be marked `default` = note: to specialize, `T` in the parent `impl` must be marked `default`
@ -48,7 +48,7 @@ LL | impl<T: Clone> Baz for T {
| ------------------------ parent `impl` is here | ------------------------ parent `impl` is here
... ...
LL | fn baz(&self) {} LL | fn baz(&self) {}
| ^^^^^^^^^^^^^^^^ cannot specialize default item `baz` | ^^^^^^^^^^^^^ cannot specialize default item `baz`
| |
= note: to specialize, `baz` in the parent `impl` must be marked `default` = note: to specialize, `baz` in the parent `impl` must be marked `default`
@ -59,7 +59,7 @@ LL | impl<T: Clone> Redundant for T {
| ------------------------------ parent `impl` is here | ------------------------------ parent `impl` is here
... ...
LL | default fn redundant(&self) {} LL | default fn redundant(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant`
| |
= note: to specialize, `redundant` in the parent `impl` must be marked `default` = note: to specialize, `redundant` in the parent `impl` must be marked `default`

View file

@ -2,7 +2,7 @@ error[E0749]: negative impls cannot have any items
--> $DIR/no-items.rs:8:5 --> $DIR/no-items.rs:8:5
| |
LL | type Foo = i32; LL | type Foo = i32;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^
error: aborting due to previous error error: aborting due to previous error