Skip to content

Commit e919669

Browse files
committed
Auto merge of rust-lang#122331 - jhpratt:rollup-cbl8xsy, r=jhpratt
Rollup of 9 pull requests Successful merges: - rust-lang#121148 (Add slice::try_range) - rust-lang#121633 (Win10: Use `GetSystemTimePreciseAsFileTime` directly) - rust-lang#121840 (Expose the Freeze trait again (unstably) and forbid implementing it manually) - rust-lang#121907 (skip sanity check for non-host targets in `check` builds) - rust-lang#122002 (std::threads: revisit stack address calculation on netbsd.) - rust-lang#122108 (Add `target.*.runner` configuration for targets) - rust-lang#122298 (RawVec::into_box: avoid unnecessary intermediate reference) - rust-lang#122315 (Allow multiple `impl Into<{D,Subd}iagMessage>` parameters in a function.) - rust-lang#122326 (Optimize `process_heap_alloc`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6639672 + 5a3d6c9 commit e919669

File tree

40 files changed

+277
-81
lines changed

40 files changed

+277
-81
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
rustc_attrs,
99
transparent_unions,
1010
auto_traits,
11+
freeze_impls,
1112
thread_local
1213
)]
1314
#![no_core]

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(
22
no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
3-
decl_macro, rustc_attrs, transparent_unions, auto_traits,
3+
decl_macro, rustc_attrs, transparent_unions, auto_traits, freeze_impls,
44
thread_local
55
)]
66
#![no_core]

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ declare_features! (
471471
(unstable, fn_align, "1.53.0", Some(82232)),
472472
/// Support delegating implementation of functions to other already implemented functions.
473473
(incomplete, fn_delegation, "1.76.0", Some(118212)),
474+
/// Allows impls for the Freeze trait.
475+
(internal, freeze_impls, "CURRENT_RUSTC_VERSION", Some(121675)),
474476
/// Allows defining gen blocks and `gen fn`.
475477
(unstable, gen_blocks, "1.75.0", Some(117078)),
476478
/// Infer generic args for both consts and types.

compiler/rustc_hir_analysis/src/coherence/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_errors::{codes::*, struct_span_code_err};
1010
use rustc_hir::def_id::{DefId, LocalDefId};
1111
use rustc_middle::query::Providers;
1212
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
13+
use rustc_session::parse::feature_err;
1314
use rustc_span::{sym, ErrorGuaranteed};
1415
use rustc_trait_selection::traits;
1516

@@ -49,6 +50,19 @@ fn enforce_trait_manually_implementable(
4950
) -> Result<(), ErrorGuaranteed> {
5051
let impl_header_span = tcx.def_span(impl_def_id);
5152

53+
if tcx.lang_items().freeze_trait() == Some(trait_def_id) {
54+
if !tcx.features().freeze_impls {
55+
feature_err(
56+
&tcx.sess,
57+
sym::freeze_impls,
58+
impl_header_span,
59+
"explicit impls for the `Freeze` trait are not permitted",
60+
)
61+
.with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
62+
.emit();
63+
}
64+
}
65+
5266
// Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
5367
if trait_def.deny_explicit_impl {
5468
let trait_name = tcx.item_name(trait_def_id);

compiler/rustc_lint/src/internal.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,8 @@ impl LateLintPass<'_> for Diagnostics {
409409
}
410410
};
411411

412-
// Does the callee have a `impl Into<{D,Subd}iagMessage>` parameter? (There should be at
413-
// most one.)
414-
let mut impl_into_diagnostic_message_param = None;
412+
// Does the callee have one or more `impl Into<{D,Subd}iagMessage>` parameters?
413+
let mut impl_into_diagnostic_message_params = vec![];
415414
let fn_sig = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder();
416415
let predicates = cx.tcx.predicates_of(def_id).instantiate_identity(cx.tcx).predicates;
417416
for (i, &param_ty) in fn_sig.inputs().iter().enumerate() {
@@ -425,20 +424,14 @@ impl LateLintPass<'_> for Diagnostics {
425424
&& let ty1 = trait_ref.args.type_at(1)
426425
&& is_diag_message(ty1)
427426
{
428-
if impl_into_diagnostic_message_param.is_some() {
429-
cx.tcx.dcx().span_bug(
430-
span,
431-
"can't handle multiple `impl Into<{D,Sub}iagMessage>` params",
432-
);
433-
}
434-
impl_into_diagnostic_message_param = Some((i, p.name));
427+
impl_into_diagnostic_message_params.push((i, p.name));
435428
}
436429
}
437430
}
438431
}
439432

