From b9ac3f3ce382f3f26938e688a063d3dd6182a0f9 Mon Sep 17 00:00:00 2001 From: Valentin Lazureanu Date: Tue, 21 Jul 2020 09:09:27 +0000 Subject: [PATCH 1/5] 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 d307131a99036..775d755444d7d 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 2be4136ad42a0..d1cbf209b06ce 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 03ec0b48f8bfe..982aefcf6045c 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 5949fd1e22ce8..aac93f313f4e1 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 e811d68d5a5f8..1e3e104c2bad6 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 e2217fdfac036..9c5fddc6b77c0 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 901dadd661278..a9cc0cc2f2475 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 fb4b7997b6a5a..9cabd186d8460 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 36f8034336ba1..c3f54b39a3f38 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 49d6ce39ddfa4..f117689d940fd 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 0baa0c833a514..7264e495b84fd 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 19948196f256f..77c0fe8dda534 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 2917a771a2cf8..e584aeb922672 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 3e7bfc7d59b9b..158ad78a1bf36 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 7d89a93129b1b..605396c5eb639 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 2549b90ddfa11..3c4587119cd55 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 b8df27094471f..2a03bb78c6b1a 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 ed154b9dc6f11..30545558933f7 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 a5381781d1d80..980888df7fee4 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 6e1d8a8fc4012..ea41a66b3e43d 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 2694cde14fde7..21736df7b0710 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 6cf8122e200db..53a988ebb79e2 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 ccff510f2d4e5..b6ce7e0b41e54 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 f813ba0c077ca..6e896a1fe80eb 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 42170bc199cbc..9c7ea34bf51b6 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 d883d3fa6e40e..d3e6cf78bc93b 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 b536e1b5548d0..12ad86429613b 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 1479791719313..993954b450e37 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 6e87e5c6912c3..2aa0824f30186 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 655b1133cf74f..3f8e15d90297d 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!( From f173a4b8ecb1f7673e9f5df19dd2f9287f461364 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 30 Jul 2020 16:12:02 -0400 Subject: [PATCH 2/5] 1.45.2 release notes --- RELEASES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index b47f64d2fafc9..4859532f7a1f7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,12 @@ +Version 1.45.2 (2020-08-03) +========================== + +* [Fix bindings in tuple struct patterns][74954] +* [Fix track_caller integration with trait objects][74784] + +[74954]: https://github.com/rust-lang/rust/issues/74954 +[74784]: https://github.com/rust-lang/rust/issues/74784 + Version 1.45.1 (2020-07-30) ========================== From b31664216e5532cbed71e70c8fc7617bd8f1bd03 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 20 Jul 2020 19:07:23 +0300 Subject: [PATCH 3/5] Add sanitizer support on FreeBSD --- src/bootstrap/native.rs | 1 + .../docker/host-x86_64/dist-x86_64-freebsd/Dockerfile | 2 +- src/librustc_codegen_ssa/back/link.rs | 1 + src/librustc_session/session.rs | 11 ++++++++--- src/tools/compiletest/src/util.rs | 11 ++++++++--- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 48b2cc24d4cd8..51b87b43db0f6 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -786,6 +786,7 @@ fn supported_sanitizers( } "x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]), "x86_64-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]), + "x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]), "x86_64-unknown-linux-gnu" => { common_libs("linux", "x86_64", &["asan", "lsan", "msan", "tsan"]) } diff --git a/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile index 2372c0dad0abf..f4c8b9fda61d0 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile @@ -29,5 +29,5 @@ ENV \ ENV HOSTS=x86_64-unknown-freebsd -ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs +ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --enable-sanitizers --disable-docs ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 9191c68d4537a..86d63bf1ee35d 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -818,6 +818,7 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) { "aarch64-fuchsia" | "aarch64-unknown-linux-gnu" | "x86_64-fuchsia" + | "x86_64-unknown-freebsd" | "x86_64-unknown-linux-gnu" => { let filename = format!("librustc{}_rt.{}.a", channel, name); let path = default_tlib.join(&filename); diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs index e9077f4085909..8fef544e4362b 100644 --- a/src/librustc_session/session.rs +++ b/src/librustc_session/session.rs @@ -1376,14 +1376,19 @@ fn validate_commandline_args_with_session_available(sess: &Session) { "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-fuchsia", + "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu", ]; const LSAN_SUPPORTED_TARGETS: &[&str] = &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; const MSAN_SUPPORTED_TARGETS: &[&str] = - &["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]; - const TSAN_SUPPORTED_TARGETS: &[&str] = - &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; + &["aarch64-unknown-linux-gnu", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"]; + const TSAN_SUPPORTED_TARGETS: &[&str] = &[ + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-gnu", + ]; // Sanitizers can only be used on some tested platforms. for s in sess.opts.debugging_opts.sanitizer { diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 0437ff8c9440a..9ea88971ef5d7 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -87,6 +87,7 @@ pub const ASAN_SUPPORTED_TARGETS: &'static [&'static str] = &[ "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-fuchsia", + "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu", ]; @@ -94,10 +95,14 @@ pub const LSAN_SUPPORTED_TARGETS: &'static [&'static str] = &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; pub const MSAN_SUPPORTED_TARGETS: &'static [&'static str] = - &["aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu"]; + &["aarch64-unknown-linux-gnu", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"]; -pub const TSAN_SUPPORTED_TARGETS: &'static [&'static str] = - &["aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"]; +pub const TSAN_SUPPORTED_TARGETS: &'static [&'static str] = &[ + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-gnu", +]; pub fn matches_os(triple: &str, name: &str) -> bool { // For the wasm32 bare target we ignore anything also ignored on emscripten From baaf0843c9743a7f36ebbff05cddee3a838d5359 Mon Sep 17 00:00:00 2001 From: Greg V Date: Fri, 31 Jul 2020 02:55:12 +0300 Subject: [PATCH 4/5] Add RUST_STD_FREEBSD_12_ABI env variable Unfortunately, sanitizers do not support versioned symbols[1], so they break filesystem access via the legacy, pre-ino64 ABI. To use sanitizers on FreeBSD >= 12, we need to build the libc crate with LIBC_CI=1 to use the new ABI -- including the libc used for std. But that removes the st_lspare field std was expecting for the deprecated metadata extension. Add a way to skip that field to allow the build to work. [1]: https://github.com/google/sanitizers/issues/628 --- library/std/build.rs | 3 +++ library/std/src/os/freebsd/fs.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/library/std/build.rs b/library/std/build.rs index 83073cc77dd1a..04bfed12153ec 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -16,6 +16,9 @@ fn main() { } else if target.contains("freebsd") { println!("cargo:rustc-link-lib=execinfo"); println!("cargo:rustc-link-lib=pthread"); + if env::var("RUST_STD_FREEBSD_12_ABI").is_ok() { + println!("cargo:rustc-cfg=freebsd12"); + } } else if target.contains("netbsd") { println!("cargo:rustc-link-lib=pthread"); println!("cargo:rustc-link-lib=rt"); diff --git a/library/std/src/os/freebsd/fs.rs b/library/std/src/os/freebsd/fs.rs index 6798e0d8f44fa..1b5c8de186f87 100644 --- a/library/std/src/os/freebsd/fs.rs +++ b/library/std/src/os/freebsd/fs.rs @@ -74,6 +74,11 @@ pub trait MetadataExt { impl MetadataExt for Metadata { #[allow(deprecated)] fn as_raw_stat(&self) -> &raw::stat { + // The methods below use libc::stat, so they work fine when libc is built with FreeBSD 12 ABI. + // This method would just return nonsense. + #[cfg(freebsd12)] + panic!("as_raw_stat not supported with FreeBSD 12 ABI"); + #[cfg(not(freebsd12))] unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } } fn st_dev(&self) -> u64 { @@ -137,6 +142,9 @@ impl MetadataExt for Metadata { self.as_inner().as_inner().st_flags as u32 } fn st_lspare(&self) -> u32 { + #[cfg(freebsd12)] + panic!("st_lspare not supported with FreeBSD 12 ABI"); + #[cfg(not(freebsd12))] self.as_inner().as_inner().st_lspare as u32 } } From dc21178830a0ae6e70101ffff8ef4843990cd902 Mon Sep 17 00:00:00 2001 From: Charles Lew Date: Thu, 23 Jul 2020 01:30:54 +0800 Subject: [PATCH 5/5] Remove `linked_list_extras` methods. --- library/alloc/src/collections/linked_list.rs | 45 +++++-------------- .../src/collections/linked_list/tests.rs | 27 ----------- 2 files changed, 10 insertions(+), 62 deletions(-) diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 1f875f6c5217f..02a746f0e2488 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1110,32 +1110,17 @@ impl IterMut<'_, T> { /// Inserts the given element just after the element most recently returned by `.next()`. /// The inserted element does not appear in the iteration. /// - /// # Examples - /// - /// ``` - /// #![feature(linked_list_extras)] - /// - /// use std::collections::LinkedList; - /// - /// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); - /// - /// { - /// let mut it = list.iter_mut(); - /// assert_eq!(it.next().unwrap(), &1); - /// // insert `2` after `1` - /// it.insert_next(2); - /// } - /// { - /// let vec: Vec<_> = list.into_iter().collect(); - /// assert_eq!(vec, [1, 2, 3, 4]); - /// } - /// ``` + /// This method will be removed soon. #[inline] #[unstable( feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see", issue = "27794" )] + #[rustc_deprecated( + reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.", + since = "1.47.0" + )] pub fn insert_next(&mut self, element: T) { match self.head { // `push_back` is okay with aliasing `element` references @@ -1163,27 +1148,17 @@ impl IterMut<'_, T> { /// Provides a reference to the next element, without changing the iterator. /// - /// # Examples - /// - /// ``` - /// #![feature(linked_list_extras)] - /// - /// use std::collections::LinkedList; - /// - /// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); - /// - /// let mut it = list.iter_mut(); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.peek_next().unwrap(), &2); - /// // We just peeked at 2, so it was not consumed from the iterator. - /// assert_eq!(it.next().unwrap(), &2); - /// ``` + /// This method will be removed soon. #[inline] #[unstable( feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see", issue = "27794" )] + #[rustc_deprecated( + reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.", + since = "1.47.0" + )] pub fn peek_next(&mut self) -> Option<&mut T> { if self.len == 0 { None diff --git a/library/alloc/src/collections/linked_list/tests.rs b/library/alloc/src/collections/linked_list/tests.rs index b8c93a28bba81..ad643a7bdf194 100644 --- a/library/alloc/src/collections/linked_list/tests.rs +++ b/library/alloc/src/collections/linked_list/tests.rs @@ -153,33 +153,6 @@ fn test_clone_from() { } } -#[test] -fn test_insert_prev() { - let mut m = list_from(&[0, 2, 4, 6, 8]); - let len = m.len(); - { - let mut it = m.iter_mut(); - it.insert_next(-2); - loop { - match it.next() { - None => break, - Some(elt) => { - it.insert_next(*elt + 1); - match it.peek_next() { - Some(x) => assert_eq!(*x, *elt + 2), - None => assert_eq!(8, *elt), - } - } - } - } - it.insert_next(0); - it.insert_next(1); - } - check_links(&m); - assert_eq!(m.len(), 3 + len * 2); - assert_eq!(m.into_iter().collect::>(), [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]); -} - #[test] #[cfg_attr(target_os = "emscripten", ignore)] fn test_send() {