Rollup merge of #106131 - compiler-errors:not-ptrs, r=davidtwco

Mention "signature" rather than "fn pointer" when impl/trait methods are incompatible

Fixes #80929
Fixes #67296
This commit is contained in:
Michael Goulet 2023-01-08 19:57:53 -08:00 committed by GitHub
commit 6afd16171d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 169 additions and 142 deletions

View File

@ -253,8 +253,8 @@ infer_trait_placeholder_mismatch = implementation of `{$trait_def_id}` is not ge
infer_trait_impl_diff = `impl` item signature doesn't match `trait` item signature infer_trait_impl_diff = `impl` item signature doesn't match `trait` item signature
.found = found `{$found}` .found = found `{$found}`
.expected = expected `{$expected}` .expected = expected `{$expected}`
.expected_found = expected `{$expected}` .expected_found = expected signature `{$expected}`
{" "}found `{$found}` {" "}found signature `{$found}`
infer_tid_rel_help = verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output infer_tid_rel_help = verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
infer_tid_consider_borrowing = consider borrowing this type parameter in the trait infer_tid_consider_borrowing = consider borrowing this type parameter in the trait

View File

@ -270,8 +270,8 @@ fn compare_method_predicate_entailment<'tcx>(
let unnormalized_impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(unnormalized_impl_sig)); let unnormalized_impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(unnormalized_impl_sig));
let norm_cause = ObligationCause::misc(impl_m_span, impl_m_hir_id); let norm_cause = ObligationCause::misc(impl_m_span, impl_m_hir_id);
let impl_fty = ocx.normalize(&norm_cause, param_env, unnormalized_impl_fty); let impl_sig = ocx.normalize(&norm_cause, param_env, unnormalized_impl_sig);
debug!("compare_impl_method: impl_fty={:?}", impl_fty); debug!("compare_impl_method: impl_fty={:?}", impl_sig);
let trait_sig = tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs); let trait_sig = tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs);
let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, trait_sig); let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, trait_sig);
@ -294,18 +294,17 @@ fn compare_method_predicate_entailment<'tcx>(
// type would be more appropriate. In other places we have a `Vec<Span>` // type would be more appropriate. In other places we have a `Vec<Span>`
// corresponding to their `Vec<Predicate>`, but we don't have that here. // corresponding to their `Vec<Predicate>`, but we don't have that here.
// Fixing this would improve the output of test `issue-83765.rs`. // Fixing this would improve the output of test `issue-83765.rs`.
let result = ocx.sup(&cause, param_env, trait_fty, impl_fty); let result = ocx.sup(&cause, param_env, trait_sig, impl_sig);
if let Err(terr) = result { if let Err(terr) = result {
debug!(?terr, "sub_types failed: impl ty {:?}, trait ty {:?}", impl_fty, trait_fty); debug!(?impl_sig, ?trait_sig, ?terr, "sub_types failed");
let emitted = report_trait_method_mismatch( let emitted = report_trait_method_mismatch(
&infcx, &infcx,
cause, cause,
terr, terr,
(trait_m, trait_fty), (trait_m, trait_sig),
(impl_m, impl_fty), (impl_m, impl_sig),
trait_sig,
impl_trait_ref, impl_trait_ref,
); );
return Err(emitted); return Err(emitted);
@ -484,7 +483,8 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
let impl_trait_ref = tcx.impl_trait_ref(impl_m.impl_container(tcx).unwrap()).unwrap(); let impl_trait_ref = tcx.impl_trait_ref(impl_m.impl_container(tcx).unwrap()).unwrap();
let param_env = tcx.param_env(def_id); let param_env = tcx.param_env(def_id);
// First, check a few of the same thing as `compare_impl_method`, just so we don't ICE during substitutions later. // First, check a few of the same things as `compare_impl_method`,
// just so we don't ICE during substitution later.
compare_number_of_generics(tcx, impl_m, trait_m, tcx.hir().span_if_local(impl_m.def_id), true)?; compare_number_of_generics(tcx, impl_m, trait_m, tcx.hir().span_if_local(impl_m.def_id), true)?;
compare_generic_param_kinds(tcx, impl_m, trait_m, true)?; compare_generic_param_kinds(tcx, impl_m, trait_m, true)?;
check_region_bounds_on_impl_item(tcx, impl_m, trait_m, true)?; check_region_bounds_on_impl_item(tcx, impl_m, trait_m, true)?;
@ -577,14 +577,11 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
debug!(?trait_sig, ?impl_sig, "equating function signatures"); debug!(?trait_sig, ?impl_sig, "equating function signatures");
let trait_fty = tcx.mk_fn_ptr(ty::Binder::dummy(trait_sig));
let impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(impl_sig));
// Unify the whole function signature. We need to do this to fully infer // Unify the whole function signature. We need to do this to fully infer
// the lifetimes of the return type, but do this after unifying just the // the lifetimes of the return type, but do this after unifying just the
// return types, since we want to avoid duplicating errors from // return types, since we want to avoid duplicating errors from
// `compare_method_predicate_entailment`. // `compare_method_predicate_entailment`.
match ocx.eq(&cause, param_env, trait_fty, impl_fty) { match ocx.eq(&cause, param_env, trait_sig, impl_sig) {
Ok(()) => {} Ok(()) => {}
Err(terr) => { Err(terr) => {
// This function gets called during `compare_method_predicate_entailment` when normalizing a // This function gets called during `compare_method_predicate_entailment` when normalizing a
@ -595,9 +592,8 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
infcx, infcx,
cause, cause,
terr, terr,
(trait_m, trait_fty), (trait_m, trait_sig),
(impl_m, impl_fty), (impl_m, impl_sig),
trait_sig,
impl_trait_ref, impl_trait_ref,
); );
return Err(emitted); return Err(emitted);
@ -771,9 +767,8 @@ fn report_trait_method_mismatch<'tcx>(
infcx: &InferCtxt<'tcx>, infcx: &InferCtxt<'tcx>,
mut cause: ObligationCause<'tcx>, mut cause: ObligationCause<'tcx>,
terr: TypeError<'tcx>, terr: TypeError<'tcx>,
(trait_m, trait_fty): (&ty::AssocItem, Ty<'tcx>), (trait_m, trait_sig): (&ty::AssocItem, ty::FnSig<'tcx>),
(impl_m, impl_fty): (&ty::AssocItem, Ty<'tcx>), (impl_m, impl_sig): (&ty::AssocItem, ty::FnSig<'tcx>),
trait_sig: ty::FnSig<'tcx>,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> ErrorGuaranteed { ) -> ErrorGuaranteed {
let tcx = infcx.tcx; let tcx = infcx.tcx;
@ -858,10 +853,7 @@ fn report_trait_method_mismatch<'tcx>(
&mut diag, &mut diag,
&cause, &cause,
trait_err_span.map(|sp| (sp, "type in trait".to_owned())), trait_err_span.map(|sp| (sp, "type in trait".to_owned())),
Some(infer::ValuePairs::Terms(ExpectedFound { Some(infer::ValuePairs::Sigs(ExpectedFound { expected: trait_sig, found: impl_sig })),
expected: trait_fty.into(),
found: impl_fty.into(),
})),
terr, terr,
false, false,
false, false,

View File

@ -427,3 +427,15 @@ impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
} }
} }
} }
impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
fn to_trace(
_: TyCtxt<'tcx>,
cause: &ObligationCause<'tcx>,
a_is_expected: bool,
a: Self,
b: Self,
) -> TypeTrace<'tcx> {
TypeTrace { cause: cause.clone(), values: Sigs(ExpectedFound::new(a_is_expected, a, b)) }
}
}