440433
// Is the callee interesting?
441-
if !has_attr && impl_into_diagnostic_message_param.is_none() {
434+
if !has_attr && impl_into_diagnostic_message_params.is_empty() {
442435
return;
443436
}
444437

@@ -481,7 +474,7 @@ impl LateLintPass<'_> for Diagnostics {
481474
// Calls to methods with an `impl Into<{D,Subd}iagMessage>` parameter must be passed an arg
482475
// with type `{D,Subd}iagMessage` or `impl Into<{D,Subd}iagMessage>`. Otherwise, emit an
483476
// `UNTRANSLATABLE_DIAGNOSTIC` lint.
484-
if let Some((param_i, param_i_p_name)) = impl_into_diagnostic_message_param {
477+
for (param_i, param_i_p_name) in impl_into_diagnostic_message_params {
485478
// Is the arg type `{Sub,D}iagMessage`or `impl Into<{Sub,D}iagMessage>`?
486479
let arg_ty = call_tys[param_i];
487480
let is_translatable = is_diag_message(arg_ty)

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ symbols! {
864864
format_placeholder,
865865
format_unsafe_arg,
866866
freeze,
867+
freeze_impls,
867868
freg,
868869
frem_algebraic,
869870
frem_fast,

config.example.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,17 @@
842842
# See that option for more info.
843843
#codegen-backends = rust.codegen-backends (array)
844844

845+
# This is a "runner" to pass to `compiletest` when executing tests. Tests will
846+
# execute this tool where the binary-to-test is passed as an argument. Can
847+
# be useful for situations such as when WebAssembly is being tested and a
848+
# runtime needs to be configured. This value is similar to
849+
# Cargo's `CARGO_$target_RUNNER` configuration.
850+
#
851+
# This configuration is a space-separated list of arguments so `foo bar` would
852+
# execute the program `foo` with the first argument as `bar` and the second
853+
# argument as the test binary.
854+
#runner = <none> (string)
855+
845856
# =============================================================================
846857
# Distribution options
847858
#

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use core::cmp;
55
use core::hint;
66
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
77
use core::ptr::{self, NonNull, Unique};
8-
use core::slice;
98

109
#[cfg(not(no_global_oom_handling))]
1110
use crate::alloc::handle_alloc_error;
@@ -192,7 +191,7 @@ impl<T, A: Allocator> RawVec<T, A> {
192191

193192
let me = ManuallyDrop::new(self);
194193
unsafe {
195-
let slice = slice::from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
194+
let slice = ptr::slice_from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
196195
Box::from_raw_in(slice, ptr::read(&me.alloc))
197196
}
198197
}

library/alloc/src/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ use crate::vec::Vec;
3333
#[cfg(test)]
3434
mod tests;
3535

36-
#[unstable(feature = "slice_range", issue = "76393")]
37-
pub use core::slice::range;
3836
#[unstable(feature = "array_chunks", issue = "74985")]
3937
pub use core::slice::ArrayChunks;
4038
#[unstable(feature = "array_chunks", issue = "74985")]
@@ -51,6 +49,8 @@ pub use core::slice::{from_mut, from_ref};
5149
pub use core::slice::{from_mut_ptr_range, from_ptr_range};
5250
#[stable(feature = "rust1", since = "1.0.0")]
5351
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
52+
#[unstable(feature = "slice_range", issue = "76393")]
53+
pub use core::slice::{range, try_range};
5454
#[stable(feature = "slice_group_by", since = "1.77.0")]
5555
pub use core::slice::{ChunkBy, ChunkByMut};
5656
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
// tidy-alphabetical-start
205205
#![cfg_attr(bootstrap, feature(diagnostic_namespace))]
206206
#![cfg_attr(bootstrap, feature(platform_intrinsics))]
207+
#![cfg_attr(not(bootstrap), feature(freeze_impls))]
207208
#![feature(abi_unadjusted)]
208209
#![feature(adt_const_params)]
209210
#![feature(allow_internal_unsafe)]

0 commit comments

Comments
 (0)