1pub mod auto_trait;
6pub(crate) mod coherence;
7pub mod const_evaluatable;
8mod dyn_compatibility;
9pub mod effects;
10mod engine;
11mod fulfill;
12pub mod misc;
13pub mod normalize;
14pub mod outlives_bounds;
15pub mod project;
16pub mod query;
17#[allow(hidden_glob_reexports)]
18mod select;
19mod specialize;
20mod structural_normalize;
21#[allow(hidden_glob_reexports)]
22mod util;
23pub mod vtable;
24pub mod wf;
25
26use std::fmt::Debug;
27use std::ops::ControlFlow;
28
29use rustc_errors::ErrorGuaranteed;
30use rustc_hir::def::DefKind;
31pub use rustc_infer::traits::*;
32use rustc_middle::query::Providers;
33use rustc_middle::span_bug;
34use rustc_middle::ty::error::{ExpectedFound, TypeError};
35use rustc_middle::ty::{
36 self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
37 TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypingMode, Upcast,
38};
39use rustc_span::def_id::DefId;
40use rustc_span::{DUMMY_SP, Span};
41use tracing::{debug, instrument};
42
43pub use self::coherence::{
44 InCrate, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
45 add_placeholder_note, orphan_check_trait_ref, overlapping_impls,
46};
47pub use self::dyn_compatibility::{
48 DynCompatibilityViolation, dyn_compatibility_violations_for_assoc_item,
49 hir_ty_lowering_dyn_compatibility_violations, is_vtable_safe_method,
50};
51pub use self::engine::{ObligationCtxt, TraitEngineExt};
52pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
53pub use self::normalize::NormalizeExt;
54pub use self::project::{normalize_inherent_projection, normalize_projection_ty};
55pub use self::select::{
56 EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache,
57 SelectionContext,
58};
59pub use self::specialize::specialization_graph::{
60 FutureCompatOverlapError, FutureCompatOverlapErrorKind,
61};
62pub use self::specialize::{
63 OverlapError, specialization_graph, translate_args, translate_args_with_cause,
64};
65pub use self::structural_normalize::StructurallyNormalizeExt;
66pub use self::util::{
67 BoundVarReplacer, PlaceholderReplacer, elaborate, expand_trait_aliases, impl_item_is_final,
68 supertrait_def_ids, supertraits, transitive_bounds_that_define_assoc_item, upcast_choices,
69 with_replaced_escaping_bound_vars,
70};
71use crate::error_reporting::InferCtxtErrorExt;
72use crate::infer::outlives::env::OutlivesEnvironment;
73use crate::infer::{InferCtxt, TyCtxtInferExt};
74use crate::regions::InferCtxtRegionExt;
75use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
76
77#[derive(Debug)]
78pub struct FulfillmentError<'tcx> {
79 pub obligation: PredicateObligation<'tcx>,
80 pub code: FulfillmentErrorCode<'tcx>,
81 pub root_obligation: PredicateObligation<'tcx>,
85}
86
87impl<'tcx> FulfillmentError<'tcx> {
88 pub fn new(
89 obligation: PredicateObligation<'tcx>,
90 code: FulfillmentErrorCode<'tcx>,
91 root_obligation: PredicateObligation<'tcx>,
92 ) -> FulfillmentError<'tcx> {
93 FulfillmentError { obligation, code, root_obligation }
94 }
95
96 pub fn is_true_error(&self) -> bool {
97 match self.code {
98 FulfillmentErrorCode::Select(_)
99 | FulfillmentErrorCode::Project(_)
100 | FulfillmentErrorCode::Subtype(_, _)
101 | FulfillmentErrorCode::ConstEquate(_, _) => true,
102 FulfillmentErrorCode::Cycle(_) | FulfillmentErrorCode::Ambiguity { overflow: _ } => {
103 false
104 }
105 }
106 }
107}
108
109#[derive(Clone)]
110pub enum FulfillmentErrorCode<'tcx> {
111 Cycle(PredicateObligations<'tcx>),
114 Select(SelectionError<'tcx>),
115 Project(MismatchedProjectionTypes<'tcx>),
116 Subtype(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), ConstEquate(ExpectedFound<ty::Const<'tcx>>, TypeError<'tcx>),
118 Ambiguity {
119 overflow: Option<bool>,
123 },
124}
125
126impl<'tcx> Debug for FulfillmentErrorCode<'tcx> {
127 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
128 match *self {
129 FulfillmentErrorCode::Select(ref e) => write!(f, "{e:?}"),
130 FulfillmentErrorCode::Project(ref e) => write!(f, "{e:?}"),
131 FulfillmentErrorCode::Subtype(ref a, ref b) => {
132 write!(f, "CodeSubtypeError({a:?}, {b:?})")
133 }
134 FulfillmentErrorCode::ConstEquate(ref a, ref b) => {
135 write!(f, "CodeConstEquateError({a:?}, {b:?})")
136 }
137 FulfillmentErrorCode::Ambiguity { overflow: None } => write!(f, "Ambiguity"),
138 FulfillmentErrorCode::Ambiguity { overflow: Some(suggest_increasing_limit) } => {
139 write!(f, "Overflow({suggest_increasing_limit})")
140 }
141 FulfillmentErrorCode::Cycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
142 }
143 }
144}
145
146#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
152pub enum SkipLeakCheck {
153 Yes,
154 #[default]
155 No,
156}
157
158impl SkipLeakCheck {
159 fn is_yes(self) -> bool {
160 self == SkipLeakCheck::Yes
161 }
162}
163
164#[derive(Copy, Clone, PartialEq, Eq, Debug)]
166pub enum TraitQueryMode {
167 Standard,
171 Canonical,
175}
176
177#[instrument(level = "debug", skip(cause, param_env))]
179pub fn predicates_for_generics<'tcx>(
180 cause: impl Fn(usize, Span) -> ObligationCause<'tcx>,
181 param_env: ty::ParamEnv<'tcx>,
182 generic_bounds: ty::InstantiatedPredicates<'tcx>,
183) -> impl Iterator<Item = PredicateObligation<'tcx>> {
184 generic_bounds.into_iter().enumerate().map(move |(idx, (clause, span))| Obligation {
185 cause: cause(idx, span),
186 recursion_depth: 0,
187 param_env,
188 predicate: clause.as_predicate(),
189 })
190}
191
192pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
198 infcx: &InferCtxt<'tcx>,
199 param_env: ty::ParamEnv<'tcx>,
200 ty: Ty<'tcx>,
201 def_id: DefId,
202) -> bool {
203 let trait_ref = ty::TraitRef::new(infcx.tcx, def_id, [ty]);
204 pred_known_to_hold_modulo_regions(infcx, param_env, trait_ref)
205}
206
207#[instrument(level = "debug", skip(infcx, param_env, pred), ret)]
212fn pred_known_to_hold_modulo_regions<'tcx>(
213 infcx: &InferCtxt<'tcx>,
214 param_env: ty::ParamEnv<'tcx>,
215 pred: impl Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>,
216) -> bool {
217 let obligation = Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, pred);
218
219 let result = infcx.evaluate_obligation_no_overflow(&obligation);
220 debug!(?result);
221
222 if result.must_apply_modulo_regions() {
223 true
224 } else if result.may_apply() {
225 let goal = infcx.resolve_vars_if_possible((obligation.predicate, obligation.param_env));
230 infcx.probe(|_| {
231 let ocx = ObligationCtxt::new(infcx);
232 ocx.register_obligation(obligation);
233
234 let errors = ocx.select_all_or_error();
235 match errors.as_slice() {
236 [] => infcx.resolve_vars_if_possible(goal) == goal,
238
239 errors => {
240 debug!(?errors);
241 false
242 }
243 }
244 })
245 } else {
246 false
247 }
248}
249
250#[instrument(level = "debug", skip(tcx, elaborated_env))]
251fn do_normalize_predicates<'tcx>(
252 tcx: TyCtxt<'tcx>,
253 cause: ObligationCause<'tcx>,
254 elaborated_env: ty::ParamEnv<'tcx>,
255 predicates: Vec<ty::Clause<'tcx>>,
256) -> Result<Vec<ty::Clause<'tcx>>, ErrorGuaranteed> {
257 let span = cause.span;
258
259 let infcx = tcx.infer_ctxt().ignoring_regions().build(TypingMode::non_body_analysis());
273 let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
274 let predicates = ocx.normalize(&cause, elaborated_env, predicates);
275
276 let errors = ocx.select_all_or_error();
277 if !errors.is_empty() {
278 let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
279 return Err(reported);
280 }
281
282 debug!("do_normalize_predicates: normalized predicates = {:?}", predicates);
283
284 let errors = infcx.resolve_regions(cause.body_id, elaborated_env, []);
290 if !errors.is_empty() {
291 tcx.dcx().span_delayed_bug(
292 span,
293 format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"),
294 );
295 }
296
297 match infcx.fully_resolve(predicates) {
298 Ok(predicates) => Ok(predicates),
299 Err(fixup_err) => {
300 span_bug!(
310 span,
311 "inference variables in normalized parameter environment: {}",
312 fixup_err
313 );
314 }
315 }
316}
317
318#[instrument(level = "debug", skip(tcx))]
321pub fn normalize_param_env_or_error<'tcx>(
322 tcx: TyCtxt<'tcx>,
323 unnormalized_env: ty::ParamEnv<'tcx>,
324 cause: ObligationCause<'tcx>,
325) -> ty::ParamEnv<'tcx> {
326 let mut predicates: Vec<_> = util::elaborate(
341 tcx,
342 unnormalized_env.caller_bounds().into_iter().map(|predicate| {
343 if tcx.features().generic_const_exprs() {
344 return predicate;
345 }
346
347 struct ConstNormalizer<'tcx>(TyCtxt<'tcx>);
348
349 impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ConstNormalizer<'tcx> {
350 fn cx(&self) -> TyCtxt<'tcx> {
351 self.0
352 }
353
354 fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
355 if c.has_escaping_bound_vars() {
359 return ty::Const::new_misc_error(self.0);
360 }
361
362 if let ty::ConstKind::Unevaluated(uv) = c.kind()
367 && self.0.def_kind(uv.def) == DefKind::AnonConst
368 {
369 let infcx = self.0.infer_ctxt().build(TypingMode::non_body_analysis());
370 let c = evaluate_const(&infcx, c, ty::ParamEnv::empty());
371 assert!(!c.has_infer() && !c.has_placeholders());
374 return c;
375 }
376
377 c
378 }
379 }
380
381 predicate.fold_with(&mut ConstNormalizer(tcx))
411 }),
412 )
413 .collect();
414
415 debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates);
416
417 let elaborated_env = ty::ParamEnv::new(tcx.mk_clauses(&predicates));
418 if !elaborated_env.has_aliases() {
419 return elaborated_env;
420 }
421
422 let outlives_predicates: Vec<_> = predicates
441 .extract_if(.., |predicate| {
442 matches!(predicate.kind().skip_binder(), ty::ClauseKind::TypeOutlives(..))
443 })
444 .collect();
445
446 debug!(
447 "normalize_param_env_or_error: predicates=(non-outlives={:?}, outlives={:?})",
448 predicates, outlives_predicates
449 );
450 let Ok(non_outlives_predicates) =
451 do_normalize_predicates(tcx, cause.clone(), elaborated_env, predicates)
452 else {
453 debug!("normalize_param_env_or_error: errored resolving non-outlives predicates");
455 return elaborated_env;
456 };
457
458 debug!("normalize_param_env_or_error: non-outlives predicates={:?}", non_outlives_predicates);
459
460 let outlives_env = non_outlives_predicates.iter().chain(&outlives_predicates).cloned();
464 let outlives_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(outlives_env));
465 let Ok(outlives_predicates) =
466 do_normalize_predicates(tcx, cause, outlives_env, outlives_predicates)
467 else {
468 debug!("normalize_param_env_or_error: errored resolving outlives predicates");
470 return elaborated_env;
471 };
472 debug!("normalize_param_env_or_error: outlives predicates={:?}", outlives_predicates);
473
474 let mut predicates = non_outlives_predicates;
475 predicates.extend(outlives_predicates);
476 debug!("normalize_param_env_or_error: final predicates={:?}", predicates);
477 ty::ParamEnv::new(tcx.mk_clauses(&predicates))
478}
479
480#[derive(Debug)]
481pub enum EvaluateConstErr {
482 HasGenericsOrInfers,
486 InvalidConstParamTy(ErrorGuaranteed),
490 EvaluationFailure(ErrorGuaranteed),
493}
494
495pub fn evaluate_const<'tcx>(
505 infcx: &InferCtxt<'tcx>,
506 ct: ty::Const<'tcx>,
507 param_env: ty::ParamEnv<'tcx>,
508) -> ty::Const<'tcx> {
509 match try_evaluate_const(infcx, ct, param_env) {
510 Ok(ct) => ct,
511 Err(EvaluateConstErr::EvaluationFailure(e) | EvaluateConstErr::InvalidConstParamTy(e)) => {
512 ty::Const::new_error(infcx.tcx, e)
513 }
514 Err(EvaluateConstErr::HasGenericsOrInfers) => ct,
515 }
516}
517
518#[instrument(level = "debug", skip(infcx), ret)]
527pub fn try_evaluate_const<'tcx>(
528 infcx: &InferCtxt<'tcx>,
529 ct: ty::Const<'tcx>,
530 param_env: ty::ParamEnv<'tcx>,
531) -> Result<ty::Const<'tcx>, EvaluateConstErr> {
532 let tcx = infcx.tcx;
533 let ct = infcx.resolve_vars_if_possible(ct);
534 debug!(?ct);
535
536 match ct.kind() {
537 ty::ConstKind::Value(..) => Ok(ct),
538 ty::ConstKind::Error(e) => Err(EvaluateConstErr::EvaluationFailure(e)),
539 ty::ConstKind::Param(_)
540 | ty::ConstKind::Infer(_)
541 | ty::ConstKind::Bound(_, _)
542 | ty::ConstKind::Placeholder(_)
543 | ty::ConstKind::Expr(_) => Err(EvaluateConstErr::HasGenericsOrInfers),
544 ty::ConstKind::Unevaluated(uv) => {
545 let (args, typing_env) = if tcx.features().generic_const_exprs()
557 && uv.has_non_region_infer()
558 {
559 match tcx.thir_abstract_const(uv.def) {
563 Ok(Some(ct)) => {
564 let ct = tcx.expand_abstract_consts(ct.instantiate(tcx, uv.args));
565 if let Err(e) = ct.error_reported() {
566 return Err(EvaluateConstErr::EvaluationFailure(e));
567 } else if ct.has_non_region_infer() || ct.has_non_region_param() {
568 return Err(EvaluateConstErr::HasGenericsOrInfers);
571 } else {
572 let args = replace_param_and_infer_args_with_placeholder(tcx, uv.args);
573 let typing_env = infcx
574 .typing_env(tcx.erase_regions(param_env))
575 .with_post_analysis_normalized(tcx);
576 (args, typing_env)
577 }
578 }
579 Err(_) | Ok(None) => {
580 let args = GenericArgs::identity_for_item(tcx, uv.def);
581 let typing_env = ty::TypingEnv::post_analysis(tcx, uv.def);
582 (args, typing_env)
583 }
584 }
585 } else if tcx.def_kind(uv.def) == DefKind::AnonConst && uv.has_non_region_infer() {
586 tcx.dcx().delayed_bug(
597 "Encountered anon const with inference variable args but no error reported",
598 );
599
600 let args = GenericArgs::identity_for_item(tcx, uv.def);
601 let typing_env = ty::TypingEnv::post_analysis(tcx, uv.def);
602 (args, typing_env)
603 } else {
604 let typing_env = infcx
608 .typing_env(tcx.erase_regions(param_env))
609 .with_post_analysis_normalized(tcx);
610 (uv.args, typing_env)
611 };
612 let uv = ty::UnevaluatedConst::new(uv.def, args);
613
614 let erased_uv = tcx.erase_regions(uv);
615 use rustc_middle::mir::interpret::ErrorHandled;
616 match tcx.const_eval_resolve_for_typeck(typing_env, erased_uv, DUMMY_SP) {
617 Ok(Ok(val)) => Ok(ty::Const::new_value(
618 tcx,
619 val,
620 tcx.type_of(uv.def).instantiate(tcx, uv.args),
621 )),
622 Ok(Err(_)) => {
623 let e = tcx.dcx().delayed_bug(
624 "Type system constant with non valtree'able type evaluated but no error emitted",
625 );
626 Err(EvaluateConstErr::InvalidConstParamTy(e))
627 }
628 Err(ErrorHandled::Reported(info, _)) => {
629 Err(EvaluateConstErr::EvaluationFailure(info.into()))
630 }
631 Err(ErrorHandled::TooGeneric(_)) => Err(EvaluateConstErr::HasGenericsOrInfers),
632 }
633 }
634 }
635}
636
637fn replace_param_and_infer_args_with_placeholder<'tcx>(
641 tcx: TyCtxt<'tcx>,
642 args: GenericArgsRef<'tcx>,
643) -> GenericArgsRef<'tcx> {
644 struct ReplaceParamAndInferWithPlaceholder<'tcx> {
645 tcx: TyCtxt<'tcx>,
646 idx: u32,
647 }
648
649 impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
650 fn cx(&self) -> TyCtxt<'tcx> {
651 self.tcx
652 }
653
654 fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
655 if let ty::Infer(_) = t.kind() {
656 let idx = {
657 let idx = self.idx;
658 self.idx += 1;
659 idx
660 };
661 Ty::new_placeholder(
662 self.tcx,
663 ty::PlaceholderType {
664 universe: ty::UniverseIndex::ROOT,
665 bound: ty::BoundTy {
666 var: ty::BoundVar::from_u32(idx),
667 kind: ty::BoundTyKind::Anon,
668 },
669 },
670 )
671 } else {
672 t.super_fold_with(self)
673 }
674 }
675
676 fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
677 if let ty::ConstKind::Infer(_) = c.kind() {
678 ty::Const::new_placeholder(
679 self.tcx,
680 ty::PlaceholderConst {
681 universe: ty::UniverseIndex::ROOT,
682 bound: ty::BoundVar::from_u32({
683 let idx = self.idx;
684 self.idx += 1;
685 idx
686 }),
687 },
688 )
689 } else {
690 c.super_fold_with(self)
691 }
692 }
693 }
694
695 args.fold_with(&mut ReplaceParamAndInferWithPlaceholder { tcx, idx: 0 })
696}
697
698pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec<ty::Clause<'tcx>>) -> bool {
703 debug!("impossible_predicates(predicates={:?})", predicates);
704 let (infcx, param_env) =
705 tcx.infer_ctxt().build_with_typing_env(ty::TypingEnv::fully_monomorphized());
706 let ocx = ObligationCtxt::new(&infcx);
707 let predicates = ocx.normalize(&ObligationCause::dummy(), param_env, predicates);
708 for predicate in predicates {
709 let obligation = Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate);
710 ocx.register_obligation(obligation);
711 }
712 let errors = ocx.select_all_or_error();
713
714 if !errors.is_empty() {
715 return true;
716 }
717
718 if !infcx.next_trait_solver() && infcx.leak_check(ty::UniverseIndex::ROOT, None).is_err() {
722 return true;
723 }
724
725 false
726}
727
728fn instantiate_and_check_impossible_predicates<'tcx>(
729 tcx: TyCtxt<'tcx>,
730 key: (DefId, GenericArgsRef<'tcx>),
731) -> bool {
732 debug!("instantiate_and_check_impossible_predicates(key={:?})", key);
733
734 let mut predicates = tcx.predicates_of(key.0).instantiate(tcx, key.1).predicates;
735
736 if let Some(trait_def_id) = tcx.trait_of_item(key.0) {
739 let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, key.1);
740 predicates.push(trait_ref.upcast(tcx));
741 }
742
743 predicates.retain(|predicate| !predicate.has_param());
744 let result = impossible_predicates(tcx, predicates);
745
746 debug!("instantiate_and_check_impossible_predicates(key={:?}) = {:?}", key, result);
747 result
748}
749
750fn is_impossible_associated_item(
755 tcx: TyCtxt<'_>,
756 (impl_def_id, trait_item_def_id): (DefId, DefId),
757) -> bool {
758 struct ReferencesOnlyParentGenerics<'tcx> {
759 tcx: TyCtxt<'tcx>,
760 generics: &'tcx ty::Generics,
761 trait_item_def_id: DefId,
762 }
763 impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for ReferencesOnlyParentGenerics<'tcx> {
764 type Result = ControlFlow<()>;
765 fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
766 if let ty::Param(param) = *t.kind()
768 && let param_def_id = self.generics.type_param(param, self.tcx).def_id
769 && self.tcx.parent(param_def_id) == self.trait_item_def_id
770 {
771 return ControlFlow::Break(());
772 }
773 t.super_visit_with(self)
774 }
775 fn visit_region(&mut self, r: ty::Region<'tcx>) -> Self::Result {
776 if let ty::ReEarlyParam(param) = r.kind()
777 && let param_def_id = self.generics.region_param(param, self.tcx).def_id
778 && self.tcx.parent(param_def_id) == self.trait_item_def_id
779 {
780 return ControlFlow::Break(());
781 }
782 ControlFlow::Continue(())
783 }
784 fn visit_const(&mut self, ct: ty::Const<'tcx>) -> Self::Result {
785 if let ty::ConstKind::Param(param) = ct.kind()
786 && let param_def_id = self.generics.const_param(param, self.tcx).def_id
787 && self.tcx.parent(param_def_id) == self.trait_item_def_id
788 {
789 return ControlFlow::Break(());
790 }
791 ct.super_visit_with(self)
792 }
793 }
794
795 let generics = tcx.generics_of(trait_item_def_id);
796 let predicates = tcx.predicates_of(trait_item_def_id);
797
798 let infcx = tcx
803 .infer_ctxt()
804 .ignoring_regions()
805 .with_next_trait_solver(true)
806 .build(TypingMode::Coherence);
807 let param_env = ty::ParamEnv::empty();
808 let fresh_args = infcx.fresh_args_for_item(tcx.def_span(impl_def_id), impl_def_id);
809
810 let impl_trait_ref = tcx
811 .impl_trait_ref(impl_def_id)
812 .expect("expected impl to correspond to trait")
813 .instantiate(tcx, fresh_args);
814
815 let mut visitor = ReferencesOnlyParentGenerics { tcx, generics, trait_item_def_id };
816 let predicates_for_trait = predicates.predicates.iter().filter_map(|(pred, span)| {
817 pred.visit_with(&mut visitor).is_continue().then(|| {
818 Obligation::new(
819 tcx,
820 ObligationCause::dummy_with_span(*span),
821 param_env,
822 ty::EarlyBinder::bind(*pred).instantiate(tcx, impl_trait_ref.args),
823 )
824 })
825 });
826
827 let ocx = ObligationCtxt::new(&infcx);
828 ocx.register_obligations(predicates_for_trait);
829 !ocx.select_where_possible().is_empty()
830}
831
832pub fn provide(providers: &mut Providers) {
833 dyn_compatibility::provide(providers);
834 vtable::provide(providers);
835 *providers = Providers {
836 specialization_graph_of: specialize::specialization_graph_provider,
837 specializes: specialize::specializes,
838 specialization_enabled_in: specialize::specialization_enabled_in,
839 instantiate_and_check_impossible_predicates,
840 is_impossible_associated_item,
841 ..*providers
842 };
843}