Skip to content

Commit

Permalink
Auto merge of #122653 - matthiaskrgr:rollup-28h37ym, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 17, 2024
2 parents 35dfc67 + 1588d9b commit eb45c84
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 20 deletions.
117 changes: 117 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,120 @@
Version 1.77.0 (2024-03-21)
==========================

<a id="1.77.0-Language"></a>

Language
--------

- [Reveal opaque types within the defining body for exhaustiveness checking.](https://github.com/rust-lang/rust/pull/116821/)
- [Stabilize C-string literals.](https://github.com/rust-lang/rust/pull/117472/)
- [Stabilize THIR unsafeck.](https://github.com/rust-lang/rust/pull/117673/)
- [Add lint `static_mut_refs` to warn on references to mutable statics.](https://github.com/rust-lang/rust/pull/117556/)
- [Support async recursive calls (as long as they have indirection).](https://github.com/rust-lang/rust/pull/117703/)
- [Undeprecate lint `unstable_features` and make use of it in the compiler.](https://github.com/rust-lang/rust/pull/118639/)
- [Make inductive cycles in coherence ambiguous always.](https://github.com/rust-lang/rust/pull/118649/)
- [Get rid of type-driven traversal in const-eval interning](https://github.com/rust-lang/rust/pull/119044/),
only as a [future compatiblity lint](https://github.com/rust-lang/rust/pull/122204) for now.
- [Deny braced macro invocations in let-else.](https://github.com/rust-lang/rust/pull/119062/)

<a id="1.77.0-Compiler"></a>

Compiler
--------

- [Include lint `soft_unstable` in future breakage reports.](https://github.com/rust-lang/rust/pull/116274/)
- [Make `i128` and `u128` 16-byte aligned on x86-based targets.](https://github.com/rust-lang/rust/pull/116672/)
- [Use `--verbose` in diagnostic output.](https://github.com/rust-lang/rust/pull/119129/)
- [Improve spacing between printed tokens.](https://github.com/rust-lang/rust/pull/120227/)
- [Merge the `unused_tuple_struct_fields` lint into `dead_code`.](https://github.com/rust-lang/rust/pull/118297/)
- [Error on incorrect implied bounds in well-formedness check](https://github.com/rust-lang/rust/pull/118553/),
with a temporary exception for Bevy.
- [Fix coverage instrumentation/reports for non-ASCII source code.](https://github.com/rust-lang/rust/pull/119033/)
- [Fix `fn`/`const` items implied bounds and well-formedness check.](https://github.com/rust-lang/rust/pull/120019/)
- [Promote `riscv32{im|imafc}-unknown-none-elf` targets to tier 2.](https://github.com/rust-lang/rust/pull/118704/)
- Add several new tier 3 targets:
- [`aarch64-unknown-illumos`](https://github.com/rust-lang/rust/pull/112936/)
- [`hexagon-unknown-none-elf`](https://github.com/rust-lang/rust/pull/117601/)
- [`riscv32imafc-esp-espidf`](https://github.com/rust-lang/rust/pull/119738/)
- [`riscv32im-risc0-zkvm-elf`](https://github.com/rust-lang/rust/pull/117958/)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

<a id="1.77.0-Libraries"></a>

Libraries
---------

- [Implement `From<&[T; N]>` for `Cow<[T]>`.](https://github.com/rust-lang/rust/pull/113489/)
- [Remove special-case handling of `vec.split_off(0)`.](https://github.com/rust-lang/rust/pull/119917/)

<a id="1.77.0-Stabilized-APIs"></a>

Stabilized APIs
---------------

- [`array::each_ref`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_ref)
- [`array::each_mut`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.each_mut)
- [`core::net`](https://doc.rust-lang.org/stable/core/net/index.html)
- [`f32::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f32.html#method.round_ties_even)
- [`f64::round_ties_even`](https://doc.rust-lang.org/stable/std/primitive.f64.html#method.round_ties_even)
- [`mem::offset_of!`](https://doc.rust-lang.org/stable/std/mem/macro.offset_of.html)
- [`slice::first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk)
- [`slice::first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.first_chunk_mut)
- [`slice::split_first_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk)
- [`slice::split_first_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_first_chunk_mut)
- [`slice::last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk)
- [`slice::last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.last_chunk_mut)
- [`slice::split_last_chunk`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk)
- [`slice::split_last_chunk_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_last_chunk_mut)
- [`slice::chunk_by`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by)
- [`slice::chunk_by_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.chunk_by_mut)
- [`Bound::map`](https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.map)
- [`File::create_new`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.create_new)
- [`Mutex::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.clear_poison)
- [`RwLock::clear_poison`](https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html#method.clear_poison)

<a id="1.77.0-Cargo"></a>

Cargo
-----

- [Extend the build directive syntax with `cargo::`.](https://github.com/rust-lang/cargo/pull/12201/)
- [Stabilize metadata `id` format as `PackageIDSpec`.](https://github.com/rust-lang/cargo/pull/12914/)
- [Pull out as `cargo-util-schemas` as a crate.](https://github.com/rust-lang/cargo/pull/13178/)
- [Strip all debuginfo when debuginfo is not requested.](https://github.com/rust-lang/cargo/pull/13257/)
- [Inherit jobserver from env for all kinds of runners.](https://github.com/rust-lang/cargo/pull/12776/)
- [Deprecate rustc plugin support in cargo.](https://github.com/rust-lang/cargo/pull/13248/)

<a id="1.77.0-Rustdoc"></a>

Rustdoc
-----

- [Allows links in markdown headings.](https://github.com/rust-lang/rust/pull/117662/)
- [Search for tuples and unit by type with `()`.](https://github.com/rust-lang/rust/pull/118194/)
- [Clean up the source sidebar's hide button.](https://github.com/rust-lang/rust/pull/119066/)
- [Prevent JS injection from `localStorage`.](https://github.com/rust-lang/rust/pull/120250/)

<a id="1.77.0-Misc"></a>

Misc
----

- [Recommend version-sorting for all sorting in style guide.](https://github.com/rust-lang/rust/pull/115046/)

<a id="1.77.0-Internal-Changes"></a>

Internal Changes
----------------

These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.

- [Add more weirdness to `weird-exprs.rs`.](https://github.com/rust-lang/rust/pull/119028/)

Version 1.76.0 (2024-02-08)
==========================

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = callee_expr.kind
&& let Res::Local(_) = path.res
&& let [segment] = &path.segments[..]
&& let [segment] = &path.segments
{
for id in self.tcx.hir().items() {
if let Some(node) = self.tcx.hir().get_if_local(id.owner_id.into())
Expand Down
18 changes: 16 additions & 2 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,22 @@ pub fn lint_level(
}
}

// Finally, run `decorate`.
decorate(&mut err);
// Finally, run `decorate`. `decorate` can call `trimmed_path_str` (directly or indirectly),
// so we need to make sure when we do call `decorate` that the diagnostic is eventually
// emitted or we'll get a `must_produce_diag` ICE.
//
// When is a diagnostic *eventually* emitted? Well, that is determined by 2 factors:
// 1. If the corresponding `rustc_errors::Level` is beyond warning, i.e. `ForceWarning(_)`
// or `Error`, then the diagnostic will be emitted regardless of CLI options.
// 2. If the corresponding `rustc_errors::Level` is warning, then that can be affected by
// `-A warnings` or `--cap-lints=xxx` on the command line. In which case, the diagnostic
// will be emitted if `can_emit_warnings` is true.
let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings();

if !skip {
decorate(&mut err);
}

explain_lint_level_source(lint, level, src, &mut err);
err.emit()
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,8 @@ pub(super) fn extract_branch_mappings(
}
let (span, _) = unexpand_into_body_span_with_visible_macro(raw_span, body_span)?;

let bcb_from_marker = |marker: BlockMarkerId| {
Some(basic_coverage_blocks.bcb_from_bb(block_markers[marker]?)?)
};
let bcb_from_marker =
|marker: BlockMarkerId| basic_coverage_blocks.bcb_from_bb(block_markers[marker]?);

let true_bcb = bcb_from_marker(true_marker)?;
let false_bcb = bcb_from_marker(false_marker)?;
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,12 @@ pub enum InstrumentCoverage {
}

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

impl Default for CoverageOptions {
fn default() -> Self {
Self { branch: false }
}
}

/// Settings for `-Z instrument-xray` flag.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct InstrumentXRay {
Expand Down
7 changes: 4 additions & 3 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The `std` column in the table below has the following meanings:

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

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

Expand All @@ -140,7 +141,7 @@ target | std | notes
[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | ARM64 OpenHarmony
`aarch64-unknown-none-softfloat` | * | Bare ARM64, softfloat
`aarch64-unknown-none` | * | Bare ARM64, hardfloat
[`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | * | ARM64 UEFI
[`aarch64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | ARM64 UEFI
[`arm-linux-androideabi`](platform-support/android.md) | ✓ | ARMv6 Android
`arm-unknown-linux-musleabi` | ✓ | ARMv6 Linux with musl 1.2.3
`arm-unknown-linux-musleabihf` | ✓ | ARMv6 Linux with musl 1.2.3, hardfloat
Expand All @@ -162,7 +163,7 @@ target | std | notes
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with musl 1.2.3 [^x86_32-floats-return-ABI]
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | * | 32-bit UEFI
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 32-bit UEFI
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64D ABI)
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64S ABI)
[`nvptx64-nvidia-cuda`](platform-support/nvptx64-nvidia-cuda.md) | * | --emit=asm generates PTX code that [runs on NVIDIA GPUs]
Expand Down Expand Up @@ -199,7 +200,7 @@ target | std | notes
[`x86_64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | x86_64 OpenHarmony
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat
`x86_64-unknown-redox` | ✓ | Redox OS
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | * | 64-bit UEFI
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 64-bit UEFI

[^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].
[wasi-rename]: https://github.com/rust-lang/compiler-team/issues/607
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ fn first_non_private<'tcx>(
path: &hir::Path<'tcx>,
) -> Option<Path> {
let target_def_id = path.res.opt_def_id()?;
let (parent_def_id, ident) = match &path.segments[..] {
let (parent_def_id, ident) = match &path.segments {
[] => return None,
// Relative paths are available in the same scope as the owner.
[leaf] => (cx.tcx.local_parent(hir_id.owner.def_id), leaf.ident),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ pub(crate) fn has_doc_flag(tcx: TyCtxt<'_>, did: DefId, flag: Symbol) -> bool {
/// Set by `bootstrap::Builder::doc_rust_lang_org_channel` in order to keep tests passing on beta/stable.
pub(crate) const DOC_RUST_LANG_ORG_CHANNEL: &str = env!("DOC_RUST_LANG_ORG_CHANNEL");
pub(crate) static DOC_CHANNEL: Lazy<&'static str> =
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').filter(|c| !c.is_empty()).next().unwrap());
Lazy::new(|| DOC_RUST_LANG_ORG_CHANNEL.rsplit('/').find(|c| !c.is_empty()).unwrap());

/// Render a sequence of macro arms in a format suitable for displaying to the user
/// as part of an item declaration.
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ impl RenderType {
string.push('{');
write_optional_id(self.id, string);
string.push('{');
for generic in &self.generics.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
for generic in &self.generics.as_deref().unwrap_or_default()[..] {
generic.write_to_string(string);
}
string.push('}');
if self.bindings.is_some() {
string.push('{');
for binding in &self.bindings.as_ref().map(Vec::as_slice).unwrap_or_default()[..] {
for binding in &self.bindings.as_deref().unwrap_or_default()[..] {
string.push('{');
binding.0.write_to_string(string);
string.push('{');
Expand Down
46 changes: 46 additions & 0 deletions tests/ui/consts/control-flow/dead_branches_dont_eval.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//@ build-pass

// issue 122301 - currently the only way to supress
// const eval and codegen of code conditional on some other const

struct Foo<T, const N: usize>(T);

impl<T, const N: usize> Foo<T, N> {
const BAR: () = if N == 0 {
panic!()
};
}

struct Invoke<T, const N: usize>(T);

impl<T, const N: usize> Invoke<T, N> {
const FUN: fn() = if N != 0 {
|| Foo::<T, N>::BAR
} else {
|| {}
};
}

// without closures

struct S<T>(T);
impl<T> S<T> {
const C: () = panic!();
}

const fn bar<T>() { S::<T>::C }

struct ConstIf<T, const N: usize>(T);

impl<T, const N: usize> ConstIf<T, N> {
const VAL: () = if N != 0 {
bar::<T>() // not called for N == 0, and hence not monomorphized
} else {
()
};
}

fn main() {
let _val = Invoke::<(), 0>::FUN();
let _val = ConstIf::<(), 0>::VAL;
}
11 changes: 11 additions & 0 deletions tests/ui/lint/decorate-ice/decorate-can-emit-warnings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Checks that the following does not ICE because `decorate` is incorrectly skipped.

//@ compile-flags: -Dunused_must_use -Awarnings --crate-type=lib

#[must_use]
fn f() {}

pub fn g() {
f();
//~^ ERROR unused return value
}
14 changes: 14 additions & 0 deletions tests/ui/lint/decorate-ice/decorate-can-emit-warnings.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: unused return value of `f` that must be used
--> $DIR/decorate-can-emit-warnings.rs:9:5
|
LL | f();
| ^^^
|
= note: requested on the command line with `-D unused-must-use`
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = f();
| +++++++

error: aborting due to 1 previous error

30 changes: 30 additions & 0 deletions tests/ui/lint/decorate-ice/decorate-def-path-str-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Checks that the following does not ICE.
//
// Previously, this test ICEs when the `unused_must_use` lint is suppressed via the combination of
// `-A warnings` and `--cap-lints=warn`, because:
//
// - Its lint diagnostic struct `UnusedDef` implements `LintDiagnostic` manually and in the impl
// `def_path_str` was called (which calls `trimmed_def_path`, which will produce a
// `must_produce_diag` ICE if a trimmed def path is constructed but never emitted in a diagnostic
// because it is expensive to compute).
// - A `LintDiagnostic` has a `decorate_lint` method which decorates a `Diag` with lint-specific
// information. This method is wrapped by a `decorate` closure in `TyCtxt` diagnostic emission
// machinery, and the `decorate` closure called as late as possible.
// - `decorate`'s invocation is delayed as late as possible until `lint_level` is called.
// - If a lint's corresponding diagnostic is suppressed (to be effectively allow at the final
// emission time) via `-A warnings` or `--cap-lints=allow` (or `-A warnings` + `--cap-lints=warn`
// like in this test case), `decorate` is still called and a diagnostic is still constructed --
// but the diagnostic is never eventually emitted, triggering the aforementioned
// `must_produce_diag` ICE due to use of `trimmed_def_path`.
//
// Issue: <https://github.com/rust-lang/rust/issues/121774>.

//@ compile-flags: -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib
//@ check-pass

#[must_use]
fn f() {}

pub fn g() {
f();
}
13 changes: 13 additions & 0 deletions tests/ui/lint/decorate-ice/decorate-force-warn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Checks that the following does not ICE because `decorate` is incorrectly skipped due to
// `--force-warn`.

//@ compile-flags: -Dunused_must_use -Awarnings --force-warn unused_must_use --crate-type=lib
//@ check-pass

#[must_use]
fn f() {}

pub fn g() {
f();
//~^ WARN unused return value
}
14 changes: 14 additions & 0 deletions tests/ui/lint/decorate-ice/decorate-force-warn.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
warning: unused return value of `f` that must be used
--> $DIR/decorate-force-warn.rs:11:5
|
LL | f();
| ^^^
|
= note: requested on the command line with `--force-warn unused-must-use`
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = f();
| +++++++

warning: 1 warning emitted

Loading

0 comments on commit eb45c84

Please sign in to comment.