Fix use of bare trait objects everywhere

This commit is contained in:
Vadim Petrochenkov 2021-03-07 18:47:39 +03:00
parent 36f1f04f18
commit dac96d45af
22 changed files with 88 additions and 74 deletions

View File

@ -124,7 +124,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
DUMMY_SP,
canonical_key,
|ref infcx, key, canonical_inference_vars| {
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
let value = operation(infcx, &mut *fulfill_cx, key)?;
infcx.make_canonicalized_query_response(
canonical_inference_vars,

View File

@ -62,7 +62,7 @@ fn scrape_region_constraints<'tcx, R>(
infcx: &InferCtxt<'_, 'tcx>,
op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
) -> Fallible<(R, Option<Rc<QueryRegionConstraints<'tcx>>>)> {
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
let dummy_body_id = ObligationCause::dummy().body_id;
// During NLL, we expect that nobody will register region

View File

@ -75,7 +75,7 @@ fn dropck_outlives<'tcx>(
// Set used to detect infinite recursion.
let mut ty_set = FxHashSet::default();
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
let cause = ObligationCause::dummy();
let mut constraints = DtorckConstraint::empty();

View File

@ -1554,7 +1554,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
if let hir::FnRetTy::Return(ty) = fn_output {
// Get the return type.
if let hir::TyKind::OpaqueDef(..) = ty.kind {
let ty = AstConv::ast_ty_to_ty(fcx, ty);
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
// Get the `impl Trait`'s `DefId`.
if let ty::Opaque(def_id, _) = ty.kind() {
let hir_id = fcx.tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
@ -1616,7 +1616,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
if let hir::FnRetTy::Return(ty) = fn_decl.output {
let ty = AstConv::ast_ty_to_ty(fcx, ty);
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
if let ty::Dynamic(..) = ty.kind() {
return true;
}

View File

@ -77,7 +77,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
tcx.infer_ctxt().enter(|ref infcx| {
let impl_param_env = tcx.param_env(self_type_did);
let tcx = infcx.tcx;
let mut fulfillment_cx = TraitEngine::new(tcx);
let mut fulfillment_cx = <dyn TraitEngine<'_>>::new(tcx);
let named_type = tcx.type_of(self_type_did);

View File

@ -472,7 +472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
let t = AstConv::ast_ty_to_ty(self, ast_t);
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
t
}
@ -854,7 +854,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// out unconstrained or ambiguous, as we're
// just trying to get hints here.
self.save_and_restore_in_snapshot_flag(|_| {
let mut fulfill = TraitEngine::new(self.tcx);
let mut fulfill = <dyn TraitEngine<'_>>::new(self.tcx);
for obligation in ok.obligations {
fulfill.register_predicate_obligation(self, obligation);
}
@ -1174,9 +1174,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let path_segs = match res {
Res::Local(_) | Res::SelfCtor(_) => vec![],
Res::Def(kind, def_id) => {
AstConv::def_ids_for_value_path_segments(self, segments, self_ty, kind, def_id)
}
Res::Def(kind, def_id) => <dyn AstConv<'_>>::def_ids_for_value_path_segments(
self, segments, self_ty, kind, def_id,
),
_ => bug!("instantiate_value_path on {:?}", res),
};
@ -1219,7 +1219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// errors if type parameters are provided in an inappropriate place.
let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect();
let generics_has_err = AstConv::prohibit_generics(
let generics_has_err = <dyn AstConv<'_>>::prohibit_generics(
self,
segments.iter().enumerate().filter_map(|(index, seg)| {
if !generic_segs.contains(&index) || is_alias_variant_ctor {
@ -1262,7 +1262,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let GenericArgCountResult {
correct: Err(GenericArgCountMismatch { reported: Some(_), .. }),
..
} = AstConv::check_generic_arg_count_for_call(
} = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
tcx,
span,
def_id,
@ -1370,7 +1370,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> subst::GenericArg<'tcx> {
match (&param.kind, arg) {
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
AstConv::ast_region_to_region(self.fcx, lt, Some(param)).into()
<dyn AstConv<'_>>::ast_region_to_region(self.fcx, lt, Some(param)).into()
}
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
self.fcx.to_ty(ty).into()
@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
let substs = self_ctor_substs.unwrap_or_else(|| {
AstConv::create_substs_for_generic_args(
<dyn AstConv<'_>>::create_substs_for_generic_args(
tcx,
def_id,
&[][..],

View File

@ -875,7 +875,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match *qpath {
QPath::Resolved(ref maybe_qself, ref path) => {
let self_ty = maybe_qself.as_ref().map(|qself| self.to_ty(qself));
let ty = AstConv::res_to_ty(self, self_ty, path, true);
let ty = <dyn AstConv<'_>>::res_to_ty(self, self_ty, path, true);
(path.res, ty)
}
QPath::TypeRelative(ref qself, ref segment) => {
@ -886,8 +886,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
Res::Err
};
let result =
AstConv::associated_path_to_ty(self, hir_id, path_span, ty, res, segment, true);
let result = <dyn AstConv<'_>>::associated_path_to_ty(
self, hir_id, path_span, ty, res, segment, true,
);
let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error());
let result = result.map(|(_, kind, def_id)| (kind, def_id));
@ -1000,7 +1001,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// would trigger in `is_send::<T::AssocType>();`
// from `typeck-default-trait-impl-assoc-type.rs`.
} else {
let ty = AstConv::ast_ty_to_ty(self, hir_ty);
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, hir_ty);
let ty = self.resolve_vars_if_possible(ty);
if ty == predicate.self_ty() {
error.obligation.cause.make_mut().span = hir_ty.span;

View File

@ -461,7 +461,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// are not, the expectation must have been caused by something else.
debug!("suggest_missing_return_type: return type {:?} node {:?}", ty, ty.kind);
let sp = ty.span;
let ty = AstConv::ast_ty_to_ty(self, ty);
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, ty);
debug!("suggest_missing_return_type: return type {:?}", ty);
debug!("suggest_missing_return_type: expected type {:?}", ty);
if ty.kind() == expected.kind() {
@ -486,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
let found = self.resolve_vars_with_obligations(found);
if let hir::FnRetTy::Return(ty) = fn_decl.output {
let ty = AstConv::ast_ty_to_ty(self, ty);
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(self, ty);
let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty));
let ty = self.normalize_associated_types_in(expr.span, ty);
if self.can_coerce(found, ty) {

View File

@ -117,7 +117,7 @@ impl Inherited<'a, 'tcx> {
maybe_typeck_results: infcx.in_progress_typeck_results,
},
infcx,
fulfillment_cx: RefCell::new(TraitEngine::new(tcx)),
fulfillment_cx: RefCell::new(<dyn TraitEngine<'_>>::new(tcx)),
locals: RefCell::new(Default::default()),
deferred_sized_obligations: RefCell::new(Vec::new()),
deferred_call_resolutions: RefCell::new(Default::default()),

View File

@ -314,7 +314,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
// variables.
let generics = self.tcx.generics_of(pick.item.def_id);
let arg_count_correct = AstConv::check_generic_arg_count_for_call(
let arg_count_correct = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
self.tcx,
self.span,
pick.item.def_id,
@ -352,7 +352,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
) -> subst::GenericArg<'tcx> {
match (&param.kind, arg) {
(GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
AstConv::ast_region_to_region(self.cfcx.fcx, lt, Some(param)).into()
<dyn AstConv<'_>>::ast_region_to_region(self.cfcx.fcx, lt, Some(param))
.into()
}
(GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => {
self.cfcx.to_ty(ty).into()
@ -373,7 +374,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
self.cfcx.var_for_def(self.cfcx.span, param)
}
}
AstConv::create_substs_for_generic_args(
<dyn AstConv<'_>>::create_substs_for_generic_args(
self.tcx,
pick.item.def_id,
parent_substs,

View File

@ -495,7 +495,7 @@ fn typeck_with_fallback<'tcx>(
let fcx = if let (Some(header), Some(decl)) = (fn_header, fn_decl) {
let fn_sig = if crate::collect::get_infer_ret_ty(&decl.output).is_some() {
let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
AstConv::ty_of_fn(
<dyn AstConv<'_>>::ty_of_fn(
&fcx,
header.unsafety,
header.abi,
@ -527,7 +527,7 @@ fn typeck_with_fallback<'tcx>(
let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
let expected_type = body_ty
.and_then(|ty| match ty.kind {
hir::TyKind::Infer => Some(AstConv::ast_ty_to_ty(&fcx, ty)),
hir::TyKind::Infer => Some(<dyn AstConv<'_>>::ast_ty_to_ty(&fcx, ty)),
_ => None,
})
.unwrap_or_else(|| match tcx.hir().get(id) {

View File

@ -246,7 +246,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
))
.emit();
} else {
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
for field in coerced_fields {
let predicate = predicate_for_trait_def(
@ -506,7 +506,7 @@ pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedI
}
};
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
// Register an obligation for `A: Trait<B>`.
let cause = traits::ObligationCause::misc(span, impl_hir_id);

View File

@ -310,7 +310,7 @@ impl ItemCtxt<'tcx> {
}
pub fn to_ty(&self, ast_ty: &hir::Ty<'_>) -> Ty<'tcx> {
AstConv::ast_ty_to_ty(self, ast_ty)
<dyn AstConv<'_>>::ast_ty_to_ty(self, ast_ty)
}
pub fn hir_id(&self) -> hir::HirId {
@ -1096,7 +1096,7 @@ fn super_predicates_that_define_assoc_type(
// Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`.
let self_param_ty = tcx.types.self_param;
let superbounds1 = if let Some(assoc_name) = assoc_name {
AstConv::compute_bounds_that_match_assoc_type(
<dyn AstConv<'_>>::compute_bounds_that_match_assoc_type(
&icx,
self_param_ty,
&bounds,
@ -1105,7 +1105,13 @@ fn super_predicates_that_define_assoc_type(
assoc_name,
)
} else {
AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span)
<dyn AstConv<'_>>::compute_bounds(
&icx,
self_param_ty,
&bounds,
SizedByDefault::No,
item.span,
)
};
let superbounds1 = superbounds1.predicates(tcx, self_param_ty);
@ -1689,7 +1695,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
ty::Binder::bind(fn_sig)
}
None => AstConv::ty_of_fn(
None => <dyn AstConv<'_>>::ty_of_fn(
&icx,
sig.header.unsafety,
sig.header.abi,
@ -1706,7 +1712,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
ident,
generics,
..
}) => AstConv::ty_of_fn(
}) => <dyn AstConv<'_>>::ty_of_fn(
&icx,
header.unsafety,
header.abi,
@ -1767,7 +1773,7 @@ fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::TraitRef<'_>> {
match tcx.hir().expect_item(hir_id).kind {
hir::ItemKind::Impl(ref impl_) => impl_.of_trait.as_ref().map(|ast_trait_ref| {
let selfty = tcx.type_of(def_id);
AstConv::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty)
<dyn AstConv<'_>>::instantiate_mono_trait_ref(&icx, ast_trait_ref, selfty)
}),
_ => bug!(),
}
@ -2018,7 +2024,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
GenericParamKind::Lifetime { .. } => {
param.bounds.iter().for_each(|bound| match bound {
hir::GenericBound::Outlives(lt) => {
let bound = AstConv::ast_region_to_region(&icx, &lt, None);
let bound = <dyn AstConv<'_>>::ast_region_to_region(&icx, &lt, None);
let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound));
predicates.insert((outlives.to_predicate(tcx), lt.span));
}
@ -2041,8 +2047,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
index += 1;
let sized = SizedByDefault::Yes;
let bounds =
AstConv::compute_bounds(&icx, param_ty, &param.bounds, sized, param.span);
let bounds = <dyn AstConv<'_>>::compute_bounds(
&icx,
param_ty,
&param.bounds,
sized,
param.span,
);
predicates.extend(bounds.predicates(tcx, param_ty));
}
GenericParamKind::Const { .. } => {
@ -2091,7 +2102,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
};
let mut bounds = Bounds::default();
let _ = AstConv::instantiate_poly_trait_ref(
let _ = <dyn AstConv<'_>>::instantiate_poly_trait_ref(
&icx,
&poly_trait_ref,
constness,
@ -2103,7 +2114,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
&hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => {
let mut bounds = Bounds::default();
AstConv::instantiate_lang_item_trait_ref(
<dyn AstConv<'_>>::instantiate_lang_item_trait_ref(
&icx,
lang_item,
span,
@ -2116,7 +2127,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
}
hir::GenericBound::Outlives(lifetime) => {
let region = AstConv::ast_region_to_region(&icx, lifetime, None);
let region =
<dyn AstConv<'_>>::ast_region_to_region(&icx, lifetime, None);
predicates.insert((
ty::Binder::bind(ty::PredicateKind::TypeOutlives(
ty::OutlivesPredicate(ty, region),
@ -2130,11 +2142,11 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
}
hir::WherePredicate::RegionPredicate(region_pred) => {
let r1 = AstConv::ast_region_to_region(&icx, &region_pred.lifetime, None);
let r1 = <dyn AstConv<'_>>::ast_region_to_region(&icx, &region_pred.lifetime, None);
predicates.extend(region_pred.bounds.iter().map(|bound| {
let (r2, span) = match bound {
hir::GenericBound::Outlives(lt) => {
(AstConv::ast_region_to_region(&icx, lt, None), lt.span)
(<dyn AstConv<'_>>::ast_region_to_region(&icx, lt, None), lt.span)
}
_ => bug!(),
};
@ -2377,7 +2389,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
} else {
hir::Unsafety::Unsafe
};
let fty = AstConv::ty_of_fn(
let fty = <dyn AstConv<'_>>::ty_of_fn(
&ItemCtxt::new(tcx, def_id),
unsafety,
abi,

View File

@ -25,7 +25,7 @@ fn associated_type_bounds<'tcx>(
InternalSubsts::identity_for_item(tcx, assoc_item_def_id),
);
let bounds = AstConv::compute_bounds(
let bounds = <dyn AstConv<'_>>::compute_bounds(
&ItemCtxt::new(tcx, assoc_item_def_id),
item_ty,
&bounds,
@ -66,7 +66,7 @@ fn opaque_type_bounds<'tcx>(
let item_ty =
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
let bounds = AstConv::compute_bounds(
let bounds = <dyn AstConv<'_>>::compute_bounds(
&ItemCtxt::new(tcx, opaque_def_id),
item_ty,
&bounds,

View File

@ -142,7 +142,7 @@ fn require_same_types<'tcx>(
) -> bool {
tcx.infer_ctxt().enter(|ref infcx| {
let param_env = ty::ParamEnv::empty();
let mut fulfill_cx = TraitEngine::new(infcx.tcx);
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(infcx.tcx);
match infcx.at(&cause, param_env).eq(expected, actual) {
Ok(InferOk { obligations, .. }) => {
fulfill_cx.register_predicate_obligations(infcx, obligations);
@ -444,7 +444,7 @@ pub fn hir_trait_to_predicates<'tcx>(
let env_def_id = tcx.hir().local_def_id(env_hir_id);
let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id.to_def_id());
let mut bounds = Bounds::default();
let _ = AstConv::instantiate_poly_trait_ref_inner(
let _ = <dyn AstConv<'_>>::instantiate_poly_trait_ref_inner(
&item_cx,
hir_trait,
DUMMY_SP,

View File

@ -285,7 +285,7 @@ impl dyn Any + Send {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is<T: Any>(&self) -> bool {
Any::is::<T>(self)
<dyn Any>::is::<T>(self)
}
/// Forwards to the method defined on the type `Any`.
@ -309,7 +309,7 @@ impl dyn Any + Send {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
Any::downcast_ref::<T>(self)
<dyn Any>::downcast_ref::<T>(self)
}
/// Forwards to the method defined on the type `Any`.
@ -337,7 +337,7 @@ impl dyn Any + Send {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
Any::downcast_mut::<T>(self)
<dyn Any>::downcast_mut::<T>(self)
}
}
@ -363,7 +363,7 @@ impl dyn Any + Send + Sync {
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
pub fn is<T: Any>(&self) -> bool {
Any::is::<T>(self)
<dyn Any>::is::<T>(self)
}
/// Forwards to the method defined on the type `Any`.
@ -387,7 +387,7 @@ impl dyn Any + Send + Sync {
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
Any::downcast_ref::<T>(self)
<dyn Any>::downcast_ref::<T>(self)
}
/// Forwards to the method defined on the type `Any`.
@ -415,7 +415,7 @@ impl dyn Any + Send + Sync {
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
#[inline]
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
Any::downcast_mut::<T>(self)
<dyn Any>::downcast_mut::<T>(self)
}
}

View File

@ -30,8 +30,8 @@ fn main() {
let x: &dyn T = &42;
x.foo();
T::foo(x);
T::bar();
<dyn T>::foo(x);
<dyn T>::bar();
unsafe { assert_eq!(COUNT, 12); }

View File

@ -31,7 +31,7 @@ fn with_trait<C:CompareToInts>(c: &C) -> bool {
}
fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied
<dyn CompareToInts>::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfi
}
fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {

View File

@ -21,8 +21,8 @@ error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfi
LL | fn same_as(&self, t: T) -> bool;
| -------------------------------- required by `CompareTo::same_as`
...
LL | CompareToInts::same_as(c, 22)
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
LL | <dyn CompareToInts>::same_as(c, 22)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
--> $DIR/repeated-supertrait-ambig.rs:38:5

View File

@ -31,7 +31,7 @@ fn with_trait<C:CompareToInts>(c: &C) -> bool {
}
fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64)
<dyn CompareToInts>::same_as(c, 22_i64) && <dyn CompareToInts>::same_as(c, 22_u64)
}
fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {

View File

@ -81,8 +81,8 @@ fn check_method() {
//~^ ERROR no function or associated item named `b` found
S::c(&S); // OK
// a, b, c are resolved as inherent items, their traits don't need to be in scope
C::a(&S); //~ ERROR associated function `a` is private
C::b(&S); // OK
<dyn C>::a(&S); //~ ERROR associated function `a` is private
<dyn C>::b(&S); // OK
C::c(&S); // OK
}
@ -98,9 +98,9 @@ fn check_assoc_const() {
S::B; //~ ERROR no associated item named `B` found
S::C; // OK
// A, B, C are resolved as inherent items, their traits don't need to be in scope
C::A; //~ ERROR associated constant `A` is private
//~^ ERROR the trait `assoc_const::C` cannot be made into an object
C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
<dyn C>::A; //~ ERROR associated constant `A` is private
//~^ ERROR the trait `assoc_const::C` cannot be made into an object
<dyn C>::B; // ERROR the trait `assoc_const::C` cannot be made into an object
C::C; // OK
}

View File

@ -67,10 +67,10 @@ LL | use method::B;
|
error[E0624]: associated function `a` is private
--> $DIR/item-privacy.rs:84:8
--> $DIR/item-privacy.rs:84:14
|
LL | C::a(&S);
| ^ private associated function
LL | <dyn C>::a(&S);
| ^ private associated function
error[E0599]: no associated item named `A` found for struct `S` in the current scope
--> $DIR/item-privacy.rs:97:8
@ -104,16 +104,16 @@ LL | use assoc_const::B;
|
error[E0624]: associated constant `A` is private
--> $DIR/item-privacy.rs:101:8
--> $DIR/item-privacy.rs:101:14
|
LL | C::A;
| ^ private associated constant
LL | <dyn C>::A;
| ^ private associated constant
error[E0038]: the trait `assoc_const::C` cannot be made into an object
--> $DIR/item-privacy.rs:101:5
--> $DIR/item-privacy.rs:101:6
|
LL | C::A;
| ^ `assoc_const::C` cannot be made into an object
LL | <dyn C>::A;
| ^^^^^ `assoc_const::C` cannot be made into an object
|
= help: consider moving `C` to another trait
= help: consider moving `B` to another trait