diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 55147ee337fde..acf67cdb94874 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -61,7 +61,7 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> { ConstraintCategory::OpaqueType => "opaque type ", ConstraintCategory::ClosureUpvar(_) => "closure capture ", ConstraintCategory::Usage => "this usage ", - ConstraintCategory::Predicate(_) + ConstraintCategory::Predicate(..) | ConstraintCategory::Boring | ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 44a84fb9d7f1a..0bffdb42d31fc 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1989,7 +1989,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { continue; }; debug!(?constraint, ?p); - let ConstraintCategory::Predicate(span) = constraint.category else { + let ConstraintCategory::Predicate(_, span) = constraint.category else { continue; }; extra_info.push(ExtraConstraintInfo::PlaceholderFromPredicate(span)); @@ -2004,11 +2004,13 @@ impl<'tcx> RegionInferenceContext<'tcx> { let cause_code = path .iter() .find_map(|constraint| { - if let ConstraintCategory::Predicate(predicate_span) = constraint.category { + if let ConstraintCategory::Predicate(source_def_id, predicate_span) = + constraint.category + { // We currently do not store the `DefId` in the `ConstraintCategory` // for performances reasons. The error reporting code used by NLL only // uses the span, so this doesn't cause any problems at the moment. - Some(ObligationCauseCode::WhereClause(CRATE_DEF_ID.to_def_id(), predicate_span)) + Some(ObligationCauseCode::WhereClause(source_def_id, predicate_span)) } else { None } @@ -2102,7 +2104,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { | ConstraintCategory::Boring | ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal - | ConstraintCategory::Predicate(_) => false, + | ConstraintCategory::Predicate(..) => false, ConstraintCategory::TypeAnnotation | ConstraintCategory::Return(_) | ConstraintCategory::Yield => true, @@ -2115,7 +2117,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { | ConstraintCategory::Boring | ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal - | ConstraintCategory::Predicate(_) + | ConstraintCategory::Predicate(..) ) } }; diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 2dc2568cd47ca..d32d9d4ff40fb 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -101,13 +101,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { &mut self, // Keep this parameter for now, in case we start using // it in `ConstraintCategory` at some point. - _def_id: DefId, + def_id: DefId, instantiated_predicates: ty::InstantiatedPredicates<'tcx>, locations: Locations, ) { for (predicate, span) in instantiated_predicates { debug!(?span, ?predicate); - let category = ConstraintCategory::Predicate(span); + let category = ConstraintCategory::Predicate(def_id, span); let predicate = self.normalize_with_category(predicate, locations, category); self.prove_predicate(predicate, locations, category); } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 80b7e3b4fa509..274104c992de5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -10,7 +10,7 @@ use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::intern::Interned; use rustc_errors::{Diag, IntoDiagArg}; use rustc_hir::def::Namespace; -use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; +use rustc_hir::def_id::DefId; use rustc_middle::bug; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode}; @@ -240,21 +240,17 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { ) -> Diag<'tcx> { let span = cause.span(); - let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = - if let ObligationCauseCode::WhereClause(def_id, span) - | ObligationCauseCode::WhereClauseInExpr(def_id, span, ..) = *cause.code() - && def_id != CRATE_DEF_ID.to_def_id() - { - ( - true, - Some(span), - Some(self.tcx().def_span(def_id)), - None, - self.tcx().def_path_str(def_id), - ) - } else { - (false, None, None, Some(span), String::new()) - }; + let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = match *cause.code() { + ObligationCauseCode::WhereClause(def_id, pred_span) + | ObligationCauseCode::WhereClauseInExpr(def_id, pred_span, ..) => ( + true, + Some(span), + if pred_span.is_dummy() { Some(span) } else { Some(pred_span) }, + None, + self.tcx().def_path_str(def_id), + ), + _ => (false, None, None, Some(span), String::new()), + }; let expected_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new_from_args( self.cx.tcx, diff --git a/compiler/rustc_infer/src/infer/error_reporting/region.rs b/compiler/rustc_infer/src/infer/error_reporting/region.rs index 5a465f46e47dc..8052db3789b04 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/region.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/region.rs @@ -262,7 +262,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer::CheckAssociatedTypeBounds { ref parent, .. } => { self.note_region_origin(err, parent); } - infer::AscribeUserTypeProvePredicate(span) => { + infer::AscribeUserTypeProvePredicate(_, span) => { RegionOriginNote::Plain { span, msg: fluent::infer_ascribe_user_type_prove_predicate, @@ -483,7 +483,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); err } - infer::AscribeUserTypeProvePredicate(span) => { + infer::AscribeUserTypeProvePredicate(_, span) => { let instantiated = note_and_explain::RegionExplanation::new( self.tcx, generic_param_scope, diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 9f55939c165e0..d07051fc11146 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -413,7 +413,7 @@ pub enum SubregionOrigin<'tcx> { trait_item_def_id: DefId, }, - AscribeUserTypeProvePredicate(Span), + AscribeUserTypeProvePredicate(DefId, Span), } // `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger. @@ -424,7 +424,9 @@ impl<'tcx> SubregionOrigin<'tcx> { pub fn to_constraint_category(&self) -> ConstraintCategory<'tcx> { match self { Self::Subtype(type_trace) => type_trace.cause.to_constraint_category(), - Self::AscribeUserTypeProvePredicate(span) => ConstraintCategory::Predicate(*span), + Self::AscribeUserTypeProvePredicate(def_id, span) => { + ConstraintCategory::Predicate(*def_id, *span) + } _ => ConstraintCategory::BoringNoLocation, } } @@ -1766,7 +1768,7 @@ impl<'tcx> SubregionOrigin<'tcx> { Reborrow(a) => a, ReferenceOutlivesReferent(_, a) => a, CompareImplItemObligation { span, .. } => span, - AscribeUserTypeProvePredicate(span) => span, + AscribeUserTypeProvePredicate(_, span) => span, CheckAssociatedTypeBounds { ref parent, .. } => parent.span(), } } @@ -1799,8 +1801,8 @@ impl<'tcx> SubregionOrigin<'tcx> { parent: Box::new(default()), }, - traits::ObligationCauseCode::AscribeUserTypeProvePredicate(span) => { - SubregionOrigin::AscribeUserTypeProvePredicate(span) + traits::ObligationCauseCode::AscribeUserTypeProvePredicate(def_id, span) => { + SubregionOrigin::AscribeUserTypeProvePredicate(def_id, span) } _ => default(), diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index d82ae7b4fb888..cdabbca1a24c4 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -66,6 +66,7 @@ use crate::infer::snapshot::undo_log::UndoLog; use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::undo_log::UndoLogs; +use rustc_hir::def_id::CRATE_DEF_ID; use rustc_middle::bug; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::query::NoSolution; @@ -153,11 +154,20 @@ impl<'tcx> InferCtxt<'tcx> { Some( deeply_normalize_ty( outlives, - SubregionOrigin::AscribeUserTypeProvePredicate(DUMMY_SP), + SubregionOrigin::AscribeUserTypeProvePredicate( + CRATE_DEF_ID.to_def_id(), + DUMMY_SP, + ), ) // FIXME(-Znext-solver): How do we accurately report an error span here :( .map_err(|NoSolution| { - (outlives, SubregionOrigin::AscribeUserTypeProvePredicate(DUMMY_SP)) + ( + outlives, + SubregionOrigin::AscribeUserTypeProvePredicate( + CRATE_DEF_ID.to_def_id(), + DUMMY_SP, + ), + ) }), ) }) diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index cd8e28522ecfb..4848100e79116 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -4,7 +4,7 @@ use crate::mir; use crate::ty::{self, CoroutineArgsExt, OpaqueHiddenType, Ty, TyCtxt}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::ErrorGuaranteed; -use rustc_hir::def_id::LocalDefId; +use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_index::bit_set::BitMatrix; use rustc_index::{Idx, IndexVec}; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; @@ -263,7 +263,7 @@ pub enum ConstraintCategory<'tcx> { /// A constraint from a user-written predicate /// with the provided span, written on the item /// with the given `DefId` - Predicate(Span), + Predicate(#[derivative(PartialOrd = "ignore", Ord = "ignore")] DefId, Span), /// A "boring" constraint (caused by the given location) is one that /// the user probably doesn't want to see described in diagnostics, diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index b74775142e487..0f36e24388e63 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -140,8 +140,8 @@ impl<'tcx> ObligationCause<'tcx> { pub fn to_constraint_category(&self) -> ConstraintCategory<'tcx> { match self.code() { ObligationCauseCode::MatchImpl(cause, _) => cause.to_constraint_category(), - ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span) => { - ConstraintCategory::Predicate(*predicate_span) + ObligationCauseCode::AscribeUserTypeProvePredicate(def_id, predicate_span) => { + ConstraintCategory::Predicate(*def_id, *predicate_span) } _ => ConstraintCategory::BoringNoLocation, } @@ -388,7 +388,7 @@ pub enum ObligationCauseCode<'tcx> { output_ty: Option>, }, - AscribeUserTypeProvePredicate(Span), + AscribeUserTypeProvePredicate(DefId, Span), RustCall, diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs index aca16950223c5..5ea7d38bf59a4 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs @@ -107,8 +107,8 @@ fn relate_mir_and_user_args<'tcx>( let span = if span == DUMMY_SP { predicate_span } else { span }; let cause = ObligationCause::new( span, - CRATE_DEF_ID, - ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span), + def_id.as_local().unwrap_or(CRATE_DEF_ID), + ObligationCauseCode::AscribeUserTypeProvePredicate(def_id, predicate_span), ); let instantiated_predicate = ocx.normalize(&cause.clone(), param_env, instantiated_predicate); @@ -118,7 +118,7 @@ fn relate_mir_and_user_args<'tcx>( // Now prove the well-formedness of `def_id` with `args`. // Note for some items, proving the WF of `ty` is not sufficient because the - // well-formedness of an item may depend on the WF of gneneric args not present in the + // well-formedness of an item may depend on the WF of generic args not present in the // item's type. Currently this is true for associated consts, e.g.: // ```rust // impl MyTy { diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..71bc941fbc50f 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -1,10 +1,13 @@ error: implementation of `Coroutine` is not general enough --> $DIR/resume-arg-late-bound.rs:15:5 | +LL | fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} + | ------------------------------- due to a where-clause on `test`... +... LL | test(gen); - | ^^^^^^^^^ implementation of `Coroutine` is not general enough + | ^^^^^^^^^ doesn't satisfy where-clause | - = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: ...`{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr index a26c617dc931d..939eb61d74113 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr @@ -1,15 +1,11 @@ error: implementation of `Trait` is not general enough --> $DIR/issue-59311.rs:17:5 | -LL | / pub fn crash(v: &V) -LL | | where -LL | | for<'a> &'a V: Trait + 'static, - | |____________________-----__________- due to a where-clause on `crash`... - | | - | doesn't satisfy where-clause -LL | { -LL | v.t(|| {}); - | ^^^^^^^^^^ +LL | for<'a> &'a V: Trait + 'static, + | ----- due to a where-clause on `crash`... +LL | { +LL | v.t(|| {}); + | ^^^^^^^^^^ doesn't satisfy where-clause | = note: ...`Trait` would have to be implemented for the type `&'a V` = note: ...but `Trait` is actually implemented for the type `&'0 V`, for some specific lifetime `'0` @@ -17,15 +13,11 @@ LL | v.t(|| {}); error: implementation of `Trait` is not general enough --> $DIR/issue-59311.rs:17:5 | -LL | / pub fn crash(v: &V) -LL | | where -LL | | for<'a> &'a V: Trait + 'static, - | |____________________-----__________- due to a where-clause on `crash`... - | | - | doesn't satisfy where-clause -LL | { -LL | v.t(|| {}); - | ^^^^^^^^^^ +LL | for<'a> &'a V: Trait + 'static, + | ----- due to a where-clause on `crash`... +LL | { +LL | v.t(|| {}); + | ^^^^^^^^^^ doesn't satisfy where-clause | = note: ...`Trait` would have to be implemented for the type `&'a V` = note: ...but `Trait` is actually implemented for the type `&'0 V`, for some specific lifetime `'0` diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr index b2bb417a8f01b..a5a34e9fd2608 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr @@ -1,40 +1,50 @@ error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:45:5 | +LL | F2: FnOnce(&::Output) -> bool + | --------------------------------------- due to a where-clause on `foo`... +... LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:45:5 | +LL | F2: FnOnce(&::Output) -> bool + | ---- due to a where-clause on `foo`... +... LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:48:5 | +LL | F2: FnOnce(&::Output) -> bool + | --------------------------------------- due to a where-clause on `foo`... +... LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-71955.rs:48:5 | +LL | F2: FnOnce(&::Output) -> bool + | ---- due to a where-clause on `foo`... +... LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 4 previous errors diff --git a/tests/ui/lifetimes/issue-105675.stderr b/tests/ui/lifetimes/issue-105675.stderr index 4b3d0e8ac5efc..e2a506dd8ba23 100644 --- a/tests/ui/lifetimes/issue-105675.stderr +++ b/tests/ui/lifetimes/issue-105675.stderr @@ -1,57 +1,75 @@ error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:5:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:5:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `for<'a> fn(&'2 u32, &'a u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&u32, &'2 u32, u32)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 u32, &u32, u32)` must implement `FnOnce<(&'1 u32, &u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32, &u32, u32)>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough --> $DIR/issue-105675.rs:9:5 | +LL | fn thing(x: impl FnOnce(&u32, &u32, u32)) {} + | ----------------------- due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&u32, &'2 u32, u32)` must implement `FnOnce<(&u32, &'1 u32, u32)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&u32, &'2 u32, u32)>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/lifetimes/issue-79187.stderr b/tests/ui/lifetimes/issue-79187.stderr index 8adde8d6dfbf3..81bd0cd05f96d 100644 --- a/tests/ui/lifetimes/issue-79187.stderr +++ b/tests/ui/lifetimes/issue-79187.stderr @@ -1,19 +1,25 @@ error: implementation of `FnOnce` is not general enough --> $DIR/issue-79187.rs:5:5 | +LL | fn thing(x: impl FnOnce(&u32)) {} + | ------------ due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue-79187.rs:5:5 | +LL | fn thing(x: impl FnOnce(&u32)) {} + | ------------ due to a where-clause on `thing`... +... LL | thing(f); - | ^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 u32)` must implement `FnOnce<(&'1 u32,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 u32,)>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr index 4dada6ff014ad..b7f66192ad44a 100644 --- a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -45,19 +45,25 @@ LL | fn g(data: &[T]) { error: implementation of `Fn` is not general enough --> $DIR/issue_74400.rs:12:5 | +LL | fn f(data: &[T], key: impl Fn(&T) -> S) { + | ----------- due to a where-clause on `f`... +... LL | f(data, identity) - | ^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough + | ^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `Fn<(&'1 T,)>`, for any lifetime `'1`... + = note: ...`fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `Fn<(&'1 T,)>`, for any lifetime `'1`... = note: ...but it actually implements `Fn<(&'2 T,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/issue_74400.rs:12:5 | +LL | fn f(data: &[T], key: impl Fn(&T) -> S) { + | - due to a where-clause on `f`... +... LL | f(data, identity) - | ^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... + = note: ...`fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` error: aborting due to 5 previous errors diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr index abc5d150a3f9c..6ca2ed3ea1125 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -66,19 +66,25 @@ LL | fn baz(_: F) {} error: implementation of `Fn` is not general enough --> $DIR/closure-arg-type-mismatch.rs:10:5 | +LL | fn baz(_: F) {} + | ------------- due to a where-clause on `baz`... +LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); - | ^^^^^^ implementation of `Fn` is not general enough + | ^^^^^^ doesn't satisfy where-clause | - = note: `fn(*mut &'2 u32)` must implement `Fn<(*mut &'1 u32,)>`, for any lifetime `'1`... + = note: ...`fn(*mut &'2 u32)` must implement `Fn<(*mut &'1 u32,)>`, for any lifetime `'1`... = note: ...but it actually implements `Fn<(*mut &'2 u32,)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/closure-arg-type-mismatch.rs:10:5 | +LL | fn baz(_: F) {} + | ------------- due to a where-clause on `baz`... +LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); - | ^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^ doesn't satisfy where-clause | - = note: `fn(*mut &'2 u32)` must implement `FnOnce<(*mut &'1 u32,)>`, for any lifetime `'1`... + = note: ...`fn(*mut &'2 u32)` must implement `FnOnce<(*mut &'1 u32,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(*mut &'2 u32,)>`, for some specific lifetime `'2` error: aborting due to 6 previous errors diff --git a/tests/ui/nll/missing-universe-cause-issue-114907.stderr b/tests/ui/nll/missing-universe-cause-issue-114907.stderr index 26ad1efec0558..df67b390dfd8d 100644 --- a/tests/ui/nll/missing-universe-cause-issue-114907.stderr +++ b/tests/ui/nll/missing-universe-cause-issue-114907.stderr @@ -1,19 +1,25 @@ error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | +LL | fn accept(_: C) -> Handshake> { + | ----------- due to a where-clause on `accept`... +... LL | accept(callback); - | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | +LL | fn accept(_: C) -> Handshake> { + | ----------- due to a where-clause on `accept`... +... LL | accept(callback); - | ^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | - = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -25,7 +31,6 @@ LL | accept(callback); | = note: closure with signature `fn(&'2 ())` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough --> $DIR/missing-universe-cause-issue-114907.rs:33:5 diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr index 1d086c658dfcd..e6261d26358f9 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.nll.stderr @@ -32,9 +32,12 @@ error: implementation of `FnOnce` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 | LL | bad(&b); - | ^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^ doesn't satisfy where-clause +... +LL | fn bad &()>(_: F) {} + | --- due to a where-clause on `bad`... | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error: aborting due to 3 previous errors diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr index 1d086c658dfcd..e6261d26358f9 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr +++ b/tests/ui/nll/polonius/location-insensitive-scopes-issue-117146.polonius.stderr @@ -32,9 +32,12 @@ error: implementation of `FnOnce` is not general enough --> $DIR/location-insensitive-scopes-issue-117146.rs:13:5 | LL | bad(&b); - | ^^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^ doesn't satisfy where-clause +... +LL | fn bad &()>(_: F) {} + | --- due to a where-clause on `bad`... | - = note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... + = note: ...closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` error: aborting due to 3 previous errors