Auto merge of #74582 - Lezzz:rename-hair, r=nikomatsakis
Rename HAIR to THIR (Typed HIR). r? @nikomatsakis Originally suggested by @eddyb
This commit is contained in:
commit
dfe1e3b641
@ -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) {
|
||||
|
@ -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 }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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::*;
|
||||
|
||||
|
@ -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::*;
|
||||
|
@ -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::*;
|
||||
|
@ -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 });
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::hair::*;
|
||||
use crate::thir::*;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
crate enum Category {
|
||||
|
@ -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 }
|
||||
}
|
||||
})
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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> {
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
@ -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,
|
||||
};
|
||||
|
@ -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;
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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<Expr<'tcx>>),
|
||||
}
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
@ -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<i32>, &Option<i32>]`.
|
||||
//
|
||||
// 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).
|
@ -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;
|
||||
|
@ -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<i32>, Result<i32, bool>)>;
|
||||
|
@ -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}');
|
||||
| ^^^^^^^^^
|
@ -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)]
|
||||
|
@ -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
|
||||
|
@ -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!(
|
||||
|
Loading…
Reference in New Issue
Block a user