Skip to content

Rollup of 4 pull requests #141717

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

Merged
merged 9 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 3 additions & 9 deletions compiler/rustc_error_codes/src/error_codes/E0658.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ An unstable feature was used.
Erroneous code example:

```compile_fail,E0658
#[repr(u128)] // error: use of unstable library feature 'repr128'
enum Foo {
Bar(u64),
}
use std::intrinsics; // error: use of unstable library feature `core_intrinsics`
```

If you're using a stable or a beta version of rustc, you won't be able to use
Expand All @@ -17,12 +14,9 @@ If you're using a nightly version of rustc, just add the corresponding feature
to be able to use it:

```
#![feature(repr128)]
#![feature(core_intrinsics)]
#[repr(u128)] // ok!
enum Foo {
Bar(u64),
}
use std::intrinsics; // ok!
```

[rustup]: https://rust-lang.github.io/rustup/concepts/channels.html
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ declare_features! (
(accepted, relaxed_adts, "1.19.0", Some(35626)),
/// Lessens the requirements for structs to implement `Unsize`.
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793)),
/// Allows the `#[repr(i128)]` attribute for enums.
(accepted, repr128, "CURRENT_RUSTC_VERSION", Some(56071)),
/// Allows `repr(align(16))` struct attribute (RFC 1358).
(accepted, repr_align, "1.25.0", Some(33626)),
/// Allows using `#[repr(align(X))]` on enums with equivalent semantics
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,6 @@ declare_features! (
(incomplete, ref_pat_eat_one_layer_2024_structural, "1.81.0", Some(123076)),
/// Allows using the `#[register_tool]` attribute.
(unstable, register_tool, "1.41.0", Some(66079)),
/// Allows the `#[repr(i128)]` attribute for enums.
(incomplete, repr128, "1.16.0", Some(56071)),
/// Allows `repr(simd)` and importing the various simd intrinsics.
(unstable, repr_simd, "1.4.0", Some(27731)),
/// Allows bounding the return type of AFIT/RPITIT.
Expand Down
15 changes: 1 addition & 14 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
use rustc_middle::middle::stability::EvalResult;
use rustc_middle::ty::error::TypeErrorToStringExt;
use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
use rustc_middle::ty::util::{Discr, IntTypeExt};
use rustc_middle::ty::util::Discr;
use rustc_middle::ty::{
AdtDef, BottomUpFolder, GenericArgKind, RegionKind, TypeFoldable, TypeSuperVisitable,
TypeVisitable, TypeVisitableExt, fold_regions,
Expand Down Expand Up @@ -1385,19 +1385,6 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
);
}

let repr_type_ty = def.repr().discr_type().to_ty(tcx);
if repr_type_ty == tcx.types.i128 || repr_type_ty == tcx.types.u128 {
if !tcx.features().repr128() {
feature_err(
&tcx.sess,
sym::repr128,
tcx.def_span(def_id),
"repr with 128-bit type is unstable",
)
.emit();
}
}

for v in def.variants() {
if let ty::VariantDiscr::Explicit(discr_def_id) = v.discr {
tcx.ensure_ok().typeck(discr_def_id.expect_local());
Expand Down
24 changes: 24 additions & 0 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,30 @@ impl CStr {
// instead of doing it afterwards.
str::from_utf8(self.to_bytes())
}

/// Returns an object that implements [`Display`] for safely printing a [`CStr`] that may
/// contain non-Unicode data.
///
/// Behaves as if `self` were first lossily converted to a `str`, with invalid UTF-8 presented
/// as the Unicode replacement character: �.
///
/// [`Display`]: fmt::Display
///
/// # Examples
///
/// ```
/// #![feature(cstr_display)]
///
/// let cstr = c"Hello, world!";
/// println!("{}", cstr.display());
/// ```
#[unstable(feature = "cstr_display", issue = "139984")]
#[must_use = "this does not display the `CStr`; \
it returns an object that can be displayed"]
#[inline]
pub fn display(&self) -> impl fmt::Display {
crate::bstr::ByteStr::from_bytes(self.to_bytes())
}
}

// `.to_bytes()` representations are compared instead of the inner `[c_char]`s,
Expand Down
6 changes: 6 additions & 0 deletions library/coretests/tests/ffi/cstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ fn debug() {
let s = c"abc\x01\x02\n\xE2\x80\xA6\xFF";
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
}

#[test]
fn display() {
let s = c"\xf0\x28\x8c\xbc";
assert_eq!(format!("{}", s.display()), "�(��");
}
1 change: 1 addition & 0 deletions library/coretests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![feature(core_io_borrowed_buf)]
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
#![feature(cstr_display)]
#![feature(dec2flt)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
Expand Down
249 changes: 114 additions & 135 deletions library/coretests/tests/num/mod.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ auto:

- name: aarch64-apple
env:
SCRIPT: ./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin
SCRIPT: >
./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin &&
./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin src/tools/cargo
RUST_CONFIGURE_ARGS: >-
--enable-sanitizers
--enable-profiler
Expand Down
18 changes: 0 additions & 18 deletions src/doc/unstable-book/src/language-features/repr128.md

This file was deleted.

3 changes: 1 addition & 2 deletions src/tools/clippy/tests/ui/auxiliary/proc_macro_attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(repr128, proc_macro_hygiene, proc_macro_quote, box_patterns)]
#![allow(incomplete_features)]
#![feature(proc_macro_hygiene, proc_macro_quote, box_patterns)]
#![allow(clippy::useless_conversion, clippy::uninlined_format_args)]

extern crate proc_macro;
Expand Down
3 changes: 1 addition & 2 deletions src/tools/clippy/tests/ui/auxiliary/proc_macro_derive.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(repr128, proc_macro_quote, proc_macro_span)]
#![allow(incomplete_features)]
#![feature(proc_macro_quote, proc_macro_span)]
#![allow(clippy::field_reassign_with_default)]
#![allow(clippy::eq_op)]
#![allow(clippy::literal_string_with_formatting_args)]
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/tests/ui/cast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@no-rustfix: only some diagnostics have suggestions

#![feature(repr128)]
#![allow(incomplete_features)]
#![warn(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
Expand Down
Loading
Loading