Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
@@ -391,6 +391,12 @@ fn check_trait_item<'tcx>(
// Check that an item definition in a subtrait is shadowing a supertrait item.
lint_item_shadowing_supertrait_item(tcx, def_id);

for blanket_impl_def_id in tcx.all_impls(def_id.to_def_id()) {
if !blanket_impl_def_id.is_local() {
tcx.ensure_ok().lint_object_blanket_impl((blanket_impl_def_id, def_id.to_def_id()));
}
}

let mut res = check_associated_item(tcx, def_id, span, method_sig);

if matches!(trait_item.kind, hir::TraitItemKind::Fn(..)) {
148 changes: 144 additions & 4 deletions compiler/rustc_hir_analysis/src/impl_wf_check.rs
Original file line number Diff line number Diff line change
@@ -10,16 +10,23 @@

use std::assert_matches::debug_assert_matches;

use min_specialization::check_min_specialization;
use itertools::Itertools;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::codes::*;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_span::ErrorGuaranteed;
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint_defs::builtin::DYN_OVERLAP;
use rustc_middle::ty::{
self, ExistentialPredicateStableCmpExt, Ty, TyCtxt, TypeVisitableExt, TypingMode, Upcast,
elaborate,
};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, sym};
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};

use crate::constrained_generic_params as cgp;
use crate::errors::UnconstrainedGenericParameter;
use crate::impl_wf_check::min_specialization::check_min_specialization;

mod min_specialization;

@@ -68,6 +75,22 @@ pub(crate) fn check_impl_wf(
if tcx.features().min_specialization() {
res = res.and(check_min_specialization(tcx, impl_def_id));
}

if let Some(trait_def_id) = tcx.trait_id_of_impl(impl_def_id.to_def_id()) {
for &subtrait_def_id in tcx
.crates(())
.into_iter()
.copied()
.chain([LOCAL_CRATE])
.flat_map(|cnum| tcx.traits(cnum))
{
if ty::elaborate::supertrait_def_ids(tcx, subtrait_def_id).contains(&trait_def_id) {
tcx.ensure_ok()
.lint_object_blanket_impl((impl_def_id.to_def_id(), subtrait_def_id));
}
}
}

res
}

@@ -234,3 +257,120 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained(
}
res
}

pub(crate) fn lint_object_blanket_impl<'tcx>(
tcx: TyCtxt<'tcx>,
(impl_def_id, trait_def_id): (DefId, DefId),
) {
if tcx.is_diagnostic_item(sym::Any, trait_def_id) {
return;
}

if !tcx.is_dyn_compatible(trait_def_id) {
return;
}

let infcx = tcx.infer_ctxt().with_next_trait_solver(true).build(TypingMode::CheckObjectOverlap);

let principal_trait_args = infcx.fresh_args_for_item(DUMMY_SP, trait_def_id);
let principal_trait = ty::TraitRef::new_from_args(tcx, trait_def_id, principal_trait_args);

let mut needed_associated_types = vec![];
let clause: ty::Clause<'tcx> = ty::TraitRef::identity(tcx, trait_def_id).upcast(tcx);
for clause in elaborate::elaborate(tcx, [clause]).filter_only_self() {
let clause = clause.instantiate_supertrait(tcx, ty::Binder::dummy(principal_trait));

let bound_predicate = clause.kind();
match bound_predicate.skip_binder() {
ty::ClauseKind::Trait(pred) => {
// FIXME(negative_bounds): Handle this correctly...
let trait_ref = tcx.anonymize_bound_vars(bound_predicate.rebind(pred.trait_ref));
needed_associated_types.extend(
tcx.associated_items(pred.trait_ref.def_id)
.in_definition_order()
// We only care about associated types.
.filter(|item| item.is_type())
// No RPITITs -- they're not dyn-compatible for now.
.filter(|item| !item.is_impl_trait_in_trait())
// If the associated type has a `where Self: Sized` bound,
// we do not need to constrain the associated type.
.filter(|item| !tcx.generics_require_sized_self(item.def_id))
.map(|item| (item.def_id, trait_ref)),
);
}
_ => (),
}
}

let mut data: Vec<_> = [ty::Binder::dummy(ty::ExistentialPredicate::Trait(
ty::ExistentialTraitRef::erase_self_ty(tcx, principal_trait),
))]
.into_iter()
.chain(needed_associated_types.into_iter().map(|(def_id, trait_ref)| {
trait_ref.map_bound(|trait_ref| {
ty::ExistentialPredicate::Projection(ty::ExistentialProjection::erase_self_ty(
tcx,
ty::ProjectionPredicate {
projection_term: ty::AliasTerm::new_from_args(tcx, def_id, trait_ref.args),
term: infcx.next_ty_var(DUMMY_SP).into(),
},
))
})
}))
.collect();
data.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));

let self_ty = Ty::new_dynamic(
tcx,
tcx.mk_poly_existential_predicates(&data),
tcx.lifetimes.re_erased,
ty::Dyn,
);

let impl_args = infcx.fresh_args_for_item(DUMMY_SP, impl_def_id);
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().instantiate(tcx, impl_args);

let ocx = ObligationCtxt::new(&infcx);
let Ok(()) =
ocx.eq(&ObligationCause::dummy(), ty::ParamEnv::empty(), principal_trait, impl_trait_ref)
else {
return;
};
let Ok(()) =
ocx.eq(&ObligationCause::dummy(), ty::ParamEnv::empty(), self_ty, impl_trait_ref.self_ty())
else {
return;
};

ocx.register_obligations(
tcx.predicates_of(impl_def_id).instantiate(tcx, impl_args).into_iter().map(
|(clause, _)| {
Obligation::new(tcx, ObligationCause::dummy(), ty::ParamEnv::empty(), clause)
},
),
);

if !ocx.select_where_possible().is_empty() {
return;
}

let local_def_id = if let Some(impl_def_id) = impl_def_id.as_local() {
impl_def_id
} else if let Some(trait_def_id) = trait_def_id.as_local() {
trait_def_id
} else {
panic!()
};
let hir_id = tcx.local_def_id_to_hir_id(local_def_id);

let self_ty = infcx.resolve_vars_if_possible(self_ty);

