Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename HAIR to THIR (Typed HIR). #74582

Merged
merged 1 commit into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub struct TypeckResults<'tcx> {
pat_binding_modes: ItemLocalMap<BindingMode>,

/// Stores the types which were implicitly dereferenced in pattern binding modes
/// for later usage in HAIR lowering. For example,
/// for later usage in THIR lowering. For example,
///
/// ```
/// match &&Some(5i32) {
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_mir_build/build/block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::build::matches::ArmHasGuard;
use crate::build::ForGuard::OutsideGuard;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_hir as hir;
use rustc_middle::mir::*;
use rustc_session::lint::builtin::UNSAFE_OP_IN_UNSAFE_FN;
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let tail_result_is_ignored =
destination_ty.is_unit() || this.block_context.currently_ignores_tail_results();
let span = match expr {
ExprRef::Hair(expr) => expr.span,
ExprRef::Thir(expr) => expr.span,
ExprRef::Mirror(ref expr) => expr.span,
};
this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored, span });
Expand Down Expand Up @@ -235,11 +235,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.push_unsafe_count
.checked_sub(1)
.unwrap_or_else(|| span_bug!(span, "unsafe count underflow"));
if self.push_unsafe_count == 0 {
Some(self.unpushed_unsafe)
} else {
None
}
if self.push_unsafe_count == 0 { Some(self.unpushed_unsafe) } else { None }
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! See docs in build/expr/mod.rs

use crate::build::Builder;
use crate::hair::*;
use crate::thir::*;
use rustc_middle::mir::*;
use rustc_middle::ty::CanonicalUserTypeAnnotation;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::expr::category::Category;
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::*;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::build::expr::category::Category;
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::AssertKind::BoundsCheck;
use rustc_middle::mir::*;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_index::vec::Idx;

use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::AssertKind;
use rustc_middle::mir::*;
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_mir_build/build/expr/as_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::scope::DropKind;
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_middle::middle::region;
Expand Down Expand Up @@ -67,12 +67,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind::StaticRef { def_id, .. } => {
assert!(!this.hir.tcx().is_thread_local_static(def_id));
local_decl.internal = true;
local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
}
ExprKind::ThreadLocalRef(def_id) => {
assert!(this.hir.tcx().is_thread_local_static(def_id));
local_decl.internal = true;
local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::hair::*;
use crate::thir::*;

#[derive(Debug, PartialEq)]
crate enum Category {
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir_build/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_ast::ast::InlineAsmOptions;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stack::ensure_sufficient_stack;
Expand Down Expand Up @@ -320,23 +320,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.unit()
}
ExprKind::InlineAsm { template, operands, options, line_spans } => {
use crate::hair;
use crate::thir;
use rustc_middle::mir;
let operands = operands
.into_iter()
.map(|op| match op {
hair::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In {
thir::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In {
reg,
value: unpack!(block = this.as_local_operand(block, expr)),
},
hair::InlineAsmOperand::Out { reg, late, expr } => {
thir::InlineAsmOperand::Out { reg, late, expr } => {
mir::InlineAsmOperand::Out {
reg,
late,
place: expr.map(|expr| unpack!(block = this.as_place(block, expr))),
}
}
hair::InlineAsmOperand::InOut { reg, late, expr } => {
thir::InlineAsmOperand::InOut { reg, late, expr } => {
let place = unpack!(block = this.as_place(block, expr));
mir::InlineAsmOperand::InOut {
reg,
Expand All @@ -346,7 +346,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
out_place: Some(place),
}
}
hair::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
thir::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
mir::InlineAsmOperand::InOut {
reg,
late,
Expand All @@ -356,13 +356,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}),
}
}
hair::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const {
thir::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const {
value: unpack!(block = this.as_local_operand(block, expr)),
},
hair::InlineAsmOperand::SymFn { expr } => {
thir::InlineAsmOperand::SymFn { expr } => {
mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) }
}
hair::InlineAsmOperand::SymStatic { def_id } => {
thir::InlineAsmOperand::SymStatic { def_id } => {
mir::InlineAsmOperand::SymStatic { def_id }
}
})
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_mir_build/build/expr/stmt.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::build::scope::BreakableTarget;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::*;

impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Builds a block of MIR statements to evaluate the HAIR `expr`.
/// Builds a block of MIR statements to evaluate the THIR `expr`.
/// If the original expression was an AST statement,
/// (e.g., `some().code(&here());`) then `opt_stmt_span` is the
/// span of that statement (including its semicolon, if any).
Expand Down Expand Up @@ -150,8 +150,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
break;
}
}
this.block_context
.push(BlockFrame::TailExpr { tail_result_is_ignored: true, span: expr.span });
this.block_context.push(BlockFrame::TailExpr {
tail_result_is_ignored: true,
span: expr.span,
});
return Some(expr.span);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! latter `EvalInto` trait.

use crate::build::{BlockAnd, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::mir::*;

pub(in crate::build) trait EvalInto<'tcx> {
Expand Down
39 changes: 23 additions & 16 deletions src/librustc_mir_build/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ use crate::build::scope::DropKind;
use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
use crate::hair::{self, *};
use rustc_data_structures::{fx::{FxHashMap, FxHashSet}, stack::ensure_sufficient_stack};
use crate::thir::{self, *};
use rustc_data_structures::{
fx::{FxHashMap, FxHashSet},
stack::ensure_sufficient_stack,
};
use rustc_hir::HirId;
use rustc_index::bit_set::BitSet;
use rustc_middle::middle::region;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty};
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_target::abi::VariantIdx;
use smallvec::{smallvec, SmallVec};

Expand Down Expand Up @@ -395,7 +398,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
..
},
ascription:
hair::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span },
thir::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span },
} => {
let place =
self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true);
Expand Down Expand Up @@ -631,7 +634,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