View File

@ -1428,8 +1428,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
impl<'tcx> OpaqueTypesVisitor<'tcx> { impl<'tcx> OpaqueTypesVisitor<'tcx> {
fn visit_expected_found( fn visit_expected_found(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
expected: Ty<'tcx>, expected: impl TypeVisitable<'tcx>,
found: Ty<'tcx>, found: impl TypeVisitable<'tcx>,
ignore_span: Span, ignore_span: Span,
) -> Self { ) -> Self {
let mut types_visitor = OpaqueTypesVisitor { let mut types_visitor = OpaqueTypesVisitor {
@ -1569,6 +1569,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
_ => (false, Mismatch::Fixed("type")), _ => (false, Mismatch::Fixed("type")),
} }
} }
ValuePairs::Sigs(infer::ExpectedFound { expected, found }) => {
OpaqueTypesVisitor::visit_expected_found(self.tcx, expected, found, span)
.report(diag);
(false, Mismatch::Fixed("signature"))
}
ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => { ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => {
(false, Mismatch::Fixed("trait")) (false, Mismatch::Fixed("trait"))
} }
@ -2040,6 +2045,17 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
ret => ret, ret => ret,
} }
} }
infer::Sigs(exp_found) => {
let exp_found = self.resolve_vars_if_possible(exp_found);
if exp_found.references_error() {
return None;
}
let (exp, fnd) = self.cmp_fn_sig(
&ty::Binder::dummy(exp_found.expected),
&ty::Binder::dummy(exp_found.found),
);
Some((exp, fnd, None, None))
}
} }
} }

View File

