Skip to content

Commit 91a0e16

Browse files
committed
Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errors
Rollup of 17 pull requests Successful merges: - #137827 (Add timestamp to unstable feature usage metrics) - #138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported) - #138046 (trim channel value in `get_closest_merge_commit`) - #138053 (Increase the max. custom try jobs requested to `20`) - #138061 (triagebot: add a `compiler_leads` ad-hoc group) - #138064 (Remove - from xtensa targets cpu names) - #138075 (Use final path segment for diagnostic) - #138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode) - #138081 (Move `yield` expressions behind their own feature gate) - #138090 (`librustdoc`: flatten nested ifs) - #138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`) - #138094 (a small borrowck cleanup) - #138098 (Stabilize feature `const_copy_from_slice`) - #138103 (Git ignore citool's target directory) - #138105 (Fix broken link to Miri intrinsics in documentation) - #138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur) - #138117 ([llvm/PassWrapper] use `size_t` when building arg strings) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 98a4878 + e6d1856 commit 91a0e16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+377
-335
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ no_llvm_build
5353
/target
5454
/library/target
5555
/src/bootstrap/target
56+
/src/ci/citool/target
5657
/src/tools/x/target
5758
# Created by `x vendor`
5859
/vendor

compiler/rustc_ast_lowering/src/expr.rs

+14-21
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
16901690
let yielded =
16911691
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));
16921692

1693+
if !self.tcx.features().yield_expr()
1694+
&& !self.tcx.features().coroutines()
1695+
&& !self.tcx.features().gen_blocks()
1696+
{
1697+
rustc_session::parse::feature_err(
1698+
&self.tcx.sess,
1699+
sym::yield_expr,
1700+
span,
1701+
fluent_generated::ast_lowering_yield,
1702+
)
1703+
.emit();
1704+
}
1705+
16931706
let is_async_gen = match self.coroutine_kind {
16941707
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)) => false,
16951708
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _)) => true,
@@ -1714,28 +1727,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
17141727
None,
17151728
);
17161729
}
1717-
Some(hir::CoroutineKind::Coroutine(_)) => {
1718-
if !self.tcx.features().coroutines() {
1719-
rustc_session::parse::feature_err(
1720-
&self.tcx.sess,
1721-
sym::coroutines,
1722-
span,
1723-
fluent_generated::ast_lowering_yield,
1724-
)
1725-
.emit();
1726-
}
1727-
false
1728-
}
1730+
Some(hir::CoroutineKind::Coroutine(_)) => false,
17291731
None => {
1730-
if !self.tcx.features().coroutines() {
1731-
rustc_session::parse::feature_err(
1732-
&self.tcx.sess,
1733-
sym::coroutines,
1734-
span,
1735-
fluent_generated::ast_lowering_yield,
1736-
)
1737-
.emit();
1738-
}
17391732
let suggestion = self.current_item.map(|s| s.shrink_to_lo());
17401733
self.dcx().emit_err(YieldInClosure { span, suggestion });
17411734
self.coroutine_kind = Some(hir::CoroutineKind::Coroutine(Movability::Movable));

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_hir::def_id::DefId;
1+
use rustc_hir::def_id::LocalDefId;
22
use rustc_infer::infer::canonical::QueryRegionConstraints;
33
use rustc_infer::infer::outlives::env::RegionBoundPairs;
44
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
@@ -88,7 +88,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
8888
pub(crate) fn apply_closure_requirements(
8989
&mut self,
9090
closure_requirements: &ClosureRegionRequirements<'tcx>,
91-
closure_def_id: DefId,
91+
closure_def_id: LocalDefId,
9292
closure_args: ty::GenericArgsRef<'tcx>,
9393
) {
9494
// Extract the values of the free regions in `closure_args`
@@ -98,7 +98,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
9898
self.tcx,
9999
closure_args,
100100
closure_requirements.num_external_vids,
101-
closure_def_id.expect_local(),
101+
closure_def_id,
102102
);
103103
debug!(?closure_mapping);
104104

compiler/rustc_borrowck/src/type_check/mod.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
328328
}
329329
}
330330

