Skip to content

Commit

Permalink
Unrolled build for rust-lang#134365
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#134365 - Zalathar:builder, r=nnethercote

Rename `rustc_mir_build::build` to `builder`

GitHub's “Go to file” feature silently ignores all files in this module, presumably because they are in a directory named `build`, which is mistaken for a build-output directory. That makes it meaningfully harder to view those files and their history via GitHub.

This PR sidesteps that issue by renaming `build` to `builder`, which in context has basically the same meaning, but can't be mistaken for a build-output directory.

---

Extracted from rust-lang#133404, after rust-lang#133592 changed the .gitignore rule from `build/` to `/build`. The problem of GitHub ignoring these files still exists even after that change, which suggests that GitHub's behaviour is a hard-coded heuristic that isn't influenced by the repository's git settings.

Currently this PR doesn't include the tidy rule forbidding `build` as a module name, but that could be added if people think it's a good idea.
  • Loading branch information
rust-timer authored Dec 17, 2024
2 parents 604d669 + c58219b commit eb8cab0
Show file tree
Hide file tree
Showing 27 changed files with 61 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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>>,
}
Expand Down Expand Up @@ -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,
Expand All @@ -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 };
Expand All @@ -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>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

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

0 comments on commit eb8cab0

Please sign in to comment.