tcx.node_span_lint(DYN_OVERLAP, hir_id, tcx.def_span(local_def_id), |diag| {
diag.primary_message("hi");
diag.span_label(
tcx.def_span(trait_def_id),
format!("built-in `{self_ty}` implementation for this trait"),
);
diag.span_label(tcx.def_span(impl_def_id), "overlaps with this blanket impl");
});
}
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -171,6 +171,7 @@ pub fn provide(providers: &mut Providers) {
inherit_sig_for_delegation_item: delegation::inherit_sig_for_delegation_item,
enforce_impl_non_lifetime_params_are_constrained:
impl_wf_check::enforce_impl_non_lifetime_params_are_constrained,
lint_object_blanket_impl: impl_wf_check::lint_object_blanket_impl,
..*providers
};
}
2 changes: 2 additions & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
@@ -968,6 +968,7 @@ impl<'tcx> InferCtxt<'tcx> {
// and post-borrowck analysis mode. We may need to modify its uses
// to support PostBorrowckAnalysis in the old solver as well.
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::PostBorrowckAnalysis { .. }
| TypingMode::PostAnalysis => false,
}
@@ -1260,6 +1261,7 @@ impl<'tcx> InferCtxt<'tcx> {
TypingMode::non_body_analysis()
}
mode @ (ty::TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| ty::TypingMode::PostBorrowckAnalysis { .. }
| ty::TypingMode::PostAnalysis) => mode,
};
6 changes: 4 additions & 2 deletions compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
@@ -87,7 +87,9 @@ impl<'tcx> InferCtxt<'tcx> {
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
let def_id = def_id.expect_local();
if let ty::TypingMode::Coherence = self.typing_mode() {
if let ty::TypingMode::Coherence | ty::TypingMode::CheckObjectOverlap =
self.typing_mode()
{
// See comment on `insert_hidden_type` for why this is sufficient in coherence
return Some(self.register_hidden_type(
OpaqueTypeKey { def_id, args },
@@ -226,7 +228,7 @@ impl<'tcx> InferCtxt<'tcx> {
// these are the same span, but not in cases like `-> (impl
// Foo, impl Bar)`.
match self.typing_mode() {
ty::TypingMode::Coherence => {
ty::TypingMode::Coherence | ty::TypingMode::CheckObjectOverlap => {
// During intercrate we do not define opaque types but instead always
// force ambiguity unless the hidden type is known to not implement
// our trait.
10 changes: 8 additions & 2 deletions compiler/rustc_infer/src/infer/relate/generalize.rs
Original file line number Diff line number Diff line change
@@ -519,7 +519,10 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
//
// cc trait-system-refactor-initiative#108
if self.infcx.next_trait_solver()
&& !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
&& !matches!(
self.infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
)
&& self.in_alias
{
inner.type_variables().equate(vid, new_var_id);
@@ -650,7 +653,10 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
// See the comment for type inference variables
// for more details.
if self.infcx.next_trait_solver()
&& !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
&& !matches!(
self.infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
)
&& self.in_alias
{
variable_table.union(vid, new_var_id);
12 changes: 12 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ declare_lint_pass! {
DEPRECATED_SAFE_2024,
DEPRECATED_WHERE_CLAUSE_LOCATION,
DUPLICATE_MACRO_ATTRIBUTES,
DYN_OVERLAP,
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
ELIDED_LIFETIMES_IN_PATHS,
ELIDED_NAMED_LIFETIMES,
@@ -5067,3 +5068,14 @@ declare_lint! {
reference: "issue #138762 <https://github.com/rust-lang/rust/issues/138762>",
};
}

declare_lint! {
/// The `dyn_overlap` lint is one of the lints of all time.
///
/// ### Uwu
///
/// Owo
pub DYN_OVERLAP,
Forbid,
"owo",
}
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -527,6 +527,10 @@ rustc_queries! {
anon
}

query lint_object_blanket_impl(_: (DefId, DefId)) {
desc { "u if wu" }
}

/// Set of param indexes for type params that are in the type's representation
query params_in_repr(key: DefId) -> &'tcx rustc_index::bit_set::DenseBitSet<u32> {
desc { "finding type parameters in the representation" }
4 changes: 2 additions & 2 deletions compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs
Original file line number Diff line number Diff line change
@@ -380,7 +380,7 @@ where

let mut candidates = vec![];

if let TypingMode::Coherence = self.typing_mode() {
if let TypingMode::Coherence | TypingMode::CheckObjectOverlap = self.typing_mode() {
if let Ok(candidate) = self.consider_coherence_unknowable_candidate(goal) {
return vec![candidate];
}
@@ -831,7 +831,7 @@ where
candidates: &mut Vec<Candidate<I>>,
) {
match self.typing_mode() {
TypingMode::Coherence => return,
TypingMode::Coherence | TypingMode::CheckObjectOverlap => return,
TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. }
3 changes: 2 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
@@ -948,7 +948,8 @@ where
GoalSource::TypeRelating
}
// FIXME(-Znext-solver=coinductive): should these WF goals also be unproductive?
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => GoalSource::Misc,
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
| ty::PredicateKind::Ambiguous => GoalSource::Misc,
p => unreachable!("unexpected nested goal in `relate`: {p:?}"),
};
self.add_goal(source, goal);
4 changes: 3 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/mod.rs
Original file line number Diff line number Diff line change
@@ -339,7 +339,9 @@ where
fn opaque_type_is_rigid(&self, def_id: I::DefId) -> bool {
match self.typing_mode() {
// Opaques are never rigid outside of analysis mode.
TypingMode::Coherence | TypingMode::PostAnalysis => false,
TypingMode::Coherence | TypingMode::CheckObjectOverlap | TypingMode::PostAnalysis => {
false
}
// During analysis, opaques are rigid unless they may be defined by
// the current body.
TypingMode::Analysis { defining_opaque_types_and_generators: non_rigid_opaques }
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ where
// would be relevant if any of the nested goals refer to the `term`.
// This is not the case here and we only prefer adding an ambiguous
// nested goal for consistency.
ty::TypingMode::Coherence => {
ty::TypingMode::Coherence | ty::TypingMode::CheckObjectOverlap => {
ecx.add_goal(GoalSource::Misc, goal.with(cx, PredicateKind::Ambiguous));
return ecx
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
@@ -280,7 +280,7 @@ where
// would be relevant if any of the nested goals refer to the `term`.
// This is not the case here and we only prefer adding an ambiguous
// nested goal for consistency.
ty::TypingMode::Coherence => {
ty::TypingMode::Coherence | ty::TypingMode::CheckObjectOverlap => {
ecx.add_goal(GoalSource::Misc, goal.with(cx, PredicateKind::Ambiguous));
return ecx
.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ where
let expected = goal.predicate.term.as_type().expect("no such thing as an opaque const");

match self.typing_mode() {
TypingMode::Coherence => {
TypingMode::Coherence | TypingMode::CheckObjectOverlap => {
// An impossible opaque type bound is the only way this goal will fail
// e.g. assigning `impl Copy := NotCopy`
self.add_item_bounds_for_hidden_type(
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/solve/search_graph.rs
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ where
// example where this would matter. We likely should change these cycles to `NoSolution`
// even in coherence once this is a bit more settled.
PathKind::Inductive => match input.typing_mode {
TypingMode::Coherence => {
TypingMode::Coherence | TypingMode::CheckObjectOverlap => {
response_no_constraints(cx, input, Certainty::overflow(false))
}
TypingMode::Analysis { .. }
5 changes: 3 additions & 2 deletions compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ where
// In intercrate mode, this is ambiguous. But outside of intercrate,
// it's not a real impl.
(ty::ImplPolarity::Reservation, _) => match ecx.typing_mode() {
TypingMode::Coherence => Certainty::AMBIGUOUS,
TypingMode::Coherence | TypingMode::CheckObjectOverlap => Certainty::AMBIGUOUS,
TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. }
@@ -1257,7 +1257,7 @@ where
&mut self,
mut candidates: Vec<Candidate<I>>,
) -> Result<(CanonicalResponse<I>, Option<TraitGoalProvenVia>), NoSolution> {
if let TypingMode::Coherence = self.typing_mode() {
if let TypingMode::Coherence | TypingMode::CheckObjectOverlap = self.typing_mode() {
let all_candidates: Vec<_> = candidates.into_iter().map(|c| c.result).collect();
return if let Some(response) = self.try_merge_responses(&all_candidates) {
Ok((response, Some(TraitGoalProvenVia::Misc)))
@@ -1360,6 +1360,7 @@ where
}
}
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::PostAnalysis
| TypingMode::Borrowck { defining_opaque_types: _ }
| TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ } => {}
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ use crate::constructor::{Constructor, ConstructorSet, IntRange};
use crate::pat::DeconstructedPat;

pub trait Captures<'a> {}
impl<'a, T: ?Sized> Captures<'a> for T {}
impl<'a, T> Captures<'a> for T {}

/// `bool` newtype that indicates whether this is a privately uninhabited field that we should skip
/// during analysis.
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
@@ -178,6 +178,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
// get a result which isn't correct for all monomorphizations.
match self.typing_mode() {
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. } => false,
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
@@ -229,6 +229,7 @@ where
defining_opaque_types_and_generators
}
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Borrowck { defining_opaque_types: _ }
| TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ }
| TypingMode::PostAnalysis => return Default::default(),
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/effects.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ pub fn evaluate_host_effect_obligation<'tcx>(
selcx: &mut SelectionContext<'_, 'tcx>,
obligation: &HostEffectObligation<'tcx>,
) -> Result<ThinVec<PredicateObligation<'tcx>>, EvaluationFailure> {
if matches!(selcx.infcx.typing_mode(), TypingMode::Coherence) {
if matches!(selcx.infcx.typing_mode(), TypingMode::Coherence | TypingMode::CheckObjectOverlap) {
span_bug!(
obligation.cause.span,
"should not select host obligation in old solver in intercrate mode"
12 changes: 10 additions & 2 deletions compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
@@ -793,7 +793,11 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
stalled_on: &mut Vec<TyOrConstInferVar>,
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
let infcx = self.selcx.infcx;
if obligation.predicate.is_global() && !matches!(infcx.typing_mode(), TypingMode::Coherence)
if obligation.predicate.is_global()
&& !matches!(
infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
)
{
// no type variables present, can use evaluation for better caching.
// FIXME: consider caching errors too.
@@ -848,7 +852,11 @@ impl<'a, 'tcx> FulfillProcessor<'a, 'tcx> {
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
let tcx = self.selcx.tcx();
let infcx = self.selcx.infcx;
if obligation.predicate.is_global() && !matches!(infcx.typing_mode(), TypingMode::Coherence)
if obligation.predicate.is_global()
&& !matches!(
infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
)
{
// no type variables present, can use evaluation for better caching.
// FIXME: consider caching errors too.
2 changes: 2 additions & 0 deletions compiler/rustc_trait_selection/src/traits/normalize.rs
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ pub(super) fn needs_normalization<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
match infcx.typing_mode() {
// FIXME(#132279): We likely want to reveal opaques during post borrowck analysis
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. } => flags.remove(ty::TypeFlags::HAS_TY_OPAQUE),
@@ -389,6 +390,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
match self.selcx.infcx.typing_mode() {
// FIXME(#132279): We likely want to reveal opaques during post borrowck analysis
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. } => ty.super_fold_with(self),
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
@@ -938,6 +938,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
// get a result which isn't correct for all monomorphizations.
match selcx.infcx.typing_mode() {
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. } => {
Original file line number Diff line number Diff line change
@@ -215,6 +215,7 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
// Only normalize `impl Trait` outside of type inference, usually in codegen.
match self.infcx.typing_mode() {
TypingMode::Coherence
| TypingMode::CheckObjectOverlap
| TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. } => ty.try_super_fold_with(self)?,
Original file line number Diff line number Diff line change
@@ -779,7 +779,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
//
// Note that this is only sound as projection candidates of opaque types
// are always applicable for auto traits.
} else if let TypingMode::Coherence = self.infcx.typing_mode() {
} else if let TypingMode::Coherence | TypingMode::CheckObjectOverlap =
self.infcx.typing_mode()
{
// We do not emit auto trait candidates for opaque types in coherence.
// Doing so can result in weird dependency cycles.
candidates.ambiguous = true;
15 changes: 10 additions & 5 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
@@ -1004,8 +1004,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
previous_stack: TraitObligationStackList<'o, 'tcx>,
mut obligation: PolyTraitObligation<'tcx>,
) -> Result<EvaluationResult, OverflowError> {
if !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
&& obligation.is_global()
if !matches!(
self.infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
) && obligation.is_global()
&& obligation.param_env.caller_bounds().iter().all(|bound| bound.has_param())
{
// If a param env has no global bounds, global obligations do not
@@ -1449,7 +1451,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Result<(), Conflict> {
let obligation = &stack.obligation;
match self.infcx.typing_mode() {
TypingMode::Coherence => {}
TypingMode::Coherence | TypingMode::CheckObjectOverlap => {}
TypingMode::Analysis { .. }
| TypingMode::Borrowck { .. }
| TypingMode::PostBorrowckAnalysis { .. }
@@ -1488,7 +1490,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// the master cache. Since coherence executes pretty quickly,
// it's not worth going to more trouble to increase the
// hit-rate, I don't think.
TypingMode::Coherence => false,
TypingMode::Coherence | TypingMode::CheckObjectOverlap => false,
// Avoid using the global cache when we're defining opaque types
// as their hidden type may impact the result of candidate selection.
//
@@ -2509,7 +2511,10 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
nested_obligations.extend(obligations);

if impl_trait_header.polarity == ty::ImplPolarity::Reservation
&& !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
&& !matches!(
self.infcx.typing_mode(),
TypingMode::Coherence | TypingMode::CheckObjectOverlap
)
{
debug!("reservation impls only apply in intercrate mode");
return Err(());
1 change: 1 addition & 0 deletions compiler/rustc_ty_utils/src/instance.rs
Original file line number Diff line number Diff line change
@@ -156,6 +156,7 @@ fn resolve_associated_item<'tcx>(
// get a result which isn't correct for all monomorphizations.
match typing_env.typing_mode {
ty::TypingMode::Coherence
| ty::TypingMode::CheckObjectOverlap
| ty::TypingMode::Analysis { .. }
| ty::TypingMode::Borrowck { .. }
| ty::TypingMode::PostBorrowckAnalysis { .. } => false,
17 changes: 14 additions & 3 deletions compiler/rustc_type_ir/src/infer_ctxt.rs
Original file line number Diff line number Diff line change
@@ -67,21 +67,27 @@ pub enum TypingMode<I: Interner> {
/// let x: <() as Assoc>::Output = true;
/// }
/// ```
Analysis { defining_opaque_types_and_generators: I::LocalDefIds },
Analysis {
defining_opaque_types_and_generators: I::LocalDefIds,
},
/// The behavior during MIR borrowck is identical to `TypingMode::Analysis`
/// except that the initial value for opaque types is the type computed during
/// HIR typeck with unique unconstrained region inference variables.
///
/// This is currently only used with by the new solver as it results in new
/// non-universal defining uses of opaque types, which is a breaking change.
/// See tests/ui/impl-trait/non-defining-use/as-projection-term.rs.
Borrowck { defining_opaque_types: I::LocalDefIds },
Borrowck {
defining_opaque_types: I::LocalDefIds,
},
/// Any analysis after borrowck for a given body should be able to use all the
/// hidden types defined by borrowck, without being able to define any new ones.
///
/// This is currently only used by the new solver, but should be implemented in
/// the old solver as well.
PostBorrowckAnalysis { defined_opaque_types: I::LocalDefIds },
PostBorrowckAnalysis {
defined_opaque_types: I::LocalDefIds,
},
/// After analysis, mostly during codegen and MIR optimizations, we're able to
/// reveal all opaque types. As the concrete type should *never* be observable
/// directly by the user, this should not be used by checks which may expose
@@ -91,6 +97,11 @@ pub enum TypingMode<I: Interner> {
/// always run in `PostAnalysis` mode, even when used during analysis. This exposes
/// some information about the underlying type to users, but not the type itself.
PostAnalysis,

// Hack modes:

// TODUwU:
CheckObjectOverlap,
}

impl<I: Interner> TypingMode<I> {
11 changes: 10 additions & 1 deletion compiler/rustc_type_ir/src/relate/combine.rs
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ where
// equal to any other type. This is an
// extremely heavy hammer, but can be relaxed in a forwards-compatible
// way later.
TypingMode::Coherence => {
TypingMode::Coherence | TypingMode::CheckObjectOverlap => {
relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]);
Ok(a)
}
@@ -143,6 +143,15 @@ where
}
}

(ty::Dynamic(a_data, _, a_kind), ty::Dynamic(b_data, _, b_kind))
if a_data.principal_def_id() == b_data.principal_def_id()
&& a_kind == b_kind
&& matches!(infcx.typing_mode(), TypingMode::CheckObjectOverlap) =>
{
relation.register_predicates([ty::Binder::dummy(ty::PredicateKind::Ambiguous)]);
Ok(a)
}

_ => structurally_relate_tys(relation, a, b),
}
}
2 changes: 1 addition & 1 deletion library/std/src/io/buffered/bufreader.rs
Original file line number Diff line number Diff line change
@@ -579,7 +579,7 @@ impl<R: ?Sized + Seek> Seek for BufReader<R> {
}
}

impl<T: ?Sized> SizeHint for BufReader<T> {
impl<T> SizeHint for BufReader<T> {
#[inline]
fn lower_bound(&self) -> usize {
SizeHint::lower_bound(self.get_ref()) + self.buffer().len()
2 changes: 1 addition & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -3151,7 +3151,7 @@ trait SizeHint {
}
}

impl<T: ?Sized> SizeHint for T {
impl<T> SizeHint for T {
#[inline]
default fn lower_bound(&self) -> usize {
0
Original file line number Diff line number Diff line change
@@ -21,5 +21,15 @@ LL | fn take(
= note: `Project` would have to be implemented for the type `for<'a> fn(&'a str) -> &'a str`
= note: ...but `Project` is actually implemented for the type `fn(&'0 str) -> &'0 str`, for some specific lifetime `'0`

error: aborting due to 3 previous errors
error: hi
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:23:1
|
LL | trait Discard { type Out; }
| ------------- built-in `dyn Discard<Out = _>` implementation for this trait
LL | impl<T: ?Sized> Discard for T { type Out = (); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 4 previous errors

Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/cant-see-copy-bound-from-child-rigid-2.rs:4:1
|
LL | trait Id {
| -------- built-in `dyn Id<This = _>` implementation for this trait
...
LL | impl<T: ?Sized> Id for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0382]: use of moved value: `x`
--> $DIR/cant-see-copy-bound-from-child-rigid-2.rs:14:9
|
@@ -8,6 +19,6 @@ LL | (x, x)
| |
| value moved here

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0382`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/associated-types-coherence-failure.rs:15:1
|
LL | pub trait IntoCow<'a, B: ?Sized> {
| -------------------------------- built-in `dyn IntoCow<'_, _>` implementation for this trait
...
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
--> $DIR/associated-types-coherence-failure.rs:21:1
|
@@ -16,6 +27,6 @@ LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwn
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned`

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0119`.
12 changes: 6 additions & 6 deletions tests/ui/borrowck/ice-mutability-error-slicing-121807.stderr
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@ LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
= note: `#[warn(anonymous_parameters)]` on by default

error[E0220]: associated type `Assoc` not found for `Self`
--> $DIR/ice-mutability-error-slicing-121807.rs:7:36
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^ associated type `Assoc` not found

error[E0185]: method `read_dword` has a `&self` declaration in the impl, but not in the trait
--> $DIR/ice-mutability-error-slicing-121807.rs:17:5
|
@@ -41,12 +47,6 @@ LL | extern "C" fn read_word(&mut self) -> u8;
LL | impl MemoryUnit for ROM {
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `read_word` in implementation

error[E0220]: associated type `Assoc` not found for `Self`
--> $DIR/ice-mutability-error-slicing-121807.rs:7:36
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^ associated type `Assoc` not found

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0185, E0220, E0261.
12 changes: 6 additions & 6 deletions tests/ui/borrowck/trait-impl-argument-difference-ice.stderr
Original file line number Diff line number Diff line change
@@ -8,6 +8,12 @@ LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
= note: `#[warn(anonymous_parameters)]` on by default

error[E0220]: associated type `Assoc` not found for `Self`
--> $DIR/trait-impl-argument-difference-ice.rs:4:36
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^ associated type `Assoc` not found

error[E0185]: method `read_dword` has a `&self` declaration in the impl, but not in the trait
--> $DIR/trait-impl-argument-difference-ice.rs:14:5
|
@@ -26,12 +32,6 @@ LL | extern "C" fn read_word(&mut self) -> u8;
LL | impl MemoryUnit for ROM {
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `read_word` in implementation

error[E0220]: associated type `Assoc` not found for `Self`
--> $DIR/trait-impl-argument-difference-ice.rs:4:36
|
LL | extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
| ^^^^^ associated type `Assoc` not found

error[E0596]: cannot borrow `*self` as mutable, as it is behind a `&` reference
--> $DIR/trait-impl-argument-difference-ice.rs:16:19
|
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:14:1
|
LL | trait Id {
| -------- built-in `dyn Id<Id = _>` implementation for this trait
...
LL | impl<T: ?Sized> Id for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
|
@@ -11,5 +22,5 @@ LL | let _send = unsend as *const S<dyn Cat<'static>>;
= note: the struct `S<T>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:14:1
|
LL | trait Id {
| -------- built-in `dyn Id<Id = _>` implementation for this trait
...
LL | impl<T: ?Sized> Id for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:24:27
|
@@ -11,5 +22,5 @@ LL | let _send = unsend as *const S<dyn Cat<'static>>;
= note: the struct `S<T>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

13 changes: 12 additions & 1 deletion tests/ui/coherence/coherence-error-suppression.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0412]: cannot find type `DoesNotExist` in this scope
LL | impl Foo for DoesNotExist {}
| ^^^^^^^^^^^^ not found in this scope

error: aborting due to 1 previous error
error: hi
--> $DIR/coherence-error-suppression.rs:9:1
|
LL | trait Foo {}
| --------- built-in `dyn Foo` implementation for this trait
...
LL | impl Foo for DoesNotExist {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
@@ -58,6 +58,16 @@ error[E0321]: cross-crate traits with a default impl, like `Send`, can only be i
LL | impl !Send for dyn Object + Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type

error: hi
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:32:1
|
LL | auto trait Marker3 {}
| ------------------ built-in `dyn Marker3` implementation for this trait
LL | impl<T: ?Sized> !Marker3 for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0321]: traits with a default impl, like `Marker3`, cannot be implemented for generic type `T`
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:32:1
|
@@ -66,7 +76,7 @@ LL | impl<T: ?Sized> !Marker3 for T {}
|
= note: a trait object implements `Marker3` if and only if `Marker3` is one of the trait object's trait bounds

error: aborting due to 9 previous errors
error: aborting due to 10 previous errors

Some errors have detailed explanations: E0117, E0321, E0371.
For more information about an error, try `rustc --explain E0117`.
Original file line number Diff line number Diff line change
@@ -58,6 +58,16 @@ error[E0321]: cross-crate traits with a default impl, like `Send`, can only be i
LL | unsafe impl Send for dyn Object + Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type

error: hi
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:32:1
|
LL | auto trait Marker3 {}
| ------------------ built-in `dyn Marker3` implementation for this trait
LL | impl<T: ?Sized> Marker3 for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0321]: traits with a default impl, like `Marker3`, cannot be implemented for generic type `T`
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:32:1
|
@@ -66,7 +76,7 @@ LL | impl<T: ?Sized> Marker3 for T {}
|
= note: a trait object implements `Marker3` if and only if `Marker3` is one of the trait object's trait bounds

error: aborting due to 9 previous errors
error: aborting due to 10 previous errors

Some errors have detailed explanations: E0117, E0321, E0371.
For more information about an error, try `rustc --explain E0117`.
13 changes: 12 additions & 1 deletion tests/ui/coherence/coherence-impl-trait-for-trait.stderr
Original file line number Diff line number Diff line change
@@ -10,12 +10,23 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the
LL | impl Bar for dyn Baz { }
| ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar`

error: hi
--> $DIR/coherence-impl-trait-for-trait.rs:13:1
|
LL | trait Baz: Bar { }
| -------------- built-in `dyn Baz` implementation for this trait
...
LL | impl Baz for dyn Baz { }
| ^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz`
--> $DIR/coherence-impl-trait-for-trait.rs:13:1
|
LL | impl Baz for dyn Baz { }
| ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz`

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0371`.
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
error: hi
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:15:1
|
LL | trait Object<U> {
| --------------- built-in `dyn Object<_, Output = _>` implementation for this trait
...
LL | impl<T: ?Sized, U> Object<U> for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0284]: type annotations needed: cannot normalize `<dyn Object<U, Output = T> as Object<U>>::Output`
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41
|
LL | foo::<dyn Object<U, Output = T>, U>(x)
| ^ cannot normalize `<dyn Object<U, Output = T> as Object<U>>::Output`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0284`.
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details

WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?3t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
error[E0284]: type annotations needed: cannot normalize `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc`
--> $DIR/associated-type.rs:45:59
|
1 change: 1 addition & 0 deletions tests/ui/coherence/occurs-check/associated-type.old.stderr
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details

WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?3t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
error: hi
--> $DIR/forbid-self-no-normalize.rs:4:1
|
LL | trait AlwaysApplicable {
| ---------------------- built-in `dyn AlwaysApplicable<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> AlwaysApplicable for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: hi
--> $DIR/forbid-self-no-normalize.rs:11:1
|
LL | trait BindsParam<T> {
| ------------------- built-in `dyn BindsParam<_, ArrayTy = _>` implementation for this trait
...
LL | impl<T> BindsParam<T> for <T as AlwaysApplicable>::Assoc {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: generic `Self` types are currently not permitted in anonymous constants
--> $DIR/forbid-self-no-normalize.rs:12:25
|
@@ -10,5 +30,5 @@ note: not a concrete type
LL | impl<T> BindsParam<T> for <T as AlwaysApplicable>::Assoc {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
error: aborting due to 3 previous errors

13 changes: 12 additions & 1 deletion tests/ui/const-generics/wrong-normalization.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/wrong-normalization.rs:10:1
|
LL | pub trait Identity {
| ------------------ built-in `dyn Identity<Identity = _>` implementation for this trait
...
LL | impl<T: ?Sized> Identity for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0118]: no nominal type found for inherent implementation
--> $DIR/wrong-normalization.rs:16:1
|
@@ -6,6 +17,6 @@ LL | impl <I8<{i8::MIN}> as Identity>::Identity {
|
= note: either implement a trait on it or create a newtype to wrap it instead

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0118`.
13 changes: 12 additions & 1 deletion tests/ui/dropck/drop-on-non-struct.stderr
Original file line number Diff line number Diff line change
@@ -22,7 +22,18 @@ error[E0120]: the `Drop` trait may only be implemented for local structs, enums,
LL | impl<'a> Drop for &'a mut isize {
| ^^^^^^^^^^^^^ must be a struct, enum, or union in the current crate

error: aborting due to 3 previous errors
error: hi
--> $DIR/drop-on-non-struct.rs:9:1
|
LL | impl Drop for Nonexistent {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/ops/drop.rs:LL:COL
|
= note: built-in `dyn Drop` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0117, E0120, E0412.
For more information about an error, try `rustc --explain E0117`.
Original file line number Diff line number Diff line change
@@ -15,6 +15,17 @@ LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
= help: consider moving `transmute` to another trait

error: hi
--> $DIR/almost-supertrait-associated-type.rs:39:1
|
LL | trait Mirror {
| ------------ built-in `dyn Mirror<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> Mirror for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/almost-supertrait-associated-type.rs:7:27
|
@@ -50,6 +61,6 @@ LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
= help: consider moving `transmute` to another trait
= note: required for the cast from `&PhantomData<T>` to `&dyn Foo<T, U>`

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0038`.
1 change: 1 addition & 0 deletions tests/ui/higher-ranked/structually-relate-aliases.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?2t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied
--> $DIR/structually-relate-aliases.rs:13:36
|
13 changes: 12 additions & 1 deletion tests/ui/impl-trait/where-allowed.stderr
Original file line number Diff line number Diff line change
@@ -378,6 +378,17 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
= note: `#[deny(invalid_type_param_default)]` on by default

error: hi
--> $DIR/where-allowed.rs:172:1
|
LL | impl PartialEq<()> for impl Debug {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: built-in `dyn PartialEq<()>` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
--> $DIR/where-allowed.rs:239:7
|
@@ -431,7 +442,7 @@ LL | type InTypeAlias<R> = impl Debug;
|
= note: `InTypeAlias` must be used in combination with a concrete type within the same crate

error: aborting due to 50 previous errors
error: aborting due to 51 previous errors

Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0658, E0666.
For more information about an error, try `rustc --explain E0053`.
13 changes: 12 additions & 1 deletion tests/ui/issues/issue-20939.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
error: hi
--> $DIR/issue-20939.rs:3:1
|
LL | trait Foo {}
| --------- built-in `dyn Foo` implementation for this trait
LL |
LL | impl<'a> Foo for dyn Foo + 'a {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0371]: the object type `(dyn Foo + 'a)` automatically implements the trait `Foo`
--> $DIR/issue-20939.rs:3:1
|
LL | impl<'a> Foo for dyn Foo + 'a {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0371`.
13 changes: 12 additions & 1 deletion tests/ui/issues/issue-30589.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0412]: cannot find type `DecoderError` in this scope
LL | impl fmt::Display for DecoderError {
| ^^^^^^^^^^^^ not found in this scope

error: aborting due to 1 previous error
error: hi
--> $DIR/issue-30589.rs:3:1
|
LL | impl fmt::Display for DecoderError {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: built-in `dyn std::fmt::Display` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
13 changes: 12 additions & 1 deletion tests/ui/issues/issue-36836.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0412]: cannot find type `Bar` in this scope
LL | impl<T> Foo for Bar<T> {}
| ^^^ not found in this scope

error: aborting due to 1 previous error
error: hi
--> $DIR/issue-36836.rs:13:1
|
LL | trait Foo {}
| --------- built-in `dyn Foo` implementation for this trait
LL |
LL | impl<T> Foo for Bar<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
12 changes: 11 additions & 1 deletion tests/ui/lazy-type-alias/unconstrained-params-in-impl.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,16 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
LL | impl<T> NotInjective<T> {}
| ^ unconstrained type parameter

error: aborting due to 1 previous error
error: hi
--> $DIR/unconstrained-params-in-impl.rs:10:1
|
LL | trait Discard { type Out; }
| ------------- built-in `dyn Discard<Out = _>` implementation for this trait
LL | impl<T: ?Sized> Discard for T { type Out = (); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0207`.
13 changes: 12 additions & 1 deletion tests/ui/lint/lint-ctypes-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/lint-ctypes-fn.rs:12:1
|
LL | trait Mirror { type It: ?Sized; }
| ------------ built-in `dyn Mirror<It = _>` implementation for this trait
LL |
LL | impl<T: ?Sized> Mirror for T { type It = Self; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: `extern` fn uses type `[u32]`, which is not FFI-safe
--> $DIR/lint-ctypes-fn.rs:70:33
|
@@ -184,5 +195,5 @@ LL | pub extern "C" fn used_generic5<T>() -> Vec<T> {
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout

error: aborting due to 20 previous errors
error: aborting due to 21 previous errors

12 changes: 11 additions & 1 deletion tests/ui/lint/lint-ctypes.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
error: hi
--> $DIR/lint-ctypes.rs:12:1
|
LL | trait Mirror { type It: ?Sized; }
| ------------ built-in `dyn Mirror<It = _>` implementation for this trait
LL | impl<T: ?Sized> Mirror for T { type It = Self; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: `extern` block uses type `Foo`, which is not FFI-safe
--> $DIR/lint-ctypes.rs:47:28
|
@@ -258,5 +268,5 @@ LL | pub static static_u128_array_type: [u128; 16];
|
= note: 128-bit integers don't currently have a known stable ABI

error: aborting due to 27 previous errors
error: aborting due to 28 previous errors

12 changes: 11 additions & 1 deletion tests/ui/lint/recommend-literal.stderr
Original file line number Diff line number Diff line change
@@ -94,6 +94,16 @@ LL | impl Stuff for short {}
| not found in this scope
| help: perhaps you intended to use this type: `i16`

error: aborting due to 9 previous errors
error: hi
--> $DIR/recommend-literal.rs:40:1
|
LL | trait Stuff {}
| ----------- built-in `dyn Stuff` implementation for this trait
LL | impl Stuff for short {}
| ^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0412`.
13 changes: 12 additions & 1 deletion tests/ui/lint/unaligned_references.current.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/unaligned_references.rs:62:5
|
LL | trait Mirror {
| ------------ built-in `dyn Mirror<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> Mirror for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0793]: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:32:13
|
@@ -128,6 +139,6 @@ LL | let _ref = &m2.1.a;
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

error: aborting due to 13 previous errors
error: aborting due to 14 previous errors

For more information about this error, try `rustc --explain E0793`.
13 changes: 12 additions & 1 deletion tests/ui/lint/unaligned_references.next.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/unaligned_references.rs:62:5
|
LL | trait Mirror {
| ------------ built-in `dyn Mirror<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> Mirror for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0793]: reference to packed field is unaligned
--> $DIR/unaligned_references.rs:32:13
|
@@ -128,6 +139,6 @@ LL | let _ref = &m2.1.a;
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)

error: aborting due to 13 previous errors
error: aborting due to 14 previous errors

For more information about this error, try `rustc --explain E0793`.
Original file line number Diff line number Diff line change
@@ -7,6 +7,17 @@ LL | #![feature(unsized_locals, unsized_fn_params)]
= note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information
= note: `#[warn(incomplete_features)]` on by default

error: hi
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:73:5
|
LL | pub trait NuisanceFoo {
| --------------------- built-in `dyn NuisanceFoo` implementation for this trait
...
LL | impl<T: ?Sized> NuisanceFoo for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0308]: mismatched types
--> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:89:24
|
@@ -84,7 +95,7 @@ LL | let _seetype: () = z;
| |
| expected due to this

error: aborting due to 6 previous errors; 1 warning emitted
error: aborting due to 7 previous errors; 1 warning emitted

Some errors have detailed explanations: E0034, E0308.
For more information about an error, try `rustc --explain E0034`.
13 changes: 12 additions & 1 deletion tests/ui/mir/ice-mir-const-qualif-125837.stderr
Original file line number Diff line number Diff line change
@@ -24,6 +24,17 @@ help: add missing generic argument
LL | impl<Item, D: Debug + Clone> Foo<Item> for D {
| ++++++

error: hi
--> $DIR/ice-mir-const-qualif-125837.rs:8:1
|
LL | trait Foo<Item> {}
| --------------- built-in `dyn Foo<{type error}>` implementation for this trait
LL |
LL | impl<Item, D: Debug + Clone> Foo for D {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0572]: return statement outside of function body
--> $DIR/ice-mir-const-qualif-125837.rs:12:17
|
@@ -35,7 +46,7 @@ LL | |
LL | | }
| |_____- ...not the enclosing function body

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0407, E0572.
For more information about an error, try `rustc --explain E0107`.
13 changes: 12 additions & 1 deletion tests/ui/mir/validate/validate-unsize-cast.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/validate-unsize-cast.rs:10:1
|
LL | pub trait CastTo<U: ?Sized>: Unsize<U> {}
| -------------------------------------- built-in `dyn CastTo<_>` implementation for this trait
...
LL | impl<T: ?Sized, U: ?Sized> CastTo<U> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the trait bound `T: Unsize<U>` is not satisfied
--> $DIR/validate-unsize-cast.rs:10:42
|
@@ -15,6 +26,6 @@ help: consider further restricting type parameter `T` with unstable trait `Unsiz
LL | impl<T: ?Sized + std::marker::Unsize<U>, U: ?Sized> CastTo<U> for T {}
| ++++++++++++++++++++++++

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
error: hi
--> $DIR/issue-111220-2-tuple-struct-fields-projection.rs:22:1
|
LL | trait Trait<T> {
| -------------- built-in `dyn Trait<_>` implementation for this trait
...
LL | impl<T: Id> Trait<T> for <T as Id>::Assoc {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0603]: tuple struct constructor `A` is private
--> $DIR/issue-111220-2-tuple-struct-fields-projection.rs:27:13
|
LL | let Self(a) = self;
| ^^^^^^^

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0603`.
13 changes: 12 additions & 1 deletion tests/ui/recursion/issue-26548-recursion-via-normalize.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/issue-26548-recursion-via-normalize.rs:11:1
|
LL | trait Mirror {
| ------------ built-in `dyn Mirror<It = _>` implementation for this trait
...
LL | impl<T: ?Sized> Mirror for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0391]: cycle detected when computing layout of `core::option::Option<S>`
|
= note: ...which requires computing layout of `S`...
@@ -6,6 +17,6 @@ error[E0391]: cycle detected when computing layout of `core::option::Option<S>`
= note: cycle used when computing layout of `core::option::Option<<S as Mirror>::It>`
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0391`.
12 changes: 11 additions & 1 deletion tests/ui/repr/repr-transparent.stderr
Original file line number Diff line number Diff line change
@@ -7,6 +7,16 @@ LL | struct MultipleNonZst(u8, u8);
| | this field has non-zero size or requires alignment
| needs at most one field with non-trivial size or alignment, but has 2

error: hi
--> $DIR/repr-transparent.rs:29:1
|
LL | trait Mirror { type It: ?Sized; }
| ------------ built-in `dyn Mirror<It = _>` implementation for this trait
LL | impl<T: ?Sized> Mirror for T { type It = Self; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0690]: transparent struct needs at most one field with non-trivial size or alignment, but has 2
--> $DIR/repr-transparent.rs:32:1
|
@@ -98,7 +108,7 @@ LL | u: u32,
LL | s: i32
| ------ this field has non-zero size or requires alignment

error: aborting due to 11 previous errors
error: aborting due to 12 previous errors

Some errors have detailed explanations: E0084, E0690, E0731.
For more information about an error, try `rustc --explain E0084`.
15 changes: 14 additions & 1 deletion tests/ui/resolve/dont-compute-arg-names-for-non-fn.stderr
Original file line number Diff line number Diff line change
@@ -9,6 +9,19 @@ help: you might have meant to use the associated type
LL | impl Foo for Self::Bar {}
| ++++++

error: aborting due to 1 previous error
error: hi
--> $DIR/dont-compute-arg-names-for-non-fn.rs:8:1
|
LL | impl Foo for Bar {}
| ^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
::: $DIR/auxiliary/foreign-trait-with-assoc.rs:1:1
|
LL | pub trait Foo {
| ------------- built-in `dyn Foo<Bar = _>` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
13 changes: 12 additions & 1 deletion tests/ui/resolve/issue-3214.stderr
Original file line number Diff line number Diff line change
@@ -22,7 +22,18 @@ note: struct defined here, with 0 generic parameters
LL | struct Foo {
| ^^^

error: aborting due to 2 previous errors
error: hi
--> $DIR/issue-3214.rs:6:5
|
LL | impl<T> Drop for Foo<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/ops/drop.rs:LL:COL
|
= note: built-in `dyn Drop` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0107, E0401.
For more information about an error, try `rustc --explain E0107`.
22 changes: 21 additions & 1 deletion tests/ui/resolve/resolve-self-in-impl.stderr
Original file line number Diff line number Diff line change
@@ -28,6 +28,26 @@ LL | trait Tr<T = u8> {
| ^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: hi
--> $DIR/resolve-self-in-impl.rs:14:1
|
LL | trait Tr<T = u8> {
| ---------------- built-in `dyn Tr<{type error}, A = _>` implementation for this trait
...
LL | impl Tr for Self {}
| ^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: hi
--> $DIR/resolve-self-in-impl.rs:15:1
|
LL | trait Tr<T = u8> {
| ---------------- built-in `dyn Tr<{type error}, A = _>` implementation for this trait
...
LL | impl Tr for S<Self> {}
| ^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: `Self` is not valid in the self type of an impl block
--> $DIR/resolve-self-in-impl.rs:16:6
|
@@ -52,6 +72,6 @@ LL | impl (Self, Self) {}
|
= note: replace `Self` with a different type

error: aborting due to 6 previous errors
error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
@@ -8,6 +8,17 @@ LL | #![feature(specialization)]
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default

error: hi
--> $DIR/default-item-normalization-ambig-1.rs:19:1
|
LL | trait Y {
| ------- built-in `dyn Y` implementation for this trait
...
LL | impl Y for <() as X>::U {}
| ^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0119]: conflicting implementations of trait `Y` for type `<() as X>::U`
--> $DIR/default-item-normalization-ambig-1.rs:20:1
|
@@ -16,6 +27,15 @@ LL | impl Y for <() as X>::U {}
LL | impl Y for <i32 as X>::U {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<() as X>::U`

error: aborting due to 1 previous error; 1 warning emitted
error: hi
--> $DIR/default-item-normalization-ambig-1.rs:20:1
|
LL | trait Y {
| ------- built-in `dyn Y` implementation for this trait
...
LL | impl Y for <i32 as X>::U {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: aborting due to 3 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0119`.
13 changes: 12 additions & 1 deletion tests/ui/specialization/issue-51892.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/issue-51892.rs:9:1
|
LL | pub trait Trait {
| --------------- built-in `dyn Trait<Type = _>` implementation for this trait
...
LL | impl<T: ?Sized> Trait for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: unconstrained generic constant
--> $DIR/issue-51892.rs:14:17
|
@@ -9,5 +20,5 @@ help: try adding a `where` bound
LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()] where [(); std::mem::size_of::<<T as Trait>::Type>()]:;
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

Original file line number Diff line number Diff line change
@@ -4,6 +4,16 @@ error[E0412]: cannot find type `NonExistent` in this scope
LL | impl Trait for NonExistent {}
| ^^^^^^^^^^^ not found in this scope

error: aborting due to 1 previous error
error: hi
--> $DIR/impl-on-nonexisting.rs:4:1
|
LL | trait Trait {}
| ----------- built-in `dyn Trait` implementation for this trait
LL | impl Trait for NonExistent {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0412`.
Original file line number Diff line number Diff line change
@@ -7,6 +7,17 @@ LL | impl Overlap for u32 {
LL | impl Overlap for <u32 as Default>::Id {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`

error: aborting due to 1 previous error
error: hi
--> $DIR/specialization-default-items-drop-coherence.rs:26:1
|
LL | trait Overlap {
| ------------- built-in `dyn Overlap<Assoc = _>` implementation for this trait
...
LL | impl Overlap for <u32 as Default>::Id {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
@@ -7,6 +7,17 @@ LL | impl Overlap for u32 {
LL | impl Overlap for <u32 as Default>::Id {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`

error: aborting due to 1 previous error
error: hi
--> $DIR/specialization-default-items-drop-coherence.rs:26:1
|
LL | trait Overlap {
| ------------- built-in `dyn Overlap<Assoc = _>` implementation for this trait
...
LL | impl Overlap for <u32 as Default>::Id {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0119`.
22 changes: 21 additions & 1 deletion tests/ui/specialization/specialization-overlap-projection.stderr
Original file line number Diff line number Diff line change
@@ -25,6 +25,26 @@ LL | impl Foo for u32 {}
LL | impl Foo for <u16 as Assoc>::Output {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`

error: aborting due to 2 previous errors; 1 warning emitted
error: hi
--> $DIR/specialization-overlap-projection.rs:20:1
|
LL | trait Foo {}
| --------- built-in `dyn Foo` implementation for this trait
LL | impl Foo for u32 {}
LL | impl Foo for <u8 as Assoc>::Output {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: hi
--> $DIR/specialization-overlap-projection.rs:22:1
|
LL | trait Foo {}
| --------- built-in `dyn Foo` implementation for this trait
...
LL | impl Foo for <u16 as Assoc>::Output {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0119`.
12 changes: 11 additions & 1 deletion tests/ui/suggestions/box-future-wrong-output.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
error: hi
--> $DIR/box-future-wrong-output.rs:9:1
|
LL | impl<T: ?Sized> FutureExt for T where T: Future {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
LL | trait FutureExt: Future {
| ----------------------- built-in `dyn FutureExt<Output = _>` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0308]: mismatched types
--> $DIR/box-future-wrong-output.rs:20:39
|
@@ -9,6 +19,6 @@ LL | let _: BoxFuture<'static, bool> = async {}.boxed();
= note: expected struct `Pin<Box<(dyn Future<Output = bool> + Send + 'static)>>`
found struct `Pin<Box<dyn Future<Output = ()> + Send>>`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
67 changes: 66 additions & 1 deletion tests/ui/suggestions/suggest-blanket-impl-local-trait.stderr
Original file line number Diff line number Diff line change
@@ -62,6 +62,17 @@ LL - impl<E> GenericTrait<E> for LocalTraitOne {}
LL + impl<E, T: LocalTraitOne> GenericTrait<E> for T {}
|

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:13:1
|
LL | trait LocalTraitTwo { }
| ------------------- built-in `dyn LocalTraitTwo` implementation for this trait
...
LL | impl LocalTraitTwo for LocalTraitOne {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0782]: expected a type, found a trait
--> $DIR/suggest-blanket-impl-local-trait.rs:18:23
|
@@ -73,6 +84,15 @@ help: you can add the `dyn` keyword if you want a trait object
LL | impl fmt::Display for dyn LocalTraitOne {
| +++

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:18:1
|
LL | impl fmt::Display for LocalTraitOne {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: built-in `dyn std::fmt::Display` implementation for this trait

error[E0782]: expected a type, found a trait
--> $DIR/suggest-blanket-impl-local-trait.rs:26:23
|
@@ -84,6 +104,42 @@ help: you can add the `dyn` keyword if you want a trait object
LL | impl fmt::Display for dyn LocalTraitTwo + Send {
| +++

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:26:1
|
LL | impl fmt::Display for LocalTraitTwo + Send {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: built-in `dyn std::fmt::Display` implementation for this trait

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:34:1
|
LL | trait LocalTraitOne { }
| ------------------- built-in `dyn LocalTraitOne` implementation for this trait
...
LL | impl LocalTraitOne for fmt::Display {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:40:1
|
LL | trait LocalTraitOne { }
| ------------------- built-in `dyn LocalTraitOne` implementation for this trait
...
LL | impl LocalTraitOne for fmt::Display + Send {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:46:1
|
LL | trait GenericTrait<T> {}
| --------------------- built-in `dyn GenericTrait<_>` implementation for this trait
...
LL | impl<E> GenericTrait<E> for LocalTraitOne {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error[E0782]: expected a type, found a trait
--> $DIR/suggest-blanket-impl-local-trait.rs:53:35
|
@@ -100,6 +156,15 @@ LL - impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
LL + impl<T, E, U: GenericTrait<T>> GenericTraitTwo<E> for U {}
|

error: aborting due to 7 previous errors
error: hi
--> $DIR/suggest-blanket-impl-local-trait.rs:53:1
|
LL | trait GenericTraitTwo<T> {}
| ------------------------ built-in `dyn GenericTraitTwo<_>` implementation for this trait
LL |
LL | impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: aborting due to 14 previous errors

For more information about this error, try `rustc --explain E0782`.
Original file line number Diff line number Diff line change
@@ -127,7 +127,17 @@ note: struct defined here, with 1 generic parameter: `T`
LL | struct Struct<T: Trait<u32, String>> {
| ^^^^^^ -

error: aborting due to 9 previous errors
error: hi
--> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:40:1
|
LL | trait YetAnotherTrait {}
| --------------------- built-in `dyn YetAnotherTrait` implementation for this trait
LL | impl<T: Trait<u32, Assoc=String>, U> YetAnotherTrait for Struct<T, U> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0107, E0207.
For more information about an error, try `rustc --explain E0107`.
13 changes: 12 additions & 1 deletion tests/ui/traits/deny-builtin-object-impl.current.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0322]: explicit impls for the `NotImplYesObject` trait are not permitted
LL | impl NotImplYesObject for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `NotImplYesObject` not allowed

error: hi
--> $DIR/deny-builtin-object-impl.rs:24:1
|
LL | trait YesImplNotObject2 {}
| ----------------------- built-in `dyn YesImplNotObject2` implementation for this trait
...
LL | impl YesImplNotObject2 for dyn YesImplNotObject2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the trait bound `dyn NotImplNotObject: NotImplNotObject` is not satisfied
--> $DIR/deny-builtin-object-impl.rs:37:32
|
@@ -38,7 +49,7 @@ note: required by a bound in `test_yes_impl_not_object`
LL | fn test_yes_impl_not_object<T: YesImplNotObject + ?Sized>() {}
| ^^^^^^^^^^^^^^^^ required by this bound in `test_yes_impl_not_object`

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0322.
For more information about an error, try `rustc --explain E0277`.
13 changes: 12 additions & 1 deletion tests/ui/traits/deny-builtin-object-impl.next.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0322]: explicit impls for the `NotImplYesObject` trait are not permitted
LL | impl NotImplYesObject for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `NotImplYesObject` not allowed

error: hi
--> $DIR/deny-builtin-object-impl.rs:24:1
|
LL | trait YesImplNotObject2 {}
| ----------------------- built-in `dyn YesImplNotObject2` implementation for this trait
...
LL | impl YesImplNotObject2 for dyn YesImplNotObject2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the trait bound `dyn NotImplNotObject: NotImplNotObject` is not satisfied
--> $DIR/deny-builtin-object-impl.rs:37:32
|
@@ -38,7 +49,7 @@ note: required by a bound in `test_yes_impl_not_object`
LL | fn test_yes_impl_not_object<T: YesImplNotObject + ?Sized>() {}
| ^^^^^^^^^^^^^^^^ required by this bound in `test_yes_impl_not_object`

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0322.
For more information about an error, try `rustc --explain E0277`.
13 changes: 12 additions & 1 deletion tests/ui/traits/impl-for-module.stderr
Original file line number Diff line number Diff line change
@@ -7,6 +7,17 @@ LL | trait A {
LL | impl A for a {
| ^ help: a trait with a similar name exists: `A`

error: aborting due to 1 previous error
error: hi
--> $DIR/impl-for-module.rs:7:1
|
LL | trait A {
| ------- built-in `dyn A` implementation for this trait
...
LL | impl A for a {
| ^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0573`.
13 changes: 12 additions & 1 deletion tests/ui/traits/issue-33140-hack-boundaries.stderr
Original file line number Diff line number Diff line change
@@ -30,6 +30,17 @@ LL | impl Trait3<dyn Sync> for dyn Send {}
LL | impl Trait3<dyn Sync> for dyn Send {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)`

error: hi
--> $DIR/issue-33140-hack-boundaries.rs:38:1
|
LL | trait Trait4a {}
| ------------- built-in `dyn Trait4a` implementation for this trait
LL |
LL | impl<T: ?Sized> Trait4a for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0119]: conflicting implementations of trait `Trait4a` for type `(dyn Send + 'static)`
--> $DIR/issue-33140-hack-boundaries.rs:39:1
|
@@ -70,7 +81,7 @@ LL | impl Trait5 for dyn Send {}
LL | impl Trait5 for dyn Send where u32: Copy {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Send + 'static)`

error: aborting due to 9 previous errors
error: aborting due to 10 previous errors

Some errors have detailed explanations: E0119, E0751.
For more information about an error, try `rustc --explain E0119`.
13 changes: 12 additions & 1 deletion tests/ui/traits/issue-78372.stderr
Original file line number Diff line number Diff line change
@@ -56,6 +56,17 @@ LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
= help: add `#![feature(dispatch_from_dyn)]` 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: hi
--> $DIR/issue-78372.rs:3:1
|
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
--> $SRC_DIR/core/src/ops/unsize.rs:LL:COL
|
= note: built-in `dyn DispatchFromDyn<Smaht<{type error}, {type error}>>` implementation for this trait
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0307]: invalid `self` parameter type: `Smaht<Self, T>`
--> $DIR/issue-78372.rs:9:18
|
@@ -71,7 +82,7 @@ error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 7 previous errors
error: aborting due to 8 previous errors

Some errors have detailed explanations: E0307, E0377, E0412, E0658.
For more information about an error, try `rustc --explain E0307`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/alias_eq_substs_eq_not_intercrate.rs:13:1
|
LL | trait Overlaps<T> {}
| ----------------- built-in `dyn Overlaps<Box<_>>` implementation for this trait
LL |
LL | impl<T: TraitB> Overlaps<Box<T>> for <T as TraitB>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0119]: conflicting implementations of trait `Overlaps<Box<_>>` for type `<_ as TraitB>::Assoc`
--> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1
|
@@ -8,6 +19,15 @@ LL | impl<U: TraitB> Overlaps<U> for <U as TraitB>::Assoc {}
|
= note: downstream crates may implement trait `TraitB` for type `std::boxed::Box<_>`

error: aborting due to 1 previous error
error: hi
--> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1
|
LL | trait Overlaps<T> {}
| ----------------- built-in `dyn Overlaps<_>` implementation for this trait
...
LL | impl<U: TraitB> Overlaps<U> for <U as TraitB>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
@@ -10,6 +10,17 @@ LL | impl Trait for <LocalTy as Overflow>::Assoc {}
= note: overflow evaluating the requirement `_ == <LocalTy as Overflow>::Assoc`
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_ref_is_knowable_norm_overflow`)

error: aborting due to 1 previous error
error: hi
--> $DIR/trait_ref_is_knowable-norm-overflow.rs:20:1
|
LL | trait Trait {}
| ----------- built-in `dyn Trait` implementation for this trait
...
LL | impl Trait for <LocalTy as Overflow>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0119`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
error: hi
--> $DIR/incompleteness-unstable-result.rs:25:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, u8>` implementation for this trait
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: hi
--> $DIR/incompleteness-unstable-result.rs:26:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, i8>` implementation for this trait
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:27:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, i16>` implementation for this trait
...
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i16> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:30:1
|
LL | trait ImplGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------- built-in `dyn ImplGuidance<u32, u8>` implementation for this trait
LL | impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:31:1
|
LL | trait ImplGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------- built-in `dyn ImplGuidance<i32, i8>` implementation for this trait
LL | impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
LL | impl<T: ?Sized> ImplGuidance<i32, i8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied
--> $DIR/incompleteness-unstable-result.rs:65:19
|
@@ -21,6 +66,6 @@ note: required by a bound in `impls_trait`
LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`

error: aborting due to 1 previous error
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
error: hi
--> $DIR/incompleteness-unstable-result.rs:25:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, u8>` implementation for this trait
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error: hi
--> $DIR/incompleteness-unstable-result.rs:26:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, i8>` implementation for this trait
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {}
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:27:1
|
LL | trait IncompleteGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------------- built-in `dyn IncompleteGuidance<_, i16>` implementation for this trait
...
LL | impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i16> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:30:1
|
LL | trait ImplGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------- built-in `dyn ImplGuidance<u32, u8>` implementation for this trait
LL | impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error: hi
--> $DIR/incompleteness-unstable-result.rs:31:1
|
LL | trait ImplGuidance<T: ?Sized, V: ?Sized> {}
| ---------------------------------------- built-in `dyn ImplGuidance<i32, i8>` implementation for this trait
LL | impl<T: ?Sized> ImplGuidance<u32, u8> for T {}
LL | impl<T: ?Sized> ImplGuidance<i32, i8> for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl

error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied
--> $DIR/incompleteness-unstable-result.rs:65:19
|
@@ -21,6 +66,6 @@ note: required by a bound in `impls_trait`
LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {}
| ^^^^^^^^^^^^^^ required by this bound in `impls_trait`

error: aborting due to 1 previous error
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ LL | trait ToUnit<'a> {
| ^^^^^^^^^^^^^^^^

WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. }
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?2t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. }
error[E0277]: the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied
--> $DIR/issue-118950-root-region.rs:19:9
|
13 changes: 12 additions & 1 deletion tests/ui/traits/object/with-self-in-projection-output-bad.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/with-self-in-projection-output-bad.rs:27:1
|
LL | trait ConstI32 {
| -------------- built-in `dyn ConstI32<Out = _>` implementation for this trait
...
LL | impl<T: ?Sized> ConstI32 for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0191]: the value of the associated type `Output` in `Base` must be specified
--> $DIR/with-self-in-projection-output-bad.rs:45:21
|
@@ -16,6 +27,6 @@ LL | type Output;
LL | let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper<Target=i32, Output = Type>`

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0191`.
16 changes: 1 addition & 15 deletions tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr
Original file line number Diff line number Diff line change
@@ -12,20 +12,6 @@ LL | trait A: B + A {}
| ^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0391]: cycle detected when computing the implied predicates of `A`
--> $DIR/cyclic-trait-resolution.rs:1:14
|
LL | trait A: B + A {}
| ^
|
= note: ...which immediately requires computing the implied predicates of `A` again
note: cycle used when checking that `<impl at $DIR/cyclic-trait-resolution.rs:7:1: 7:14>` is well-formed
--> $DIR/cyclic-trait-resolution.rs:7:1
|
LL | impl A for () {}
| ^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/illegal-upcast-from-impl.rs:11:1
|
LL | trait Super {
| ----------- built-in `dyn Super<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> Super for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0308]: mismatched types
--> $DIR/illegal-upcast-from-impl.rs:15:66
|
@@ -9,6 +20,6 @@ LL | fn illegal(x: &dyn Sub<Assoc = ()>) -> &dyn Super<Assoc = i32> { x }
= note: expected reference `&dyn Super<Assoc = i32>`
found reference `&dyn Sub<Assoc = ()>`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/illegal-upcast-from-impl.rs:11:1
|
LL | trait Super {
| ----------- built-in `dyn Super<Assoc = _>` implementation for this trait
...
LL | impl<T: ?Sized> Super for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0308]: mismatched types
--> $DIR/illegal-upcast-from-impl.rs:15:66
|
@@ -9,6 +20,6 @@ LL | fn illegal(x: &dyn Sub<Assoc = ()>) -> &dyn Super<Assoc = i32> { x }
= note: expected reference `&dyn Super<Assoc = i32>`
found reference `&dyn Sub<Assoc = ()>`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
13 changes: 12 additions & 1 deletion tests/ui/traits/trivial_impl_sized.stderr
Original file line number Diff line number Diff line change
@@ -21,6 +21,17 @@ note: the lint level is defined here
LL | #[deny(dead_code)]
| ^^^^^^^^^

error: hi
--> $DIR/trivial_impl_sized.rs:39:1
|
LL | trait Trait {
| ----------- built-in `dyn Trait` implementation for this trait
...
LL | impl<T: ?Sized> Trait for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0046]: not all trait items implemented, missing: `foo`
--> $DIR/trivial_impl_sized.rs:39:1
|
@@ -32,6 +43,6 @@ LL | }
LL | impl<T: ?Sized> Trait for T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0046`.
13 changes: 12 additions & 1 deletion tests/ui/unsized/issue-71659.current.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/issue-71659.rs:13:1
|
LL | pub trait CastTo<T: ?Sized>: Unsize<T> {
| -------------------------------------- built-in `dyn CastTo<_>` implementation for this trait
...
LL | impl<T: ?Sized, U: ?Sized + Unsize<T>> CastTo<T> for U {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied
--> $DIR/issue-71659.rs:34:15
|
@@ -13,6 +24,6 @@ LL | where
LL | Self: CastTo<T>,
| ^^^^^^^^^ required by this bound in `Cast::cast`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
13 changes: 12 additions & 1 deletion tests/ui/unsized/issue-71659.next.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/issue-71659.rs:13:1
|
LL | pub trait CastTo<T: ?Sized>: Unsize<T> {
| -------------------------------------- built-in `dyn CastTo<_>` implementation for this trait
...
LL | impl<T: ?Sized, U: ?Sized + Unsize<T>> CastTo<T> for U {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied
--> $DIR/issue-71659.rs:34:15
|
@@ -13,6 +24,6 @@ LL | where
LL | Self: CastTo<T>,
| ^^^^^^^^^ required by this bound in `Cast::cast`

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
13 changes: 12 additions & 1 deletion tests/ui/wf/wf-normalization-sized.next.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
error: hi
--> $DIR/wf-normalization-sized.rs:15:1
|
LL | trait WellUnformed {
| ------------------ built-in `dyn WellUnformed<RequestNormalize = _>` implementation for this trait
...
LL | impl<T: ?Sized> WellUnformed for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overlaps with this blanket impl
|
= note: `#[forbid(dyn_overlap)]` on by default

error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time
--> $DIR/wf-normalization-sized.rs:19:11
|
@@ -17,6 +28,6 @@ LL | const _: <Vec<str> as WellUnformed>::RequestNormalize = ();
note: required by an implicit `Sized` bound in `Vec`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.