331+
#[instrument(level = "debug", skip(self))]
331332
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
332-
debug!(?constant, ?location, "visit_const_operand");
333-
334333
self.super_const_operand(constant, location);
335334
let ty = constant.const_.ty();
336335

@@ -339,14 +338,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
339338
self.typeck.constraints.liveness_constraints.add_location(live_region_vid, location);
340339
});
341340

342-
// HACK(compiler-errors): Constants that are gathered into Body.required_consts
343-
// have their locations erased...
344-
let locations = if location != Location::START {
345-
location.to_locations()
346-
} else {
347-
Locations::All(constant.span)
348-
};
349-
341+
let locations = location.to_locations();
350342
if let Some(annotation_index) = constant.user_ty {
351343
if let Err(terr) = self.typeck.relate_type_and_user_type(
352344
constant.const_.ty(),
@@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
491483
}
492484
}
493485

486+
#[instrument(level = "debug", skip(self))]
494487
fn visit_body(&mut self, body: &Body<'tcx>) {
495-
// The types of local_decls are checked above which is called in super_body.
496-
self.super_body(body);
488+
// We intentionally do not recurse into `body.required_consts` or
489+
// `body.mentioned_items` here as the MIR at this phase should still
490+
// refer to all items and we don't want to check them multiple times.
491+
492+
for (local, local_decl) in body.local_decls.iter_enumerated() {
493+
self.visit_local_decl(local, local_decl);
494+
}
495+
496+
for (block, block_data) in body.basic_blocks.iter_enumerated() {
497+
let mut location = Location { block, statement_index: 0 };
498+
for stmt in &block_data.statements {
499+
if !stmt.source_info.span.is_dummy() {
500+
self.last_span = stmt.source_info.span;
501+
}
502+
self.visit_statement(stmt, location);
503+
location.statement_index += 1;
504+
}
505+
506+
self.visit_terminator(block_data.terminator(), location);
507+
}
497508
}
498509
}
499510

@@ -2582,7 +2593,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25822593
ConstraintCategory::Boring, // same as above.
25832594
self.constraints,
25842595
)
2585-
.apply_closure_requirements(closure_requirements, def_id.to_def_id(), args);
2596+
.apply_closure_requirements(closure_requirements, def_id, args);
25862597
}
25872598

25882599
// Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589.

compiler/rustc_feature/src/unstable.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! List of the unstable feature gates.
22
33
use std::path::PathBuf;
4+
use std::time::{SystemTime, UNIX_EPOCH};
45