PatKind::AscribeUserType {
ref subpattern,
ascription: hair::pattern::Ascription { ref user_ty, user_ty_span, variance: _ },
ascription: thir::pattern::Ascription { ref user_ty, user_ty_span, variance: _ },
} => {
// This corresponds to something like
//
Expand Down Expand Up @@ -1982,16 +1985,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
source_info,
internal: false,
is_block_tail: None,
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm {
binding_mode,
// hypothetically, `visit_primary_bindings` could try to unzip
// an outermost hir::Ty as we descend, matching up
// idents in pat; but complex w/ unclear UI payoff.
// Instead, just abandon providing diagnostic info.
opt_ty_info: None,
opt_match_place,
pat_span,
})))),
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
VarBindingForm {
binding_mode,
// hypothetically, `visit_primary_bindings` could try to unzip
// an outermost hir::Ty as we descend, matching up
// idents in pat; but complex w/ unclear UI payoff.
// Instead, just abandon providing diagnostic info.
opt_ty_info: None,
opt_match_place,
pat_span,
},
)))),
};
let for_arm_body = self.local_decls.push(local);
self.var_debug_info.push(VarDebugInfo {
Expand All @@ -2009,7 +2014,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
source_info,
internal: false,
is_block_tail: None,
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::RefForGuard))),
local_info: Some(box LocalInfo::User(ClearCrossCrate::Set(
BindingForm::RefForGuard,
))),
});
self.var_debug_info.push(VarDebugInfo {
name,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/matches/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use crate::build::matches::{Ascription, Binding, Candidate, MatchPair};
use crate::build::Builder;
use crate::hair::{self, *};
use crate::thir::{self, *};
use rustc_attr::{SignedInt, UnsignedInt};
use rustc_hir::RangeEnd;
use rustc_middle::mir::interpret::truncate;
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
match *match_pair.pattern.kind {
PatKind::AscribeUserType {
ref subpattern,
ascription: hair::pattern::Ascription { variance, user_ty, user_ty_span },
ascription: thir::pattern::Ascription { variance, user_ty, user_ty_span },
} => {
// Apply the type ascription to the value at `match_pair.place`, which is the
// value being matched, taking the variance field into account.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir_build/build/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

use crate::build::matches::{Candidate, MatchPair, Test, TestKind};
use crate::build::Builder;
use crate::hair::pattern::compare_const_vals;
use crate::hair::*;
use crate::thir::pattern::compare_const_vals;
use crate::thir::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::RangeEnd;
use rustc_index::bit_set::BitSet;
Expand Down Expand Up @@ -443,7 +443,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination: Some((eq_result, eq_block)),
cleanup: Some(cleanup),
from_hir_call: false,
fn_span: source_info.span
fn_span: source_info.span,
},
);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/matches/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::build::matches::MatchPair;
use crate::build::Builder;
use crate::hair::*;
use crate::thir::*;
use rustc_middle::mir::*;
use rustc_middle::ty;
use smallvec::SmallVec;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir_build/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::build;
use crate::build::scope::DropKind;
use crate::hair::cx::Cx;
use crate::hair::{BindingMode, LintLevel, PatKind};
use crate::thir::cx::Cx;
use crate::thir::{BindingMode, LintLevel, PatKind};
use rustc_attr::{self as attr, UnwindAttr};
use rustc_errors::ErrorReported;
use rustc_hir as hir;
Expand Down Expand Up @@ -294,7 +294,7 @@ struct Builder<'a, 'tcx> {
/// see the `scope` module for more details.
scopes: scope::Scopes<'tcx>,

/// The block-context: each time we build the code within an hair::Block,
/// The block-context: each time we build the code within an thir::Block,
/// we push a frame here tracking whether we are building a statement or
/// if we are pushing the tail expression of the block. This is used to
/// embed information in generated temps about whether they were created
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir_build/build/scope.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
Managing the scope stack. The scopes are tied to lexical scopes, so as
we descend the HAIR, we push a scope on the stack, build its
we descend the THIR, we push a scope on the stack, build its
contents, and then pop it off. Every scope is named by a
`region::Scope`.

Expand Down Expand Up @@ -83,12 +83,12 @@ should go to.
*/

use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
use crate::hair::{Expr, ExprRef, LintLevel};
use rustc_middle::middle::region;
use rustc_middle::mir::*;
use crate::thir::{Expr, ExprRef, LintLevel};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
use rustc_hir::GeneratorKind;
use rustc_middle::middle::region;
use rustc_middle::mir::*;
use rustc_span::{Span, DUMMY_SP};
use std::collections::hash_map::Entry;
use std::mem;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir_build/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ extern crate log;
extern crate rustc_middle;

mod build;
mod hair;
mod lints;
mod thir;

use rustc_middle::ty::query::Providers;

pub fn provide(providers: &mut Providers) {
providers.check_match = hair::pattern::check_match;
providers.lit_to_const = hair::constant::lit_to_const;
providers.check_match = thir::pattern::check_match;
providers.lit_to_const = thir::constant::lit_to_const;
providers.mir_built = build::mir_built;
}
Loading