Skip to content
/ rust Public
forked from rust-lang/rust

Commit cc5392a

Browse files
authored
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.
2 parents cdb61ba + c58219b commit cc5392a

27 files changed

+61
-53
lines changed

compiler/rustc_mir_build/src/build/block.rs renamed to compiler/rustc_mir_build/src/builder/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use rustc_middle::{span_bug, ty};
55
use rustc_span::Span;
66
use tracing::debug;
77

8-
use crate::build::ForGuard::OutsideGuard;
9-
use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
10-
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
8+
use crate::builder::ForGuard::OutsideGuard;
9+
use crate::builder::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
10+
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
1111

1212
impl<'a, 'tcx> Builder<'a, 'tcx> {
1313
pub(crate) fn ast_block(

compiler/rustc_mir_build/src/build/cfg.rs renamed to compiler/rustc_mir_build/src/builder/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_middle::mir::*;
44
use rustc_middle::ty::TyCtxt;
55
use tracing::debug;
66

7-
use crate::build::CFG;
7+
use crate::builder::CFG;
88

99
impl<'tcx> CFG<'tcx> {
1010
pub(crate) fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {

compiler/rustc_mir_build/src/build/coverageinfo.rs renamed to compiler/rustc_mir_build/src/builder/coverageinfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use rustc_middle::thir::{ExprId, ExprKind, Pat, Thir};
88
use rustc_middle::ty::TyCtxt;
99
use rustc_span::def_id::LocalDefId;
1010

11-
use crate::build::coverageinfo::mcdc::MCDCInfoBuilder;
12-
use crate::build::{Builder, CFG};
11+
use crate::builder::coverageinfo::mcdc::MCDCInfoBuilder;
12+
use crate::builder::{Builder, CFG};
1313

1414
mod mcdc;
1515

compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs renamed to compiler/rustc_mir_build/src/builder/coverageinfo/mcdc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::thir::LogicalOp;
99
use rustc_middle::ty::TyCtxt;
1010
use rustc_span::Span;
1111

12-
use crate::build::Builder;
12+
use crate::builder::Builder;
1313
use crate::errors::MCDCExceedsConditionLimit;
1414

1515
/// LLVM uses `i16` to represent condition id. Hence `i16::MAX` is the hard limit for number of

compiler/rustc_mir_build/src/build/custom/parse/instruction.rs renamed to compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_span::Span;
99
use rustc_span::source_map::Spanned;
1010

1111
use super::{PResult, ParseCtxt, parse_by_kind};
12-
use crate::build::custom::ParseError;
13-
use crate::build::expr::as_constant::as_constant_inner;
12+
use crate::builder::custom::ParseError;
13+
use crate::builder::expr::as_constant::as_constant_inner;
1414

1515
impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
1616
pub(crate) fn parse_statement(&self, expr_id: ExprId) -> PResult<StatementKind<'tcx>> {

compiler/rustc_mir_build/src/build/expr/as_constant.rs renamed to compiler/rustc_mir_build/src/builder/expr/as_constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::ty::{
1414
use rustc_middle::{bug, mir, span_bug};
1515
use tracing::{instrument, trace};
1616

17-
use crate::build::{Builder, parse_float_into_constval};
17+
use crate::builder::{Builder, parse_float_into_constval};
1818

1919
impl<'a, 'tcx> Builder<'a, 'tcx> {
2020
/// Compile `expr`, yielding a compile-time constant. Assumes that

compiler/rustc_mir_build/src/build/expr/as_operand.rs renamed to compiler/rustc_mir_build/src/builder/expr/as_operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use rustc_middle::mir::*;
44
use rustc_middle::thir::*;
55
use tracing::{debug, instrument};
66

7-
use crate::build::expr::category::Category;
8-
use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
7+
use crate::builder::expr::category::Category;
8+
use crate::builder::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
99

1010
impl<'a, 'tcx> Builder<'a, 'tcx> {
1111
/// Construct a temporary lifetime restricted to just the local scope

compiler/rustc_mir_build/src/build/expr/as_place.rs renamed to compiler/rustc_mir_build/src/builder/expr/as_place.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use rustc_middle::{bug, span_bug};
1414
use rustc_span::{DesugaringKind, Span};
1515
use tracing::{debug, instrument, trace};
1616

17-
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
18-
use crate::build::expr::category::Category;
19-
use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
17+
use crate::builder::ForGuard::{OutsideGuard, RefWithinGuard};
18+
use crate::builder::expr::category::Category;
19+
use crate::builder::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
2020

2121
/// The "outermost" place that holds this value.
2222
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -68,7 +68,7 @@ pub(crate) enum PlaceBase {
6868
/// This is used internally when building a place for an expression like `a.b.c`. The fields `b`
6969
/// and `c` can be progressively pushed onto the place builder that is created when converting `a`.
7070
#[derive(Clone, Debug, PartialEq)]
71-
pub(in crate::build) struct PlaceBuilder<'tcx> {
71+
pub(in crate::builder) struct PlaceBuilder<'tcx> {
7272
base: PlaceBase,
7373
projection: Vec<PlaceElem<'tcx>>,
7474
}
@@ -249,7 +249,7 @@ fn strip_prefix<'a, 'tcx>(
249249
}
250250

251251
impl<'tcx> PlaceBuilder<'tcx> {
252-
pub(in crate::build) fn to_place(&self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> {
252+
pub(in crate::builder) fn to_place(&self, cx: &Builder<'_, 'tcx>) -> Place<'tcx> {
253253
self.try_to_place(cx).unwrap_or_else(|| match self.base {
254254
PlaceBase::Local(local) => span_bug!(
255255
cx.local_decls[local].source_info.span,
@@ -265,7 +265,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
265265
}
266266

267267
/// Creates a `Place` or returns `None` if an upvar cannot be resolved
268-
pub(in crate::build) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Place<'tcx>> {
268+
pub(in crate::builder) fn try_to_place(&self, cx: &Builder<'_, 'tcx>) -> Option<Place<'tcx>> {
269269
let resolved = self.resolve_upvar(cx);
270270
let builder = resolved.as_ref().unwrap_or(self);
271271
let PlaceBase::Local(local) = builder.base else { return None };
@@ -283,7 +283,7 @@ impl<'tcx> PlaceBuilder<'tcx> {
283283
/// not captured. This can happen because the final mir that will be
284284
/// generated doesn't require a read for this place. Failures will only
285285
/// happen inside closures.
286-
pub(in crate::build) fn resolve_upvar(
286+
pub(in crate::builder) fn resolve_upvar(
287287
&self,
288288
cx: &Builder<'_, 'tcx>,
289289
) -> Option<PlaceBuilder<'tcx>> {

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs renamed to compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use rustc_span::source_map::Spanned;
1616
use rustc_span::{DUMMY_SP, Span};
1717
use tracing::debug;
1818

19-
use crate::build::expr::as_place::PlaceBase;
20-
use crate::build::expr::category::{Category, RvalueFunc};
21-
use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
19+
use crate::builder::expr::as_place::PlaceBase;
20+
use crate::builder::expr::category::{Category, RvalueFunc};
21+
use crate::builder::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
2222

2323
impl<'a, 'tcx> Builder<'a, 'tcx> {
2424
/// Returns an rvalue suitable for use until the end of the current

compiler/rustc_mir_build/src/build/expr/as_temp.rs renamed to compiler/rustc_mir_build/src/builder/expr/as_temp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use rustc_middle::mir::*;
77
use rustc_middle::thir::*;
88
use tracing::{debug, instrument};
99

10-
use crate::build::scope::DropKind;
11-
use crate::build::{BlockAnd, BlockAndExtension, Builder};
10+
use crate::builder::scope::DropKind;
11+
use crate::builder::{BlockAnd, BlockAndExtension, Builder};
1212

1313
impl<'a, 'tcx> Builder<'a, 'tcx> {
1414
/// Compile `expr` into a fresh temporary. This is used when building

compiler/rustc_mir_build/src/build/expr/into.rs renamed to compiler/rustc_mir_build/src/builder/expr/into.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use rustc_middle::ty::CanonicalUserTypeAnnotation;
1111
use rustc_span::source_map::Spanned;
1212
use tracing::{debug, instrument};
1313

14-
use crate::build::expr::category::{Category, RvalueFunc};
15-
use crate::build::matches::DeclareLetBindings;
16-
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
14+
use crate::builder::expr::category::{Category, RvalueFunc};
15+
use crate::builder::matches::DeclareLetBindings;
16+
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
1717

1818
impl<'a, 'tcx> Builder<'a, 'tcx> {
1919
/// Compile `expr`, storing the result into `destination`, which

compiler/rustc_mir_build/src/build/expr/stmt.rs renamed to compiler/rustc_mir_build/src/builder/expr/stmt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use rustc_middle::thir::*;
55
use rustc_span::source_map::Spanned;
66
use tracing::debug;
77

8-
use crate::build::scope::BreakableTarget;
9-
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
8+
use crate::builder::scope::BreakableTarget;
9+
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
1010

1111
impl<'a, 'tcx> Builder<'a, 'tcx> {
1212
/// Builds a block of MIR statements to evaluate the THIR `expr`.

compiler/rustc_mir_build/src/build/matches/match_pair.rs renamed to compiler/rustc_mir_build/src/builder/matches/match_pair.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use rustc_middle::mir::*;
22
use rustc_middle::thir::{self, *};
33
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
44

5-
use crate::build::Builder;
6-
use crate::build::expr::as_place::{PlaceBase, PlaceBuilder};
7-
use crate::build::matches::{FlatPat, MatchPairTree, TestCase};
5+
use crate::builder::Builder;
6+
use crate::builder::expr::as_place::{PlaceBase, PlaceBuilder};
7+
use crate::builder::matches::{FlatPat, MatchPairTree, TestCase};
88

99
impl<'a, 'tcx> Builder<'a, 'tcx> {
1010
/// Builds and returns [`MatchPairTree`] subtrees, one for each pattern in
@@ -86,7 +86,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8686
impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
8787
/// Recursively builds a match pair tree for the given pattern and its
8888
/// subpatterns.
89-
pub(in crate::build) fn for_pattern(
89+
pub(in crate::builder) fn for_pattern(
9090
mut place_builder: PlaceBuilder<'tcx>,
9191
pattern: &'pat Pat<'tcx>,
9292
cx: &mut Builder<'_, 'tcx>,

compiler/rustc_mir_build/src/build/matches/mod.rs renamed to compiler/rustc_mir_build/src/builder/matches/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use rustc_span::symbol::Symbol;
1818
use rustc_span::{BytePos, Pos, Span};
1919
use tracing::{debug, instrument};
2020

21-
use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
22-
use crate::build::expr::as_place::PlaceBuilder;
23-
use crate::build::scope::DropKind;
24-
use crate::build::{
21+
use crate::builder::ForGuard::{self, OutsideGuard, RefWithinGuard};
22+
use crate::builder::expr::as_place::PlaceBuilder;
23+
use crate::builder::scope::DropKind;
24+
use crate::builder::{
2525
BlockAnd, BlockAndExtension, Builder, GuardFrame, GuardFrameLocal, LocalsForNode,
2626
};
2727

compiler/rustc_mir_build/src/build/matches/simplify.rs renamed to compiler/rustc_mir_build/src/builder/matches/simplify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::mem;
1616

1717
use tracing::{debug, instrument};
1818

19-
use crate::build::Builder;
20-
use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase};
19+
use crate::builder::Builder;
20+
use crate::builder::matches::{MatchPairTree, PatternExtraData, TestCase};
2121

2222
impl<'a, 'tcx> Builder<'a, 'tcx> {
2323
/// Simplify a list of match pairs so they all require a test. Stores relevant bindings and

compiler/rustc_mir_build/src/build/matches/test.rs renamed to compiler/rustc_mir_build/src/builder/matches/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use rustc_span::symbol::{Symbol, sym};
2020
use rustc_span::{DUMMY_SP, Span};
2121
use tracing::{debug, instrument};
2222

23-
use crate::build::Builder;
24-
use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind};
23+
use crate::builder::Builder;
24+
use crate::builder::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind};
2525

2626
impl<'a, 'tcx> Builder<'a, 'tcx> {
2727
/// Identifies what test is needed to decide if `match_pair` is applicable.

compiler/rustc_mir_build/src/build/matches/util.rs renamed to compiler/rustc_mir_build/src/builder/matches/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use rustc_middle::ty::Ty;
44
use rustc_span::Span;
55
use tracing::debug;
66

7-
use crate::build::Builder;
8-
use crate::build::expr::as_place::PlaceBase;
9-
use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase};
7+
use crate::builder::Builder;
8+
use crate::builder::expr::as_place::PlaceBase;
9+
use crate::builder::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase};
1010

1111
impl<'a, 'tcx> Builder<'a, 'tcx> {
1212
/// Creates a false edge to `imaginary_target` and a real edge to

compiler/rustc_mir_build/src/build/misc.rs renamed to compiler/rustc_mir_build/src/builder/misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_span::Span;
77
use rustc_trait_selection::infer::InferCtxtExt;
88
use tracing::debug;
99

10-
use crate::build::Builder;
10+
use crate::builder::Builder;
1111

1212
impl<'a, 'tcx> Builder<'a, 'tcx> {
1313
/// Adds a new temporary value of type `ty` storing the result of

compiler/rustc_mir_build/src/build/mod.rs renamed to compiler/rustc_mir_build/src/builder/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! This module used to be named `build`, but that was causing GitHub's
2+
//! "Go to file" feature to silently ignore all files in the module, probably
3+
//! because it assumes that "build" is a build-output directory.
4+
//! See <https://github.com/rust-lang/rust/pull/134365>.
5+
16
use itertools::Itertools;
27
use rustc_abi::{ExternAbi, FieldIdx};
38
use rustc_apfloat::Float;
@@ -23,8 +28,8 @@ use rustc_span::symbol::sym;
2328
use rustc_span::{Span, Symbol};
2429

2530
use super::lints;
26-
use crate::build::expr::as_place::PlaceBuilder;
27-
use crate::build::scope::DropKind;
31+
use crate::builder::expr::as_place::PlaceBuilder;
32+
use crate::builder::scope::DropKind;
2833

2934
pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
3035
tcx: TyCtxt<'tcx>,

compiler/rustc_mir_build/src/build/scope.rs renamed to compiler/rustc_mir_build/src/builder/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ use rustc_span::source_map::Spanned;
9595
use rustc_span::{DUMMY_SP, Span};
9696
use tracing::{debug, instrument};
9797

98-
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
98+
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
9999

100100
#[derive(Debug)]
101101
pub(crate) struct Scopes<'tcx> {

compiler/rustc_mir_build/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_span::def_id::{DefId, LocalDefId};
1818
use rustc_span::symbol::Symbol;
1919
use rustc_span::{Span, sym};
2020

21-
use crate::build::ExprCategory;
21+
use crate::builder::ExprCategory;
2222
use crate::errors::*;
2323

2424
struct UnsafetyVisitor<'a, 'tcx> {

compiler/rustc_mir_build/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
#![warn(unreachable_pub)]
1212
// tidy-alphabetical-end
1313

14-
mod build;
14+
// The `builder` module used to be named `build`, but that was causing GitHub's
15+
// "Go to file" feature to silently ignore all files in the module, probably
16+
// because it assumes that "build" is a build-output directory. See #134365.
17+
mod builder;
1518
mod check_tail_calls;
1619
mod check_unsafety;
1720
mod errors;
@@ -25,9 +28,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
2528
pub fn provide(providers: &mut Providers) {
2629
providers.check_match = thir::pattern::check_match;
2730
providers.lit_to_const = thir::constant::lit_to_const;
28-
providers.hooks.build_mir = build::mir_build;
31+
providers.hooks.build_mir = builder::mir_build;
2932
providers.closure_saved_names_of_captured_variables =
30-
build::closure_saved_names_of_captured_variables;
33+
builder::closure_saved_names_of_captured_variables;
3134
providers.check_unsafety = check_unsafety::check_unsafety;
3235
providers.check_tail_calls = check_tail_calls::check_tail_calls;
3336
providers.thir_body = thir::cx::thir_body;

compiler/rustc_mir_build/src/thir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
55
use rustc_middle::ty::{self, ScalarInt, TyCtxt, TypeVisitableExt as _};
66
use tracing::trace;
77

8-
use crate::build::parse_float_into_scalar;
8+
use crate::builder::parse_float_into_scalar;
99

1010
pub(crate) fn lit_to_const<'tcx>(
1111
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)