diff options
Diffstat (limited to 'compiler/rustc_mir_build/src')
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/block.rs (renamed from compiler/rustc_mir_build/src/build/block.rs) | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/cfg.rs (renamed from compiler/rustc_mir_build/src/build/cfg.rs) | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/coverageinfo.rs (renamed from compiler/rustc_mir_build/src/build/coverageinfo.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/coverageinfo/mcdc.rs (renamed from compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs) | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/custom/mod.rs (renamed from compiler/rustc_mir_build/src/build/custom/mod.rs) | 0 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/custom/parse.rs (renamed from compiler/rustc_mir_build/src/build/custom/parse.rs) | 0 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs (renamed from compiler/rustc_mir_build/src/build/custom/parse/instruction.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/as_constant.rs (renamed from compiler/rustc_mir_build/src/build/expr/as_constant.rs) | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/as_operand.rs (renamed from compiler/rustc_mir_build/src/build/expr/as_operand.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/as_place.rs (renamed from compiler/rustc_mir_build/src/build/expr/as_place.rs) | 46 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs (renamed from compiler/rustc_mir_build/src/build/expr/as_rvalue.rs) | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/as_temp.rs (renamed from compiler/rustc_mir_build/src/build/expr/as_temp.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/category.rs (renamed from compiler/rustc_mir_build/src/build/expr/category.rs) | 0 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/into.rs (renamed from compiler/rustc_mir_build/src/build/expr/into.rs) | 22 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/mod.rs (renamed from compiler/rustc_mir_build/src/build/expr/mod.rs) | 0 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/expr/stmt.rs (renamed from compiler/rustc_mir_build/src/build/expr/stmt.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/match_pair.rs (renamed from compiler/rustc_mir_build/src/build/matches/match_pair.rs) | 8 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/mod.rs (renamed from compiler/rustc_mir_build/src/build/matches/mod.rs) | 8 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/simplify.rs (renamed from compiler/rustc_mir_build/src/build/matches/simplify.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/test.rs (renamed from compiler/rustc_mir_build/src/build/matches/test.rs) | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/util.rs (renamed from compiler/rustc_mir_build/src/build/matches/util.rs) | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/misc.rs (renamed from compiler/rustc_mir_build/src/build/misc.rs) | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/mod.rs (renamed from compiler/rustc_mir_build/src/build/mod.rs) | 9 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/scope.rs (renamed from compiler/rustc_mir_build/src/build/scope.rs) | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/check_unsafety.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/lib.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/constant.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/expr.rs | 10 |
28 files changed, 106 insertions, 66 deletions
diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/builder/block.rs index 89e64015bc4..ba63a97de89 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/builder/block.rs @@ -5,9 +5,9 @@ use rustc_middle::{span_bug, ty}; use rustc_span::Span; use tracing::debug; -use crate::build::ForGuard::OutsideGuard; -use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops}; -use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::builder::ForGuard::OutsideGuard; +use crate::builder::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops}; +use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; impl<'a, 'tcx> Builder<'a, 'tcx> { pub(crate) fn ast_block( diff --git a/compiler/rustc_mir_build/src/build/cfg.rs b/compiler/rustc_mir_build/src/builder/cfg.rs index 9c5ee5b0996..cca309115ba 100644 --- a/compiler/rustc_mir_build/src/build/cfg.rs +++ b/compiler/rustc_mir_build/src/builder/cfg.rs @@ -4,7 +4,7 @@ use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; use tracing::debug; -use crate::build::CFG; +use crate::builder::CFG; impl<'tcx> CFG<'tcx> { pub(crate) fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> { diff --git a/compiler/rustc_mir_build/src/build/coverageinfo.rs b/compiler/rustc_mir_build/src/builder/coverageinfo.rs index 52a4a4b4b51..a80bd4f3c80 100644 --- a/compiler/rustc_mir_build/src/build/coverageinfo.rs +++ b/compiler/rustc_mir_build/src/builder/coverageinfo.rs @@ -8,8 +8,8 @@ use rustc_middle::thir::{ExprId, ExprKind, Pat, Thir}; use rustc_middle::ty::TyCtxt; use rustc_span::def_id::LocalDefId; -use crate::build::coverageinfo::mcdc::MCDCInfoBuilder; -use crate::build::{Builder, CFG}; +use crate::builder::coverageinfo::mcdc::MCDCInfoBuilder; +use crate::builder::{Builder, CFG}; mod mcdc; diff --git a/compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs b/compiler/rustc_mir_build/src/builder/coverageinfo/mcdc.rs index 343d4000043..6b4871dc1fc 100644 --- a/compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs +++ b/compiler/rustc_mir_build/src/builder/coverageinfo/mcdc.rs @@ -9,7 +9,7 @@ use rustc_middle::thir::LogicalOp; use rustc_middle::ty::TyCtxt; use rustc_span::Span; -use crate::build::Builder; +use crate::builder::Builder; use crate::errors::MCDCExceedsConditionLimit; /// LLVM uses `i16` to represent condition id. Hence `i16::MAX` is the hard limit for number of diff --git a/compiler/rustc_mir_build/src/build/custom/mod.rs b/compiler/rustc_mir_build/src/builder/custom/mod.rs index 34cdc288f0b..34cdc288f0b 100644 --- a/compiler/rustc_mir_build/src/build/custom/mod.rs +++ b/compiler/rustc_mir_build/src/builder/custom/mod.rs diff --git a/compiler/rustc_mir_build/src/build/custom/parse.rs b/compiler/rustc_mir_build/src/builder/custom/parse.rs index 538068e1fac..538068e1fac 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse.rs +++ b/compiler/rustc_mir_build/src/builder/custom/parse.rs diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs index 67114efdff5..59f440432eb 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs @@ -9,8 +9,8 @@ use rustc_span::Span; use rustc_span::source_map::Spanned; use super::{PResult, ParseCtxt, parse_by_kind}; -use crate::build::custom::ParseError; -use crate::build::expr::as_constant::as_constant_inner; +use crate::builder::custom::ParseError; +use crate::builder::expr::as_constant::as_constant_inner; impl<'a, 'tcx> ParseCtxt<'a, 'tcx> { pub(crate) fn parse_statement(&self, expr_id: ExprId) -> PResult<StatementKind<'tcx>> { diff --git a/compiler/rustc_mir_build/src/build/expr/as_constant.rs b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs index 640408cb9c8..177c1e33a83 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_constant.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::{ use rustc_middle::{bug, mir, span_bug}; use tracing::{instrument, trace}; -use crate::build::{Builder, parse_float_into_constval}; +use crate::builder::{Builder, parse_float_into_constval}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, yielding a compile-time constant. Assumes that diff --git a/compiler/rustc_mir_build/src/build/expr/as_operand.rs b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs index 777ff9e68f0..63e9b1dc6cd 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs @@ -4,8 +4,8 @@ use rustc_middle::mir::*; use rustc_middle::thir::*; use tracing::{debug, instrument}; -use crate::build::expr::category::Category; -use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; +use crate::builder::expr::category::Category; +use crate::builder::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Construct a temporary lifetime restricted to just the local scope diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/builder/expr/as_place.rs index 70a74910a68..01aec70f437 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_place.rs @@ -14,9 +14,9 @@ use rustc_middle::{bug, span_bug}; use rustc_span::{DesugaringKind, Span}; use tracing::{debug, instrument, trace}; -use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; -use crate::build::expr::category::Category; -use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap}; +use crate::builder::ForGuard::{OutsideGuard, RefWithinGuard}; +use crate::builder::expr::category::Category; +use crate::builder::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap}; /// The "outermost" place that holds this value. #[derive(Copy, Clone, Debug, PartialEq)] @@ -68,7 +68,7 @@ pub(crate) enum PlaceBase { /// This is used internally when building a place for an expression like `a.b.c`. The fields `b` /// and `c` can be progressively pushed onto the place builder that is created when converting `a`. #[derive(Clone, Debug, PartialEq)] -pub(in crate::build) struct PlaceBuilder<'tcx> { +pub(in crate::builder) struct PlaceBuilder<'tcx> { base: PlaceBase, projection: Vec<PlaceElem<'tcx>>, } @@ -249,7 +249,7 @@ fn strip_prefix<'a, 'tcx>( } impl<'tcx> PlaceBuilder<'tcx> { - pub(in crate::build) fn to_place(&self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> { + pub(in crate::builder) fn to_place(&self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> { self.try_to_place(cx).unwrap_or_else(|| match self.base { PlaceBase::Local(local) => span_bug!( cx.local_decls[local].source_info.span, @@ -265,7 +265,7 @@ impl<'tcx> PlaceBuilder<'tcx> { } /// Creates a `Place` or returns `None` if an upvar cannot be resolved - pub(in crate::build) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Place<'tcx>> { + pub(in crate::builder) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Place<'tcx>> { let resolved = self.resolve_upvar(cx); let builder = resolved.as_ref().unwrap_or(self); let PlaceBase::Local(local) = builder.base else { return None }; @@ -283,7 +283,7 @@ impl<'tcx> PlaceBuilder<'tcx> { /// not captured. This can happen because the final mir that will be /// generated doesn't require a read for this place. Failures will only /// happen inside closures. - pub(in crate::build) fn resolve_upvar( + pub(in crate::builder) fn resolve_upvar( &self, cx: &Builder<'_, 'tcx>, ) -> Option<PlaceBuilder<'tcx>> { @@ -647,13 +647,31 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match place_ty.kind() { ty::Array(_elem_ty, len_const) => { - // We know how long an array is, so just use that as a constant - // directly -- no locals needed. We do need one statement so - // that borrow- and initialization-checking consider it used, - // though. FIXME: Do we really *need* to count this as a use? - // Could partial array tracking work off something else instead? - self.cfg.push_fake_read(block, source_info, FakeReadCause::ForIndex, place); - let const_ = Const::from_ty_const(*len_const, usize_ty, self.tcx); + let ty_const = if let Some((_, len_ty)) = len_const.try_to_valtree() + && len_ty != self.tcx.types.usize + { + // Bad const generics can give us a constant from the type that's + // not actually a `usize`, so in that case give an error instead. + // FIXME: It'd be nice if the type checker made sure this wasn't + // possible, instead. + let err = self.tcx.dcx().span_delayed_bug( + span, + format!( + "Array length should have already been a type error, as it's {len_ty:?}" + ), + ); + ty::Const::new_error(self.tcx, err) + } else { + // We know how long an array is, so just use that as a constant + // directly -- no locals needed. We do need one statement so + // that borrow- and initialization-checking consider it used, + // though. FIXME: Do we really *need* to count this as a use? + // Could partial array tracking work off something else instead? + self.cfg.push_fake_read(block, source_info, FakeReadCause::ForIndex, place); + *len_const + }; + + let const_ = Const::from_ty_const(ty_const, usize_ty, self.tcx); Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ })) } ty::Slice(_elem_ty) => { diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs index c66af118453..9961c2488ef 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs @@ -16,9 +16,9 @@ use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, Span}; use tracing::debug; -use crate::build::expr::as_place::PlaceBase; -use crate::build::expr::category::{Category, RvalueFunc}; -use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; +use crate::builder::expr::as_place::PlaceBase; +use crate::builder::expr::category::{Category, RvalueFunc}; +use crate::builder::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Returns an rvalue suitable for use until the end of the current diff --git a/compiler/rustc_mir_build/src/build/expr/as_temp.rs b/compiler/rustc_mir_build/src/builder/expr/as_temp.rs index 466f67b1ba4..5e3a24e18fb 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_temp.rs @@ -7,8 +7,8 @@ use rustc_middle::mir::*; use rustc_middle::thir::*; use tracing::{debug, instrument}; -use crate::build::scope::DropKind; -use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::builder::scope::DropKind; +use crate::builder::{BlockAnd, BlockAndExtension, Builder}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr` into a fresh temporary. This is used when building diff --git a/compiler/rustc_mir_build/src/build/expr/category.rs b/compiler/rustc_mir_build/src/builder/expr/category.rs index e0349e3e3f6..e0349e3e3f6 100644 --- a/compiler/rustc_mir_build/src/build/expr/category.rs +++ b/compiler/rustc_mir_build/src/builder/expr/category.rs diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs index a3d5376dcd4..88f63d4e22c 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/builder/expr/into.rs @@ -11,9 +11,9 @@ use rustc_middle::ty::CanonicalUserTypeAnnotation; use rustc_span::source_map::Spanned; use tracing::{debug, instrument}; -use crate::build::expr::category::{Category, RvalueFunc}; -use crate::build::matches::DeclareLetBindings; -use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary}; +use crate::builder::expr::category::{Category, RvalueFunc}; +use crate::builder::matches::DeclareLetBindings; +use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, storing the result into `destination`, which @@ -367,14 +367,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .collect() } AdtExprBase::DefaultFields(field_types) => { - itertools::zip_eq(field_names, &**field_types) - .map(|(n, ty)| match fields_map.get(&n) { + itertools::zip_eq(field_names, field_types) + .map(|(n, &ty)| match fields_map.get(&n) { Some(v) => v.clone(), None => match variant.fields[n].value { Some(def) => { - let value = Const::from_unevaluated(this.tcx, def) - .instantiate(this.tcx, args); - this.literal_operand(expr_span, value) + let value = Const::Unevaluated( + UnevaluatedConst::new(def, args), + ty, + ); + Operand::Constant(Box::new(ConstOperand { + span: expr_span, + user_ty: None, + const_: value, + })) } None => { let name = variant.fields[n].name; diff --git a/compiler/rustc_mir_build/src/build/expr/mod.rs b/compiler/rustc_mir_build/src/builder/expr/mod.rs index 3de43a3370f..3de43a3370f 100644 --- a/compiler/rustc_mir_build/src/build/expr/mod.rs +++ b/compiler/rustc_mir_build/src/builder/expr/mod.rs diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/builder/expr/stmt.rs index 15ee6dd014c..4ae3536d9c2 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/builder/expr/stmt.rs @@ -5,8 +5,8 @@ use rustc_middle::thir::*; use rustc_span::source_map::Spanned; use tracing::debug; -use crate::build::scope::BreakableTarget; -use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::builder::scope::BreakableTarget; +use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds a block of MIR statements to evaluate the THIR `expr`. diff --git a/compiler/rustc_mir_build/src/build/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index 33fbd7b1a3f..9d59ffc88ba 100644 --- a/compiler/rustc_mir_build/src/build/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -2,9 +2,9 @@ use rustc_middle::mir::*; use rustc_middle::thir::{self, *}; use rustc_middle::ty::{self, Ty, TypeVisitableExt}; -use crate::build::Builder; -use crate::build::expr::as_place::{PlaceBase, PlaceBuilder}; -use crate::build::matches::{FlatPat, MatchPairTree, TestCase}; +use crate::builder::Builder; +use crate::builder::expr::as_place::{PlaceBase, PlaceBuilder}; +use crate::builder::matches::{FlatPat, MatchPairTree, TestCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds and returns [`MatchPairTree`] subtrees, one for each pattern in @@ -86,7 +86,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> { /// Recursively builds a match pair tree for the given pattern and its /// subpatterns. - pub(in crate::build) fn for_pattern( + pub(in crate::builder) fn for_pattern( mut place_builder: PlaceBuilder<'tcx>, pattern: &'pat Pat<'tcx>, cx: &mut Builder<'_, 'tcx>, diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 5791460a6b1..edbe9c69109 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -18,10 +18,10 @@ use rustc_span::symbol::Symbol; use rustc_span::{BytePos, Pos, Span}; use tracing::{debug, instrument}; -use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard}; -use crate::build::expr::as_place::PlaceBuilder; -use crate::build::scope::DropKind; -use crate::build::{ +use crate::builder::ForGuard::{self, OutsideGuard, RefWithinGuard}; +use crate::builder::expr::as_place::PlaceBuilder; +use crate::builder::scope::DropKind; +use crate::builder::{ BlockAnd, BlockAndExtension, Builder, GuardFrame, GuardFrameLocal, LocalsForNode, }; diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/builder/matches/simplify.rs index 5b402604395..ebaed1e431b 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/builder/matches/simplify.rs @@ -16,8 +16,8 @@ use std::mem; use tracing::{debug, instrument}; -use crate::build::Builder; -use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase}; +use crate::builder::Builder; +use crate::builder::matches::{MatchPairTree, PatternExtraData, TestCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Simplify a list of match pairs so they all require a test. Stores relevant bindings and diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index 4f7bbc4ce3e..596d525f5d8 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -20,8 +20,8 @@ use rustc_span::symbol::{Symbol, sym}; use rustc_span::{DUMMY_SP, Span}; use tracing::{debug, instrument}; -use crate::build::Builder; -use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind}; +use crate::builder::Builder; +use crate::builder::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Identifies what test is needed to decide if `match_pair` is applicable. diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/builder/matches/util.rs index 555684ded81..1bd399e511b 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/builder/matches/util.rs @@ -4,9 +4,9 @@ use rustc_middle::ty::Ty; use rustc_span::Span; use tracing::debug; -use crate::build::Builder; -use crate::build::expr::as_place::PlaceBase; -use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase}; +use crate::builder::Builder; +use crate::builder::expr::as_place::PlaceBase; +use crate::builder::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase}; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Creates a false edge to `imaginary_target` and a real edge to diff --git a/compiler/rustc_mir_build/src/build/misc.rs b/compiler/rustc_mir_build/src/builder/misc.rs index a14dcad6573..a53ae05e84f 100644 --- a/compiler/rustc_mir_build/src/build/misc.rs +++ b/compiler/rustc_mir_build/src/builder/misc.rs @@ -7,7 +7,7 @@ use rustc_span::Span; use rustc_trait_selection::infer::InferCtxtExt; use tracing::debug; -use crate::build::Builder; +use crate::builder::Builder; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Adds a new temporary value of type `ty` storing the result of diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index f43c29d8f5d..96e4ca3493d 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -1,3 +1,8 @@ +//! This module used to be named `build`, but that was causing GitHub's +//! "Go to file" feature to silently ignore all files in the module, probably +//! because it assumes that "build" is a build-output directory. +//! See <https://github.com/rust-lang/rust/pull/134365>. + use itertools::Itertools; use rustc_abi::{ExternAbi, FieldIdx}; use rustc_apfloat::Float; @@ -23,8 +28,8 @@ use rustc_span::symbol::sym; use rustc_span::{Span, Symbol}; use super::lints; -use crate::build::expr::as_place::PlaceBuilder; -use crate::build::scope::DropKind; +use crate::builder::expr::as_place::PlaceBuilder; +use crate::builder::scope::DropKind; pub(crate) fn closure_saved_names_of_captured_variables<'tcx>( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index 636e47b7ad2..882e29de46d 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -95,7 +95,7 @@ use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, Span}; use tracing::{debug, instrument}; -use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; +use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; #[derive(Debug)] pub(crate) struct Scopes<'tcx> { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 90be690e034..fc0031616aa 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -18,7 +18,7 @@ use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::symbol::Symbol; use rustc_span::{Span, sym}; -use crate::build::ExprCategory; +use crate::builder::ExprCategory; use crate::errors::*; struct UnsafetyVisitor<'a, 'tcx> { diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 833e5019865..467725841dc 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -11,7 +11,10 @@ #![warn(unreachable_pub)] // tidy-alphabetical-end -mod build; +// The `builder` module used to be named `build`, but that was causing GitHub's +// "Go to file" feature to silently ignore all files in the module, probably +// because it assumes that "build" is a build-output directory. See #134365. +mod builder; mod check_tail_calls; mod check_unsafety; mod errors; @@ -25,9 +28,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" } pub fn provide(providers: &mut Providers) { providers.check_match = thir::pattern::check_match; providers.lit_to_const = thir::constant::lit_to_const; - providers.hooks.build_mir = build::mir_build; + providers.hooks.build_mir = builder::mir_build; providers.closure_saved_names_of_captured_variables = - build::closure_saved_names_of_captured_variables; + builder::closure_saved_names_of_captured_variables; providers.check_unsafety = check_unsafety::check_unsafety; providers.check_tail_calls = check_tail_calls::check_tail_calls; providers.thir_body = thir::cx::thir_body; diff --git a/compiler/rustc_mir_build/src/thir/constant.rs b/compiler/rustc_mir_build/src/thir/constant.rs index 30b6718683b..ce1c635d1b9 100644 --- a/compiler/rustc_mir_build/src/thir/constant.rs +++ b/compiler/rustc_mir_build/src/thir/constant.rs @@ -5,7 +5,7 @@ use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; use rustc_middle::ty::{self, ScalarInt, TyCtxt, TypeVisitableExt as _}; use tracing::trace; -use crate::build::parse_float_into_scalar; +use crate::builder::parse_float_into_scalar; pub(crate) fn lit_to_const<'tcx>( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 6770e562d50..ae49b266153 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -25,6 +25,14 @@ use crate::thir::cx::Cx; use crate::thir::util::UserAnnotatedTyHelpers; impl<'tcx> Cx<'tcx> { + /// Create a THIR expression for the given HIR expression. This expands all + /// adjustments and directly adds the type information from the + /// `typeck_results`. See the [dev-guide] for more details. + /// + /// (The term "mirror" in this case does not refer to "flipped" or + /// "reversed".) + /// + /// [dev-guide]: https://rustc-dev-guide.rust-lang.org/thir.html pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId { // `mirror_expr` is recursing very deep. Make sure the stack doesn't overflow. ensure_sufficient_stack(|| self.mirror_expr_inner(expr)) @@ -1189,7 +1197,7 @@ impl<'tcx> Cx<'tcx> { .temporary_scope(self.region_scope_tree, closure_expr.hir_id.local_id); let var_ty = place.base_ty; - // The result of capture analysis in `rustc_hir_analysis/check/upvar.rs`represents a captured path + // The result of capture analysis in `rustc_hir_typeck/src/upvar.rs` represents a captured path // as it's seen for use within the closure and not at the time of closure creation. // // That is we see expect to see it start from a captured upvar and not something that is local |