@ -3,7 +3,7 @@
use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}; use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::Subtype; use crate::infer::{Subtype, ValuePairs};
use crate::traits::ObligationCauseCode::CompareImplItemObligation; use crate::traits::ObligationCauseCode::CompareImplItemObligation;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
@ -11,6 +11,7 @@ use rustc_hir::def::Res;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::print::RegionHighlightMode; use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
use rustc_span::Span; use rustc_span::Span;
@ -23,22 +24,27 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let error = self.error.as_ref()?; let error = self.error.as_ref()?;
debug!("try_report_impl_not_conforming_to_trait {:?}", error); debug!("try_report_impl_not_conforming_to_trait {:?}", error);
if let RegionResolutionError::SubSupConflict( if let RegionResolutionError::SubSupConflict(
_, _,
var_origin, var_origin,
sub_origin, sub_origin,
_sub, _sub,
sup_origin, sup_origin,
_sup, _sup,
_, _,
) = error.clone() ) = error.clone()
&& let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin) && let (Subtype(sup_trace), Subtype(sub_trace)) = (&sup_origin, &sub_origin)
&& let sub_expected_found @ Some((sub_expected, sub_found)) = sub_trace.values.ty()
&& let sup_expected_found @ Some(_) = sup_trace.values.ty()
&& let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code() && let CompareImplItemObligation { trait_item_def_id, .. } = sub_trace.cause.code()
&& sup_expected_found == sub_expected_found && sub_trace.values == sup_trace.values
&& let ValuePairs::Sigs(ExpectedFound { expected, found }) = sub_trace.values
{ {
let guar = // FIXME(compiler-errors): Don't like that this needs `Ty`s, but
self.emit_err(var_origin.span(), sub_expected, sub_found, *trait_item_def_id); // all of the region highlighting machinery only deals with those.
let guar = self.emit_err(
var_origin.span(),
self.cx.tcx.mk_fn_ptr(ty::Binder::dummy(expected)),
self.cx.tcx.mk_fn_ptr(ty::Binder::dummy(found)),
*trait_item_def_id,
);
return Some(guar); return Some(guar);
} }
None None

View File

