Add ValuePairs::Terms & Fix compile error

And use correct substs.
This commit is contained in:
kadmin 2022-01-28 18:14:27 +00:00
parent bd03d8167f
commit c654e4d6f4
38 changed files with 143 additions and 181 deletions

View File

@ -288,21 +288,13 @@ impl<'tcx> ToTrace<'tcx> for &'tcx Const<'tcx> {
impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> { impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> {
fn to_trace( fn to_trace(
tcx: TyCtxt<'tcx>, _: TyCtxt<'tcx>,
cause: &ObligationCause<'tcx>, cause: &ObligationCause<'tcx>,
a_is_expected: bool, a_is_expected: bool,
a: Self, a: Self,
b: Self, b: Self,
) -> TypeTrace<'tcx> { ) -> TypeTrace<'tcx> {
match (a, b) { TypeTrace { cause: cause.clone(), values: Terms(ExpectedFound::new(a_is_expected, a, b)) }
(ty::Term::Ty(a), ty::Term::Ty(b)) => {
ToTrace::to_trace(tcx, cause, a_is_expected, a, b)
}
(ty::Term::Const(a), ty::Term::Const(b)) => {
ToTrace::to_trace(tcx, cause, a_is_expected, a, b)
}
(_, _) => span_bug!(cause.span, "Unexpected type/const mismatch"),
}
} }
} }

View File

@ -2127,6 +2127,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
infer::Types(exp_found) => self.expected_found_str_ty(exp_found), infer::Types(exp_found) => self.expected_found_str_ty(exp_found),
infer::Regions(exp_found) => self.expected_found_str(exp_found), infer::Regions(exp_found) => self.expected_found_str(exp_found),
infer::Consts(exp_found) => self.expected_found_str(exp_found), infer::Consts(exp_found) => self.expected_found_str(exp_found),
infer::Terms(exp_found) => self.expected_found_str(exp_found),
infer::TraitRefs(exp_found) => { infer::TraitRefs(exp_found) => {
let pretty_exp_found = ty::error::ExpectedFound { let pretty_exp_found = ty::error::ExpectedFound {
expected: exp_found.expected.print_only_trait_path(), expected: exp_found.expected.print_only_trait_path(),

View File

@ -371,6 +371,7 @@ pub enum ValuePairs<'tcx> {
Types(ExpectedFound<Ty<'tcx>>), Types(ExpectedFound<Ty<'tcx>>),
Regions(ExpectedFound<ty::Region<'tcx>>), Regions(ExpectedFound<ty::Region<'tcx>>),
Consts(ExpectedFound<&'tcx ty::Const<'tcx>>), Consts(ExpectedFound<&'tcx ty::Const<'tcx>>),
Terms(ExpectedFound<ty::Term<'tcx>>),
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>), TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>), PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
} }

View File

@ -1356,26 +1356,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
normalized_ty, normalized_ty,
data.term, data.term,
) { ) {
values = Some(match (normalized_ty, data.term) { values = Some(infer::ValuePairs::Terms(ExpectedFound::new(
(ty::Term::Ty(normalized_ty), ty::Term::Ty(ty)) => { is_normalized_ty_expected,
infer::ValuePairs::Types(ExpectedFound::new( normalized_ty,
is_normalized_ty_expected, data.term,
normalized_ty, )));
ty,
))
}
(ty::Term::Const(normalized_ct), ty::Term::Const(ct)) => {
infer::ValuePairs::Consts(ExpectedFound::new(
is_normalized_ty_expected,
normalized_ct,
ct,
))
}
(_, _) => span_bug!(
obligation.cause.span,
"found const or type where other expected"
),
});
err_buf = error; err_buf = error;
err = &err_buf; err = &err_buf;
} }

View File

