Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #120209

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5ec0a21
Introduce explanation about fields being used in ordering
The-Ludwig Dec 7, 2023
c0a9f72
Undeprecate and use lint `unstable_features`
fmease Dec 5, 2023
bfe04e0
Fix deallocation with wrong allocator in (A)Rc::from_box_in
zachs18 Jan 9, 2024
a8bb418
make unsafe_op_in_unsafe_fn MachineApplicable and add it to 2024 comp…
asquared31415 Jan 13, 2024
341f0a1
revert temporary patch #108288
onur-ozkan Jan 17, 2024
8a461aa
distribute actual stage of the compiled compiler
onur-ozkan Jan 18, 2024
7263a76
coverage: Don't instrument `#[automatically_derived]` functions
Zalathar Jan 21, 2024
1821bfa
chore: suggest wrapping in an `assert!()` instead
HTGAzureX1212 Jan 21, 2024
df3ec4c
aho-corasick 0.7.20 -> aho-corasick 1.0.2
michaelciraci Jan 20, 2024
1afd216
use u64 to represent file size
onur-ozkan Jan 21, 2024
0e3035b
Manually implement derived `NonZero` traits.
reitermarkus Jan 20, 2024
ff02662
Correct the anchor of an URL in an error message
noritada Jan 21, 2024
30b8b44
use /usr/bin/env bash instead of /bin/bash
rowan-sl Jan 21, 2024
4816db8
Rollup merge of #118639 - fmease:deny-features-in-stable-rustc-crates…
TaKO8Ki Jan 21, 2024
fe765d1
Rollup merge of #118714 - The-Ludwig:explain_ord_derive_enum_field, r…
TaKO8Ki Jan 21, 2024
80f76e8
Rollup merge of #119801 - zachs18:zachs18-patch-1, r=steffahn,Nilstrieb
TaKO8Ki Jan 21, 2024
ec6b57d
Rollup merge of #119948 - asquared31415:unsafe_op_in_unsafe_fn_fix, r…
TaKO8Ki Jan 21, 2024
8f55386
Rollup merge of #119999 - onur-ozkan:remote-test-tools, r=Mark-Simula…
TaKO8Ki Jan 21, 2024
26accc6
Rollup merge of #120058 - onur-ozkan:compiler-assemble, r=Mark-Simula…
TaKO8Ki Jan 21, 2024
240a47a
Rollup merge of #120160 - reitermarkus:nonzero-traits, r=dtolnay
TaKO8Ki Jan 21, 2024
be401a7
Rollup merge of #120177 - michaelciraci:merge-deps-2, r=Nilstrieb
TaKO8Ki Jan 21, 2024
96131e9
Rollup merge of #120185 - Zalathar:auto-derived, r=oli-obk
TaKO8Ki Jan 21, 2024
ea631e5
Rollup merge of #120194 - HTGAzureX1212:HTGAzureX1212shorten-option-m…
TaKO8Ki Jan 21, 2024
0fcda8c
Rollup merge of #120200 - noritada:fix/broken-error-message-link, r=d…
TaKO8Ki Jan 21, 2024
1024093
Rollup merge of #120203 - rowan-sl:usr-bin-env-bash, r=compiler-errors
TaKO8Ki Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ dependencies = [

[[package]]
name = "bstr"
version = "1.5.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
dependencies = [
"memchr",
"once_cell",
"regex-automata 0.1.10",
"regex-automata 0.4.3",
"serde",
]

Expand Down Expand Up @@ -1589,11 +1588,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"

[[package]]
name = "globset"
version = "0.4.10"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"
dependencies = [
"aho-corasick 0.7.20",
"aho-corasick 1.0.2",
"bstr",
"fnv",
"log",
Expand Down Expand Up @@ -2370,9 +2369,9 @@ dependencies = [

[[package]]
name = "memchr"
version = "2.5.0"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -3183,6 +3182,12 @@ dependencies = [
"memchr",
]

[[package]]
name = "regex-automata"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"

[[package]]
name = "regex-syntax"
version = "0.6.29"
Expand Down Expand Up @@ -5424,7 +5429,7 @@ name = "tidy"
version = "0.1.0"
dependencies = [
"cargo-platform",
"cargo_metadata 0.15.4",
"cargo_metadata 0.18.0",
"ignore",
"lazy_static",
"miropt-test-tools",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`

codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target

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)
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)

codegen_ssa_version_script_write_failure = failed to write version script: {$error}

Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
//! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
// We want to be able to build this crate with a stable compiler, so no
// `#![feature]` attributes should be added.
// We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added.
#![deny(unstable_features)]

mod cursor;
pub mod unescape;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ lint_builtin_unsafe_impl = implementation of an `unsafe` trait

lint_builtin_unsafe_trait = declaration of an `unsafe` trait

lint_builtin_unstable_features = unstable feature
lint_builtin_unstable_features = use of an unstable feature

lint_builtin_unused_doc_comment = unused doc comment
.label = rustdoc does not generate documentation for {$kind}
Expand Down
34 changes: 27 additions & 7 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,30 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes {
}

declare_lint! {
/// The `unstable_features` is deprecated and should no longer be used.
/// The `unstable_features` lint detects uses of `#![feature]`.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(unstable_features)]
/// #![feature(test)]
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// In larger nightly-based projects which
///
/// * consist of a multitude of crates where a subset of crates has to compile on
/// stable either unconditionally or depending on a `cfg` flag to for example
/// allow stable users to depend on them,
/// * don't use nightly for experimental features but for, e.g., unstable options only,
///
/// this lint may come in handy to enforce policies of these kinds.
UNSTABLE_FEATURES,
Allow,
"enabling unstable features (deprecated. do not use)"
"enabling unstable features"
}

declare_lint_pass!(
Expand All @@ -1246,11 +1266,11 @@ declare_lint_pass!(

impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &ast::Attribute) {
if attr.has_name(sym::feature) {
if let Some(items) = attr.meta_item_list() {
for item in items {
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
}
if attr.has_name(sym::feature)
&& let Some(items) = attr.meta_item_list()
{
for item in items {
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,11 @@ declare_lint! {
pub UNSAFE_OP_IN_UNSAFE_FN,
Allow,
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
reference: "issue #71668 <https://github.com/rust-lang/rust/issues/71668>",
explain_reason: false
};
@edition Edition2024 => Warn;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl AddToDiagnostic for UnsafeNotInheritedLintNote {
diag.tool_only_multipart_suggestion(
fluent::mir_build_wrap_suggestion,
vec![(body_start, "{ unsafe ".into()), (body_end, "}".into())],
Applicability::MaybeIncorrect,
Applicability::MachineApplicable,
);
}
}
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,18 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
return false;
}

// Don't instrument functions with `#[automatically_derived]` on their
// enclosing impl block, on the assumption that most users won't care about
// coverage for derived impls.
if let Some(impl_of) = tcx.impl_of_method(def_id.to_def_id())
&& tcx.is_automatically_derived(impl_of)
{
trace!("InstrumentCoverage skipped for {def_id:?} (automatically derived)");
return false;
}

if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::NO_COVERAGE) {
trace!("InstrumentCoverage skipped for {def_id:?} (`#[coverage(off)]`)");
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_parse_format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
// WARNING: We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added!
// We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added.
#![deny(unstable_features)]

use rustc_lexer::unescape;
pub use Alignment::*;
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {

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

Self::from_ptr_in(ptr, alloc)
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {

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

Self::from_ptr_in(ptr, alloc)
Expand Down
6 changes: 4 additions & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ impl<T: Clone> Clone for Reverse<T> {
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
/// based on the top-to-bottom declaration order of the struct's members.
///
/// When `derive`d on enums, variants are ordered by their discriminants.
/// When `derive`d on enums, variants are ordered primarily by their discriminants.
/// Secondarily, they are ordered by their fields.
/// By default, the discriminant is smallest for variants at the top, and
/// largest for variants at the bottom. Here's an example:
///
Expand Down Expand Up @@ -963,7 +964,8 @@ pub macro Ord($item:item) {
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering
/// based on the top-to-bottom declaration order of the struct's members.
///
/// When `derive`d on enums, variants are ordered by their discriminants.
/// When `derive`d on enums, variants are primarily ordered by their discriminants.
/// Secondarily, they are ordered by their fields.
/// By default, the discriminant is smallest for variants at the top, and
/// largest for variants at the bottom. Here's an example:
///
Expand Down
109 changes: 101 additions & 8 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Definitions of integer that is known not to equal zero.

use crate::cmp::Ordering;
use crate::fmt;
use crate::hash::{Hash, Hasher};
use crate::marker::StructuralPartialEq;
use crate::ops::{BitOr, BitOrAssign, Div, Neg, Rem};
use crate::str::FromStr;

Expand Down Expand Up @@ -31,13 +34,6 @@ pub trait ZeroablePrimitive: Sized + Copy + private::Sealed {
type NonZero;
}

#[unstable(
feature = "nonzero_internals",
reason = "implementation detail which may disappear or be replaced at any time",
issue = "none"
)]
pub(crate) type NonZero<T> = <T as ZeroablePrimitive>::NonZero;

macro_rules! impl_zeroable_primitive {
($NonZero:ident ( $primitive:ty )) => {
#[unstable(
Expand Down Expand Up @@ -71,6 +67,13 @@ impl_zeroable_primitive!(NonZeroI64(i64));
impl_zeroable_primitive!(NonZeroI128(i128));
impl_zeroable_primitive!(NonZeroIsize(isize));

#[unstable(
feature = "nonzero_internals",
reason = "implementation detail which may disappear or be replaced at any time",
issue = "none"
)]
pub(crate) type NonZero<T> = <T as ZeroablePrimitive>::NonZero;

macro_rules! impl_nonzero_fmt {
( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => {
$(
Expand Down Expand Up @@ -128,7 +131,7 @@ macro_rules! nonzero_integer {
///
/// [null pointer optimization]: crate::option#representation
#[$stability]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Copy, Eq)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
Expand Down Expand Up @@ -494,6 +497,96 @@ macro_rules! nonzero_integer {
}
}

#[$stability]
impl Clone for $Ty {
#[inline]
fn clone(&self) -> Self {
// SAFETY: The contained value is non-zero.
unsafe { Self(self.0) }
}
}

#[$stability]
impl PartialEq for $Ty {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}

#[inline]
fn ne(&self, other: &Self) -> bool {
self.0 != other.0
}
}

#[unstable(feature = "structural_match", issue = "31434")]
impl StructuralPartialEq for $Ty {}

#[$stability]
impl PartialOrd for $Ty {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
}

#[inline]
fn lt(&self, other: &Self) -> bool {
self.0 < other.0
}

#[inline]
fn le(&self, other: &Self) -> bool {
self.0 <= other.0
}

#[inline]
fn gt(&self, other: &Self) -> bool {
self.0 > other.0
}

#[inline]
fn ge(&self, other: &Self) -> bool {
self.0 >= other.0
}
}

#[$stability]
impl Ord for $Ty {
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}

#[inline]
fn max(self, other: Self) -> Self {
// SAFETY: The maximum of two non-zero values is still non-zero.
unsafe { Self(self.0.max(other.0)) }
}

#[inline]
fn min(self, other: Self) -> Self {
// SAFETY: The minimum of two non-zero values is still non-zero.
unsafe { Self(self.0.min(other.0)) }
}

#[inline]
fn clamp(self, min: Self, max: Self) -> Self {
// SAFETY: A non-zero value clamped between two non-zero values is still non-zero.
unsafe { Self(self.0.clamp(min.0, max.0)) }
}
}

#[$stability]
impl Hash for $Ty {
#[inline]
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
self.0.hash(state)
}
}

#[stable(feature = "from_nonzero", since = "1.31.0")]
impl From<$Ty> for $Int {
#[doc = concat!("Converts a `", stringify!($Ty), "` into an `", stringify!($Int), "`")]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl<T> Option<T> {
/// assert_eq!(x.is_none(), true);
/// ```
#[must_use = "if you intended to assert that this doesn't have a value, consider \
`.and_then(|_| panic!(\"`Option` had a value when expected `None`\"))` instead"]
wrapping this in an `assert!()` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_option_basics", since = "1.48.0")]
Expand Down
Loading
Loading