Skip to content

Commit eb45c84

Browse files
committed
Auto merge of #122653 - matthiaskrgr:rollup-28h37ym, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #120640 (Mark UEFI std support as WIP) - #121862 (Add release notes for 1.77.0) - #122572 (add test for #122301 to cover behavior that's on stable) - #122578 (Only invoke `decorate` if the diag can eventually be emitted) - #122615 (Mention Zalathar for coverage changes) - #122636 (some minor code simplifications) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 35dfc67 + 1588d9b commit eb45c84

File tree

16 files changed

+297
-20
lines changed

16 files changed

+297
-20
lines changed

RELEASES.md

+117
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,120 @@
1+
Version 1.77.0 (2024-03-21)
2+
==========================
3+
4+
<a id="1.77.0-Language"></a>
5+
6+
Language
7+
--------
8+
9+
- [Reveal opaque types within the defining body for exhaustiveness checking.](https://github.com/rust-lang/rust/pull/116821/)
10+
- [Stabilize C-string literals.](https://github.com/rust-lang/rust/pull/117472/)
11+
- [Stabilize THIR unsafeck.](https://github.com/rust-lang/rust/pull/117673/)
12+
- [Add lint `static_mut_refs` to warn on references to mutable statics.](https://github.com/rust-lang/rust/pull/117556/)
13+
- [Support async recursive calls (as long as they have indirection).](https://github.com/rust-lang/rust/pull/117703/)
14+
- [Undeprecate lint `unstable_features` and make use of it in the compiler.](https://github.com/rust-lang/rust/pull/118639/)
15+
- [Make inductive cycles in coherence ambiguous always.](https://github.com/rust-lang/rust/pull/118649/)
16+
- [Get rid of type-driven traversal in const-eval interning](https://github.com/rust-lang/rust/pull/119044/),
17+
only as a [future compatiblity lint](https://github.com/rust-lang/rust/pull/122204) for now.
18+
- [Deny braced macro invocations in let-else.](https://github.com/rust-lang/rust/pull/119062/)
19+
20+
<a id="1.77.0-Compiler"></a>
21+
22+
Compiler
23+
--------
24+
25+
- [Include lint `soft_unstable` in future breakage reports.](https://github.com/rust-lang/rust/pull/116274/)
26+
- [Make `i128` and `u128` 16-byte aligned on x86-based targets.](https://github.com/rust-lang/rust/pull/116672/)
27+
- [Use `--verbose` in diagnostic output.](https://github.com/rust-lang/rust/pull/119129/)
28+
- [Improve spacing between printed tokens.](https://github.com/rust-lang/rust/pull/120227/)
29+
- [Merge the `unused_tuple_struct_fields` lint into `dead_code`.](https://github.com/rust-lang/rust/pull/118297/)
30+
- [Error on incorrect implied bounds in well-formedness check](https://github.com/rust-lang/rust/pull/118553/),
31+
with a temporary exception for Bevy.
32+
- [Fix coverage instrumentation/reports for non-ASCII source code.](https://github.com/rust-lang/rust/pull/119033/)
33+
- [Fix `fn`/`const` items implied bounds and well-formedness check.](https://github.com/rust-lang/rust/pull/120019/)
34+
- [Promote `riscv32{im|imafc}-unknown-none-elf` targets to tier 2.](https://github.com/rust-lang/rust/pull/118704/)
35+
- Add several new tier 3 targets:
36+
- [`aarch64-unknown-illumos`](https://github.com/rust-lang/rust/pull/112936/)
37+
- [`hexagon-unknown-none-elf`](https://github.com/rust-lang/rust/pull/117601/)
38+
- [`riscv32imafc-esp-espidf`](https://github.com/rust-lang/rust/pull/119738/)
39+
- [`riscv32im-risc0-zkvm-elf`](https://github.com/rust-lang/rust/pull/117958/)
40+
41+
Refer to Rust's [platform support page][platform-support-doc]
42+
for more information on Rust's tiered platform support.
43+
44+
<a id="1.77.0-Libraries"></a>
45+
46+
Libraries
47+
---------
48+
49+
- [Implement `From<&[T; N]>` for `Cow<[T]>`.](https://github.com/rust-lang/rust/pull/113489/)
50+
- [Remove special-case handling of `vec.split_off(0)`.](https://github.com/rust-lang/rust/pull/119917/)
51+
52+
<a id="1.77.0-Stabilized-APIs"></a>
53+
54+
Stabilized APIs
55+
---------------
56+
57+
- [`array::each_ref`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_ref)
58+
- [`array::each_mut`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_mut)
59+
- [`core::net`](https://doc.rust-lang.org/stable/core/net/index.html)
60+
- [`f32::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.round_ties_even)
61+
- [`f64::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.round_ties_even)
62+
- [`mem::offset_of!`](https://doc.rust-lang.org/stable/std/mem/macro.offset_of.html)
63+
- [`slice::first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk)
64+
- [`slice::first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk_mut)
65+
- [`slice::split_first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk)
66+
- [`slice::split_first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk_mut)
67+
- [`slice::last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk)
68+
- [`slice::last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk_mut)
69+
- [`slice::split_last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk)
70+
- [`slice::split_last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk_mut)
71+
- [`slice::chunk_by`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by)
72+
- [`slice::chunk_by_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by_mut)
73+
- [`Bound::map`](https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.map)
74+
- [`File::create_new`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.create_new)
75+
- [`Mutex::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.clear_poison)
76+
- [`RwLock::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html#method.clear_poison)
77+
78+
<a id="1.77.0-Cargo"></a>
79+
80+
Cargo
81+
-----
82+
83+
- [Extend the build directive syntax with `cargo::`.](https://github.com/rust-lang/cargo/pull/12201/)
84+
- [Stabilize metadata `id` format as `PackageIDSpec`.](https://github.com/rust-lang/cargo/pull/12914/)
85+
- [Pull out as `cargo-util-schemas` as a crate.](https://github.com/rust-lang/cargo/pull/13178/)
86+
- [Strip all debuginfo when debuginfo is not requested.](https://github.com/rust-lang/cargo/pull/13257/)
87+
- [Inherit jobserver from env for all kinds of runners.](https://github.com/rust-lang/cargo/pull/12776/)
88+
- [Deprecate rustc plugin support in cargo.](https://github.com/rust-lang/cargo/pull/13248/)
89+
90+
<a id="1.77.0-Rustdoc"></a>
91+
92+
Rustdoc
93+
-----
94+
95+
- [Allows links in markdown headings.](https://github.com/rust-lang/rust/pull/117662/)
96+
- [Search for tuples and unit by type with `()`.](https://github.com/rust-lang/rust/pull/118194/)
97+
- [Clean up the source sidebar's hide button.](https://github.com/rust-lang/rust/pull/119066/)
98+
- [Prevent JS injection from `localStorage`.](https://github.com/rust-lang/rust/pull/120250/)
99+
100+
<a id="1.77.0-Misc"></a>
101+
102+
Misc
103+
----
104+
105+
- [Recommend version-sorting for all sorting in style guide.](https://github.com/rust-lang/rust/pull/115046/)
106+
107+
<a id="1.77.0-Internal-Changes"></a>
108+
109+
Internal Changes
110+
----------------
111+
112+
These changes do not affect any public interfaces of Rust, but they represent
113+
significant improvements to the performance or internals of rustc and related
114+
tools.
115+
116+
- [Add more weirdness to `weird-exprs.rs`.](https://github.com/rust-lang/rust/pull/119028/)
117+
1118
Version 1.76.0 (2024-02-08)
2119
==========================
3120

compiler/rustc_hir_typeck/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
755755

756756
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = callee_expr.kind
757757
&& let Res::Local(_) = path.res
758-
&& let [segment] = &path.segments[..]
758+
&& let [segment] = &path.segments
759759
{
760760
for id in self.tcx.hir().items() {
761761
if let Some(node) = self.tcx.hir().get_if_local(id.owner_id.into())

compiler/rustc_middle/src/lint.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,22 @@ pub fn lint_level(
398398
}
399399
}
400400

401-
// Finally, run `decorate`.
402-
decorate(&mut err);
401+
// Finally, run `decorate`. `decorate` can call `trimmed_path_str` (directly or indirectly),
402+
// so we need to make sure when we do call `decorate` that the diagnostic is eventually
403+
// emitted or we'll get a `must_produce_diag` ICE.
404+
//
405+
// When is a diagnostic *eventually* emitted? Well, that is determined by 2 factors:
406+
// 1. If the corresponding `rustc_errors::Level` is beyond warning, i.e. `ForceWarning(_)`
407+
// or `Error`, then the diagnostic will be emitted regardless of CLI options.
408+
// 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by
409+
// `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic
410+
// will be emitted if `can_emit_warnings` is true.
411+
let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings();
412+
413+
if !skip {
414+
decorate(&mut err);
415+
}
416+
403417
explain_lint_level_source(lint, level, src, &mut err);
404418
err.emit()
405419
}

compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,8 @@ pub(super) fn extract_branch_mappings(
401401
}
402402
let (span, _) = unexpand_into_body_span_with_visible_macro(raw_span, body_span)?;
403403

404-
let bcb_from_marker = |marker: BlockMarkerId| {
405-
Some(basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)?)
406-
};
404+
let bcb_from_marker =
405+
|marker: BlockMarkerId| basic_coverage_blocks.bcb_from_bb(block_markers[marker]?);
407406

408407
let true_bcb = bcb_from_marker(true_marker)?;
409408
let false_bcb = bcb_from_marker(false_marker)?;

compiler/rustc_session/src/config.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,12 @@ pub enum InstrumentCoverage {
144144
}
145145

146146
/// Individual flag values controlled by `-Z coverage-options`.
147-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
147+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)]
148148
pub struct CoverageOptions {
149149
/// Add branch coverage instrumentation.
150150
pub branch: bool,
151151
}
152152

153-
impl Default for CoverageOptions {
154-
fn default() -> Self {
155-
Self { branch: false }
156-
}
157-
}
158-
159153
/// Settings for `-Z instrument-xray` flag.
160154
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
161155
pub struct InstrumentXRay {

src/doc/rustc/src/platform-support.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ The `std` column in the table below has the following meanings:
118118

119119
* ✓ indicates the full standard library is available.
120120
* \* indicates the target only supports [`no_std`] development.
121+
* ? indicates the standard library support is unknown or a work-in-progress.
121122

122123
[`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html
123124

@@ -140,7 +141,7 @@ target | std | notes
140141
[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARM64 OpenHarmony
141142
`aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat
142143
`aarch64-unknown-none` | * | Bare ARM64, hardfloat
143-
[`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | * | ARM64 UEFI
144+
[`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | ARM64 UEFI
144145
[`arm-linux-androideabi`](platform-support/android.md) | ✓ | ARMv6 Android
145146
`arm-unknown-linux-musleabi` | ✓ | ARMv6 Linux with musl 1.2.3
146147
`arm-unknown-linux-musleabihf` | ✓ | ARMv6 Linux with musl 1.2.3, hardfloat
@@ -162,7 +163,7 @@ target | std | notes
162163
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
163164
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
164165
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with musl 1.2.3 [^x86_32-floats-return-ABI]
165-
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | * | 32-bit UEFI
166+
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 32-bit UEFI
166167
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64D ABI)
167168
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64S ABI)
168169
[`nvptx64-nvidia-cuda`](platform-support/nvptx64-nvidia-cuda.md) | * | --emit=asm generates PTX code that [runs on NVIDIA GPUs]
@@ -199,7 +200,7 @@ target | std | notes
199200
[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | x86_64 OpenHarmony
200201
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat
201202
`x86_64-unknown-redox` | ✓ | Redox OS
202-
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | * | 64-bit UEFI
203+
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 64-bit UEFI
203204

204205
[^x86_32-floats-x87]: Floating-point support on `i586` targets is non-compliant: the `x87` registers and instructions used for these targets do not provide IEEE-754-compliant behavior, in particular when it comes to rounding and NaN payload bits. See [issue #114479][x86-32-float-issue].
205206
[wasi-rename]: https://github.com/rust-lang/compiler-team/issues/607

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ fn first_non_private<'tcx>(
15721572
path: &hir::Path<'tcx>,
15731573
) -> Option<Path> {
15741574
let target_def_id = path.res.opt_def_id()?;
1575-
let (parent_def_id, ident) = match &path.segments[..] {
1575+
let (parent_def_id, ident) = match &path.segments {
15761576
[] => return None,
15771577
// Relative paths are available in the same scope as the owner.
15781578
[leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident),

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
598598
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
599599
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
600600
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
601-
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').filter(|c| !c.is_empty()).next().unwrap());
601+
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());
602602

603603
/// Render a sequence of macro arms in a format suitable for displaying to the user
604604
/// as part of an item declaration.

src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ impl RenderType {
150150
string.push('{');
151151
write_optional_id(self.id, string);
152152
string.push('{');
153-
for generic in &self.generics.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
153+
for generic in &self.generics.as_deref().unwrap_or_default()[..] {
154154
generic.write_to_string(string);
155155
}
156156
string.push('}');
157157
if self.bindings.is_some() {
158158
string.push('{');
159-
for binding in &self.bindings.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
159+
for binding in &self.bindings.as_deref().unwrap_or_default()[..] {
160160
string.push('{');
161161
binding.0.write_to_string(string);
162162
string.push('{');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//@ build-pass
2+
3+
// issue 122301 - currently the only way to supress
4+
// const eval and codegen of code conditional on some other const
5+
6+
struct Foo<T, const N: usize>(T);
7+
8+
impl<T, const N: usize> Foo<T, N> {
9+
const BAR: () = if N == 0 {
10+
panic!()
11+
};
12+
}
13+
14+
struct Invoke<T, const N: usize>(T);
15+
16+
impl<T, const N: usize> Invoke<T, N> {
17+
const FUN: fn() = if N != 0 {
18+
|| Foo::<T, N>::BAR
19+
} else {
20+
|| {}
21+
};
22+
}
23+
24+
// without closures
25+
26+
struct S<T>(T);
27+
impl<T> S<T> {
28+
const C: () = panic!();
29+
}
30+
31+
const fn bar<T>() { S::<T>::C }
32+
33+
struct ConstIf<T, const N: usize>(T);
34+
35+
impl<T, const N: usize> ConstIf<T, N> {
36+
const VAL: () = if N != 0 {
37+
bar::<T>() // not called for N == 0, and hence not monomorphized
38+
} else {
39+
()
40+
};
41+
}
42+
43+
fn main() {
44+
let _val = Invoke::<(), 0>::FUN();
45+
let _val = ConstIf::<(), 0>::VAL;
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Checks that the following does not ICE because `decorate` is incorrectly skipped.
2+
3+
//@ compile-flags: -Dunused_must_use -Awarnings --crate-type=lib
4+
5+
#[must_use]
6+
fn f() {}
7+
8+
pub fn g() {
9+
f();
10+
//~^ ERROR unused return value
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: unused return value of `f` that must be used
2+
--> $DIR/decorate-can-emit-warnings.rs:9:5
3+
|
4+
LL | f();
5+
| ^^^
6+
|
7+
= note: requested on the command line with `-D unused-must-use`
8+
help: use `let _ = ...` to ignore the resulting value
9+
|
10+
LL | let _ = f();
11+
| +++++++
12+
13+
error: aborting due to 1 previous error
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Checks that the following does not ICE.
2+
//
3+
// Previously, this test ICEs when the `unused_must_use` lint is suppressed via the combination of
4+
// `-A warnings` and `--cap-lints=warn`, because:
5+
//
6+
// - Its lint diagnostic struct `UnusedDef` implements `LintDiagnostic` manually and in the impl
7+
// `def_path_str` was called (which calls `trimmed_def_path`, which will produce a
8+
// `must_produce_diag` ICE if a trimmed def path is constructed but never emitted in a diagnostic
9+
// because it is expensive to compute).
10+
// - A `LintDiagnostic` has a `decorate_lint` method which decorates a `Diag` with lint-specific
11+
// information. This method is wrapped by a `decorate` closure in `TyCtxt` diagnostic emission
12+
// machinery, and the `decorate` closure called as late as possible.
13+
// - `decorate`'s invocation is delayed as late as possible until `lint_level` is called.
14+
// - If a lint's corresponding diagnostic is suppressed (to be effectively allow at the final
15+
// emission time) via `-A warnings` or `--cap-lints=allow` (or `-A warnings` + `--cap-lints=warn`
16+
// like in this test case), `decorate` is still called and a diagnostic is still constructed --
17+
// but the diagnostic is never eventually emitted, triggering the aforementioned
18+
// `must_produce_diag` ICE due to use of `trimmed_def_path`.
19+
//
20+
// Issue: <https://github.com/rust-lang/rust/issues/121774>.
21+
22+
//@ compile-flags: -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib
23+
//@ check-pass
24+
25+
#[must_use]
26+
fn f() {}
27+
28+
pub fn g() {
29+
f();
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Checks that the following does not ICE because `decorate` is incorrectly skipped due to
2+
// `--force-warn`.
3+
4+
//@ compile-flags: -Dunused_must_use -Awarnings --force-warn unused_must_use --crate-type=lib
5+
//@ check-pass
6+
7+
#[must_use]
8+
fn f() {}
9+
10+
pub fn g() {
11+
f();
12+
//~^ WARN unused return value
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: unused return value of `f` that must be used
2+
--> $DIR/decorate-force-warn.rs:11:5
3+
|
4+
LL | f();
5+
| ^^^
6+
|
7+
= note: requested on the command line with `--force-warn unused-must-use`
8+
help: use `let _ = ...` to ignore the resulting value
9+
|
10+
LL | let _ = f();
11+
| +++++++
12+
13+
warning: 1 warning emitted
14+

0 commit comments

Comments
 (0)