Merge hir::CaptureClause into ast::CaptureBy.
This commit is contained in:
parent
5b30da10b6
commit
cb233f5420
6 changed files with 12 additions and 27 deletions
|
@ -473,7 +473,6 @@ impl LoweringContext<'_> {
|
|||
async_gen_kind: hir::AsyncGeneratorKind,
|
||||
body: impl FnOnce(&mut LoweringContext<'_>) -> hir::Expr,
|
||||
) -> hir::ExprKind {
|
||||
let capture_clause = self.lower_capture_clause(capture_clause);
|
||||
let output = match ret_ty {
|
||||
Some(ty) => FunctionRetTy::Ty(ty),
|
||||
None => FunctionRetTy::Default(span),
|
||||
|
@ -700,7 +699,6 @@ impl LoweringContext<'_> {
|
|||
generator_kind,
|
||||
movability,
|
||||
);
|
||||
let capture_clause = this.lower_capture_clause(capture_clause);
|
||||
this.current_item = prev;
|
||||
hir::ExprKind::Closure(
|
||||
capture_clause,
|
||||
|
@ -712,13 +710,6 @@ impl LoweringContext<'_> {
|
|||
})
|
||||
}
|
||||
|
||||
fn lower_capture_clause(&mut self, c: CaptureBy) -> hir::CaptureClause {
|
||||
match c {
|
||||
CaptureBy::Value => hir::CaptureByValue,
|
||||
CaptureBy::Ref => hir::CaptureByRef,
|
||||
}
|
||||
}
|
||||
|
||||
fn generator_movability_for_fn(
|
||||
&mut self,
|
||||
decl: &FnDecl,
|
||||
|
@ -807,7 +798,7 @@ impl LoweringContext<'_> {
|
|||
this.expr(fn_decl_span, async_body, ThinVec::new())
|
||||
});
|
||||
hir::ExprKind::Closure(
|
||||
this.lower_capture_clause(capture_clause),
|
||||
capture_clause,
|
||||
fn_decl,
|
||||
body_id,
|
||||
fn_decl_span,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
|
||||
|
||||
pub use self::BlockCheckMode::*;
|
||||
pub use self::CaptureClause::*;
|
||||
pub use self::FunctionRetTy::*;
|
||||
pub use self::PrimTy::*;
|
||||
pub use self::UnOp::*;
|
||||
|
@ -22,7 +21,7 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan};
|
|||
use syntax::source_map::Spanned;
|
||||
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
|
||||
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
|
||||
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability};
|
||||
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy};
|
||||
use syntax::attr::{InlineAttr, OptimizeAttr};
|
||||
use syntax::symbol::{Symbol, kw};
|
||||
use syntax::tokenstream::TokenStream;
|
||||
|
@ -1629,7 +1628,7 @@ pub enum ExprKind {
|
|||
///
|
||||
/// This may also be a generator literal or an `async block` as indicated by the
|
||||
/// `Option<Movability>`.
|
||||
Closure(CaptureClause, P<FnDecl>, BodyId, Span, Option<Movability>),
|
||||
Closure(CaptureBy, P<FnDecl>, BodyId, Span, Option<Movability>),
|
||||
/// A block (e.g., `'label: { ... }`).
|
||||
Block(P<Block>, Option<Label>),
|
||||
|
||||
|
@ -1820,12 +1819,6 @@ impl fmt::Display for YieldSource {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
pub enum CaptureClause {
|
||||
CaptureByValue,
|
||||
CaptureByRef,
|
||||
}
|
||||
|
||||
// N.B., if you change this, you'll probably want to change the corresponding
|
||||
// type structure in middle/ty.rs as well.
|
||||
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
|
||||
|
@ -2620,7 +2613,7 @@ pub struct Upvar {
|
|||
pub span: Span
|
||||
}
|
||||
|
||||
pub type CaptureModeMap = NodeMap<CaptureClause>;
|
||||
pub type CaptureModeMap = NodeMap<CaptureBy>;
|
||||
|
||||
// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
|
||||
// has length > 0 if the trait is found through an chain of imports, starting with the
|
||||
|
|
|
@ -1909,10 +1909,10 @@ impl<'a> State<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn print_capture_clause(&mut self, capture_clause: hir::CaptureClause) {
|
||||
pub fn print_capture_clause(&mut self, capture_clause: hir::CaptureBy) {
|
||||
match capture_clause {
|
||||
hir::CaptureByValue => self.word_space("move"),
|
||||
hir::CaptureByRef => {},
|
||||
hir::CaptureBy::Value => self.word_space("move"),
|
||||
hir::CaptureBy::Ref => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
|
|||
impl_stable_hash_for!(enum ::syntax::ast::StrStyle { Cooked, Raw(pounds) });
|
||||
impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner });
|
||||
impl_stable_hash_for!(enum ::syntax::ast::Movability { Static, Movable });
|
||||
impl_stable_hash_for!(enum ::syntax::ast::CaptureBy { Value, Ref });
|
||||
|
||||
impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
|
|
|
@ -36,7 +36,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
pub fn check_expr_closure(
|
||||
&self,
|
||||
expr: &hir::Expr,
|
||||
_capture: hir::CaptureClause,
|
||||
_capture: hir::CaptureBy,
|
||||
decl: &'tcx hir::FnDecl,
|
||||
body_id: hir::BodyId,
|
||||
gen: Option<hir::Movability>,
|
||||
|
|
|
@ -81,7 +81,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
closure_hir_id: hir::HirId,
|
||||
span: Span,
|
||||
body: &hir::Body,
|
||||
capture_clause: hir::CaptureClause,
|
||||
capture_clause: hir::CaptureBy,
|
||||
) {
|
||||
/*!
|
||||
* Analysis starting point.
|
||||
|
@ -141,8 +141,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
upvar_list.insert(var_hir_id, upvar_id);
|
||||
|
||||
let capture_kind = match capture_clause {
|
||||
hir::CaptureByValue => ty::UpvarCapture::ByValue,
|
||||
hir::CaptureByRef => {
|
||||
hir::CaptureBy::Value => ty::UpvarCapture::ByValue,
|
||||
hir::CaptureBy::Ref => {
|
||||
let origin = UpvarRegion(upvar_id, span);
|
||||
let upvar_region = self.next_region_var(origin);
|
||||
let upvar_borrow = ty::UpvarBorrow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue