diff --git a/RELEASES.md b/RELEASES.md index 20e317a4d236a..3f7814d184c66 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,120 @@ +Version 1.77.0 (2024-03-21) +========================== + + + +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/) + + + +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. + + + +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/) + + + +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) + + + +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/) + + + +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/) + + + +Misc +---- + +- [Recommend version-sorting for all sorting in style guide.](https://github.com/rust-lang/rust/pull/115046/) + + + +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) ========================== diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 25d3453137988..9a500fa712bf3 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -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()) diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index d8d6899f05704..8d9e0dfd86902 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -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() } diff --git a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs index 86097bdcd9537..3f6a4156044e8 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs @@ -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)?; diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index b7ee2c9802541..e56684808bb50 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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 { diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 2ebbf5e15e66b..96300497bd12c 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -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 @@ -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 @@ -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] @@ -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 diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index dfc026fe50bb4..855fb132fc877 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1572,7 +1572,7 @@ fn first_non_private<'tcx>( path: &hir::Path<'tcx>, ) -> Option { 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), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 0b20cca3bcab2..365d63d965744 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -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. diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 6c5040414bced..f1887684797a6 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -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('{'); diff --git a/tests/ui/consts/control-flow/dead_branches_dont_eval.rs b/tests/ui/consts/control-flow/dead_branches_dont_eval.rs new file mode 100644 index 0000000000000..374349732f9ef --- /dev/null +++ b/tests/ui/consts/control-flow/dead_branches_dont_eval.rs @@ -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); + +impl Foo { + const BAR: () = if N == 0 { + panic!() + }; +} + +struct Invoke(T); + +impl Invoke { + const FUN: fn() = if N != 0 { + || Foo::::BAR + } else { + || {} + }; +} + +// without closures + +struct S(T); +impl S { + const C: () = panic!(); +} + +const fn bar() { S::::C } + +struct ConstIf(T); + +impl ConstIf { + const VAL: () = if N != 0 { + bar::() // not called for N == 0, and hence not monomorphized + } else { + () + }; +} + +fn main() { + let _val = Invoke::<(), 0>::FUN(); + let _val = ConstIf::<(), 0>::VAL; +} diff --git a/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.rs b/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.rs new file mode 100644 index 0000000000000..5adb5f526dcc3 --- /dev/null +++ b/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.rs @@ -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 +} diff --git a/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.stderr b/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.stderr new file mode 100644 index 0000000000000..fde81de6136ed --- /dev/null +++ b/tests/ui/lint/decorate-ice/decorate-can-emit-warnings.stderr @@ -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 + diff --git a/tests/ui/lint/decorate-ice/decorate-def-path-str-ice.rs b/tests/ui/lint/decorate-ice/decorate-def-path-str-ice.rs new file mode 100644 index 0000000000000..8116e36ed0d9a --- /dev/null +++ b/tests/ui/lint/decorate-ice/decorate-def-path-str-ice.rs @@ -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: . + +//@ compile-flags: -Dunused_must_use -Awarnings --cap-lints=warn --crate-type=lib +//@ check-pass + +#[must_use] +fn f() {} + +pub fn g() { + f(); +} diff --git a/tests/ui/lint/decorate-ice/decorate-force-warn.rs b/tests/ui/lint/decorate-ice/decorate-force-warn.rs new file mode 100644 index 0000000000000..e33210ed0cefa --- /dev/null +++ b/tests/ui/lint/decorate-ice/decorate-force-warn.rs @@ -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 +} diff --git a/tests/ui/lint/decorate-ice/decorate-force-warn.stderr b/tests/ui/lint/decorate-ice/decorate-force-warn.stderr new file mode 100644 index 0000000000000..5e6b74d414b27 --- /dev/null +++ b/tests/ui/lint/decorate-ice/decorate-force-warn.stderr @@ -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 + diff --git a/triagebot.toml b/triagebot.toml index 515600793da58..0a36eab7b8738 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -726,6 +726,30 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] [mentions."tests/ui/check-cfg"] cc = ["@Urgau"] +[mentions."compiler/rustc_middle/src/mir/coverage.rs"] +message = "Some changes occurred in coverage instrumentation." +cc = ["@Zalathar"] + +[mentions."compiler/rustc_mir_build/src/build/coverageinfo.rs"] +message = "Some changes occurred in coverage instrumentation." +cc = ["@Zalathar"] + +[mentions."compiler/rustc_mir_transform/src/coverage"] +message = "Some changes occurred in coverage instrumentation." +cc = ["@Zalathar"] + +[mentions."compiler/rustc_codegen_llvm/src/coverageinfo"] +message = "Some changes occurred in coverage instrumentation." +cc = ["@Zalathar"] + +[mentions."compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs"] +message = "Some changes occurred in coverage instrumentation." +cc = ["@Zalathar"] + +[mentions."tests/coverage"] +message = "Some changes occurred in coverage tests." +cc = ["@Zalathar"] + [assign] warn_non_default_branch = true contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"