Skip to content

Commit 5e52943

Browse files
authored
Merge branch 'master' into search-core
2 parents 0b8ae16 + d2fb97f commit 5e52943

File tree

198 files changed

+3406
-1498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+3406
-1498
lines changed

Cargo.lock

Lines changed: 129 additions & 129 deletions
Large diffs are not rendered by default.

RELEASES.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,131 @@
1+
Version 1.79.0 (2024-06-13)
2+
==========================
3+
4+
<a id="1.79.0-Language"></a>
5+
6+
Language
7+
--------
8+
- [Stabilize inline `const {}` expressions.](https://github.com/rust-lang/rust/pull/104087/)
9+
- [Prevent opaque types being instantiated twice with different regions within the same function.](https://github.com/rust-lang/rust/pull/116935/)
10+
- [Stabilize WebAssembly target features that are in phase 4 and 5.](https://github.com/rust-lang/rust/pull/117457/)
11+
- [Add the `redundant_lifetimes` lint to detect lifetimes which are semantically redundant.](https://github.com/rust-lang/rust/pull/118391/)
12+
- [Stabilize the `unnameable_types` lint for public types that can't be named.](https://github.com/rust-lang/rust/pull/120144/)
13+
- [Enable debuginfo in macros, and stabilize `-C collapse-macro-debuginfo` and `#[collapse_debuginfo]`.](https://github.com/rust-lang/rust/pull/120845/)
14+
- [Propagate temporary lifetime extension into `if` and `match` expressions.](https://github.com/rust-lang/rust/pull/121346/)
15+
- [Restrict promotion of `const fn` calls.](https://github.com/rust-lang/rust/pull/121557/)
16+
- [Warn against refining impls of crate-private traits with `refining_impl_trait` lint.](https://github.com/rust-lang/rust/pull/121720/)
17+
- [Stabilize associated type bounds (RFC 2289).](https://github.com/rust-lang/rust/pull/122055/)
18+
- [Stabilize importing `main` from other modules or crates.](https://github.com/rust-lang/rust/pull/122060/)
19+
- [Check return types of function types for well-formedness](https://github.com/rust-lang/rust/pull/115538)
20+
- [Rework `impl Trait` lifetime inference](https://github.com/rust-lang/rust/pull/116891/)
21+
- [Change inductive trait solver cycles to be ambiguous](https://github.com/rust-lang/rust/pull/122791)
22+
23+
<a id="1.79.0-Compiler"></a>
24+
25+
Compiler
26+
--------
27+
- [Define `-C strip` to only affect binaries, not artifacts like `.pdb`.](https://github.com/rust-lang/rust/pull/115120/)
28+
- [Stabilize `-Crelro-level` for controlling runtime link hardening.](https://github.com/rust-lang/rust/pull/121694/)
29+
- [Stabilize checking of `cfg` names and values at compile-time with `--check-cfg`.](https://github.com/rust-lang/rust/pull/123501/)
30+
*Note that this only stabilizes the compiler part, the Cargo part is still unstable in this release.*
31+
- [Add `aarch64-apple-visionos` and `aarch64-apple-visionos-sim` tier 3 targets.](https://github.com/rust-lang/rust/pull/121419/)
32+
- [Add `riscv32ima-unknown-none-elf` tier 3 target.](https://github.com/rust-lang/rust/pull/122696/)
33+
- [Promote several Windows targets to tier 2](https://github.com/rust-lang/rust/pull/121712): `aarch64-pc-windows-gnullvm`, `i686-pc-windows-gnullvm`, and `x86_64-pc-windows-gnullvm`.
34+
35+
Refer to Rust's [platform support page][platform-support-doc]
36+
for more information on Rust's tiered platform support.
37+
38+
<a id="1.79.0-Libraries"></a>
39+
40+
Libraries
41+
---------
42+
43+
- [Implement `FromIterator` for `(impl Default + Extend, impl Default + Extend)`.](https://github.com/rust-lang/rust/pull/107462/)
44+
- [Implement `{Div,Rem}Assign<NonZero<X>>` on `X`.](https://github.com/rust-lang/rust/pull/121952/)
45+
- [Document overrides of `clone_from()` in core/std.](https://github.com/rust-lang/rust/pull/122201/)
46+
- [Link MSVC default lib in core.](https://github.com/rust-lang/rust/pull/122268/)
47+
- [Caution against using `transmute` between pointers and integers.](https://github.com/rust-lang/rust/pull/122379/)
48+
- [Enable frame pointers for the standard library.](https://github.com/rust-lang/rust/pull/122646/)
49+
50+
<a id="1.79.0-Stabilized-APIs"></a>
51+
52+
Stabilized APIs
53+
---------------
54+
55+
- [`{integer}::unchecked_add`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_add)
56+
- [`{integer}::unchecked_mul`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_mul)
57+
- [`{integer}::unchecked_sub`](https://doc.rust-lang.org/stable/core/primitive.i32.html#method.unchecked_sub)
58+
- [`<[T]>::split_at_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_unchecked)
59+
- [`<[T]>::split_at_mut_unchecked`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.split_at_mut_unchecked)
60+
- [`<[u8]>::utf8_chunks`](https://doc.rust-lang.org/stable/core/primitive.slice.html#method.utf8_chunks)
61+
- [`str::Utf8Chunks`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunks.html)
62+
- [`str::Utf8Chunk`](https://doc.rust-lang.org/stable/core/str/struct.Utf8Chunk.html)
63+
- [`<*const T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned)
64+
- [`<*mut T>::is_aligned`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_aligned-1)
65+
- [`NonNull::is_aligned`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_aligned)
66+
- [`<*const [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len)
67+
- [`<*mut [T]>::len`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.len-1)
68+
- [`<*const [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty)
69+
- [`<*mut [T]>::is_empty`](https://doc.rust-lang.org/stable/core/primitive.pointer.html#method.is_empty-1)
70+
- [`NonNull::<[T]>::is_empty`](https://doc.rust-lang.org/stable/core/ptr/struct.NonNull.html#method.is_empty)
71+
- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
72+
- [`io::Error::downcast`](https://doc.rust-lang.org/stable/std/io/struct.Error.html#method.downcast)
73+
- [`num::NonZero<T>`](https://doc.rust-lang.org/stable/core/num/struct.NonZero.html)
74+
- [`path::absolute`](https://doc.rust-lang.org/stable/std/path/fn.absolute.html)
75+
- [`proc_macro::Literal::byte_character`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.byte_character)
76+
- [`proc_macro::Literal::c_string`](https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.c_string)
77+
78+
These APIs are now stable in const contexts:
79+
80+
- [`Atomic*::into_inner`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicUsize.html#method.into_inner)
81+
- [`io::Cursor::new`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.new)
82+
- [`io::Cursor::get_ref`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.get_ref)
83+
- [`io::Cursor::position`](https://doc.rust-lang.org/stable/std/io/struct.Cursor.html#method.position)
84+
- [`io::empty`](https://doc.rust-lang.org/stable/std/io/fn.empty.html)
85+
- [`io::repeat`](https://doc.rust-lang.org/stable/std/io/fn.repeat.html)
86+
- [`io::sink`](https://doc.rust-lang.org/stable/std/io/fn.sink.html)
87+
- [`panic::Location::caller`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.caller)
88+
- [`panic::Location::file`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.file)
89+
- [`panic::Location::line`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.line)
90+
- [`panic::Location::column`](https://doc.rust-lang.org/stable/std/panic/struct.Location.html#method.column)
91+
92+
<a id="1.79.0-Cargo"></a>
93+
94+
Cargo
95+
-----
96+
97+
- [Prevent dashes in `lib.name`, always normalizing to `_`.](https://github.com/rust-lang/cargo/pull/12783/)
98+
- [Stabilize MSRV-aware version requirement selection in `cargo add`.](https://github.com/rust-lang/cargo/pull/13608/)
99+
- [Switch to using `gitoxide` by default for listing files.](https://github.com/rust-lang/cargo/pull/13696/)
100+
- [Error on `[project]` in Edition 2024; `cargo fix --edition` will change it to `[package]`.](https://github.com/rust-lang/cargo/pull/13747/)
101+
102+
<a id="1.79.0-Rustdoc"></a>
103+
104+
Rustdoc
105+
-----
106+
107+
- [Always display stability version even if it's the same as the containing item.](https://github.com/rust-lang/rust/pull/118441/)
108+
- [Show a single search result for items with multiple paths.](https://github.com/rust-lang/rust/pull/119912/)
109+
- [Support typing `/` in docs to begin a search.](https://github.com/rust-lang/rust/pull/123355/)
110+
111+
<a id="1.79.0-Misc"></a>
112+
113+
Misc
114+
----
115+
116+
<a id="1.79.0-Compatibility-Notes"></a>
117+
118+
Compatibility Notes
119+
-------------------
120+
121+
- [Update the minimum external LLVM to 17.](https://github.com/rust-lang/rust/pull/122649/)
122+
- [`RustcEncodable` and `RustcDecodable` are soft-destabilized, to be removed
123+
from the prelude in next edition.](https://github.com/rust-lang/rust/pull/116016/)
124+
- [The `wasm_c_abi` future-incompatibility lint will warn about use of the
125+
non-spec-compliant C ABI.](https://github.com/rust-lang/rust/pull/117918/)
126+
Use `wasm-bindgen v0.2.88` to generate forward-compatible bindings.
127+
- [Check return types of function types for well-formedness](https://github.com/rust-lang/rust/pull/115538)
128+
1129
Version 1.78.0 (2024-05-02)
2130
==========================
3131

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,10 @@ fn codegen_stmt<'tcx>(
832832
let val = match null_op {
833833
NullOp::SizeOf => layout.size.bytes(),
834834
NullOp::AlignOf => layout.align.abi.bytes(),
835-
NullOp::OffsetOf(fields) => {
836-
layout.offset_of_subfield(fx, fields.iter()).bytes()
837-
}
835+
NullOp::OffsetOf(fields) => fx
836+
.tcx
837+
.offset_of_subfield(ParamEnv::reveal_all(), layout, fields.iter())
838+
.bytes(),
838839
NullOp::UbChecks => {
839840
let val = fx.tcx.sess.ub_checks();
840841
let val = CValue::by_val(

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,12 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11091109
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
11101110
let arg_tys = sig.inputs();
11111111

1112-
// Vectors must be immediates (non-power-of-2 #[repr(packed)] are not)
1113-
for (ty, arg) in arg_tys.iter().zip(args) {
1114-
if ty.is_simd() && !matches!(arg.val, OperandValue::Immediate(_)) {
1115-
return_error!(InvalidMonomorphization::SimdArgument { span, name, ty: *ty });
1112+
// Sanity-check: all vector arguments must be immediates.
1113+
if cfg!(debug_assertions) {
1114+
for (ty, arg) in arg_tys.iter().zip(args) {
1115+
if ty.is_simd() {
1116+
assert!(matches!(arg.val, OperandValue::Immediate(_)));
1117+
}
11161118
}
11171119
}
11181120

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
680680
bx.cx().const_usize(val)
681681
}
682682
mir::NullOp::OffsetOf(fields) => {
683-
let val = layout.offset_of_subfield(bx.cx(), fields.iter()).bytes();
683+
let val = bx
684+
.tcx()
685+
.offset_of_subfield(bx.param_env(), layout, fields.iter())
686+
.bytes();
684687
bx.cx().const_usize(val)
685688
}
686689
mir::NullOp::UbChecks => {

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
253253
Scalar::from_target_usize(val, self)
254254
}
255255
mir::NullOp::OffsetOf(fields) => {
256-
let val = layout.offset_of_subfield(self, fields.iter()).bytes();
256+
let val = self
257+
.tcx
258+
.offset_of_subfield(self.param_env, layout, fields.iter())
259+
.bytes();
257260
Scalar::from_target_usize(val, self)
258261
}
259262
mir::NullOp::UbChecks => Scalar::from_bool(self.tcx.sess.ub_checks()),

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ declare_features! (
559559
(unstable, offset_of_enum, "1.75.0", Some(120141)),
560560
/// Allows using multiple nested field accesses in offset_of!
561561
(unstable, offset_of_nested, "1.77.0", Some(120140)),
562+
/// Allows using fields with slice type in offset_of!
563+
(unstable, offset_of_slice, "CURRENT_RUSTC_VERSION", Some(126151)),
562564
/// Allows using `#[optimize(X)]`.
563565
(unstable, optimize_attribute, "1.34.0", Some(54882)),
564566
/// Allows postfix match `expr.match { ... }`

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,7 +3363,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33633363

33643364
let field_ty = self.field_ty(expr.span, field, args);
33653365

3366-
// FIXME: DSTs with static alignment should be allowed
3366+
// Enums are anyway always sized. But just to safeguard against future
3367+
// language extensions, let's double-check.
33673368
self.require_type_is_sized(field_ty, expr.span, ObligationCauseCode::Misc);
33683369

33693370
if field.vis.is_accessible_from(sub_def_scope, self.tcx) {
@@ -3391,8 +3392,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33913392
{
33923393
let field_ty = self.field_ty(expr.span, field, args);
33933394

3394-
// FIXME: DSTs with static alignment should be allowed
3395-
self.require_type_is_sized(field_ty, expr.span, ObligationCauseCode::Misc);
3395+
if self.tcx.features().offset_of_slice {
3396+
self.require_type_has_static_alignment(
3397+
field_ty,
3398+
expr.span,
3399+
ObligationCauseCode::Misc,
3400+
);
3401+
} else {
3402+
self.require_type_is_sized(
3403+
field_ty,
3404+
expr.span,
3405+
ObligationCauseCode::Misc,
3406+
);
3407+
}
33963408

33973409
if field.vis.is_accessible_from(def_scope, self.tcx) {
33983410
self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
@@ -3412,10 +3424,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34123424
if let Ok(index) = field.as_str().parse::<usize>()
34133425
&& field.name == sym::integer(index)
34143426
{
3415-
for ty in tys.iter().take(index + 1) {
3416-
self.require_type_is_sized(ty, expr.span, ObligationCauseCode::Misc);
3417-
}
34183427
if let Some(&field_ty) = tys.get(index) {
3428+
if self.tcx.features().offset_of_slice {
3429+
self.require_type_has_static_alignment(
3430+
field_ty,
3431+
expr.span,
3432+
ObligationCauseCode::Misc,
3433+
);
3434+
} else {
3435+
self.require_type_is_sized(
3436+
field_ty,
3437+
expr.span,
3438+
ObligationCauseCode::Misc,
3439+
);
3440+
}
3441+
34193442
field_indices.push((FIRST_VARIANT, index.into()));
34203443
current_container = field_ty;
34213444

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
386386
}
387387
}
388388

389+
pub fn require_type_has_static_alignment(
390+
&self,
391+
ty: Ty<'tcx>,
392+
span: Span,
393+
code: traits::ObligationCauseCode<'tcx>,
394+
) {
395+
if !ty.references_error() {
396+
let tail =
397+
self.tcx.struct_tail_with_normalize(ty, |ty| self.normalize(span, ty), || {});
398+
// Sized types have static alignment, and so do slices.
399+
if tail.is_trivially_sized(self.tcx) || matches!(tail.kind(), ty::Slice(..)) {
400+
// Nothing else is required here.
401+
} else {
402+
// We can't be sure, let's required full `Sized`.
403+
let lang_item = self.tcx.require_lang_item(LangItem::Sized, None);
404+
self.require_type_meets(ty, span, code, lang_item);
405+
}
406+
}
407+
}
408+
389409
pub fn register_bound(
390410
&self,
391411
ty: Ty<'tcx>,

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,3 +1351,37 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
13511351
}
13521352

13531353
impl<'tcx, C: FnAbiOfHelpers<'tcx>> FnAbiOf<'tcx> for C {}
1354+
1355+
impl<'tcx> TyCtxt<'tcx> {
1356+
pub fn offset_of_subfield<I>(
1357+
self,
1358+
param_env: ty::ParamEnv<'tcx>,
1359+
mut layout: TyAndLayout<'tcx>,
1360+
indices: I,
1361+
) -> Size
1362+
where
1363+
I: Iterator<Item = (VariantIdx, FieldIdx)>,
1364+
{
1365+
let cx = LayoutCx { tcx: self, param_env };
1366+
let mut offset = Size::ZERO;
1367+
1368+
for (variant, field) in indices {
1369+
layout = layout.for_variant(&cx, variant);
1370+
let index = field.index();
1371+
offset += layout.fields.offset(index);
1372+
layout = layout.field(&cx, index);
1373+
if !layout.is_sized() {
1374+
// If it is not sized, then the tail must still have at least a known static alignment.
1375+
let tail = self.struct_tail_erasing_lifetimes(layout.ty, param_env);
1376+
if !matches!(tail.kind(), ty::Slice(..)) {
1377+
bug!(
1378+
"offset of not-statically-aligned field (type {:?}) cannot be computed statically",
1379+
layout.ty
1380+
);
1381+
}
1382+
}
1383+
}
1384+
1385+
offset
1386+
}
1387+
}

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::bug;
1010
use rustc_middle::mir::interpret::{InterpResult, Scalar};
1111
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
1212
use rustc_middle::mir::*;
13-
use rustc_middle::ty::layout::LayoutOf;
13+
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
1414
use rustc_middle::ty::{self, Ty, TyCtxt};
1515
use rustc_mir_dataflow::value_analysis::{
1616
Map, PlaceIndex, State, TrackElem, ValueAnalysis, ValueAnalysisWrapper, ValueOrPlace,
@@ -285,9 +285,11 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
285285
let val = match null_op {
286286
NullOp::SizeOf if layout.is_sized() => layout.size.bytes(),
287287
NullOp::AlignOf if layout.is_sized() => layout.align.abi.bytes(),
288-
NullOp::OffsetOf(fields) => {
289-
layout.offset_of_subfield(&self.ecx, fields.iter()).bytes()
290-
}
288+
NullOp::OffsetOf(fields) => self
289+
.ecx
290+
.tcx
291+
.offset_of_subfield(self.ecx.param_env(), layout, fields.iter())
292+
.bytes(),
291293
_ => return ValueOrPlace::Value(FlatSet::Top),
292294
};
293295
FlatSet::Elem(Scalar::from_target_usize(val, &self.tcx))

0 commit comments

Comments
 (0)