@ -361,6 +361,7 @@ pub enum ValuePairs<'tcx> {
Terms(ExpectedFound<ty::Term<'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>>),
Sigs(ExpectedFound<ty::FnSig<'tcx>>),
} }
impl<'tcx> ValuePairs<'tcx> { impl<'tcx> ValuePairs<'tcx> {

View File

@ -22,8 +22,8 @@ note: type in trait
| |
LL | fn make() -> Self::Ty { LL | fn make() -> Self::Ty {
| ^^^^^^^^ | ^^^^^^^^
= note: expected fn pointer `fn() -> <A<T> as Tr>::Ty` = note: expected signature `fn() -> <A<T> as Tr>::Ty`
found fn pointer `fn() -> u8` found signature `fn() -> u8`
error[E0053]: method `make` has an incompatible type for trait error[E0053]: method `make` has an incompatible type for trait
--> $DIR/defaults-specialization.rs:35:18 --> $DIR/defaults-specialization.rs:35:18
@ -42,8 +42,8 @@ note: type in trait
| |
LL | fn make() -> Self::Ty { LL | fn make() -> Self::Ty {
| ^^^^^^^^ | ^^^^^^^^
= note: expected fn pointer `fn() -> <B<T> as Tr>::Ty` = note: expected signature `fn() -> <B<T> as Tr>::Ty`
found fn pointer `fn() -> bool` found signature `fn() -> bool`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/defaults-specialization.rs:10:9 --> $DIR/defaults-specialization.rs:10:9

View File

@ -9,8 +9,8 @@ note: type in trait
| |
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected fn pointer `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>`
found fn pointer `fn(&i32) -> impl Future<Output = i32>` found signature `fn(&i32) -> impl Future<Output = i32>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -22,8 +22,8 @@ error[E0308]: method not compatible with trait
LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
| |
= note: expected fn pointer `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)`
found fn pointer `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)`
note: the lifetime `'c` as defined here... note: the lifetime `'c` as defined here...
--> $DIR/regions-bound-missing-bound-in-impl.rs:27:24 --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24
| |
@ -41,8 +41,8 @@ error[E0308]: method not compatible with trait
LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { LL | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
| |
= note: expected fn pointer `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)` = note: expected signature `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'_>)`
found fn pointer `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)` found signature `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'_>)`
note: the lifetime `'c` as defined here... note: the lifetime `'c` as defined here...
--> $DIR/regions-bound-missing-bound-in-impl.rs:27:24 --> $DIR/regions-bound-missing-bound-in-impl.rs:27:24
| |

View File

@ -7,8 +7,8 @@ LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> {
| expected struct `Pin`, found struct `MyFuture` | expected struct `Pin`, found struct `MyFuture`
| help: change the self-receiver type to match the trait: `self: Pin<&mut MyFuture>` | help: change the self-receiver type to match the trait: `self: Pin<&mut MyFuture>`
| |
= note: expected fn pointer `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>` = note: expected signature `fn(Pin<&mut MyFuture>, &mut Context<'_>) -> Poll<_>`
found fn pointer `fn(MyFuture, &mut Context<'_>) -> Poll<_>` found signature `fn(MyFuture, &mut Context<'_>) -> Poll<_>`
error[E0053]: method `foo` has an incompatible type for trait error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/bad-self-type.rs:22:18 --> $DIR/bad-self-type.rs:22:18
@ -24,8 +24,8 @@ note: type in trait
| |
LL | fn foo(self); LL | fn foo(self);
| ^^^^ | ^^^^
= note: expected fn pointer `fn(MyFuture)` = note: expected signature `fn(MyFuture)`
found fn pointer `fn(Box<MyFuture>)` found signature `fn(Box<MyFuture>)`
error[E0053]: method `bar` has an incompatible type for trait error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/bad-self-type.rs:24:18 --> $DIR/bad-self-type.rs:24:18
@ -38,8 +38,8 @@ note: type in trait
| |
LL | fn bar(self) -> Option<()>; LL | fn bar(self) -> Option<()>;
| ^^^^^^^^^^ | ^^^^^^^^^^
= note: expected fn pointer `fn(MyFuture) -> Option<()>` = note: expected signature `fn(MyFuture) -> Option<()>`
found fn pointer `fn(MyFuture)` found signature `fn(MyFuture)`
help: change the output type to match the trait help: change the output type to match the trait
| |
LL | fn bar(self) -> Option<()> {} LL | fn bar(self) -> Option<()> {}

View File

@ -7,8 +7,8 @@ LL | fn from(_: fn((), (), &mut ())) -> Self {
| types differ in mutability | types differ in mutability
| help: change the parameter type to match the trait: `for<'a> fn((), (), &'a ())` | help: change the parameter type to match the trait: `for<'a> fn((), (), &'a ())`
| |
= note: expected fn pointer `fn(for<'a> fn((), (), &'a ())) -> A` = note: expected signature `fn(for<'a> fn((), (), &'a ())) -> A`
found fn pointer `fn(for<'a> fn((), (), &'a mut ())) -> A` found signature `fn(for<'a> fn((), (), &'a mut ())) -> A`
error[E0053]: method `from` has an incompatible type for trait error[E0053]: method `from` has an incompatible type for trait
--> $DIR/issue-90444.rs:11:16 --> $DIR/issue-90444.rs:11:16
@ -19,8 +19,8 @@ LL | fn from(_: fn((), (), u64)) -> Self {
| expected `u32`, found `u64` | expected `u32`, found `u64`
| help: change the parameter type to match the trait: `fn((), (), u32)` | help: change the parameter type to match the trait: `fn((), (), u32)`
| |
= note: expected fn pointer `fn(fn((), (), u32)) -> B` = note: expected signature `fn(fn((), (), u32)) -> B`
found fn pointer `fn(fn((), (), u64)) -> B` found signature `fn(fn((), (), u64)) -> B`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -14,8 +14,8 @@ note: type in trait
| |
LL | fn b<C:Clone,D>(&self, x: C) -> C; LL | fn b<C:Clone,D>(&self, x: C) -> C;
| ^ | ^
= note: expected fn pointer `fn(&E, F) -> F` = note: expected signature `fn(&E, F) -> F`
found fn pointer `fn(&E, G) -> G` found signature `fn(&E, G) -> G`
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

View File

@ -13,8 +13,8 @@ note: type in trait
| |
LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug); LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
| ^^ | ^^
= note: expected fn pointer `fn(&(), &B, &impl Debug)` = note: expected signature `fn(&(), &B, &impl Debug)`
found fn pointer `fn(&(), &impl Debug, &B)` found signature `fn(&(), &impl Debug, &B)`
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters

View File

@ -12,8 +12,8 @@ note: type in trait
| |
LL | fn owo(x: ()) -> impl Sized; LL | fn owo(x: ()) -> impl Sized;
| ^^ | ^^
= note: expected fn pointer `fn(())` = note: expected signature `fn(())`
found fn pointer `fn(u8)` found signature `fn(u8)`
error[E0053]: method `owo` has an incompatible type for trait error[E0053]: method `owo` has an incompatible type for trait
--> $DIR/method-signature-matches.rs:20:21 --> $DIR/method-signature-matches.rs:20:21
@ -39,8 +39,8 @@ note: type in trait
| |
LL | async fn owo(x: ()) {} LL | async fn owo(x: ()) {}
| ^^ | ^^
= note: expected fn pointer `fn(()) -> _` = note: expected signature `fn(()) -> _`
found fn pointer `fn(u8) -> _` found signature `fn(u8) -> _`
error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0
--> $DIR/method-signature-matches.rs:29:28 --> $DIR/method-signature-matches.rs:29:28
@ -75,8 +75,8 @@ note: type in trait
| |
LL | fn early<'early, T>(x: &'early T) -> impl Sized; LL | fn early<'early, T>(x: &'early T) -> impl Sized;
| ^^^^^^^^^ | ^^^^^^^^^
= note: expected fn pointer `fn(&'early T)` = note: expected signature `fn(&'early T)`
found fn pointer `fn(&())` found signature `fn(&())`
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@ -7,8 +7,8 @@ LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a { LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
| |
= note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static` = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + 'static`
found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

View File

@ -15,8 +15,8 @@ note: type in trait
| |
LL | fn bar(&self) -> impl Sized; LL | fn bar(&self) -> impl Sized;
| ^^^^^^^^^^ | ^^^^^^^^^^
= note: expected fn pointer `fn(&U) -> impl Sized` = note: expected signature `fn(&U) -> impl Sized`
found fn pointer `fn(&U) -> U` found signature `fn(&U) -> U`
error: aborting due to previous error error: aborting due to previous error

View File

@ -18,8 +18,8 @@ LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
| expected struct `Bar`, found opaque type | expected struct `Bar`, found opaque type
| help: change the parameter type to match the trait: `&(a::Bar, i32)` | help: change the parameter type to match the trait: `&(a::Bar, i32)`
| |
= note: expected fn pointer `fn(&a::Bar, &(a::Bar, i32)) -> _` = note: expected signature `fn(&a::Bar, &(a::Bar, i32)) -> _`
found fn pointer `fn(&a::Bar, &(a::Foo, i32)) -> _` found signature `fn(&a::Bar, &(a::Foo, i32)) -> _`
error: unconstrained opaque type error: unconstrained opaque type
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16 --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16
@ -41,8 +41,8 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
| expected opaque type, found struct `Bar` | expected opaque type, found struct `Bar`
| help: change the parameter type to match the trait: `&(b::Foo, i32)` | help: change the parameter type to match the trait: `&(b::Foo, i32)`
| |
= note: expected fn pointer `fn(&b::Bar, &(b::Foo, i32)) -> _` = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _`
found fn pointer `fn(&b::Bar, &(b::Bar, i32)) -> _` found signature `fn(&b::Bar, &(b::Bar, i32)) -> _`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -7,8 +7,8 @@ LL | fn fmt(&self, x: &str) -> () { }
| types differ in mutability | types differ in mutability
| help: change the parameter type to match the trait: `&mut Formatter<'_>` | help: change the parameter type to match the trait: `&mut Formatter<'_>`
| |
= note: expected fn pointer `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` = note: expected signature `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>`
found fn pointer `fn(&MyType, &str)` found signature `fn(&MyType, &str)`
error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2 error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2
--> $DIR/trait_type.rs:12:11 --> $DIR/trait_type.rs:12:11

View File

@ -7,8 +7,8 @@ struct Baz;
impl Foo for Baz { impl Foo for Baz {
fn bar(&mut self, other: &dyn Foo) {} fn bar(&mut self, other: &dyn Foo) {}
//~^ ERROR method `bar` has an incompatible type for trait //~^ ERROR method `bar` has an incompatible type for trait
//~| expected fn pointer `fn(&mut Baz, &mut dyn Foo)` //~| expected signature `fn(&mut Baz, &mut dyn Foo)`
//~| found fn pointer `fn(&mut Baz, &dyn Foo)` //~| found signature `fn(&mut Baz, &dyn Foo)`
} }
fn main() {} fn main() {}

View File

@ -12,8 +12,8 @@ note: type in trait
| |
LL | fn bar(&mut self, other: &mut dyn Foo); LL | fn bar(&mut self, other: &mut dyn Foo);
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
= note: expected fn pointer `fn(&mut Baz, &mut dyn Foo)` = note: expected signature `fn(&mut Baz, &mut dyn Foo)`
found fn pointer `fn(&mut Baz, &dyn Foo)` found signature `fn(&mut Baz, &dyn Foo)`
error: aborting due to previous error error: aborting due to previous error

View File

@ -10,8 +10,8 @@ impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> {
type Output = (); type Output = ();
fn call_once(self, _args: ()) { fn call_once(self, _args: ()) {
//~^ ERROR `call_once` has an incompatible type for trait //~^ ERROR `call_once` has an incompatible type for trait
//~| expected fn pointer `extern "rust-call" fn //~| expected signature `extern "rust-call" fn
//~| found fn pointer `fn //~| found signature `fn
println!("{:?}", self.x); println!("{:?}", self.x);
} }
} }