@ -22,6 +22,7 @@ use crate::traits::error_reporting::InferCtxtExt as _;
use rustc_data_structures::sso::SsoHashSet; use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorReported; use rustc_errors::ErrorReported;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::resolve::OpportunisticRegionResolver; use rustc_infer::infer::resolve::OpportunisticRegionResolver;
@ -200,7 +201,7 @@ fn project_and_unify_type<'cx, 'tcx>(
let infcx = selcx.infcx(); let infcx = selcx.infcx();
match obligation.predicate.term { match obligation.predicate.term {
ty::Term::Ty(obligation_pred_ty) => { ty::Term::Ty(obligation_pred_ty) => {
let normalized_ty = match opt_normalize_projection_type::<false>( let normalized_ty = match opt_normalize_projection_type(
selcx, selcx,
obligation.param_env, obligation.param_env,
obligation.predicate.projection_ty, obligation.predicate.projection_ty,
@ -215,7 +216,7 @@ fn project_and_unify_type<'cx, 'tcx>(
debug!(?normalized_ty, ?obligations, "project_and_unify_type result"); debug!(?normalized_ty, ?obligations, "project_and_unify_type result");
match infcx match infcx
.at(&obligation.cause, obligation.param_env) .at(&obligation.cause, obligation.param_env)
.eq(normalized_ty, obligation_pred_ty.into()) .eq(normalized_ty, obligation_pred_ty)
{ {
Ok(InferOk { obligations: inferred_obligations, value: () }) => { Ok(InferOk { obligations: inferred_obligations, value: () }) => {
obligations.extend(inferred_obligations); obligations.extend(inferred_obligations);
@ -228,7 +229,7 @@ fn project_and_unify_type<'cx, 'tcx>(
} }
} }
ty::Term::Const(obligation_pred_const) => { ty::Term::Const(obligation_pred_const) => {
let normalized_const = match opt_normalize_projection_type::<true>( let normalized_const = match opt_normalize_projection_type(
selcx, selcx,
obligation.param_env, obligation.param_env,
obligation.predicate.projection_ty, obligation.predicate.projection_ty,
@ -492,7 +493,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
let (data, mapped_regions, mapped_types, mapped_consts) = let (data, mapped_regions, mapped_types, mapped_consts) =
BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, data); BoundVarReplacer::replace_bound_vars(infcx, &mut self.universes, data);
let data = data.super_fold_with(self); let data = data.super_fold_with(self);
let normalized_ty = opt_normalize_projection_type::<false>( let normalized_ty = opt_normalize_projection_type(
self.selcx, self.selcx,
self.param_env, self.param_env,
data, data,
@ -826,7 +827,7 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>(
depth: usize, depth: usize,
obligations: &mut Vec<PredicateObligation<'tcx>>, obligations: &mut Vec<PredicateObligation<'tcx>>,
) -> Term<'tcx> { ) -> Term<'tcx> {
opt_normalize_projection_type::<false>( opt_normalize_projection_type(
selcx, selcx,
param_env, param_env,
projection_ty, projection_ty,
@ -859,7 +860,7 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>(
/// function takes an obligations vector and appends to it directly, which is /// function takes an obligations vector and appends to it directly, which is
/// slightly uglier but avoids the need for an extra short-lived allocation. /// slightly uglier but avoids the need for an extra short-lived allocation.
#[instrument(level = "debug", skip(selcx, param_env, cause, obligations))] #[instrument(level = "debug", skip(selcx, param_env, cause, obligations))]
fn opt_normalize_projection_type<'a, 'b, 'tcx, const INTO_CONST: bool>( fn opt_normalize_projection_type<'a, 'b, 'tcx>(
selcx: &'a mut SelectionContext<'b, 'tcx>, selcx: &'a mut SelectionContext<'b, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
@ -946,7 +947,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx, const INTO_CONST: bool>(
let obligation = Obligation::with_depth(cause.clone(), depth, param_env, projection_ty); let obligation = Obligation::with_depth(cause.clone(), depth, param_env, projection_ty);
match project::<INTO_CONST>(selcx, &obligation) { match project(selcx, &obligation) {
Ok(Projected::Progress(Progress { Ok(Projected::Progress(Progress {
term: projected_term, term: projected_term,
obligations: mut projected_obligations, obligations: mut projected_obligations,
@ -1087,7 +1088,7 @@ impl<'tcx> Progress<'tcx> {
/// IMPORTANT: /// IMPORTANT:
/// - `obligation` must be fully normalized /// - `obligation` must be fully normalized
#[tracing::instrument(level = "info", skip(selcx))] #[tracing::instrument(level = "info", skip(selcx))]
fn project<'cx, 'tcx, const INTO_CONST: bool>( fn project<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
) -> Result<Projected<'tcx>, ProjectionError<'tcx>> { ) -> Result<Projected<'tcx>, ProjectionError<'tcx>> {
@ -1123,7 +1124,7 @@ fn project<'cx, 'tcx, const INTO_CONST: bool>(
match candidates { match candidates {
ProjectionCandidateSet::Single(candidate) => { ProjectionCandidateSet::Single(candidate) => {
Ok(Projected::Progress(confirm_candidate::<INTO_CONST>(selcx, obligation, candidate))) Ok(Projected::Progress(confirm_candidate(selcx, obligation, candidate)))
} }
ProjectionCandidateSet::None => Ok(Projected::NoProgress( ProjectionCandidateSet::None => Ok(Projected::NoProgress(
selcx selcx
@ -1525,7 +1526,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
}); });
} }
fn confirm_candidate<'cx, 'tcx, const INTO_CONST: bool>( fn confirm_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
candidate: ProjectionCandidate<'tcx>, candidate: ProjectionCandidate<'tcx>,
@ -1542,7 +1543,7 @@ fn confirm_candidate<'cx, 'tcx, const INTO_CONST: bool>(
} }
ProjectionCandidate::Select(impl_source) => { ProjectionCandidate::Select(impl_source) => {
confirm_select_candidate::<INTO_CONST>(selcx, obligation, impl_source) confirm_select_candidate(selcx, obligation, impl_source)
} }
}; };
@ -1558,15 +1559,13 @@ fn confirm_candidate<'cx, 'tcx, const INTO_CONST: bool>(
progress progress
} }
fn confirm_select_candidate<'cx, 'tcx, const INTO_CONST: bool>( fn confirm_select_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
impl_source: Selection<'tcx>, impl_source: Selection<'tcx>,
) -> Progress<'tcx> { ) -> Progress<'tcx> {
match impl_source { match impl_source {
super::ImplSource::UserDefined(data) => { super::ImplSource::UserDefined(data) => confirm_impl_candidate(selcx, obligation, data),
confirm_impl_candidate::<INTO_CONST>(selcx, obligation, data)
}
super::ImplSource::Generator(data) => confirm_generator_candidate(selcx, obligation, data), super::ImplSource::Generator(data) => confirm_generator_candidate(selcx, obligation, data),
super::ImplSource::Closure(data) => confirm_closure_candidate(selcx, obligation, data), super::ImplSource::Closure(data) => confirm_closure_candidate(selcx, obligation, data),
super::ImplSource::FnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data), super::ImplSource::FnPointer(data) => confirm_fn_pointer_candidate(selcx, obligation, data),
@ -1836,7 +1835,7 @@ fn confirm_param_env_candidate<'cx, 'tcx>(
} }
} }
fn confirm_impl_candidate<'cx, 'tcx, const INTO_CONST: bool>( fn confirm_impl_candidate<'cx, 'tcx>(
selcx: &mut SelectionContext<'cx, 'tcx>, selcx: &mut SelectionContext<'cx, 'tcx>,
obligation: &ProjectionTyObligation<'tcx>, obligation: &ProjectionTyObligation<'tcx>,
impl_impl_source: ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>, impl_impl_source: ImplSourceUserDefinedData<'tcx, PredicateObligation<'tcx>>,
@ -1874,10 +1873,12 @@ fn confirm_impl_candidate<'cx, 'tcx, const INTO_CONST: bool>(
let substs = let substs =
translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.defining_node); translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.defining_node);
let ty = tcx.type_of(assoc_ty.item.def_id); let ty = tcx.type_of(assoc_ty.item.def_id);
let term: ty::Term<'tcx> = if INTO_CONST { let is_const = matches!(tcx.def_kind(assoc_ty.item.def_id), DefKind::AssocConst);
// FIXME(associated_const_equality): what are the right substs? let term: ty::Term<'tcx> = if is_const {
let identity_substs =
crate::traits::InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id); let did = ty::WithOptConstParam::unknown(assoc_ty.item.def_id);
let val = ty::ConstKind::Unevaluated(ty::Unevaluated::new(did, substs)); let val = ty::ConstKind::Unevaluated(ty::Unevaluated::new(did, identity_substs));
tcx.mk_const(ty::Const { ty, val }).into() tcx.mk_const(ty::Const { ty, val }).into()
} else { } else {
ty.into() ty.into()

View File

@ -1244,6 +1244,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// the "projection predicate" for: // the "projection predicate" for:
// //
// `<T as Iterator>::Item = u32` // `<T as Iterator>::Item = u32`
let def_kind = tcx.def_kind(projection_ty.skip_binder().item_def_id);
match (def_kind, term) {
(hir::def::DefKind::AssocTy, ty::Term::Ty(_))
| (hir::def::DefKind::AssocConst, ty::Term::Const(_)) => (),
(_, _) => {
tcx.sess
.struct_span_err(
binding.span,
"type/const mismatch in equality bind of associated field",
)
.span_label(binding.span, "type/const Mismatch")
.emit();
}
}
bounds.projection_bounds.push(( bounds.projection_bounds.push((
projection_ty.map_bound(|projection_ty| ty::ProjectionPredicate { projection_ty.map_bound(|projection_ty| ty::ProjectionPredicate {
projection_ty, projection_ty,

View File

@ -21,7 +21,9 @@ impl FooTy for Bar {
fn foo<F: Foo<N=usize>>() {} fn foo<F: Foo<N=usize>>() {}
//~^ ERROR type/const mismatch
fn foo2<F: FooTy<T=3usize>>() {} fn foo2<F: FooTy<T=3usize>>() {}
//~^ ERROR type/const mismatch
fn main() { fn main() {
foo::<Bar>(); foo::<Bar>();

View File

@ -0,0 +1,14 @@
error: type/const mismatch in equality bind of associated field
--> $DIR/assoc-const-ty-mismatch.rs:23:15
|
LL | fn foo<F: Foo<N=usize>>() {}
| ^^^^^^^ type/const Mismatch
error: type/const mismatch in equality bind of associated field
--> $DIR/assoc-const-ty-mismatch.rs:25:18
|
LL | fn foo2<F: FooTy<T=3usize>>() {}
| ^^^^^^^^ type/const Mismatch
error: aborting due to 2 previous errors

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
LL | fn b() { blue_car(ModelT); } LL | fn b() { blue_car(ModelT); }
| ^^^^^^^^ type mismatch resolving `<ModelT as Vehicle>::Color == Blue` | ^^^^^^^^ type mismatch resolving `<ModelT as Vehicle>::Color == Blue`
| |
note: expected this to be `Blue` note: expected struct `Blue`, found struct `Black`
--> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:16:40 --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:16:40
| |
LL | impl Vehicle for ModelT { type Color = Black; } LL | impl Vehicle for ModelT { type Color = Black; }
@ -21,7 +21,7 @@ error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black`
LL | fn c() { black_car(ModelU); } LL | fn c() { black_car(ModelU); }
| ^^^^^^^^^ type mismatch resolving `<ModelU as Vehicle>::Color == Black` | ^^^^^^^^^ type mismatch resolving `<ModelU as Vehicle>::Color == Black`
| |
note: expected this to be `Black` note: expected struct `Black`, found struct `Blue`
--> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:21:40 --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:21:40
| |
LL | impl Vehicle for ModelU { type Color = Blue; } LL | impl Vehicle for ModelU { type Color = Blue; }

View File

@ -19,7 +19,7 @@ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
LL | foo1(a); LL | foo1(a);
| ^^^^ type mismatch resolving `<isize as Foo>::A == Bar` | ^^^^ type mismatch resolving `<isize as Foo>::A == Bar`
| |
note: expected this to be `Bar` note: expected struct `Bar`, found `usize`
--> $DIR/associated-types-eq-3.rs:12:14 --> $DIR/associated-types-eq-3.rs:12:14
| |
LL | type A = usize; LL | type A = usize;
@ -36,7 +36,7 @@ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
LL | baz(&a); LL | baz(&a);
| ^^ type mismatch resolving `<isize as Foo>::A == Bar` | ^^ type mismatch resolving `<isize as Foo>::A == Bar`
| |
note: expected this to be `Bar` note: expected struct `Bar`, found `usize`
--> $DIR/associated-types-eq-3.rs:12:14 --> $DIR/associated-types-eq-3.rs:12:14
| |
LL | type A = usize; LL | type A = usize;

View File

@ -4,13 +4,11 @@ error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize
LL | foo::<UintStruct>(); LL | foo::<UintStruct>();
| ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize` | ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
| |
note: expected this to be `&isize` note: expected `isize`, found `usize`
--> $DIR/associated-types-eq-hr.rs:26:14 --> $DIR/associated-types-eq-hr.rs:26:14
| |
LL | type A = &'a usize; LL | type A = &'a usize;
| ^^^^^^^^^ | ^^^^^^^^^
= note: expected reference `&isize`
found reference `&usize`
note: required by a bound in `foo` note: required by a bound in `foo`
--> $DIR/associated-types-eq-hr.rs:45:36 --> $DIR/associated-types-eq-hr.rs:45:36
| |
@ -26,13 +24,11 @@ error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>
LL | bar::<IntStruct>(); LL | bar::<IntStruct>();
| ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize` | ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
| |
note: expected this to be `&usize` note: expected `usize`, found `isize`
--> $DIR/associated-types-eq-hr.rs:14:14 --> $DIR/associated-types-eq-hr.rs:14:14
| |
LL | type A = &'a isize; LL | type A = &'a isize;
| ^^^^^^^^^ | ^^^^^^^^^
= note: expected reference `&usize`
found reference `&isize`
note: required by a bound in `bar` note: required by a bound in `bar`
--> $DIR/associated-types-eq-hr.rs:52:36 --> $DIR/associated-types-eq-hr.rs:52:36
| |

View File

@ -7,12 +7,12 @@ LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
LL | is_iterator_of::<Option<T>, _>(&adapter); LL | is_iterator_of::<Option<T>, _>(&adapter);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`
| |
note: expected this to be `Option<T>` note: expected enum `Option`, found type parameter `T`
--> $DIR/associated-types-issue-20346.rs:23:17 --> $DIR/associated-types-issue-20346.rs:23:17
| |
LL | type Item = T; LL | type Item = T;
| ^ | ^
= note: expected enum `Option<T>` = note: expected type `Option<T>`
found type `T` found type `T`
note: required by a bound in `is_iterator_of` note: required by a bound in `is_iterator_of`
--> $DIR/associated-types-issue-20346.rs:15:34 --> $DIR/associated-types-issue-20346.rs:15:34

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
LL | want_y(t); LL | want_y(t);
| ^^^^^^ expected `i32`, found associated type | ^^^^^^ expected `i32`, found associated type
| |
= note: expected type `i32` = note: expected type `i32`
found associated type `<T as Foo>::Y` found type `<T as Foo>::Y`
note: required by a bound in `want_y` note: required by a bound in `want_y`
--> $DIR/associated-types-multiple-types-one-trait.rs:44:17 --> $DIR/associated-types-multiple-types-one-trait.rs:44:17
| |
@ -22,8 +22,8 @@ error[E0271]: type mismatch resolving `<T as Foo>::X == u32`
LL | want_x(t); LL | want_x(t);
| ^^^^^^ expected `u32`, found associated type | ^^^^^^ expected `u32`, found associated type
| |
= note: expected type `u32` = note: expected type `u32`
found associated type `<T as Foo>::X` found type `<T as Foo>::X`
note: required by a bound in `want_x` note: required by a bound in `want_x`
--> $DIR/associated-types-multiple-types-one-trait.rs:42:17 --> $DIR/associated-types-multiple-types-one-trait.rs:42:17
| |

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T { LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
| - this type parameter ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T` | - this type parameter ^^^^^^^^^^^^^^^^^ expected associated type, found type parameter `T`
| |
= note: expected associated type `<T as Deref>::Target` = note: expected type `<T as Deref>::Target`
found type parameter `T` found type `T`
help: consider further restricting this bound help: consider further restricting this bound
| |
LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T { LL | impl<T: Copy + std::ops::Deref + Deref<Target = T>> UnsafeCopy<'_, T> for T {

View File

@ -1,14 +1,11 @@
error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32` error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32`
--> $DIR/impl-trait-return-missing-constraint.rs:25:13 --> $DIR/impl-trait-return-missing-constraint.rs:25:13
| |
LL | fn bar() -> impl Bar {
| -------- the found opaque type
...
LL | fn baz() -> impl Bar<Item = i32> { LL | fn baz() -> impl Bar<Item = i32> {
| ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type | ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type
| |
= note: expected type `i32` = note: expected type `i32`
found associated type `<impl Bar as Foo>::Item` found type `<impl Bar as Foo>::Item`
help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32`
| |
LL | fn bar() -> impl Bar<Item = i32> { LL | fn bar() -> impl Bar<Item = i32> {

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<() as Array>::Element == &()`
LL | <() as Visit>::visit(); LL | <() as Visit>::visit();
| ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array>::Element == &()` | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Array>::Element == &()`
| |
note: expected this to be `&()` note: expected `&()`, found `()`
--> $DIR/issue-44153.rs:10:20 --> $DIR/issue-44153.rs:10:20
| |
LL | type Element = (); LL | type Element = ();

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == char`
LL | type Sibling = Foo2; LL | type Sibling = Foo2;
| ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == char` | ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == char`
| |
note: expected this to be `char` note: expected `char`, found `u32`
--> $DIR/issue-72806.rs:18:15 --> $DIR/issue-72806.rs:18:15
| |
LL | type Ok = u32; LL | type Ok = u32;

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<A as Trait>::Associated == ()`
LL | accepts_trait(a); LL | accepts_trait(a);
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<A as Trait>::Associated` found type `<A as Trait>::Associated`
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27 --> $DIR/issue-87261.rs:43:27
| |
@ -22,8 +22,8 @@ error[E0271]: type mismatch resolving `<B as Trait>::Associated == ()`
LL | accepts_trait(b); LL | accepts_trait(b);
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<B as Trait>::Associated` found type `<B as Trait>::Associated`
= help: consider constraining the associated type `<B as Trait>::Associated` to `()` = help: consider constraining the associated type `<B as Trait>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
@ -38,8 +38,8 @@ error[E0271]: type mismatch resolving `<C as Trait>::Associated == ()`
LL | accepts_trait(c); LL | accepts_trait(c);
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<C as Trait>::Associated` found type `<C as Trait>::Associated`
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27 --> $DIR/issue-87261.rs:43:27
| |
@ -56,8 +56,8 @@ error[E0271]: type mismatch resolving `<D as Trait>::Associated == ()`
LL | accepts_trait(d); LL | accepts_trait(d);
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<D as Trait>::Associated` found type `<D as Trait>::Associated`
= help: consider constraining the associated type `<D as Trait>::Associated` to `()` = help: consider constraining the associated type `<D as Trait>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
@ -72,8 +72,8 @@ error[E0271]: type mismatch resolving `<E as GenericTrait<()>>::Associated == ()
LL | accepts_generic_trait(e); LL | accepts_generic_trait(e);
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<E as GenericTrait<()>>::Associated` found type `<E as GenericTrait<()>>::Associated`
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46 --> $DIR/issue-87261.rs:44:46
| |
@ -90,8 +90,8 @@ error[E0271]: type mismatch resolving `<F as GenericTrait<()>>::Associated == ()
LL | accepts_generic_trait(f); LL | accepts_generic_trait(f);
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<F as GenericTrait<()>>::Associated` found type `<F as GenericTrait<()>>::Associated`
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46 --> $DIR/issue-87261.rs:44:46
| |
@ -108,8 +108,8 @@ error[E0271]: type mismatch resolving `<G as GenericTrait<()>>::Associated == ()
LL | accepts_generic_trait(g); LL | accepts_generic_trait(g);
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<G as GenericTrait<()>>::Associated` found type `<G as GenericTrait<()>>::Associated`
= help: consider constraining the associated type `<G as GenericTrait<()>>::Associated` to `()` = help: consider constraining the associated type `<G as GenericTrait<()>>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`
@ -121,14 +121,11 @@ LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()` error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:79:5 --> $DIR/issue-87261.rs:79:5
| |
LL | fn returns_opaque() -> impl Trait + 'static {
| -------------------- the found opaque type
...
LL | accepts_trait(returns_opaque()); LL | accepts_trait(returns_opaque());
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl Trait as Trait>::Associated` found type `<impl Trait as Trait>::Associated`
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27 --> $DIR/issue-87261.rs:43:27
| |
@ -142,14 +139,11 @@ LL | fn returns_opaque() -> impl Trait<Associated = ()> + 'static {
error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()` error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:82:5 --> $DIR/issue-87261.rs:82:5
| |
LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static {
| --------------------------- the found opaque type
...
LL | accepts_trait(returns_opaque_derived()); LL | accepts_trait(returns_opaque_derived());
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl DerivedTrait as Trait>::Associated` found type `<impl DerivedTrait as Trait>::Associated`
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27 --> $DIR/issue-87261.rs:43:27
| |
@ -163,14 +157,11 @@ LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static
error[E0271]: type mismatch resolving `<impl Foo + Trait as Trait>::Associated == ()` error[E0271]: type mismatch resolving `<impl Foo + Trait as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:85:5 --> $DIR/issue-87261.rs:85:5
| |
LL | fn returns_opaque_foo() -> impl Trait + Foo {
| ---------------- the found opaque type
...
LL | accepts_trait(returns_opaque_foo()); LL | accepts_trait(returns_opaque_foo());
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl Foo + Trait as Trait>::Associated` found type `<impl Foo + Trait as Trait>::Associated`
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27 --> $DIR/issue-87261.rs:43:27
| |
@ -184,14 +175,11 @@ LL | fn returns_opaque_foo() -> impl Trait<Associated = ()> + Foo {
error[E0271]: type mismatch resolving `<impl Foo + DerivedTrait as Trait>::Associated == ()` error[E0271]: type mismatch resolving `<impl Foo + DerivedTrait as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:88:5 --> $DIR/issue-87261.rs:88:5
| |
LL | fn returns_opaque_derived_foo() -> impl DerivedTrait + Foo {
| ----------------------- the found opaque type
...
LL | accepts_trait(returns_opaque_derived_foo()); LL | accepts_trait(returns_opaque_derived_foo());
| ^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl Foo + DerivedTrait as Trait>::Associated` found type `<impl Foo + DerivedTrait as Trait>::Associated`
= help: consider constraining the associated type `<impl Foo + DerivedTrait as Trait>::Associated` to `()` = help: consider constraining the associated type `<impl Foo + DerivedTrait as Trait>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_trait` note: required by a bound in `accepts_trait`
@ -203,14 +191,11 @@ LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()` error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
--> $DIR/issue-87261.rs:91:5 --> $DIR/issue-87261.rs:91:5
| |
LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static {
| ------------------------------- the found opaque type
...
LL | accepts_generic_trait(returns_opaque_generic()); LL | accepts_generic_trait(returns_opaque_generic());
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated` found type `<impl GenericTrait<()> as GenericTrait<()>>::Associated`
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46 --> $DIR/issue-87261.rs:44:46
| |
@ -224,14 +209,11 @@ LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'st
error[E0271]: type mismatch resolving `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated == ()` error[E0271]: type mismatch resolving `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated == ()`
--> $DIR/issue-87261.rs:94:5 --> $DIR/issue-87261.rs:94:5
| |
LL | fn returns_opaque_generic_foo() -> impl GenericTrait<()> + Foo {
| --------------------------- the found opaque type
...
LL | accepts_generic_trait(returns_opaque_generic_foo()); LL | accepts_generic_trait(returns_opaque_generic_foo());
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated` found type `<impl Foo + GenericTrait<()> as GenericTrait<()>>::Associated`
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46 --> $DIR/issue-87261.rs:44:46
| |
@ -245,14 +227,11 @@ LL | fn returns_opaque_generic_foo() -> impl GenericTrait<(), Associated = ()> +
error[E0271]: type mismatch resolving `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated == ()` error[E0271]: type mismatch resolving `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated == ()`
--> $DIR/issue-87261.rs:97:5 --> $DIR/issue-87261.rs:97:5
| |
LL | fn returns_opaque_generic_duplicate() -> impl GenericTrait<()> + GenericTrait<u8> {
| ---------------------------------------- the found opaque type
...
LL | accepts_generic_trait(returns_opaque_generic_duplicate()); LL | accepts_generic_trait(returns_opaque_generic_duplicate());
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
| |
= note: expected unit type `()` = note: expected type `()`
found associated type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated` found type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated`
= help: consider constraining the associated type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated` to `()` = help: consider constraining the associated type `<impl GenericTrait<u8> + GenericTrait<()> as GenericTrait<()>>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_generic_trait` note: required by a bound in `accepts_generic_trait`

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
LL | type Sibling = Foo2; LL | type Sibling = Foo2;
| ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == ()` | ^^^^ type mismatch resolving `<Foo2 as Bar2>::Ok == ()`
| |
note: expected this to be `()` note: expected `()`, found `u32`
--> $DIR/point-at-type-on-obligation-failure.rs:18:15 --> $DIR/point-at-type-on-obligation-failure.rs:18:15
| |
LL | type Ok = u32; LL | type Ok = u32;

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i8 as Trait>::AssociatedType == u32`
LL | foo(3_i8); LL | foo(3_i8);
| ^^^ type mismatch resolving `<i8 as Trait>::AssociatedType == u32` | ^^^ type mismatch resolving `<i8 as Trait>::AssociatedType == u32`
| |
note: expected this to be `u32` note: expected `u32`, found `&str`
--> $DIR/E0271.rs:7:43 --> $DIR/E0271.rs:7:43
| |
LL | impl Trait for i8 { type AssociatedType = &'static str; } LL | impl Trait for i8 { type AssociatedType = &'static str; }

View File

@ -9,7 +9,6 @@ impl TraitWAssocConst for Demo {
fn foo<A: TraitWAssocConst<A=32>>() {} fn foo<A: TraitWAssocConst<A=32>>() {}
//~^ ERROR associated const equality //~^ ERROR associated const equality
//~| ERROR associated const equality
fn main() { fn main() {
foo::<Demo>(); foo::<Demo>();

View File

@ -7,12 +7,6 @@ LL | fn foo<A: TraitWAssocConst<A=32>>() {}
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
error: associated const equality is incomplete error: aborting due to previous error
--> $DIR/feature-gate-associated_const_equality.rs:10:28
|
LL | fn foo<A: TraitWAssocConst<A=32>>() {}
| ^^^^ cannot yet relate associated const
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.

View File

@ -19,7 +19,7 @@ LL | fn foo() -> impl Generator<Return = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found enum `Result` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found enum `Result`
| |
= note: expected type `i32` = note: expected type `i32`
found enum `Result<{integer}, _>` found type `Result<{integer}, _>`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -6,8 +6,8 @@ LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
LL | type Item<'a> = T; LL | type Item<'a> = T;
| ^ expected type parameter `T`, found associated type | ^ expected type parameter `T`, found associated type
| |
= note: expected type parameter `T` = note: expected type `T`
found associated type `<T as Deref>::Target` found type `<T as Deref>::Target`
note: required by a bound in `UnsafeCopy::Item` note: required by a bound in `UnsafeCopy::Item`
--> $DIR/issue-68656-unsized-values.rs:6:36 --> $DIR/issue-68656-unsized-values.rs:6:36
| |

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
LL | bug(Box::new(x)); LL | bug(Box::new(x));
| ^^^ type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]` | ^^^ type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
| |
note: expected this to be `[u8]` note: expected slice `[u8]`, found `i32`
--> $DIR/issue-74684-2.rs:10:18 --> $DIR/issue-74684-2.rs:10:18
| |
LL | type F<'a> = i32; LL | type F<'a> = i32;

View File

@ -4,13 +4,13 @@ error[E0271]: type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb
LL | let v = Unit2.m( LL | let v = Unit2.m(
| ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V` | ^ type mismatch resolving `for<'r> <L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]> as T0<'r, (&'r u8,)>>::O == <_ as Ty<'r>>::V`
| |
note: expected this to be `<_ as Ty<'_>>::V` note: expected associated type, found struct `Unit4`
--> $DIR/issue-62203-hrtb-ice.rs:21:14 --> $DIR/issue-62203-hrtb-ice.rs:21:14
| |
LL | type O = T::Output; LL | type O = T::Output;
| ^^^^^^^^^ | ^^^^^^^^^
= note: expected associated type `<_ as Ty<'_>>::V` = note: expected type `<_ as Ty<'_>>::V`
found struct `Unit4` found type `Unit4`
= help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V` = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `T1::m` note: required by a bound in `T1::m`

View File

@ -4,13 +4,13 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as imp
LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc`
| |
note: expected this to be `<T as impl_trait::Trait>::Assoc` note: expected associated type, found `()`
--> $DIR/bound-normalization-fail.rs:14:19 --> $DIR/bound-normalization-fail.rs:14:19
| |
LL | type Output = T; LL | type Output = T;
| ^ | ^
= note: expected associated type `<T as impl_trait::Trait>::Assoc` = note: expected type `<T as impl_trait::Trait>::Assoc`
found unit type `()` found type `()`
help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()` help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()`
| |
LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {
@ -28,13 +28,13 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lif
LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc`
| |
note: expected this to be `<T as lifetimes::Trait<'static>>::Assoc` note: expected associated type, found `()`
--> $DIR/bound-normalization-fail.rs:14:19 --> $DIR/bound-normalization-fail.rs:14:19
| |
LL | type Output = T; LL | type Output = T;
| ^ | ^
= note: expected associated type `<T as lifetimes::Trait<'static>>::Assoc` = note: expected type `<T as lifetimes::Trait<'static>>::Assoc`
found unit type `()` found type `()`
help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()` help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()`
| |
LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {

View File

@ -1,19 +1,16 @@
error[E0271]: type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` error[E0271]: type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
--> $DIR/issue-70877.rs:7:12 --> $DIR/issue-70877.rs:7:12
| |
LL | type FooRet = impl std::fmt::Debug;
| -------------------- the found opaque type
...
LL | type Foo = impl Iterator<Item = FooItem>; LL | type Foo = impl Iterator<Item = FooItem>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
| |
note: expected this to be `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` note: expected enum `Option`, found opaque type
--> $DIR/issue-70877.rs:13:17 --> $DIR/issue-70877.rs:13:17
| |
LL | type Item = FooItem; LL | type Item = FooItem;
| ^^^^^^^ | ^^^^^^^
= note: expected struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` = note: expected type `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
found struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>` found type `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()`
LL | fn test() -> impl Test { LL | fn test() -> impl Test {
| ^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == ()` | ^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == ()`
| |
note: expected this to be `()` note: expected `()`, found `u8`
--> $DIR/projection-mismatch-in-impl-where-clause.rs:6:18 --> $DIR/projection-mismatch-in-impl-where-clause.rs:6:18
| |
LL | type Assoc = u8; LL | type Assoc = u8;

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<TakeWhile<&mut std::vec::IntoIter<u8>, [
LL | .cloned() LL | .cloned()
| ^^^^^^ expected reference, found `u8` | ^^^^^^ expected reference, found `u8`
| |
= note: expected reference `&_` = note: expected type `&_`
found type `u8` found type `u8`
note: required by a bound in `cloned` note: required by a bound in `cloned`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
| |

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
LL | for _ in HashMap::new().iter().cloned() {} LL | for _ in HashMap::new().iter().cloned() {}
| ^^^^^^ expected reference, found tuple | ^^^^^^ expected reference, found tuple
| |
= note: expected reference `&_` = note: expected type `&_`
found tuple `(&_, &_)` found type `(&_, &_)`
note: required by a bound in `cloned` note: required by a bound in `cloned`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
| |
@ -18,8 +18,8 @@ error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _,
LL | for _ in HashMap::new().iter().cloned() {} LL | for _ in HashMap::new().iter().cloned() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
| |
= note: expected tuple `(&_, &_)` = note: expected type `(&_, &_)`
found reference `&_` found type `&_`
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>` = note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>` = note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()`
LL | <() as Visit>::visit(); LL | <() as Visit>::visit();
| ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()`
| |
note: expected this to be `()` note: expected `()`, found `&()`
--> $DIR/issue-39970.rs:10:20 --> $DIR/issue-39970.rs:10:20
| |
LL | type Element = &'a (); LL | type Element = &'a ();

View File

@ -4,8 +4,8 @@ error[E0271]: type mismatch resolving `<Rc<Apple> as Deref>::Target == Rc<Apple>
LL | let _ = Pin::new(Apple) == Rc::pin(Apple); LL | let _ = Pin::new(Apple) == Rc::pin(Apple);
| ^^ expected struct `Apple`, found struct `Rc` | ^^ expected struct `Apple`, found struct `Rc`
| |
= note: expected struct `Apple` = note: expected type `Apple`
found struct `Rc<Apple>` found type `Rc<Apple>`
= note: required because of the requirements on the impl of `PartialEq<Pin<Rc<Apple>>>` for `Pin<Apple>` = note: required because of the requirements on the impl of `PartialEq<Pin<Rc<Apple>>>` for `Pin<Apple>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -8,8 +8,8 @@ LL | | panic!("Can't connect to server.");
LL | | }) as Box<dyn FnMut()>); LL | | }) as Box<dyn FnMut()>);
| |______^ expected `()`, found `!` | |______^ expected `()`, found `!`
| |
= note: expected unit type `()` = note: expected type `()`
found type `!` found type `!`
= note: required for the cast to the object type `dyn FnMut()` = note: required for the cast to the object type `dyn FnMut()`
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
LL | is_obj(x) LL | is_obj(x)
| ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64` | ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64`
| |
note: expected this to be `i64` note: expected `i64`, found `i32`
--> $DIR/check-trait-object-bounds-5.rs:9:14 --> $DIR/check-trait-object-bounds-5.rs:9:14
| |
LL | type T = U; LL | type T = U;

View File

@ -4,7 +4,7 @@ error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
LL | is_obj(x) LL | is_obj(x)
| ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64` | ^^^^^^ type mismatch resolving `<i32 as Is>::T == i64`
| |
note: expected this to be `i64` note: expected `i64`, found `i32`
--> $DIR/check-trait-object-bounds-6.rs:9:14 --> $DIR/check-trait-object-bounds-6.rs:9:14
| |
LL | type T = U; LL | type T = U;

View File

@ -1,18 +1,16 @@
error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()` error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()`
--> $DIR/issue-63355.rs:34:20 --> $DIR/issue-63355.rs:34:20
| |
LL | pub type FooImpl = impl Foo;
| -------- the found opaque type
LL | pub type BarImpl = impl Bar<Foo = FooImpl>; LL | pub type BarImpl = impl Bar<Foo = FooImpl>;
| ^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Bar>::Foo == ()` | ^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Bar>::Foo == ()`
| |
note: expected this to be `()` note: expected `()`, found opaque type
--> $DIR/issue-63355.rs:24:16 --> $DIR/issue-63355.rs:24:16
| |
LL | type Foo = FooImpl; LL | type Foo = FooImpl;
| ^^^^^^^ | ^^^^^^^
= note: expected unit type `()` = note: expected type `()`
found opaque type `impl Foo` found type `impl Foo`
error: aborting due to previous error error: aborting due to previous error

View File

@ -3,17 +3,9 @@ error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as
| |
LL | type G<'a, T> = impl Future<Output = ()>; LL | type G<'a, T> = impl Future<Output = ()>;
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
...
LL | async move { self.f().await }
| ------------------ the found `async` block
| |
::: $SRC_DIR/core/src/future/mod.rs:LL:COL = note: expected type `()`
| found type `<impl Future<Output = [async output]> as Future>::Output`
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
= note: expected unit type `()`
found associated type `<impl Future<Output = [async output]> as Future>::Output`
= help: consider constraining the associated type `<impl Future<Output = [async output]> as Future>::Output` to `()` = help: consider constraining the associated type `<impl Future<Output = [async output]> as Future>::Output` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html