Skip to content

Commit

Permalink
Auto merge of rust-lang#138127 - compiler-errors:rollup-kcarqrz, r=co…
Browse files Browse the repository at this point in the history
…mpiler-errors

Rollup of 17 pull requests

Successful merges:

 - rust-lang#137827 (Add timestamp to unstable feature usage metrics)
 - rust-lang#138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported)
 - rust-lang#138046 (trim channel value in `get_closest_merge_commit`)
 - rust-lang#138053 (Increase the max. custom try jobs requested to `20`)
 - rust-lang#138061 (triagebot: add a `compiler_leads` ad-hoc group)
 - rust-lang#138064 (Remove - from xtensa targets cpu names)
 - rust-lang#138075 (Use final path segment for diagnostic)
 - rust-lang#138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode)
 - rust-lang#138081 (Move `yield` expressions behind their own feature gate)
 - rust-lang#138090 (`librustdoc`: flatten nested ifs)
 - rust-lang#138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`)
 - rust-lang#138094 (a small borrowck cleanup)
 - rust-lang#138098 (Stabilize feature `const_copy_from_slice`)
 - rust-lang#138103 (Git ignore citool's target directory)
 - rust-lang#138105 (Fix broken link to Miri intrinsics in documentation)
 - rust-lang#138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur)
 - rust-lang#138117 ([llvm/PassWrapper] use `size_t` when building arg strings)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 7, 2025
2 parents 98a4878 + e6d1856 commit 91a0e16
Show file tree
Hide file tree
Showing 51 changed files with 377 additions and 335 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ no_llvm_build
/target
/library/target
/src/bootstrap/target
/src/ci/citool/target
/src/tools/x/target
# Created by `x vendor`
/vendor
Expand Down
35 changes: 14 additions & 21 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
let yielded =
opt_expr.as_ref().map(|x| self.lower_expr(x)).unwrap_or_else(|| self.expr_unit(span));

if !self.tcx.features().yield_expr()
&& !self.tcx.features().coroutines()
&& !self.tcx.features().gen_blocks()
{
rustc_session::parse::feature_err(
&self.tcx.sess,
sym::yield_expr,
span,
fluent_generated::ast_lowering_yield,
)
.emit();
}

let is_async_gen = match self.coroutine_kind {
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)) => false,
Some(hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _)) => true,
Expand All @@ -1714,28 +1727,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
None,
);
}
Some(hir::CoroutineKind::Coroutine(_)) => {
if !self.tcx.features().coroutines() {
rustc_session::parse::feature_err(
&self.tcx.sess,
sym::coroutines,
span,
fluent_generated::ast_lowering_yield,
)
.emit();
}
false
}
Some(hir::CoroutineKind::Coroutine(_)) => false,
None => {
if !self.tcx.features().coroutines() {
rustc_session::parse::feature_err(
&self.tcx.sess,
sym::coroutines,
span,
fluent_generated::ast_lowering_yield,
)
.emit();
}
let suggestion = self.current_item.map(|s| s.shrink_to_lo());
self.dcx().emit_err(YieldInClosure { span, suggestion });
self.coroutine_kind = Some(hir::CoroutineKind::Coroutine(Movability::Movable));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::LocalDefId;
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
pub(crate) fn apply_closure_requirements(
&mut self,
closure_requirements: &ClosureRegionRequirements<'tcx>,
closure_def_id: DefId,
closure_def_id: LocalDefId,
closure_args: ty::GenericArgsRef<'tcx>,
) {
// Extract the values of the free regions in `closure_args`
Expand All @@ -98,7 +98,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
self.tcx,
closure_args,
closure_requirements.num_external_vids,
closure_def_id.expect_local(),
closure_def_id,
);
debug!(?closure_mapping);

Expand Down
37 changes: 24 additions & 13 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
}
}

#[instrument(level = "debug", skip(self))]
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
debug!(?constant, ?location, "visit_const_operand");

self.super_const_operand(constant, location);
let ty = constant.const_.ty();

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

// HACK(compiler-errors): Constants that are gathered into Body.required_consts
// have their locations erased...
let locations = if location != Location::START {
location.to_locations()
} else {
Locations::All(constant.span)
};

let locations = location.to_locations();
if let Some(annotation_index) = constant.user_ty {
if let Err(terr) = self.typeck.relate_type_and_user_type(
constant.const_.ty(),
Expand Down Expand Up @@ -491,9 +483,28 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
}
}

#[instrument(level = "debug", skip(self))]
fn visit_body(&mut self, body: &Body<'tcx>) {
// The types of local_decls are checked above which is called in super_body.
self.super_body(body);
// We intentionally do not recurse into `body.required_consts` or
// `body.mentioned_items` here as the MIR at this phase should still
// refer to all items and we don't want to check them multiple times.

for (local, local_decl) in body.local_decls.iter_enumerated() {
self.visit_local_decl(local, local_decl);
}

for (block, block_data) in body.basic_blocks.iter_enumerated() {
let mut location = Location { block, statement_index: 0 };
for stmt in &block_data.statements {
if !stmt.source_info.span.is_dummy() {
self.last_span = stmt.source_info.span;
}
self.visit_statement(stmt, location);
location.statement_index += 1;
}

self.visit_terminator(block_data.terminator(), location);
}
}
}

Expand Down Expand Up @@ -2582,7 +2593,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
ConstraintCategory::Boring, // same as above.
self.constraints,
)
.apply_closure_requirements(closure_requirements, def_id.to_def_id(), args);
.apply_closure_requirements(closure_requirements, def_id, args);
}

// Now equate closure args to regions inherited from `typeck_root_def_id`. Fixes #98589.
Expand Down
17 changes: 16 additions & 1 deletion compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! List of the unstable feature gates.
use std::path::PathBuf;
use std::time::{SystemTime, UNIX_EPOCH};

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

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

let now = || {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("system time should always be greater than the unix epoch")
.as_nanos()
};

let lib_features = self
.enabled_lib_features
.iter()
.map(|EnabledLibFeature { gate_name, .. }| LibFeature { symbol: gate_name.to_string() })
.map(|EnabledLibFeature { gate_name, .. }| LibFeature {
symbol: gate_name.to_string(),
timestamp: now(),
})
.collect();

let lang_features = self
Expand All @@ -715,6 +729,7 @@ impl Features {
.map(|EnabledLangFeature { gate_name, stable_since, .. }| LangFeature {
symbol: gate_name.to_string(),
since: stable_since.map(|since| since.to_string()),
timestamp: now(),
})
.collect();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
CallableKind::Function
};
maybe_emit_help(def_id, path.segments[0].ident, args, callable_kind);
maybe_emit_help(def_id, path.segments.last().unwrap().ident, args, callable_kind);
}
hir::ExprKind::MethodCall(method, _receiver, args, _span) => {
let Some(def_id) =
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(

if (ArgsCstrBuff != nullptr) {
#if LLVM_VERSION_GE(20, 0)
int buffer_offset = 0;
size_t buffer_offset = 0;
assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0');
auto Arg0 = std::string(ArgsCstrBuff);
buffer_offset = Arg0.size() + 1;
Expand All @@ -502,7 +502,7 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
Options.MCOptions.Argv0 = Arg0;
Options.MCOptions.CommandlineArgs = CommandlineArgs;
#else
int buffer_offset = 0;
size_t buffer_offset = 0;
assert(ArgsCstrBuff[ArgsCstrBuffLen - 1] == '\0');

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

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

std::string *cmd_arg_strings = new std::string[num_cmd_arg_strings];
for (int i = 0; i < num_cmd_arg_strings; ++i) {
for (size_t i = 0; i < num_cmd_arg_strings; ++i) {
assert(buffer_offset < ArgsCstrBuffLen);
const int len = std::strlen(ArgsCstrBuff + buffer_offset);
const size_t len = std::strlen(ArgsCstrBuff + buffer_offset);
cmd_arg_strings[i] = std::string(&ArgsCstrBuff[buffer_offset], len);
buffer_offset += len + 1;
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,11 @@ pub struct TyCtxt<'tcx> {
gcx: &'tcx GlobalCtxt<'tcx>,
}

// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. Its
// field are asserted to implement these traits below, so this is trivially safe, and it greatly
// speeds-up compilation of this crate and its dependents.
unsafe impl DynSend for TyCtxt<'_> {}
unsafe impl DynSync for TyCtxt<'_> {}
fn _assert_tcx_fields() {
sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>();
sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
vendor: "espressif".into(),

executables: true,
cpu: "esp32-s2".into(),
cpu: "esp32s2".into(),
linker: Some("xtensa-esp32s2-elf-gcc".into()),

// See https://github.com/espressif/rust-esp32-example/issues/3#issuecomment-861054477
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
vendor: "espressif".into(),
cpu: "esp32-s2".into(),
cpu: "esp32s2".into(),
linker: Some("xtensa-esp32s2-elf-gcc".into()),
max_atomic_width: Some(32),
features: "+forced-atomics".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target {
vendor: "espressif".into(),

executables: true,
cpu: "esp32-s3".into(),
cpu: "esp32s3".into(),
linker: Some("xtensa-esp32s3-elf-gcc".into()),

// The esp32s3 only supports native 32bit atomics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {

options: TargetOptions {
vendor: "espressif".into(),
cpu: "esp32-s3".into(),
cpu: "esp32s3".into(),
linker: Some("xtensa-esp32s3-elf-gcc".into()),
max_atomic_width: Some(32),
atomic_cas: true,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! In order to make an intrinsic usable at compile-time, it needs to be declared in the "new"
//! style, i.e. as a `#[rustc_intrinsic]` function, not inside an `extern` block. Then copy the
//! implementation from <https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics> to
//! implementation from <https://github.com/rust-lang/miri/blob/master/src/intrinsics> to
//! <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>
//! and make the intrinsic declaration a `const fn`.
//!
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3732,8 +3732,7 @@ impl<T> [T] {
#[doc(alias = "memcpy")]
#[inline]
#[stable(feature = "copy_from_slice", since = "1.9.0")]
#[rustc_const_unstable(feature = "const_copy_from_slice", issue = "131415")]
#[rustc_const_stable_indirect]
#[rustc_const_stable(feature = "const_copy_from_slice", since = "CURRENT_RUSTC_VERSION")]
#[track_caller]
pub const fn copy_from_slice(&mut self, src: &[T])
where
Expand Down
13 changes: 7 additions & 6 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ fn main() {
}

// check_version warnings are not printed during setup, or during CI
let changelog_suggestion = if matches!(config.cmd, Subcommand::Setup { .. }) || CiEnv::is_ci() {
None
} else {
check_version(&config)
};
let changelog_suggestion =
if matches!(config.cmd, Subcommand::Setup { .. }) || CiEnv::is_ci() || config.dry_run() {
None
} else {
check_version(&config)
};

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

if io::stdout().is_terminal() && !config.dry_run() {
if io::stdout().is_terminal() {
t!(fs::write(warned_id_path, latest_change_id.to_string()));
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn format_rusage_data(child: Child) -> Option<String> {
let mut kernel_filetime = Default::default();
let mut kernel_time = Default::default();
let mut memory_counters = PROCESS_MEMORY_COUNTERS::default();
let memory_counters_size = std::mem::size_of_val(&memory_counters);
let memory_counters_size = size_of_val(&memory_counters);

unsafe {
GetProcessTimes(
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/utils/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub unsafe fn setup(build: &mut crate::Build) {
#[cfg(windows)]
mod for_windows {
use std::ffi::c_void;
use std::{io, mem};
use std::io;

use windows::Win32::Foundation::CloseHandle;
use windows::Win32::System::Diagnostics::Debug::{
Expand Down Expand Up @@ -82,7 +82,7 @@ mod for_windows {
job,
JobObjectExtendedLimitInformation,
&info as *const _ as *const c_void,
mem::size_of_val(&info) as u32,
size_of_val(&info) as u32,
);
assert!(r.is_ok(), "{}", io::Error::last_os_error());

Expand Down
2 changes: 1 addition & 1 deletion src/build_helper/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn get_closest_merge_commit(
git.current_dir(git_dir);
}

let channel = include_str!("../../ci/channel");
let channel = include_str!("../../ci/channel").trim();

let merge_base = {
if CiEnv::is_ci() &&
Expand Down
Loading

0 comments on commit 91a0e16

Please sign in to comment.