Skip to content

Commit 8ace346

Browse files
committed
Auto merge of #120209 - TaKO8Ki:rollup-sicsyig, r=TaKO8Ki
Rollup of 12 pull requests Successful merges: - #118639 (Undeprecate lint `unstable_features` and make use of it in the compiler) - #118714 ( Explanation that fields are being used when deriving `(Partial)Ord` on enums) - #119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in) - #119948 (Make `unsafe_op_in_unsafe_fn` migrated in edition 2024) - #119999 (remote-test: use u64 to represent file size) - #120058 (bootstrap: improvements for compiler builds) - #120160 (Manually implement derived `NonZero` traits.) - #120177 (Remove duplicate dependencies for rustc) - #120185 (coverage: Don't instrument `#[automatically_derived]` functions) - #120194 (Shorten `#[must_use]` Diagnostic Message for `Option::is_none`) - #120200 (Correct the anchor of an URL in an error message) - #120203 (Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ef71f10 + 1024093 commit 8ace346

40 files changed

+383
-226
lines changed

Cargo.lock

+15-10
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,12 @@ dependencies = [
310310

311311
[[package]]
312312
name = "bstr"
313-
version = "1.5.0"
313+
version = "1.9.0"
314314
source = "registry+https://github.com/rust-lang/crates.io-index"
315-
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
315+
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
316316
dependencies = [
317317
"memchr",
318-
"once_cell",
319-
"regex-automata 0.1.10",
318+
"regex-automata 0.4.3",
320319
"serde",
321320
]
322321

@@ -1589,11 +1588,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
15891588

15901589
[[package]]
15911590
name = "globset"
1592-
version = "0.4.10"
1591+
version = "0.4.13"
15931592
source = "registry+https://github.com/rust-lang/crates.io-index"
1594-
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
1593+
checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"
15951594
dependencies = [
1596-
"aho-corasick 0.7.20",
1595+
"aho-corasick 1.0.2",
15971596
"bstr",
15981597
"fnv",
15991598
"log",
@@ -2370,9 +2369,9 @@ dependencies = [
23702369

23712370
[[package]]
23722371
name = "memchr"
2373-
version = "2.5.0"
2372+
version = "2.7.1"
23742373
source = "registry+https://github.com/rust-lang/crates.io-index"
2375-
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
2374+
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
23762375
dependencies = [
23772376
"compiler_builtins",
23782377
"rustc-std-workspace-core",
@@ -3183,6 +3182,12 @@ dependencies = [
31833182
"memchr",
31843183
]
31853184

3185+
[[package]]
3186+
name = "regex-automata"
3187+
version = "0.4.3"
3188+
source = "registry+https://github.com/rust-lang/crates.io-index"
3189+
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
3190+
31863191
[[package]]
31873192
name = "regex-syntax"
31883193
version = "0.6.29"
@@ -5424,7 +5429,7 @@ name = "tidy"
54245429
version = "0.1.0"
54255430
dependencies = [
54265431
"cargo-platform",
5427-
"cargo_metadata 0.15.4",
5432+
"cargo_metadata 0.18.0",
54285433
"ignore",
54295434
"lazy_static",
54305435
"miropt-test-tools",

compiler/rustc_codegen_ssa/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`
325325
326326
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
327327
328-
codegen_ssa_use_cargo_directive = use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
328+
codegen_ssa_use_cargo_directive = use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
329329
330330
codegen_ssa_version_script_write_failure = failed to write version script: {$error}
331331

compiler/rustc_lexer/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
//! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html
2121
#![deny(rustc::untranslatable_diagnostic)]
2222
#![deny(rustc::diagnostic_outside_of_impl)]
23-
// We want to be able to build this crate with a stable compiler, so no
24-
// `#![feature]` attributes should be added.
23+
// We want to be able to build this crate with a stable compiler,
24+
// so no `#![feature]` attributes should be added.
25+
#![deny(unstable_features)]
2526

2627
mod cursor;
2728
pub mod unescape;

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ lint_builtin_unsafe_impl = implementation of an `unsafe` trait
148148
149149
lint_builtin_unsafe_trait = declaration of an `unsafe` trait
150150
151-
lint_builtin_unstable_features = unstable feature
151+
lint_builtin_unstable_features = use of an unstable feature
152152
153153
lint_builtin_unused_doc_comment = unused doc comment
154154
.label = rustdoc does not generate documentation for {$kind}

compiler/rustc_lint/src/builtin.rs

+27-7
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,30 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes {
12331233
}
12341234

12351235
declare_lint! {
1236-
/// The `unstable_features` is deprecated and should no longer be used.
1236+
/// The `unstable_features` lint detects uses of `#![feature]`.
1237+
///
1238+
/// ### Example
1239+
///
1240+
/// ```rust,compile_fail
1241+
/// #![deny(unstable_features)]
1242+
/// #![feature(test)]
1243+
/// ```
1244+
///
1245+
/// {{produces}}
1246+
///
1247+
/// ### Explanation
1248+
///
1249+
/// In larger nightly-based projects which
1250+
///
1251+
/// * consist of a multitude of crates where a subset of crates has to compile on
1252+
/// stable either unconditionally or depending on a `cfg` flag to for example
1253+
/// allow stable users to depend on them,
1254+
/// * don't use nightly for experimental features but for, e.g., unstable options only,
1255+
///
1256+
/// this lint may come in handy to enforce policies of these kinds.
12371257
UNSTABLE_FEATURES,
12381258
Allow,
1239-
"enabling unstable features (deprecated. do not use)"
1259+
"enabling unstable features"
12401260
}
12411261

12421262
declare_lint_pass!(
@@ -1246,11 +1266,11 @@ declare_lint_pass!(
12461266

12471267
impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
12481268
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &ast::Attribute) {
1249-
if attr.has_name(sym::feature) {
1250-
if let Some(items) = attr.meta_item_list() {
1251-
for item in items {
1252-
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
1253-
}
1269+
if attr.has_name(sym::feature)
1270+
&& let Some(items) = attr.meta_item_list()
1271+
{
1272+
for item in items {
1273+
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
12541274
}
12551275
}
12561276
}

compiler/rustc_lint_defs/src/builtin.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2755,6 +2755,11 @@ declare_lint! {
27552755
pub UNSAFE_OP_IN_UNSAFE_FN,
27562756
Allow,
27572757
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
2758+
@future_incompatible = FutureIncompatibleInfo {
2759+
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
2760+
reference: "issue #71668 <https://github.com/rust-lang/rust/issues/71668>",
2761+
explain_reason: false
2762+
};
27582763
@edition Edition2024 => Warn;
27592764
}
27602765

compiler/rustc_mir_build/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl AddToDiagnostic for UnsafeNotInheritedLintNote {
430430
diag.tool_only_multipart_suggestion(
431431
fluent::mir_build_wrap_suggestion,
432432
vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
433-
Applicability::MaybeIncorrect,
433+
Applicability::MachineApplicable,
434434
);
435435
}
436436
}

compiler/rustc_mir_transform/src/coverage/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,18 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
351351
return false;
352352
}
353353

354+
// Don't instrument functions with `#[automatically_derived]` on their
355+
// enclosing impl block, on the assumption that most users won't care about
356+
// coverage for derived impls.
357+
if let Some(impl_of) = tcx.impl_of_method(def_id.to_def_id())
358+
&& tcx.is_automatically_derived(impl_of)
359+
{
360+
trace!("InstrumentCoverage skipped for {def_id:?} (automatically derived)");
361+
return false;
362+
}
363+
354364
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NO_COVERAGE) {
365+
trace!("InstrumentCoverage skipped for {def_id:?} (`#[coverage(off)]`)");
355366
return false;
356367
}
357368

compiler/rustc_parse_format/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
)]
1212
#![deny(rustc::untranslatable_diagnostic)]
1313
#![deny(rustc::diagnostic_outside_of_impl)]
14-
// WARNING: We want to be able to build this crate with a stable compiler,
15-
// so no `#![feature]` attributes should be added!
14+
// We want to be able to build this crate with a stable compiler,
15+
// so no `#![feature]` attributes should be added.
16+
#![deny(unstable_features)]
1617

1718
use rustc_lexer::unescape;
1819
pub use Alignment::*;

library/alloc/src/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
19241924

19251925
// Free the allocation without dropping its contents
19261926
let (bptr, alloc) = Box::into_raw_with_allocator(src);
1927-
let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
1927+
let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
19281928
drop(src);
19291929

19301930
Self::from_ptr_in(ptr, alloc)

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
18691869

18701870
// Free the allocation without dropping its contents
18711871
let (bptr, alloc) = Box::into_raw_with_allocator(src);
1872-
let src = Box::from_raw(bptr as *mut mem::ManuallyDrop<T>);
1872+
let src = Box::from_raw_in(bptr as *mut mem::ManuallyDrop<T>, alloc.by_ref());
18731873
drop(src);
18741874

18751875
Self::from_ptr_in(ptr, alloc)

library/core/src/cmp.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ impl<T: Clone> Clone for Reverse<T> {
710710
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
711711
/// based on the top-to-bottom declaration order of the struct's members.
712712
///
713-
/// When `derive`d on enums, variants are ordered by their discriminants.
713+
/// When `derive`d on enums, variants are ordered primarily by their discriminants.
714+
/// Secondarily, they are ordered by their fields.
714715
/// By default, the discriminant is smallest for variants at the top, and
715716
/// largest for variants at the bottom. Here's an example:
716717
///
@@ -963,7 +964,8 @@ pub macro Ord($item:item) {
963964
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
964965
/// based on the top-to-bottom declaration order of the struct's members.
965966
///
966-
/// When `derive`d on enums, variants are ordered by their discriminants.
967+
/// When `derive`d on enums, variants are primarily ordered by their discriminants.
968+
/// Secondarily, they are ordered by their fields.
967969
/// By default, the discriminant is smallest for variants at the top, and
968970
/// largest for variants at the bottom. Here's an example:
969971
///

library/core/src/num/nonzero.rs

+101-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Definitions of integer that is known not to equal zero.
22
3+
use crate::cmp::Ordering;
34
use crate::fmt;
5+
use crate::hash::{Hash, Hasher};
6+
use crate::marker::StructuralPartialEq;
47
use crate::ops::{BitOr, BitOrAssign, Div, Neg, Rem};
58
use crate::str::FromStr;
69

@@ -31,13 +34,6 @@ pub trait ZeroablePrimitive: Sized + Copy + private::Sealed {
3134
type NonZero;
3235
}
3336

34-
#[unstable(
35-
feature = "nonzero_internals",
36-
reason = "implementation detail which may disappear or be replaced at any time",
37-
issue = "none"
38-
)]
39-
pub(crate) type NonZero<T> = <T as ZeroablePrimitive>::NonZero;
40-
4137
macro_rules! impl_zeroable_primitive {
4238
($NonZero:ident ( $primitive:ty )) => {
4339
#[unstable(
@@ -71,6 +67,13 @@ impl_zeroable_primitive!(NonZeroI64(i64));
7167
impl_zeroable_primitive!(NonZeroI128(i128));
7268
impl_zeroable_primitive!(NonZeroIsize(isize));
7369

70+
#[unstable(
71+
feature = "nonzero_internals",
72+
reason = "implementation detail which may disappear or be replaced at any time",
73+
issue = "none"
74+
)]
75+
pub(crate) type NonZero<T> = <T as ZeroablePrimitive>::NonZero;
76+
7477
macro_rules! impl_nonzero_fmt {
7578
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
7679
$(
@@ -128,7 +131,7 @@ macro_rules! nonzero_integer {
128131
///
129132
/// [null pointer optimization]: crate::option#representation
130133
#[$stability]
131-
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
134+
#[derive(Copy, Eq)]
132135
#[repr(transparent)]
133136
#[rustc_layout_scalar_valid_range_start(1)]
134137
#[rustc_nonnull_optimization_guaranteed]
@@ -494,6 +497,96 @@ macro_rules! nonzero_integer {
494497
}
495498
}
496499

500+
#[$stability]
501+
impl Clone for $Ty {
502+
#[inline]
503+
fn clone(&self) -> Self {
504+
// SAFETY: The contained value is non-zero.
505+
unsafe { Self(self.0) }
506+
}
507+
}
508+
509+
#[$stability]
510+
impl PartialEq for $Ty {
511+
#[inline]
512+
fn eq(&self, other: &Self) -> bool {
513+
self.0 == other.0
514+
}
515+
516+
#[inline]
517+
fn ne(&self, other: &Self) -> bool {
518+
self.0 != other.0
519+
}
520+
}
521+
522+
#[unstable(feature = "structural_match", issue = "31434")]
523+
impl StructuralPartialEq for $Ty {}
524+
525+
#[$stability]
526+
impl PartialOrd for $Ty {
527+
#[inline]
528+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
529+
self.0.partial_cmp(&other.0)
530+
}
531+
532+
#[inline]
533+
fn lt(&self, other: &Self) -> bool {
534+
self.0 < other.0
535+
}
536+
537+
#[inline]
538+
fn le(&self, other: &Self) -> bool {
539+
self.0 <= other.0
540+
}
541+
542+
#[inline]
543+
fn gt(&self, other: &Self) -> bool {
544+
self.0 > other.0
545+
}
546+
547+
#[inline]
548+
fn ge(&self, other: &Self) -> bool {
549+
self.0 >= other.0
550+
}
551+
}
552+
553+
#[$stability]
554+
impl Ord for $Ty {
555+
#[inline]
556+
fn cmp(&self, other: &Self) -> Ordering {
557+
self.0.cmp(&other.0)
558+
}
559+
560+
#[inline]
561+
fn max(self, other: Self) -> Self {
562+
// SAFETY: The maximum of two non-zero values is still non-zero.
563+
unsafe { Self(self.0.max(other.0)) }
564+
}
565+
566+
#[inline]
567+
fn min(self, other: Self) -> Self {
568+
// SAFETY: The minimum of two non-zero values is still non-zero.
569+
unsafe { Self(self.0.min(other.0)) }
570+
}
571+
572+
#[inline]
573+
fn clamp(self, min: Self, max: Self) -> Self {
574+
// SAFETY: A non-zero value clamped between two non-zero values is still non-zero.
575+
unsafe { Self(self.0.clamp(min.0, max.0)) }
576+
}
577+
}
578+
579+
#[$stability]
580+
impl Hash for $Ty {
581+
#[inline]
582+
fn hash<H>(&self, state: &mut H)
583+
where
584+
H: Hasher,
585+
{
586+
self.0.hash(state)
587+
}
588+
}
589+
497590
#[stable(feature = "from_nonzero", since = "1.31.0")]
498591
impl From<$Ty> for $Int {
499592
#[doc = concat!("Converts a `", stringify!($Ty), "` into an `", stringify!($Int), "`")]

library/core/src/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ impl<T> Option<T> {
642642
/// assert_eq!(x.is_none(), true);
643643
/// ```
644644
#[must_use = "if you intended to assert that this doesn't have a value, consider \
645-
`.and_then(|_| panic!(\"`Option` had a value when expected `None`\"))` instead"]
645+
wrapping this in an `assert!()` instead"]
646646
#[inline]
647647
#[stable(feature = "rust1", since = "1.0.0")]
648648
#[rustc_const_stable(feature = "const_option_basics", since = "1.48.0")]

0 commit comments

Comments
 (0)