Skip to content

Rename rustc_mir_build::build to builder #134365

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
Original file line number Diff line number Diff line change
@@ -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> {
Original file line number Diff line number Diff line change
@@ -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;

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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>> {
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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>> {
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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>,
Original file line number Diff line number Diff line change
@@ -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,
};

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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>,
Original file line number Diff line number Diff line change
@@ -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> {
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
@@ -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> {
9 changes: 6 additions & 3 deletions compiler/rustc_mir_build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here, e.g. "This used to be called build, but that causes GitHub's “Go to file” feature to silently ignore all files in this module, presumably because they are in a directory named build, which is mistaken for a build-output directory."

r=me with that change.

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;
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/constant.rs
Original file line number Diff line number Diff line change
@@ -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>,