Skip to main content

rustc_next_trait_solver/solve/
effect_goals.rs

1//! Dealing with host effect goals, i.e. enforcing the constness in
2//! `T: const Trait` or `T: [const] Trait`.
3
4use rustc_type_ir::fast_reject::DeepRejectCtxt;
5use rustc_type_ir::inherent::*;
6use rustc_type_ir::lang_items::SolverTraitLangItem;
7use rustc_type_ir::solve::inspect::ProbeKind;
8use rustc_type_ir::solve::{
9    AliasBoundKind, NoSolutionOrRerunNonErased, QueryResultOrRerunNonErased, RerunNonErased,
10    SizedTraitKind,
11};
12use rustc_type_ir::{self as ty, Interner, Unnormalized, elaborate};
13use tracing::instrument;
14
15use super::assembly::{Candidate, structural_traits};
16use crate::delegate::SolverDelegate;
17use crate::solve::{
18    BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, NoSolution, assembly,
19};
20
21impl<D, I> assembly::GoalKind<D> for ty::HostEffectClause<I>
22where
23    D: SolverDelegate<Interner = I>,
24    I: Interner,
25{
26    fn self_ty(self) -> I::Ty {
27        self.self_ty()
28    }
29
30    fn trait_ref(self, _: I) -> ty::TraitRef<I> {
31        self.trait_ref
32    }
33
34    fn with_replaced_self_ty(self, cx: I, self_ty: I::Ty) -> Self {
35        self.with_replaced_self_ty(cx, self_ty)
36    }
37
38    fn trait_def_id(self, _: I) -> I::TraitId {
39        self.def_id()
40    }
41
42    fn fast_reject_assumption(
43        ecx: &mut EvalCtxt<'_, D>,
44        goal: Goal<I, Self>,
45        _goal_lang_item: Option<SolverTraitLangItem>,
46        assumption: I::Clause,
47    ) -> Result<(), NoSolution> {
48        if let Some(host_clause) = assumption.as_host_effect_clause()
49            && host_clause.def_id() == goal.predicate.def_id()
50            && host_clause.constness().satisfies(goal.predicate.constness)
51            && DeepRejectCtxt::relate_rigid_rigid(ecx.cx()).args_may_unify(
52                goal.predicate.trait_ref.args,
53                host_clause.skip_binder().trait_ref.args,
54            )
55        {
56            Ok(())
57        } else {
58            Err(NoSolution)
59        }
60    }
61
62    fn match_assumption(
63        ecx: &mut EvalCtxt<'_, D>,
64        goal: Goal<I, Self>,
65        assumption: I::Clause,
66        then: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResultOrRerunNonErased<I>,
67    ) -> QueryResultOrRerunNonErased<I> {
68        let host_clause = assumption.as_host_effect_clause().unwrap();
69
70        let assumption_trait_pred = ecx.instantiate_binder_with_infer(host_clause);
71        ecx.eq(goal.param_env, goal.predicate.trait_ref, assumption_trait_pred.trait_ref)?;
72
73        then(ecx)
74    }
75
76    /// Register additional assumptions for aliases corresponding to `[const]` item bounds.
77    ///
78    /// Unlike item bounds, they are not simply implied by the well-formedness of the alias.
79    /// Instead, they only hold if the const conditions on the alias also hold. This is why
80    /// we also register the const conditions of the alias after matching the goal against
81    /// the assumption.
82    fn consider_additional_alias_assumptions(
83        ecx: &mut EvalCtxt<'_, D>,
84        goal: Goal<I, Self>,
85        alias_ty: ty::AliasTy<I>,
86    ) -> Vec<Candidate<I>> {
87        let cx = ecx.cx();
88        let mut candidates = ::alloc::vec::Vec::new()vec![];
89
90        let def_id = match alias_ty.kind {
91            ty::AliasTyKind::Projection { def_id } => def_id.into(),
92            ty::AliasTyKind::Inherent { def_id } => def_id.into(),
93            ty::AliasTyKind::Opaque { def_id } => def_id.into(),
94            ty::AliasTyKind::Free { def_id } => def_id.into(),
95        };
96
97        if !ecx.cx().alias_has_const_conditions(def_id) {
98            return ::alloc::vec::Vec::new()vec![];
99        }
100
101        for clause in elaborate::elaborate(
102            cx,
103            cx.explicit_implied_const_bounds(def_id).iter_instantiated(cx, alias_ty.args).map(
104                |trait_ref| {
105                    trait_ref.to_host_effect_clause(cx, goal.predicate.constness).skip_norm_wip()
106                },
107            ),
108        ) {
109            candidates.extend(Self::probe_and_match_goal_against_assumption(
110                ecx,
111                CandidateSource::AliasBound(AliasBoundKind::SelfBounds),
112                goal,
113                clause,
114                |ecx| {
115                    // Const conditions must hold for the implied const bound to hold.
116                    ecx.add_goals(
117                        GoalSource::AliasBoundConstCondition,
118                        cx.const_conditions(def_id).iter_instantiated(cx, alias_ty.args).map(
119                            |trait_ref| {
120                                goal.with(
121                                    cx,
122                                    trait_ref
123                                        .to_host_effect_clause(cx, goal.predicate.constness)
124                                        .skip_norm_wip(),
125                                )
126                            },
127                        ),
128                    )?;
129                    ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
130                },
131            ));
132        }
133
134        candidates
135    }
136
137    fn consider_impl_candidate(
138        ecx: &mut EvalCtxt<'_, D>,
139        goal: Goal<I, Self>,
140        goal_trait_ref: ty::TraitRef<I>,
141        impl_def_id: I::ImplId,
142        then: impl FnOnce(&mut EvalCtxt<'_, D>) -> QueryResultOrRerunNonErased<I>,
143    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
144        let cx = ecx.cx();
145
146        let impl_trait_ref = cx.impl_trait_ref(impl_def_id);
147        if !DeepRejectCtxt::relate_rigid_infer(ecx.cx())
148            .args_may_unify(goal_trait_ref.args, impl_trait_ref.skip_binder().args)
149        {
150            return Err(NoSolution.into());
151        }
152
153        // For every `default impl`, there's always a non-default `impl` that will *also* apply.
154        // There's no reason to register a candidate for this impl, since it is *not* proof that
155        // the trait goal holds.
156        if cx.impl_is_default(impl_def_id) {
157            return Err(NoSolution.into());
158        }
159
160        match cx.impl_polarity(impl_def_id) {
161            ty::ImplPolarity::Negative => return Err(NoSolution.into()),
162            ty::ImplPolarity::Positive => (),
163        };
164
165        if !cx.impl_is_const(impl_def_id) {
166            return Err(NoSolution.into());
167        }
168
169        ecx.probe_trait_candidate(CandidateSource::Impl(impl_def_id)).enter(|ecx| {
170            let impl_args = ecx.fresh_args_for_item(impl_def_id.into());
171            ecx.record_impl_args(impl_args);
172            let impl_trait_ref = impl_trait_ref.instantiate(cx, impl_args).skip_norm_wip();
173
174            ecx.eq(goal.param_env, goal_trait_ref, impl_trait_ref)?;
175            let where_clause_bounds = cx
176                .clauses_of(impl_def_id.into())
177                .iter_instantiated(cx, impl_args)
178                .map(Unnormalized::skip_norm_wip)
179                .map(|clause| goal.with(cx, clause));
180            ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds)?;
181
182            // For this impl to be `const`, we need to check its `[const]` bounds too.
183            let const_conditions = cx
184                .const_conditions(impl_def_id.into())
185                .iter_instantiated(cx, impl_args)
186                .map(|bound_trait_ref| {
187                    goal.with(
188                        cx,
189                        bound_trait_ref
190                            .to_host_effect_clause(cx, goal.predicate.constness)
191                            .skip_norm_wip(),
192                    )
193                });
194            ecx.add_goals(GoalSource::ImplWhereBound, const_conditions)?;
195
196            then(ecx)
197        })
198    }
199
200    fn consider_error_guaranteed_candidate(
201        ecx: &mut EvalCtxt<'_, D>,
202        _goal: Goal<I, Self>,
203        _guar: I::ErrorGuaranteed,
204    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
205        ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
206            .enter(|ecx| ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes))
207    }
208
209    fn consider_auto_trait_candidate(
210        ecx: &mut EvalCtxt<'_, D>,
211        _goal: Goal<I, Self>,
212    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
213        ecx.cx().delay_bug("auto traits are never const");
214        Err(NoSolution.into())
215    }
216
217    fn consider_trait_alias_candidate(
218        ecx: &mut EvalCtxt<'_, D>,
219        goal: Goal<I, Self>,
220    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
221        let cx = ecx.cx();
222
223        ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
224            let where_clause_bounds = cx
225                .clauses_of(goal.predicate.def_id().into())
226                .iter_instantiated(cx, goal.predicate.trait_ref.args)
227                .map(Unnormalized::skip_norm_wip)
228                .map(|c| goal.with(cx, c));
229
230            let const_conditions = cx
231                .const_conditions(goal.predicate.def_id().into())
232                .iter_instantiated(cx, goal.predicate.trait_ref.args)
233                .map(|bound_trait_ref| {
234                    goal.with(
235                        cx,
236                        bound_trait_ref
237                            .to_host_effect_clause(cx, goal.predicate.constness)
238                            .skip_norm_wip(),
239                    )
240                });
241            // While you could think of trait aliases to have a single builtin impl
242            // which uses its implied trait bounds as where-clauses, using
243            // `GoalSource::ImplWhereClause` here would be incorrect, as we also
244            // impl them, which means we're "stepping out of the impl constructor"
245            // again. To handle this, we treat these cycles as ambiguous for now.
246            ecx.add_goals(GoalSource::Misc, where_clause_bounds)?;
247            ecx.add_goals(GoalSource::Misc, const_conditions)?;
248            ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
249        })
250    }
251
252    fn consider_builtin_sizedness_candidates(
253        _ecx: &mut EvalCtxt<'_, D>,
254        _goal: Goal<I, Self>,
255        _sizedness: SizedTraitKind,
256    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
257        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Sized/MetaSized is never const")));
}unreachable!("Sized/MetaSized is never const")
258    }
259
260    fn consider_builtin_copy_clone_candidate(
261        ecx: &mut EvalCtxt<'_, D>,
262        goal: Goal<I, Self>,
263    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
264        let cx = ecx.cx();
265
266        let self_ty = goal.predicate.self_ty();
267        let constituent_tys =
268            structural_traits::instantiate_constituent_tys_for_copy_clone_trait(ecx, self_ty)?;
269
270        ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
271            ecx.enter_forall_with_assumptions(constituent_tys, goal.param_env, |ecx, tys| {
272                ecx.add_goals(
273                    GoalSource::ImplWhereBound,
274                    tys.into_iter().map(|ty| {
275                        goal.with(
276                            cx,
277                            ty::ClauseKind::HostEffect(
278                                goal.predicate.with_replaced_self_ty(cx, ty),
279                            ),
280                        )
281                    }),
282                )
283            })?;
284
285            ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
286        })
287    }
288
289    fn consider_builtin_fn_ptr_trait_candidate(
290        _ecx: &mut EvalCtxt<'_, D>,
291        _goal: Goal<I, Self>,
292    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
293        {
    ::core::panicking::panic_fmt(format_args!("not implemented: {0}",
            format_args!("Fn* are not yet const")));
}unimplemented!("Fn* are not yet const")
294    }
295
296    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::TRACE <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("consider_builtin_fn_trait_candidates",
                                "rustc_next_trait_solver::solve::effect_goals",
                                ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs"),
                                ::tracing_core::__macro_support::Option::Some(296u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::effect_goals"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<Candidate<I>, NoSolutionOrRerunNonErased> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let cx = ecx.cx();
                        let self_ty = goal.predicate.self_ty();
                        let (inputs_and_output, def_id, args) =
                            structural_traits::extract_fn_def_from_const_callable(cx,
                                    self_ty)?;
                        let (inputs, output) =
                            ecx.instantiate_binder_with_infer(inputs_and_output);
                        let output_is_sized_pred =
                            ty::TraitRef::new(cx,
                                cx.require_trait_lang_item(SolverTraitLangItem::Sized),
                                [output]);
                        let requirements =
                            cx.const_conditions(def_id).iter_instantiated(cx,
                                        args).map(|trait_ref|
                                        {
                                            (GoalSource::ImplWhereBound,
                                                goal.with(cx,
                                                    trait_ref.to_host_effect_clause(cx,
                                                            goal.predicate.constness).skip_norm_wip()))
                                        }).chain([(GoalSource::ImplWhereBound,
                                            goal.with(cx, output_is_sized_pred))]);
                        let pred =
                            ty::Binder::dummy(ty::TraitRef::new(cx,
                                        goal.predicate.def_id(),
                                        [goal.predicate.self_ty(),
                                                inputs])).to_host_effect_clause(cx,
                                goal.predicate.constness);
                        Self::probe_and_consider_implied_clause(ecx,
                            CandidateSource::BuiltinImpl(BuiltinImplSource::Misc), goal,
                            pred, requirements)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs:296",
                        "rustc_next_trait_solver::solve::effect_goals",
                        ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs"),
                        ::tracing_core::__macro_support::Option::Some(296u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::effect_goals"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "trace", skip_all, ret)]
297    fn consider_builtin_fn_trait_candidates(
298        ecx: &mut EvalCtxt<'_, D>,
299        goal: Goal<I, Self>,
300        _kind: rustc_type_ir::ClosureKind,
301    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
302        let cx = ecx.cx();
303
304        let self_ty = goal.predicate.self_ty();
305        let (inputs_and_output, def_id, args) =
306            structural_traits::extract_fn_def_from_const_callable(cx, self_ty)?;
307        let (inputs, output) = ecx.instantiate_binder_with_infer(inputs_and_output);
308
309        // A built-in `Fn` impl only holds if the output is sized.
310        // (FIXME: technically we only need to check this if the type is a fn ptr...)
311        let output_is_sized_pred =
312            ty::TraitRef::new(cx, cx.require_trait_lang_item(SolverTraitLangItem::Sized), [output]);
313        let requirements = cx
314            .const_conditions(def_id)
315            .iter_instantiated(cx, args)
316            .map(|trait_ref| {
317                (
318                    GoalSource::ImplWhereBound,
319                    goal.with(
320                        cx,
321                        trait_ref
322                            .to_host_effect_clause(cx, goal.predicate.constness)
323                            .skip_norm_wip(),
324                    ),
325                )
326            })
327            .chain([(GoalSource::ImplWhereBound, goal.with(cx, output_is_sized_pred))]);
328
329        let pred = ty::Binder::dummy(ty::TraitRef::new(
330            cx,
331            goal.predicate.def_id(),
332            [goal.predicate.self_ty(), inputs],
333        ))
334        .to_host_effect_clause(cx, goal.predicate.constness);
335
336        Self::probe_and_consider_implied_clause(
337            ecx,
338            CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
339            goal,
340            pred,
341            requirements,
342        )
343    }
344
345    fn consider_builtin_async_fn_trait_candidates(
346        _ecx: &mut EvalCtxt<'_, D>,
347        _goal: Goal<I, Self>,
348        _kind: rustc_type_ir::ClosureKind,
349    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
350        {
    ::core::panicking::panic_fmt(format_args!("not implemented: {0}",
            format_args!("AsyncFn* are not yet const")));
}unimplemented!("AsyncFn* are not yet const")
351    }
352
353    fn consider_builtin_async_fn_kind_helper_candidate(
354        _ecx: &mut EvalCtxt<'_, D>,
355        _goal: Goal<I, Self>,
356    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
357        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("AsyncFnKindHelper is not const")));
}unreachable!("AsyncFnKindHelper is not const")
358    }
359
360    fn consider_builtin_tuple_candidate(
361        _ecx: &mut EvalCtxt<'_, D>,
362        _goal: Goal<I, Self>,
363    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
364        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Tuple trait is not const")));
}unreachable!("Tuple trait is not const")
365    }
366
367    fn consider_builtin_pointee_candidate(
368        _ecx: &mut EvalCtxt<'_, D>,
369        _goal: Goal<I, Self>,
370    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
371        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Pointee is not const")));
}unreachable!("Pointee is not const")
372    }
373
374    fn consider_builtin_future_candidate(
375        _ecx: &mut EvalCtxt<'_, D>,
376        _goal: Goal<I, Self>,
377    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
378        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Future is not const")));
}unreachable!("Future is not const")
379    }
380
381    fn consider_builtin_iterator_candidate(
382        _ecx: &mut EvalCtxt<'_, D>,
383        _goal: Goal<I, Self>,
384    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
385        Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution))
386    }
387
388    fn consider_builtin_fused_iterator_candidate(
389        _ecx: &mut EvalCtxt<'_, D>,
390        _goal: Goal<I, Self>,
391    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
392        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("FusedIterator is not const")));
}unreachable!("FusedIterator is not const")
393    }
394
395    fn consider_builtin_async_iterator_candidate(
396        _ecx: &mut EvalCtxt<'_, D>,
397        _goal: Goal<I, Self>,
398    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
399        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("AsyncIterator is not const")));
}unreachable!("AsyncIterator is not const")
400    }
401
402    fn consider_builtin_coroutine_candidate(
403        _ecx: &mut EvalCtxt<'_, D>,
404        _goal: Goal<I, Self>,
405    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
406        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Coroutine is not const")));
}unreachable!("Coroutine is not const")
407    }
408
409    fn consider_builtin_discriminant_kind_candidate(
410        _ecx: &mut EvalCtxt<'_, D>,
411        _goal: Goal<I, Self>,
412    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
413        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("DiscriminantKind is not const")));
}unreachable!("DiscriminantKind is not const")
414    }
415
416    fn consider_builtin_destruct_candidate(
417        ecx: &mut EvalCtxt<'_, D>,
418        goal: Goal<I, Self>,
419    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
420        let cx = ecx.cx();
421
422        let self_ty = goal.predicate.self_ty();
423        let const_conditions = structural_traits::const_conditions_for_destruct(cx, self_ty)?;
424
425        ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
426            ecx.add_goals(
427                GoalSource::AliasBoundConstCondition,
428                const_conditions.into_iter().map(|trait_ref| {
429                    goal.with(
430                        cx,
431                        ty::Binder::dummy(trait_ref)
432                            .to_host_effect_clause(cx, goal.predicate.constness),
433                    )
434                }),
435            )?;
436            ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
437        })
438    }
439
440    fn consider_builtin_transmute_candidate(
441        _ecx: &mut EvalCtxt<'_, D>,
442        _goal: Goal<I, Self>,
443    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
444        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("TransmuteFrom is not const")));
}unreachable!("TransmuteFrom is not const")
445    }
446
447    fn consider_builtin_bikeshed_guaranteed_no_drop_candidate(
448        _ecx: &mut EvalCtxt<'_, D>,
449        _goal: Goal<I, Self>,
450    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
451        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("BikeshedGuaranteedNoDrop is not const")));
};unreachable!("BikeshedGuaranteedNoDrop is not const");
452    }
453
454    fn consider_builtin_try_as_dyn_candidate(
455        _ecx: &mut EvalCtxt<'_, D>,
456        goal: Goal<I, Self>,
457    ) -> Result<Candidate<I>, NoSolutionOrRerunNonErased> {
458        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("`TryAsDynCompat` is not const: {0:?}", goal)));
}unreachable!("`TryAsDynCompat` is not const: {:?}", goal)
459    }
460
461    fn consider_structural_builtin_unsize_candidates(
462        _ecx: &mut EvalCtxt<'_, D>,
463        _goal: Goal<I, Self>,
464    ) -> Result<Vec<Candidate<I>>, RerunNonErased> {
465        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Unsize is not const")));
}unreachable!("Unsize is not const")
466    }
467
468    fn consider_builtin_field_candidate(
469        _ecx: &mut EvalCtxt<'_, D>,
470        _goal: Goal<<D as SolverDelegate>::Interner, Self>,
471    ) -> Result<Candidate<<D as SolverDelegate>::Interner>, NoSolutionOrRerunNonErased> {
472        {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("Field is not const")));
}unreachable!("Field is not const")
473    }
474}
475
476impl<D, I> EvalCtxt<'_, D>
477where
478    D: SolverDelegate<Interner = I>,
479    I: Interner,
480{
481    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("compute_host_effect_goal",
                                    "rustc_next_trait_solver::solve::effect_goals",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/48f4b05538b8eca412137042d9647a61e692c6b3/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs"),
                                    ::tracing_core::__macro_support::Option::Some(481u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_next_trait_solver::solve::effect_goals"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("goal")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("goal");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&goal)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: QueryResultOrRerunNonErased<I> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let (_, proven_via) =
                self.probe(|_|
                                ProbeKind::ShadowedEnvProbing).enter(|ecx|
                            {
                                let trait_goal: Goal<I, ty::TraitClause<I>> =
                                    goal.with(ecx.cx(), goal.predicate.trait_ref);
                                ecx.compute_trait_goal(trait_goal)
                            })?;
            self.assemble_and_merge_candidates(proven_via, goal, |_ecx| None,
                |_ecx| Err(NoSolution.into()))
        }
    }
}#[instrument(level = "trace", skip(self))]
482    pub(super) fn compute_host_effect_goal(
483        &mut self,
484        goal: Goal<I, ty::HostEffectClause<I>>,
485    ) -> QueryResultOrRerunNonErased<I> {
486        let (_, proven_via) = self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| {
487            let trait_goal: Goal<I, ty::TraitClause<I>> =
488                goal.with(ecx.cx(), goal.predicate.trait_ref);
489            ecx.compute_trait_goal(trait_goal)
490        })?;
491        self.assemble_and_merge_candidates(
492            proven_via,
493            goal,
494            |_ecx| None,
495            |_ecx| Err(NoSolution.into()),
496        )
497    }
498}