From 40e6dccfb4b0e0f21cbc846a70b348132ee4d0f2 Mon Sep 17 00:00:00 2001 From: Valentin Lazureanu Date: Tue, 21 Jul 2020 09:09:27 +0000 Subject: [PATCH] Rename HAIR to THIR (Typed HIR). --- src/librustc_middle/ty/context.rs | 2 +- src/librustc_mir_build/build/block.rs | 10 ++-- .../build/expr/as_constant.rs | 2 +- .../build/expr/as_operand.rs | 2 +- src/librustc_mir_build/build/expr/as_place.rs | 2 +- .../build/expr/as_rvalue.rs | 2 +- src/librustc_mir_build/build/expr/as_temp.rs | 8 +-- src/librustc_mir_build/build/expr/category.rs | 2 +- src/librustc_mir_build/build/expr/into.rs | 18 +++---- src/librustc_mir_build/build/expr/stmt.rs | 10 ++-- src/librustc_mir_build/build/into.rs | 2 +- src/librustc_mir_build/build/matches/mod.rs | 39 ++++++++------ .../build/matches/simplify.rs | 4 +- src/librustc_mir_build/build/matches/test.rs | 6 +-- src/librustc_mir_build/build/matches/util.rs | 2 +- src/librustc_mir_build/build/mod.rs | 6 +-- src/librustc_mir_build/build/scope.rs | 8 +-- src/librustc_mir_build/lib.rs | 6 +-- .../{hair => thir}/constant.rs | 0 .../{hair => thir}/cx/block.rs | 8 +-- .../{hair => thir}/cx/expr.rs | 12 ++--- .../{hair => thir}/cx/mod.rs | 6 +-- .../{hair => thir}/cx/to_ref.rs | 6 +-- src/librustc_mir_build/{hair => thir}/mod.rs | 20 +++---- .../{hair => thir}/pattern/_match.rs | 0 .../{hair => thir}/pattern/check_match.rs | 0 .../{hair => thir}/pattern/const_to_pat.rs | 0 .../{hair => thir}/pattern/mod.rs | 4 +- src/librustc_mir_build/{hair => thir}/util.rs | 0 src/librustc_typeck/check/pat.rs | 2 +- .../const_constructor/const-construct-call.rs | 2 +- ... half-open-range-pats-thir-lower-empty.rs} | 0 ...f-open-range-pats-thir-lower-empty.stderr} | 52 +++++++++---------- ...k-pat-by-move-and-ref-inverse-promotion.rs | 2 +- src/test/ui/pattern/const-pat-ice.stderr | 2 +- .../clippy/clippy_lints/src/utils/mod.rs | 2 +- 36 files changed, 128 insertions(+), 121 deletions(-) rename src/librustc_mir_build/{hair => thir}/constant.rs (100%) rename src/librustc_mir_build/{hair => thir}/cx/block.rs (96%) rename src/librustc_mir_build/{hair => thir}/cx/expr.rs (99%) rename src/librustc_mir_build/{hair => thir}/cx/mod.rs (98%) rename src/librustc_mir_build/{hair => thir}/cx/to_ref.rs (93%) rename src/librustc_mir_build/{hair => thir}/mod.rs (95%) rename src/librustc_mir_build/{hair => thir}/pattern/_match.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/check_match.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/const_to_pat.rs (100%) rename src/librustc_mir_build/{hair => thir}/pattern/mod.rs (99%) rename src/librustc_mir_build/{hair => thir}/util.rs (100%) rename src/test/ui/half-open-range-patterns/{half-open-range-pats-hair-lower-empty.rs => half-open-range-pats-thir-lower-empty.rs} (100%) rename src/test/ui/half-open-range-patterns/{half-open-range-pats-hair-lower-empty.stderr => half-open-range-pats-thir-lower-empty.stderr} (69%) diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index d307131a990..775d755444d 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -352,7 +352,7 @@ pub struct TypeckResults<'tcx> { pat_binding_modes: ItemLocalMap, /// 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) { diff --git a/src/librustc_mir_build/build/block.rs b/src/librustc_mir_build/build/block.rs index 2be4136ad42..d1cbf209b06 100644 --- a/src/librustc_mir_build/build/block.rs +++ b/src/librustc_mir_build/build/block.rs @@ -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; @@ -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 }); @@ -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 } } }; diff --git a/src/librustc_mir_build/build/expr/as_constant.rs b/src/librustc_mir_build/build/expr/as_constant.rs index 03ec0b48f8b..982aefcf604 100644 --- a/src/librustc_mir_build/build/expr/as_constant.rs +++ b/src/librustc_mir_build/build/expr/as_constant.rs @@ -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; diff --git a/src/librustc_mir_build/build/expr/as_operand.rs b/src/librustc_mir_build/build/expr/as_operand.rs index 5949fd1e22c..aac93f313f4 100644 --- a/src/librustc_mir_build/build/expr/as_operand.rs +++ b/src/librustc_mir_build/build/expr/as_operand.rs @@ -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::*; diff --git a/src/librustc_mir_build/build/expr/as_place.rs b/src/librustc_mir_build/build/expr/as_place.rs index e811d68d5a5..1e3e104c2ba 100644 --- a/src/librustc_mir_build/build/expr/as_place.rs +++ b/src/librustc_mir_build/build/expr/as_place.rs @@ -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::*; diff --git a/src/librustc_mir_build/build/expr/as_rvalue.rs b/src/librustc_mir_build/build/expr/as_rvalue.rs index e2217fdfac0..9c5fddc6b77 100644 --- a/src/librustc_mir_build/build/expr/as_rvalue.rs +++ b/src/librustc_mir_build/build/expr/as_rvalue.rs @@ -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::*; diff --git a/src/librustc_mir_build/build/expr/as_temp.rs b/src/librustc_mir_build/build/expr/as_temp.rs index 901dadd6612..a9cc0cc2f24 100644 --- a/src/librustc_mir_build/build/expr/as_temp.rs +++ b/src/librustc_mir_build/build/expr/as_temp.rs @@ -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; @@ -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 }); } _ => {} } diff --git a/src/librustc_mir_build/build/expr/category.rs b/src/librustc_mir_build/build/expr/category.rs index fb4b7997b6a..9cabd186d84 100644 --- a/src/librustc_mir_build/build/expr/category.rs +++ b/src/librustc_mir_build/build/expr/category.rs @@ -1,4 +1,4 @@ -use crate::hair::*; +use crate::thir::*; #[derive(Debug, PartialEq)] crate enum Category { diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index 36f8034336b..c3f54b39a3f 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -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; @@ -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, @@ -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, @@ -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 } } }) diff --git a/src/librustc_mir_build/build/expr/stmt.rs b/src/librustc_mir_build/build/expr/stmt.rs index 49d6ce39ddf..f117689d940 100644 --- a/src/librustc_mir_build/build/expr/stmt.rs +++ b/src/librustc_mir_build/build/expr/stmt.rs @@ -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). @@ -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); } } diff --git a/src/librustc_mir_build/build/into.rs b/src/librustc_mir_build/build/into.rs index 0baa0c833a5..7264e495b84 100644 --- a/src/librustc_mir_build/build/into.rs +++ b/src/librustc_mir_build/build/into.rs @@ -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> { diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index 19948196f25..77c0fe8dda5 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -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}; @@ -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); @@ -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 // @@ -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 { @@ -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, diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index 2917a771a2c..e584aeb9226 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -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; @@ -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. diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index 3e7bfc7d59b..158ad78a1bf 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -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; @@ -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, }, ); diff --git a/src/librustc_mir_build/build/matches/util.rs b/src/librustc_mir_build/build/matches/util.rs index 7d89a93129b..605396c5eb6 100644 --- a/src/librustc_mir_build/build/matches/util.rs +++ b/src/librustc_mir_build/build/matches/util.rs @@ -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; diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 2549b90ddfa..3c4587119cd 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -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; @@ -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 diff --git a/src/librustc_mir_build/build/scope.rs b/src/librustc_mir_build/build/scope.rs index b8df2709447..2a03bb78c6b 100644 --- a/src/librustc_mir_build/build/scope.rs +++ b/src/librustc_mir_build/build/scope.rs @@ -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`. @@ -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; diff --git a/src/librustc_mir_build/lib.rs b/src/librustc_mir_build/lib.rs index ed154b9dc6f..30545558933 100644 --- a/src/librustc_mir_build/lib.rs +++ b/src/librustc_mir_build/lib.rs @@ -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; } diff --git a/src/librustc_mir_build/hair/constant.rs b/src/librustc_mir_build/thir/constant.rs similarity index 100% rename from src/librustc_mir_build/hair/constant.rs rename to src/librustc_mir_build/thir/constant.rs diff --git a/src/librustc_mir_build/hair/cx/block.rs b/src/librustc_mir_build/thir/cx/block.rs similarity index 96% rename from src/librustc_mir_build/hair/cx/block.rs rename to src/librustc_mir_build/thir/cx/block.rs index a5381781d1d..980888df7fe 100644 --- a/src/librustc_mir_build/hair/cx/block.rs +++ b/src/librustc_mir_build/thir/cx/block.rs @@ -1,6 +1,6 @@ -use crate::hair::cx::to_ref::ToRef; -use crate::hair::cx::Cx; -use crate::hair::{self, *}; +use crate::thir::cx::to_ref::ToRef; +use crate::thir::cx::Cx; +use crate::thir::{self, *}; use rustc_hir as hir; use rustc_middle::middle::region; @@ -71,7 +71,7 @@ fn mirror_stmts<'a, 'tcx>( ty: pattern.ty, span: pattern.span, kind: Box::new(PatKind::AscribeUserType { - ascription: hair::pattern::Ascription { + ascription: thir::pattern::Ascription { user_ty: PatTyProj::from_user_type(user_ty), user_ty_span: ty.span, variance: ty::Variance::Covariant, diff --git a/src/librustc_mir_build/hair/cx/expr.rs b/src/librustc_mir_build/thir/cx/expr.rs similarity index 99% rename from src/librustc_mir_build/hair/cx/expr.rs rename to src/librustc_mir_build/thir/cx/expr.rs index 6e1d8a8fc40..ea41a66b3e4 100644 --- a/src/librustc_mir_build/hair/cx/expr.rs +++ b/src/librustc_mir_build/thir/cx/expr.rs @@ -1,8 +1,8 @@ -use crate::hair::cx::block; -use crate::hair::cx::to_ref::ToRef; -use crate::hair::cx::Cx; -use crate::hair::util::UserAnnotatedTyHelpers; -use crate::hair::*; +use crate::thir::cx::block; +use crate::thir::cx::to_ref::ToRef; +use crate::thir::cx::Cx; +use crate::thir::util::UserAnnotatedTyHelpers; +use crate::thir::*; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_index::vec::Idx; @@ -1020,7 +1020,7 @@ fn overloaded_place<'a, 'tcx>( // line up (this is because `*x` and `x[y]` represent places): let recv_ty = match args[0] { - ExprRef::Hair(e) => cx.typeck_results().expr_ty_adjusted(e), + ExprRef::Thir(e) => cx.typeck_results().expr_ty_adjusted(e), ExprRef::Mirror(ref e) => e.ty, }; diff --git a/src/librustc_mir_build/hair/cx/mod.rs b/src/librustc_mir_build/thir/cx/mod.rs similarity index 98% rename from src/librustc_mir_build/hair/cx/mod.rs rename to src/librustc_mir_build/thir/cx/mod.rs index 2694cde14fd..21736df7b07 100644 --- a/src/librustc_mir_build/hair/cx/mod.rs +++ b/src/librustc_mir_build/thir/cx/mod.rs @@ -1,9 +1,9 @@ //! This module contains the functionality to convert from the wacky tcx data -//! structures into the HAIR. The `builder` is generally ignorant of the tcx, +//! structures into the THIR. The `builder` is generally ignorant of the tcx, //! etc., and instead goes through the `Cx` for most of its work. -use crate::hair::util::UserAnnotatedTyHelpers; -use crate::hair::*; +use crate::thir::util::UserAnnotatedTyHelpers; +use crate::thir::*; use rustc_ast::ast; use rustc_ast::attr; diff --git a/src/librustc_mir_build/hair/cx/to_ref.rs b/src/librustc_mir_build/thir/cx/to_ref.rs similarity index 93% rename from src/librustc_mir_build/hair/cx/to_ref.rs rename to src/librustc_mir_build/thir/cx/to_ref.rs index 6cf8122e200..53a988ebb79 100644 --- a/src/librustc_mir_build/hair/cx/to_ref.rs +++ b/src/librustc_mir_build/thir/cx/to_ref.rs @@ -1,4 +1,4 @@ -use crate::hair::*; +use crate::thir::*; use rustc_hir as hir; @@ -11,7 +11,7 @@ impl<'tcx> ToRef for &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { - ExprRef::Hair(self) + ExprRef::Thir(self) } } @@ -19,7 +19,7 @@ impl<'tcx> ToRef for &'tcx &'tcx hir::Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { - ExprRef::Hair(&**self) + ExprRef::Thir(&**self) } } diff --git a/src/librustc_mir_build/hair/mod.rs b/src/librustc_mir_build/thir/mod.rs similarity index 95% rename from src/librustc_mir_build/hair/mod.rs rename to src/librustc_mir_build/thir/mod.rs index ccff510f2d4..b6ce7e0b41e 100644 --- a/src/librustc_mir_build/hair/mod.rs +++ b/src/librustc_mir_build/thir/mod.rs @@ -1,5 +1,5 @@ -//! The MIR is built from some high-level abstract IR -//! (HAIR). This section defines the HAIR along with a trait for +//! The MIR is built from some typed high-level IR +//! (THIR). This section defines the THIR along with a trait for //! accessing it. The intention is to allow MIR construction to be //! unit-tested and separated from the Rust source and compiler data //! structures. @@ -99,18 +99,18 @@ crate enum StmtKind<'tcx> { #[cfg(target_arch = "x86_64")] rustc_data_structures::static_assert_size!(Expr<'_>, 168); -/// The Hair trait implementor lowers their expressions (`&'tcx H::Expr`) +/// The Thir trait implementor lowers their expressions (`&'tcx H::Expr`) /// into instances of this `Expr` enum. This lowering can be done /// basically as lazily or as eagerly as desired: every recursive /// reference to an expression in this enum is an `ExprRef<'tcx>`, which /// may in turn be another instance of this enum (boxed), or else an /// unlowered `&'tcx H::Expr`. Note that instances of `Expr` are very -/// short-lived. They are created by `Hair::to_expr`, analyzed and +/// short-lived. They are created by `Thir::to_expr`, analyzed and /// converted into MIR, and then discarded. /// /// If you compare `Expr` to the full compiler AST, you will see it is /// a good bit simpler. In fact, a number of the more straight-forward -/// MIR simplifications are already done in the impl of `Hair`. For +/// MIR simplifications are already done in the impl of `Thir`. For /// example, method calls and overloaded operators are absent: they are /// expected to be converted into `Expr::Call` instances. #[derive(Clone, Debug)] @@ -302,7 +302,7 @@ crate enum ExprKind<'tcx> { #[derive(Clone, Debug)] crate enum ExprRef<'tcx> { - Hair(&'tcx hir::Expr<'tcx>), + Thir(&'tcx hir::Expr<'tcx>), Mirror(Box>), } @@ -342,7 +342,7 @@ crate enum LogicalOp { impl<'tcx> ExprRef<'tcx> { crate fn span(&self) -> Span { match self { - ExprRef::Hair(expr) => expr.span, + ExprRef::Thir(expr) => expr.span, ExprRef::Mirror(expr) => expr.span, } } @@ -385,7 +385,7 @@ crate enum InlineAsmOperand<'tcx> { // The Mirror trait /// "Mirroring" is the process of converting from a HIR type into one -/// of the HAIR types defined in this file. This is basically a "on +/// of the THIR types defined in this file. This is basically a "on /// the fly" desugaring step that hides a lot of the messiness in the /// tcx. For example, the mirror of a `&'tcx hir::Expr` is an /// `Expr<'tcx>`. @@ -394,7 +394,7 @@ crate enum InlineAsmOperand<'tcx> { /// + e2`, the references to the inner expressions `e1` and `e2` are /// `ExprRef<'tcx>` instances, and they may or may not be eagerly /// mirrored. This allows a single AST node from the compiler to -/// expand into one or more Hair nodes, which lets the Hair nodes be +/// expand into one or more Thir nodes, which lets the Thir nodes be /// simpler. crate trait Mirror<'tcx> { type Output; @@ -415,7 +415,7 @@ impl<'tcx> Mirror<'tcx> for ExprRef<'tcx> { fn make_mirror(self, hir: &mut Cx<'_, 'tcx>) -> Expr<'tcx> { match self { - ExprRef::Hair(h) => h.make_mirror(hir), + ExprRef::Thir(h) => h.make_mirror(hir), ExprRef::Mirror(m) => *m, } } diff --git a/src/librustc_mir_build/hair/pattern/_match.rs b/src/librustc_mir_build/thir/pattern/_match.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/_match.rs rename to src/librustc_mir_build/thir/pattern/_match.rs diff --git a/src/librustc_mir_build/hair/pattern/check_match.rs b/src/librustc_mir_build/thir/pattern/check_match.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/check_match.rs rename to src/librustc_mir_build/thir/pattern/check_match.rs diff --git a/src/librustc_mir_build/hair/pattern/const_to_pat.rs b/src/librustc_mir_build/thir/pattern/const_to_pat.rs similarity index 100% rename from src/librustc_mir_build/hair/pattern/const_to_pat.rs rename to src/librustc_mir_build/thir/pattern/const_to_pat.rs diff --git a/src/librustc_mir_build/hair/pattern/mod.rs b/src/librustc_mir_build/thir/pattern/mod.rs similarity index 99% rename from src/librustc_mir_build/hair/pattern/mod.rs rename to src/librustc_mir_build/thir/pattern/mod.rs index 19c86655bd5..bdefaadfdfe 100644 --- a/src/librustc_mir_build/hair/pattern/mod.rs +++ b/src/librustc_mir_build/thir/pattern/mod.rs @@ -6,7 +6,7 @@ mod const_to_pat; pub(crate) use self::check_match::check_match; -use crate::hair::util::UserAnnotatedTyHelpers; +use crate::thir::util::UserAnnotatedTyHelpers; use rustc_ast::ast; use rustc_errors::struct_span_err; @@ -402,7 +402,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> { // // `vec![&&Option, &Option]`. // - // Applying the adjustments, we want to instead output `&&Some(n)` (as a HAIR pattern). So + // Applying the adjustments, we want to instead output `&&Some(n)` (as a THIR pattern). So // we wrap the unadjusted pattern in `PatKind::Deref` repeatedly, consuming the // adjustments in *reverse order* (last-in-first-out, so that the last `Deref` inserted // gets the least-dereferenced type). diff --git a/src/librustc_mir_build/hair/util.rs b/src/librustc_mir_build/thir/util.rs similarity index 100% rename from src/librustc_mir_build/hair/util.rs rename to src/librustc_mir_build/thir/util.rs diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs index 42170bc199c..9c7ea34bf51 100644 --- a/src/librustc_typeck/check/pat.rs +++ b/src/librustc_typeck/check/pat.rs @@ -345,7 +345,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("inspecting {:?}", expected); debug!("current discriminant is Ref, inserting implicit deref"); - // Preserve the reference type. We'll need it later during HAIR lowering. + // Preserve the reference type. We'll need it later during THIR lowering. pat_adjustments.push(expected); expected = inner_ty; diff --git a/src/test/ui/consts/const_constructor/const-construct-call.rs b/src/test/ui/consts/const_constructor/const-construct-call.rs index d883d3fa6e4..d3e6cf78bc9 100644 --- a/src/test/ui/consts/const_constructor/const-construct-call.rs +++ b/src/test/ui/consts/const_constructor/const-construct-call.rs @@ -6,7 +6,7 @@ #![cfg_attr(const_fn, feature(const_fn))] -// Ctor(..) is transformed to Ctor { 0: ... } in HAIR lowering, so directly +// Ctor(..) is transformed to Ctor { 0: ... } in THIR lowering, so directly // calling constructors doesn't require them to be const. type ExternalType = std::panic::AssertUnwindSafe<(Option, Result)>; diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs similarity index 100% rename from src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.rs rename to src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr similarity index 69% rename from src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr rename to src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr index b536e1b5548..12ad8642961 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-hair-lower-empty.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr @@ -1,155 +1,155 @@ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:12:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | LL | m!(0, ..core::u8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:15:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..core::u16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:18:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | LL | m!(0, ..core::u32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:21:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | LL | m!(0, ..core::u64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:24:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..core::u128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:28:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..core::i8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:31:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | LL | m!(0, ..core::i16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:34:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | LL | m!(0, ..core::i32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:37:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | LL | m!(0, ..core::i64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:40:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | LL | m!(0, ..core::i128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:44:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | LL | m!(0f32, ..core::f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:47:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | LL | m!(0f64, ..core::f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:51:13 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 | LL | m!('a', ..'\u{0}'); | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:12:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:12:11 | LL | m!(0, ..core::u8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:15:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..core::u16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:18:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:18:11 | LL | m!(0, ..core::u32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:21:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:21:11 | LL | m!(0, ..core::u64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:24:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..core::u128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:28:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..core::i8::MIN); | ^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:31:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:31:11 | LL | m!(0, ..core::i16::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:34:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:34:11 | LL | m!(0, ..core::i32::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:37:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:37:11 | LL | m!(0, ..core::i64::MIN); | ^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:40:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:40:11 | LL | m!(0, ..core::i128::MIN); | ^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:44:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:44:14 | LL | m!(0f32, ..core::f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:47:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:47:14 | LL | m!(0f64, ..core::f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-hair-lower-empty.rs:51:13 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:51:13 | LL | m!('a', ..'\u{0}'); | ^^^^^^^^^ diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs index 14797917193..993954b450e 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.rs @@ -1,5 +1,5 @@ // Test that `by_move_binding @ pat_with_by_ref_bindings` is prevented even with promotion. -// Currently this logic exists in HAIR match checking as opposed to borrowck. +// Currently this logic exists in THIR match checking as opposed to borrowck. #![feature(bindings_after_at)] #![feature(move_ref_pattern)] diff --git a/src/test/ui/pattern/const-pat-ice.stderr b/src/test/ui/pattern/const-pat-ice.stderr index 6e87e5c6912..2aa0824f301 100644 --- a/src/test/ui/pattern/const-pat-ice.stderr +++ b/src/test/ui/pattern/const-pat-ice.stderr @@ -1,4 +1,4 @@ -thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir_build/hair/pattern/_match.rs:LL:CC +thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir_build/thir/pattern/_match.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: internal compiler error: unexpected panic diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index 655b1133cf7..3f8e15d9029 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -883,7 +883,7 @@ pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_>, expr: &Expr<'_ } /// Returns `true` if a pattern is refutable. -// TODO: should be implemented using rustc/mir_build/hair machinery +// TODO: should be implemented using rustc/mir_build/thir machinery pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool { fn is_enum_variant(cx: &LateContext<'_>, qpath: &QPath<'_>, id: HirId) -> bool { matches!(