]>
git.proxmox.com Git - rustc.git/blob - src/librustc_mir/build/into.rs
1 //! In general, there are a number of things for which it's convenient
2 //! to just call `builder.into` and have it emit its result into a
3 //! given location. This is basically for expressions or things that can be
4 //! wrapped up as expressions (e.g., blocks). To make this ergonomic, we use this
5 //! latter `EvalInto` trait.
7 use crate::build
::{BlockAnd, Builder}
;
11 pub(in crate::build
) trait EvalInto
<'tcx
> {
14 builder
: &mut Builder
<'_
, 'tcx
>,
15 destination
: &Place
<'tcx
>,
20 impl<'a
, 'tcx
> Builder
<'a
, 'tcx
> {
21 pub fn into
<E
>(&mut self,
22 destination
: &Place
<'tcx
>,
26 where E
: EvalInto
<'tcx
>
28 expr
.eval_into(self, destination
, block
)
32 impl<'tcx
> EvalInto
<'tcx
> for ExprRef
<'tcx
> {
35 builder
: &mut Builder
<'_
, 'tcx
>,
36 destination
: &Place
<'tcx
>,
39 let expr
= builder
.hir
.mirror(self);
40 builder
.into_expr(destination
, block
, expr
)
44 impl<'tcx
> EvalInto
<'tcx
> for Expr
<'tcx
> {
47 builder
: &mut Builder
<'_
, 'tcx
>,
48 destination
: &Place
<'tcx
>,
51 builder
.into_expr(destination
, block
, self)