Skip to content

Commit a44881d

Browse files
committed
Auto merge of #64510 - Centril:rollup-m03zsq8, r=Centril
Rollup of 10 pull requests Successful merges: - #63955 (Make sure interned constants are immutable) - #64028 (Stabilize `Vec::new` and `String::new` as `const fn`s) - #64119 (ci: ensure all tool maintainers are assignable on issues) - #64444 (fix building libstd without backtrace feature) - #64446 (Fix build script sanitizer check.) - #64451 (when Miri tests are not passing, do not add Miri component) - #64467 (Hide diagnostics emitted during --cfg parsing) - #64497 (Don't print the "total" `-Ztime-passes` output if `--prints=...` is also given) - #64499 (Use `Symbol` in two more functions.) - #64504 (use println!() instead of println!("")) Failed merges: r? @ghost
2 parents 16c4011 + f4ff418 commit a44881d

39 files changed

+478
-247
lines changed

Cargo.lock

+2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ dependencies = [
201201
name = "build-manifest"
202202
version = "0.1.0"
203203
dependencies = [
204+
"reqwest",
204205
"serde",
206+
"serde_json",
205207
"toml",
206208
]
207209

src/bootstrap/dist.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,8 @@ impl Step for HashSign {
20002000
}
20012001

20022002
fn run(self, builder: &Builder<'_>) {
2003+
// This gets called by `promote-release`
2004+
// (https://github.com/rust-lang/rust-central-station/tree/master/promote-release).
20032005
let mut cmd = builder.tool_cmd(Tool::BuildManifest);
20042006
if builder.config.dry_run {
20052007
return;
@@ -2010,10 +2012,14 @@ impl Step for HashSign {
20102012
let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| {
20112013
panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n")
20122014
});
2013-
let file = builder.config.dist_gpg_password_file.as_ref().unwrap_or_else(|| {
2014-
panic!("\n\nfailed to specify `dist.gpg-password-file` in `config.toml`\n\n")
2015-
});
2016-
let pass = t!(fs::read_to_string(&file));
2015+
let pass = if env::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err() {
2016+
let file = builder.config.dist_gpg_password_file.as_ref().unwrap_or_else(|| {
2017+
panic!("\n\nfailed to specify `dist.gpg-password-file` in `config.toml`\n\n")
2018+
});
2019+
t!(fs::read_to_string(&file))
2020+
} else {
2021+
String::new()
2022+
};
20172023

20182024
let today = output(Command::new("date").arg("+%Y-%m-%d"));
20192025

src/ci/azure-pipelines/steps/run.yml

+7
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,15 @@ steps:
147147
git clone --depth=1 https://github.com/rust-lang-nursery/rust-toolstate.git
148148
cd rust-toolstate
149149
python2.7 "$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "" ""
150+
# Only check maintainers if this build is supposed to publish toolstate.
151+
# Builds that are not supposed to publish don't have the access token.
152+
if [ -n "${TOOLSTATE_PUBLISH+is_set}" ]; then
153+
TOOLSTATE_VALIDATE_MAINTAINERS_REPO=rust-lang/rust python2.7 "${BUILD_SOURCESDIRECTORY}/src/tools/publish_toolstate.py"
154+
fi
150155
cd ..
151156
rm -rf rust-toolstate
157+
env:
158+
TOOLSTATE_REPO_ACCESS_TOKEN: $(TOOLSTATE_REPO_ACCESS_TOKEN)
152159
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['IMAGE'], 'mingw-check'))
153160
displayName: Verify the publish_toolstate script works
154161

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
#![feature(allocator_internals)]
118118
#![feature(on_unimplemented)]
119119
#![feature(rustc_const_unstable)]
120-
#![feature(const_vec_new)]
120+
#![cfg_attr(bootstrap, feature(const_vec_new))]
121121
#![feature(slice_partition_dedup)]
122122
#![feature(maybe_uninit_extra, maybe_uninit_slice)]
123123
#![feature(alloc_layout_extra)]

src/liballoc/raw_vec.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,38 @@ impl<T, A: Alloc> RawVec<T, A> {
113113
}
114114

115115
impl<T> RawVec<T, Global> {
116+
/// HACK(Centril): This exists because `#[unstable]` `const fn`s needn't conform
117+
/// to `min_const_fn` and so they cannot be called in `min_const_fn`s either.
118+
///
119+
/// If you change `RawVec<T>::new` or dependencies, please take care to not
120+
/// introduce anything that would truly violate `min_const_fn`.
121+
///
122+
/// NOTE: We could avoid this hack and check conformance with some
123+
/// `#[rustc_force_min_const_fn]` attribute which requires conformance
124+
/// with `min_const_fn` but does not necessarily allow calling it in
125+
/// `stable(...) const fn` / user code not enabling `foo` when
126+
/// `#[rustc_const_unstable(feature = "foo", ..)]` is present.
127+
pub const NEW: Self = Self::new();
128+
116129
/// Creates the biggest possible `RawVec` (on the system heap)
117130
/// without allocating. If `T` has positive size, then this makes a
118131
/// `RawVec` with capacity `0`. If `T` is zero-sized, then it makes a
119132
/// `RawVec` with capacity `usize::MAX`. Useful for implementing
120133
/// delayed allocation.
121134
pub const fn new() -> Self {
122-
Self::new_in(Global)
135+
// FIXME(Centril): Reintegrate this with `fn new_in` when we can.
136+
137+
// `!0` is `usize::MAX`. This branch should be stripped at compile time.
138+
// FIXME(mark-i-m): use this line when `if`s are allowed in `const`:
139+
//let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
140+
141+
// `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
142+
RawVec {
143+
ptr: Unique::empty(),
144+
// FIXME(mark-i-m): use `cap` when ifs are allowed in const
145+
cap: [0, !0][(mem::size_of::<T>() == 0) as usize],
146+
a: Global,
147+
}
123148
}
124149

125150
/// Creates a `RawVec` (on the system heap) with exactly the

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl String {
369369
/// ```
370370
#[inline]
371371
#[stable(feature = "rust1", since = "1.0.0")]
372-
#[rustc_const_unstable(feature = "const_string_new")]
372+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_string_new"))]
373373
pub const fn new() -> String {
374374
String { vec: Vec::new() }
375375
}

src/liballoc/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ impl<T> Vec<T> {
314314
/// ```
315315
#[inline]
316316
#[stable(feature = "rust1", since = "1.0.0")]
317-
#[rustc_const_unstable(feature = "const_vec_new")]
317+
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_vec_new"))]
318318
pub const fn new() -> Vec<T> {
319319
Vec {
320-
buf: RawVec::new(),
320+
buf: RawVec::NEW,
321321
len: 0,
322322
}
323323
}

src/librustc/session/config.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::session::{early_error, early_warn, Session};
77
use crate::session::search_paths::SearchPath;
88

99
use rustc_data_structures::fx::FxHashSet;
10+
use rustc_data_structures::sync::Lrc;
1011

1112
use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
1213
use rustc_target::spec::{Target, TargetTriple};
@@ -19,6 +20,7 @@ use syntax::parse::{ParseSess, new_parser_from_source_str};
1920
use syntax::parse::token;
2021
use syntax::symbol::{sym, Symbol};
2122
use syntax::feature_gate::UnstableFeatures;
23+
use syntax::source_map::SourceMap;
2224

2325
use errors::emitter::HumanReadableErrorType;
2426
use errors::{ColorConfig, FatalError, Handler};
@@ -1850,11 +1852,20 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
18501852
opts
18511853
}
18521854

1855+
struct NullEmitter;
1856+
1857+
impl errors::emitter::Emitter for NullEmitter {
1858+
fn emit_diagnostic(&mut self, _: &errors::DiagnosticBuilder<'_>) {}
1859+
}
1860+
18531861
// Converts strings provided as `--cfg [cfgspec]` into a `crate_cfg`.
18541862
pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String>)> {
18551863
syntax::with_default_globals(move || {
18561864
let cfg = cfgspecs.into_iter().map(|s| {
1857-
let sess = ParseSess::new(FilePathMapping::empty());
1865+
1866+
let cm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
1867+
let handler = Handler::with_emitter(false, None, Box::new(NullEmitter));
1868+
let sess = ParseSess::with_span_handler(handler, cm);
18581869
let filename = FileName::cfg_spec_source_code(&s);
18591870
let mut parser = new_parser_from_source_str(&sess, filename, s.to_string());
18601871

src/librustc_asan/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
78
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
89
return;
910
}

src/librustc_codegen_llvm/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,21 @@ impl CodegenBackend for LlvmCodegenBackend {
226226
for &(name, _) in back::write::RELOC_MODEL_ARGS.iter() {
227227
println!(" {}", name);
228228
}
229-
println!("");
229+
println!();
230230
}
231231
PrintRequest::CodeModels => {
232232
println!("Available code models:");
233233
for &(name, _) in back::write::CODE_GEN_MODEL_ARGS.iter(){
234234
println!(" {}", name);
235235
}
236-
println!("");
236+
println!();
237237
}
238238
PrintRequest::TlsModels => {
239239
println!("Available TLS models:");
240240
for &(name, _) in back::write::TLS_MODEL_ARGS.iter(){
241241
println!(" {}", name);
242242
}
243-
println!("");
243+
println!();
244244
}
245245
req => llvm_util::print(req, sess),
246246
}

src/librustc_driver/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ pub struct TimePassesCallbacks {
134134

135135
impl Callbacks for TimePassesCallbacks {
136136
fn config(&mut self, config: &mut interface::Config) {
137+
// If a --prints=... option has been given, we don't print the "total"
138+
// time because it will mess up the --prints output. See #64339.
137139
self.time_passes =
138-
config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time;
140+
config.opts.prints.is_empty() &&
141+
(config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time);
139142
}
140143
}
141144

src/librustc_lsan/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
78
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
89
return;
910
}

src/librustc_mir/const_eval.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ fn eval_body_using_ecx<'mir, 'tcx>(
134134
ecx: &mut CompileTimeEvalContext<'mir, 'tcx>,
135135
cid: GlobalId<'tcx>,
136136
body: &'mir mir::Body<'tcx>,
137-
param_env: ty::ParamEnv<'tcx>,
138137
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
139-
debug!("eval_body_using_ecx: {:?}, {:?}", cid, param_env);
138+
debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
140139
let tcx = ecx.tcx.tcx;
141140
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
142141
assert!(!layout.is_unsized());
@@ -162,7 +161,6 @@ fn eval_body_using_ecx<'mir, 'tcx>(
162161
ecx,
163162
cid.instance.def_id(),
164163
ret,
165-
param_env,
166164
)?;
167165

168166
debug!("eval_body_using_ecx done: {:?}", *ret);
@@ -658,7 +656,7 @@ pub fn const_eval_raw_provider<'tcx>(
658656

659657
let res = ecx.load_mir(cid.instance.def, cid.promoted);
660658
res.and_then(
661-
|body| eval_body_using_ecx(&mut ecx, cid, body, key.param_env)
659+
|body| eval_body_using_ecx(&mut ecx, cid, body)
662660
).and_then(|place| {
663661
Ok(RawConst {
664662
alloc_id: place.ptr.assert_ptr().alloc_id,

0 commit comments

Comments
 (0)