View File

@ -4,8 +4,8 @@ error[E0053]: method `call_once` has an incompatible type for trait
LL | fn call_once(self, _args: ()) { LL | fn call_once(self, _args: ()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn
| |
= note: expected fn pointer `extern "rust-call" fn(Debuger<_>, ())` = note: expected signature `extern "rust-call" fn(Debuger<_>, ())`
found fn pointer `fn(Debuger<_>, ())` found signature `fn(Debuger<_>, ())`
error: aborting due to previous error error: aborting due to previous error

View File

@ -9,8 +9,8 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
| expected `&T`, found type parameter `T` | expected `&T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)` | help: change the parameter type to match the trait: `(&'a T,)`
| |
= note: expected fn pointer `extern "rust-call" fn(&Foo, (&'a T,))` = note: expected signature `extern "rust-call" fn(&Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(&Foo, (T,))` found signature `extern "rust-call" fn(&Foo, (T,))`
error[E0053]: method `call_mut` has an incompatible type for trait error[E0053]: method `call_mut` has an incompatible type for trait
--> $DIR/issue-20225.rs:11:51 --> $DIR/issue-20225.rs:11:51
@ -23,8 +23,8 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
| expected `&T`, found type parameter `T` | expected `&T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)` | help: change the parameter type to match the trait: `(&'a T,)`
| |
= note: expected fn pointer `extern "rust-call" fn(&mut Foo, (&'a T,))` = note: expected signature `extern "rust-call" fn(&mut Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(&mut Foo, (T,))` found signature `extern "rust-call" fn(&mut Foo, (T,))`
error[E0053]: method `call_once` has an incompatible type for trait error[E0053]: method `call_once` has an incompatible type for trait
--> $DIR/issue-20225.rs:18:47 --> $DIR/issue-20225.rs:18:47
@ -38,8 +38,8 @@ LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
| expected `&T`, found type parameter `T` | expected `&T`, found type parameter `T`
| help: change the parameter type to match the trait: `(&'a T,)` | help: change the parameter type to match the trait: `(&'a T,)`
| |
= note: expected fn pointer `extern "rust-call" fn(Foo, (&'a T,))` = note: expected signature `extern "rust-call" fn(Foo, (&'a T,))`
found fn pointer `extern "rust-call" fn(Foo, (T,))` found signature `extern "rust-call" fn(Foo, (T,))`
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@ -7,8 +7,8 @@ LL | fn next(&mut self) -> Result<i32, i32> { Ok(7) }
| expected enum `Option`, found enum `Result` | expected enum `Option`, found enum `Result`
| help: change the output type to match the trait: `Option<i32>` | help: change the output type to match the trait: `Option<i32>`
| |
= note: expected fn pointer `fn(&mut S) -> Option<i32>` = note: expected signature `fn(&mut S) -> Option<i32>`
found fn pointer `fn(&mut S) -> Result<i32, i32>` found signature `fn(&mut S) -> Result<i32, i32>`
error: aborting due to previous error error: aborting due to previous error

View File

@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait
LL | fn next(&'a mut self) -> Option<Self::Item> LL | fn next(&'a mut self) -> Option<Self::Item>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
| |
= note: expected fn pointer `fn(&mut RepeatMut<'a, T>) -> Option<_>` = note: expected signature `fn(&mut RepeatMut<'a, T>) -> Option<_>`
found fn pointer `fn(&'a mut RepeatMut<'a, T>) -> Option<_>` found signature `fn(&'a mut RepeatMut<'a, T>) -> Option<_>`
note: the anonymous lifetime as defined here... note: the anonymous lifetime as defined here...
--> $DIR/issue-37884.rs:6:5 --> $DIR/issue-37884.rs:6:5
| |

View File

@ -7,8 +7,8 @@ LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 { LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'1 i32) -> &'1 i32` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 i32, &'1 i32) -> &'1 i32`
| |
= note: expected `fn(&'1 i32, &'a i32) -> &'a i32` = note: expected signature `fn(&'1 i32, &'a i32) -> &'a i32`
found `fn(&'1 i32, &'1 i32) -> &'1 i32` found signature `fn(&'1 i32, &'1 i32) -> &'1 i32`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

View File

@ -12,8 +12,8 @@ note: type in trait
| |
LL | fn foo(x: u16); LL | fn foo(x: u16);
| ^^^ | ^^^
= note: expected fn pointer `fn(u16)` = note: expected signature `fn(u16)`
found fn pointer `fn(i16)` found signature `fn(i16)`
error[E0053]: method `bar` has an incompatible type for trait error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/E0053.rs:11:12 --> $DIR/E0053.rs:11:12
@ -29,8 +29,8 @@ note: type in trait
| |
LL | fn bar(&self); LL | fn bar(&self);
| ^^^^^ | ^^^^^
= note: expected fn pointer `fn(&Bar)` = note: expected signature `fn(&Bar)`
found fn pointer `fn(&mut Bar)` found signature `fn(&mut Bar)`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -18,8 +18,8 @@ LL | fn next(&mut self) -> Option<IteratorChunk<T, S>> {
| |
= note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` = note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>`
| |
= note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>` = note: expected signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'static, T, S>>`
found `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>` found signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

View File

@ -7,8 +7,8 @@ LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType>>;
LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> { LL | fn adjacent_edges(&self) -> Box<dyn MyTrait<Item = &Self::EdgeType> + '_> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
| |
= note: expected `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>` = note: expected signature `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + 'static)>`
found `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>` found signature `fn(&'1 T) -> Box<(dyn MyTrait<Item = &'1 T> + '1)>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/issue-75361-mismatched-impl.rs:12:55 --> $DIR/issue-75361-mismatched-impl.rs:12:55
| |

View File

@ -12,8 +12,8 @@ note: type in trait
| |
LL | fn foo(x: u16); LL | fn foo(x: u16);
| ^^^ | ^^^
= note: expected fn pointer `fn(u16)` = note: expected signature `fn(u16)`
found fn pointer `fn(i16)` found signature `fn(i16)`
error[E0053]: method `bar` has an incompatible type for trait error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/trait-impl-fn-incompatibility.rs:10:28 --> $DIR/trait-impl-fn-incompatibility.rs:10:28
@ -29,8 +29,8 @@ note: type in trait
| |
LL | fn bar(&mut self, bar: &mut Bar); LL | fn bar(&mut self, bar: &mut Bar);
| ^^^^^^^^ | ^^^^^^^^
= note: expected fn pointer `fn(&mut Bar, &mut Bar)` = note: expected signature `fn(&mut Bar, &mut Bar)`
found fn pointer `fn(&mut Bar, &Bar)` found signature `fn(&mut Bar, &Bar)`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -6,8 +6,8 @@ impl Mumbo for usize {
// Cannot have a larger effect than the trait: // Cannot have a larger effect than the trait:
unsafe fn jumbo(&self, x: &usize) { *self + *x; } unsafe fn jumbo(&self, x: &usize) { *self + *x; }
//~^ ERROR method `jumbo` has an incompatible type for trait //~^ ERROR method `jumbo` has an incompatible type for trait
//~| expected fn pointer `fn //~| expected signature `fn
//~| found fn pointer `unsafe fn //~| found signature `unsafe fn
} }
fn main() {} fn main() {}

View File

@ -9,8 +9,8 @@ note: type in trait
| |
LL | fn jumbo(&self, x: &usize) -> usize; LL | fn jumbo(&self, x: &usize) -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected fn pointer `fn(&usize, &usize) -> usize` = note: expected signature `fn(&usize, &usize) -> usize`
found fn pointer `unsafe fn(&usize, &usize)` found signature `unsafe fn(&usize, &usize)`
error: aborting due to previous error error: aborting due to previous error

View File

@ -12,8 +12,8 @@ note: type in trait
| |
LL | fn foo(_: fn(u8) -> ()); LL | fn foo(_: fn(u8) -> ());
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
= note: expected fn pointer `fn(fn(u8))` = note: expected signature `fn(fn(u8))`
found fn pointer `fn(fn(u16))` found signature `fn(fn(u16))`
error[E0053]: method `bar` has an incompatible type for trait error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/issue-35869.rs:13:15 --> $DIR/issue-35869.rs:13:15
@ -29,8 +29,8 @@ note: type in trait
| |
LL | fn bar(_: Option<u8>); LL | fn bar(_: Option<u8>);
| ^^^^^^^^^^ | ^^^^^^^^^^
= note: expected fn pointer `fn(Option<u8>)` = note: expected signature `fn(Option<u8>)`
found fn pointer `fn(Option<u16>)` found signature `fn(Option<u16>)`
error[E0053]: method `baz` has an incompatible type for trait error[E0053]: method `baz` has an incompatible type for trait
--> $DIR/issue-35869.rs:15:15 --> $DIR/issue-35869.rs:15:15
@ -46,8 +46,8 @@ note: type in trait
| |
LL | fn baz(_: (u8, u16)); LL | fn baz(_: (u8, u16));
| ^^^^^^^^^ | ^^^^^^^^^
= note: expected fn pointer `fn((u8, _))` = note: expected signature `fn((u8, _))`
found fn pointer `fn((u16, _))` found signature `fn((u16, _))`
error[E0053]: method `qux` has an incompatible type for trait error[E0053]: method `qux` has an incompatible type for trait
--> $DIR/issue-35869.rs:17:17 --> $DIR/issue-35869.rs:17:17
@ -63,8 +63,8 @@ note: type in trait
| |
LL | fn qux() -> u8; LL | fn qux() -> u8;
| ^^ | ^^
= note: expected fn pointer `fn() -> u8` = note: expected signature `fn() -> u8`
found fn pointer `fn() -> u16` found signature `fn() -> u16`
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View File

@ -4,8 +4,8 @@ error[E0308]: method not compatible with trait
LL | fn foo(x: Foo<'b,'a>) { LL | fn foo(x: Foo<'b,'a>) {
| ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
| |
= note: expected fn pointer `fn(Foo<'a, 'b>)` = note: expected signature `fn(Foo<'a, 'b>)`
found fn pointer `fn(Foo<'b, 'a>)` found signature `fn(Foo<'b, 'a>)`
note: the lifetime `'b` as defined here... note: the lifetime `'b` as defined here...
--> $DIR/matching-lifetimes.rs:13:9 --> $DIR/matching-lifetimes.rs:13:9
| |
@ -23,8 +23,8 @@ error[E0308]: method not compatible with trait
LL | fn foo(x: Foo<'b,'a>) { LL | fn foo(x: Foo<'b,'a>) {
| ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
| |
= note: expected fn pointer `fn(Foo<'a, 'b>)` = note: expected signature `fn(Foo<'a, 'b>)`
found fn pointer `fn(Foo<'b, 'a>)` found signature `fn(Foo<'b, 'a>)`
note: the lifetime `'a` as defined here... note: the lifetime `'a` as defined here...
--> $DIR/matching-lifetimes.rs:13:6 --> $DIR/matching-lifetimes.rs:13:6
| |

View File

@ -7,8 +7,8 @@ LL | fn get_relation(&self) -> To;
LL | fn get_relation(&self) -> &ProofReader { LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Article) -> &'1 ProofReader` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Article) -> &'1 ProofReader`
| |
= note: expected `fn(&'1 Article) -> &'2 ProofReader` = note: expected signature `fn(&'1 Article) -> &'2 ProofReader`
found `fn(&'1 Article) -> &'1 ProofReader` found signature `fn(&'1 Article) -> &'1 ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/param-without-lifetime-constraint.rs:10:31 --> $DIR/param-without-lifetime-constraint.rs:10:31
| |

View File

@ -7,8 +7,8 @@ LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self, &Self>;
LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
| |
= note: expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>`
found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/self-without-lifetime-constraint.rs:41:60 --> $DIR/self-without-lifetime-constraint.rs:41:60
| |

View File

@ -7,8 +7,8 @@ trait Foo {
impl Foo for u32 { impl Foo for u32 {
fn len(&self) -> u32 { *self } fn len(&self) -> u32 { *self }
//~^ ERROR method `len` has an incompatible type for trait //~^ ERROR method `len` has an incompatible type for trait
//~| expected fn pointer `unsafe fn(&u32) -> _` //~| expected signature `unsafe fn(&u32) -> _`
//~| found fn pointer `fn(&u32) -> _` //~| found signature `fn(&u32) -> _`
} }
fn main() { } fn main() { }

View File

@ -9,8 +9,8 @@ note: type in trait
| |
LL | unsafe fn len(&self) -> u32; LL | unsafe fn len(&self) -> u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: expected fn pointer `unsafe fn(&u32) -> _` = note: expected signature `unsafe fn(&u32) -> _`
found fn pointer `fn(&u32) -> _` found signature `fn(&u32) -> _`
error: aborting due to previous error error: aborting due to previous error

View File

@ -7,8 +7,8 @@ LL | fn mul(self, s: &f64) -> Vec1 {
| expected `f64`, found `&f64` | expected `f64`, found `&f64`
| help: change the parameter type to match the trait: `f64` | help: change the parameter type to match the trait: `f64`
| |
= note: expected fn pointer `fn(Vec1, f64) -> Vec1` = note: expected signature `fn(Vec1, f64) -> Vec1`
found fn pointer `fn(Vec1, &f64) -> Vec1` found signature `fn(Vec1, &f64) -> Vec1`
error[E0053]: method `mul` has an incompatible type for trait error[E0053]: method `mul` has an incompatible type for trait
--> $DIR/wrong-mul-method-signature.rs:33:21 --> $DIR/wrong-mul-method-signature.rs:33:21
@ -19,8 +19,8 @@ LL | fn mul(self, s: f64) -> Vec2 {
| expected struct `Vec2`, found `f64` | expected struct `Vec2`, found `f64`
| help: change the parameter type to match the trait: `Vec2` | help: change the parameter type to match the trait: `Vec2`
| |
= note: expected fn pointer `fn(Vec2, Vec2) -> f64` = note: expected signature `fn(Vec2, Vec2) -> f64`
found fn pointer `fn(Vec2, f64) -> Vec2` found signature `fn(Vec2, f64) -> Vec2`
error[E0053]: method `mul` has an incompatible type for trait error[E0053]: method `mul` has an incompatible type for trait
--> $DIR/wrong-mul-method-signature.rs:52:29 --> $DIR/wrong-mul-method-signature.rs:52:29
@ -31,8 +31,8 @@ LL | fn mul(self, s: f64) -> f64 {
| expected `i32`, found `f64` | expected `i32`, found `f64`
| help: change the output type to match the trait: `i32` | help: change the output type to match the trait: `i32`
| |
= note: expected fn pointer `fn(Vec3, _) -> i32` = note: expected signature `fn(Vec3, _) -> i32`
found fn pointer `fn(Vec3, _) -> f64` found signature `fn(Vec3, _) -> f64`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong-mul-method-signature.rs:63:45 --> $DIR/wrong-mul-method-signature.rs:63:45