56
use rustc_data_structures::fx::FxHashSet;
67
use rustc_span::{Span, Symbol, sym};
@@ -669,6 +670,7 @@ declare_features! (
669670
(unstable, xop_target_feature, "1.81.0", Some(127208)),
670671
/// Allows `do yeet` expressions
671672
(unstable, yeet_expr, "1.62.0", Some(96373)),
673+
(unstable, yield_expr, "CURRENT_RUSTC_VERSION", Some(43122)),
672674
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
673675
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
674676
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
@@ -685,11 +687,13 @@ impl Features {
685687
) -> Result<(), Box<dyn std::error::Error>> {
686688
#[derive(serde::Serialize)]
687689
struct LibFeature {
690+
timestamp: u128,
688691
symbol: String,
689692
}
690693

691694
#[derive(serde::Serialize)]
692695
struct LangFeature {
696+
timestamp: u128,
693697
symbol: String,
694698
since: Option<String>,
695699
}
@@ -703,10 +707,20 @@ impl Features {
703707
let metrics_file = std::fs::File::create(metrics_path)?;
704708
let metrics_file = std::io::BufWriter::new(metrics_file);
705709

710+
let now = || {
711+
SystemTime::now()
712+
.duration_since(UNIX_EPOCH)
713+
.expect("system time should always be greater than the unix epoch")
714+
.as_nanos()
715+
};
716+
706717
let lib_features = self
707718
.enabled_lib_features
708719
.iter()
709-
.map(|EnabledLibFeature { gate_name, .. }| LibFeature { symbol: gate_name.to_string() })
720+
.map(|EnabledLibFeature { gate_name, .. }| LibFeature {
721+
symbol: gate_name.to_string(),
722+
timestamp: now(),
723+
})
710724
.collect();
711725

712726
let lang_features = self
@@ -715,6 +729,7 @@ impl Features {
715729
.map(|EnabledLangFeature { gate_name, stable_since, .. }| LangFeature {
716730
symbol: gate_name.to_string(),
717731
since: stable_since.map(|since| since.to_string()),
732+
timestamp: now(),
718733
})
719734
.collect();
720735

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12651265
} else {
12661266
CallableKind::Function
12671267
};
1268-
maybe_emit_help(def_id, path.segments[0].ident, args, callable_kind);
1268+
maybe_emit_help(def_id, path.segments.last().unwrap().ident, args, callable_kind);
12691269
}
12701270
hir::ExprKind::MethodCall(method, _receiver, args, _span) => {
12711271
let Some(def_id) =

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
484484

485485
if (ArgsCstrBuff != nullptr) {
486486
#if LLVM_VERSION_GE(20, 0)
487-
int buffer_offset = 0;
487+
size_t buffer_offset = 0;
488488
assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0');
489489
auto Arg0 = std::string(ArgsCstrBuff);
490490
buffer_offset = Arg0.size() + 1;
@@ -502,7 +502,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
502502
Options.MCOptions.Argv0 = Arg0;
503503
Options.MCOptions.CommandlineArgs = CommandlineArgs;
504504
#else
505-
int buffer_offset = 0;
505+
size_t buffer_offset = 0;
506506
assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0');
507507

508508
const size_t arg0_len = std::strlen(ArgsCstrBuff);
@@ -511,13 +511,13 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
511511
arg0[arg0_len] = '\0';
512512
buffer_offset += arg0_len + 1;
513513

514-
const int num_cmd_arg_strings = std::count(
514+
const size_t num_cmd_arg_strings = std::count(
515515
&ArgsCstrBuff[buffer_offset], &ArgsCstrBuff[ArgsCstrBuffLen], '\0');
516516

517517
std::string *cmd_arg_strings = new std::string[num_cmd_arg_strings];
518-
for (int i = 0; i < num_cmd_arg_strings; ++i) {
518+
for (size_t i = 0; i < num_cmd_arg_strings; ++i) {
519519
assert(buffer_offset < ArgsCstrBuffLen);
520-
const int len = std::strlen(ArgsCstrBuff + buffer_offset);
520+
const size_t len = std::strlen(ArgsCstrBuff + buffer_offset);
521521
cmd_arg_strings[i] = std::string(&ArgsCstrBuff[buffer_offset], len);
522522
buffer_offset += len + 1;
523523
}

compiler/rustc_middle/src/ty/context.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,11 @@ pub struct TyCtxt<'tcx> {
13271327
gcx: &'tcx GlobalCtxt<'tcx>,
13281328
}
13291329

1330+
// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. Its
1331+
// field are asserted to implement these traits below, so this is trivially safe, and it greatly
1332+
// speeds-up compilation of this crate and its dependents.
1333+
unsafe impl DynSend for TyCtxt<'_> {}
1334+
unsafe impl DynSync for TyCtxt<'_> {}
13301335
fn _assert_tcx_fields() {
13311336
sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>();
13321337
sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>();

compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
2020
vendor: "espressif".into(),
2121

2222
executables: true,
23-
cpu: "esp32-s2".into(),
23+
cpu: "esp32s2".into(),
2424
linker: Some("xtensa-esp32s2-elf-gcc".into()),
2525

2626
// See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477

compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616

1717
options: TargetOptions {
1818
vendor: "espressif".into(),
19-
cpu: "esp32-s2".into(),
19+
cpu: "esp32s2".into(),
2020
linker: Some("xtensa-esp32s2-elf-gcc".into()),
2121
max_atomic_width: Some(32),
2222
features: "+forced-atomics".into(),

compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
2020
vendor: "espressif".into(),
2121

2222
executables: true,
23-
cpu: "esp32-s3".into(),
23+
cpu: "esp32s3".into(),
2424
linker: Some("xtensa-esp32s3-elf-gcc".into()),
2525

2626
// The esp32s3 only supports native 32bit atomics.

compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
1616

1717
options: TargetOptions {
1818
vendor: "espressif".into(),
19-
cpu: "esp32-s3".into(),
19+
cpu: "esp32s3".into(),
2020
linker: Some("xtensa-esp32s3-elf-gcc".into()),
2121
max_atomic_width: Some(32),
2222
atomic_cas: true,

library/core/src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! In order to make an intrinsic usable at compile-time, it needs to be declared in the "new"
1212
//! style, i.e. as a `#[rustc_intrinsic]` function, not inside an `extern` block. Then copy the
13-
//! implementation from <https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics> to
13+
//! implementation from <https://github.com/rust-lang/miri/blob/master/src/intrinsics> to
1414
//! <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>
1515
//! and make the intrinsic declaration a `const fn`.
1616
//!

library/core/src/slice/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3732,8 +3732,7 @@ impl<T> [T] {
37323732
#[doc(alias = "memcpy")]
37333733
#[inline]
37343734
#[stable(feature = "copy_from_slice", since = "1.9.0")]
3735-
#[rustc_const_unstable(feature = "const_copy_from_slice", issue = "131415")]
3736-
#[rustc_const_stable_indirect]
3735+
#[rustc_const_stable(feature = "const_copy_from_slice", since = "CURRENT_RUSTC_VERSION")]
37373736
#[track_caller]
37383737
pub const fn copy_from_slice(&mut self, src: &[T])
37393738
where

src/bootstrap/src/bin/main.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ fn main() {
7070
}
7171

7272
// check_version warnings are not printed during setup, or during CI
73-
let changelog_suggestion = if matches!(config.cmd, Subcommand::Setup { .. }) || CiEnv::is_ci() {
74-
None
75-
} else {
76-
check_version(&config)
77-
};
73+
let changelog_suggestion =
74+
if matches!(config.cmd, Subcommand::Setup { .. }) || CiEnv::is_ci() || config.dry_run() {
75+
None
76+
} else {
77+
check_version(&config)
78+
};
7879

7980
// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
8081
// changelog warning, not the `x.py setup` message.
@@ -187,7 +188,7 @@ fn check_version(config: &Config) -> Option<String> {
187188
"update `config.toml` to use `change-id = {latest_change_id}` instead"
188189
));
189190

190-
if io::stdout().is_terminal() && !config.dry_run() {
191+
if io::stdout().is_terminal() {
191192
t!(fs::write(warned_id_path, latest_change_id.to_string()));
192193
}
193194
} else {

src/bootstrap/src/bin/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn format_rusage_data(child: Child) -> Option<String> {
349349
let mut kernel_filetime = Default::default();
350350
let mut kernel_time = Default::default();
351351
let mut memory_counters = PROCESS_MEMORY_COUNTERS::default();
352-
let memory_counters_size = std::mem::size_of_val(&memory_counters);
352+
let memory_counters_size = size_of_val(&memory_counters);
353353

354354
unsafe {
355355
GetProcessTimes(

src/bootstrap/src/utils/job.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub unsafe fn setup(build: &mut crate::Build) {
4242
#[cfg(windows)]
4343
mod for_windows {
4444
use std::ffi::c_void;
45-
use std::{io, mem};
45+
use std::io;
4646

4747
use windows::Win32::Foundation::CloseHandle;
4848
use windows::Win32::System::Diagnostics::Debug::{
@@ -82,7 +82,7 @@ mod for_windows {
8282
job,
8383
JobObjectExtendedLimitInformation,
8484
&info as *const _ as *const c_void,
85-
mem::size_of_val(&info) as u32,
85+
size_of_val(&info) as u32,
8686
);
8787
assert!(r.is_ok(), "{}", io::Error::last_os_error());
8888

src/build_helper/src/git.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn get_closest_merge_commit(
129129
git.current_dir(git_dir);
130130
}
131131

132-
let channel = include_str!("../../ci/channel");
132+
let channel = include_str!("../../ci/channel").trim();
133133

134134
let merge_base = {
135135
if CiEnv::is_ci() &&

0 commit comments

Comments
 (0)