diff --git a/RELEASES.md b/RELEASES.md index 9e442be408bfc..5153573aeecb1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,148 @@ +Version 1.100.0 (2026-11-12) +========================== + + + +Language +-------- +- [Stabilize never type](https://github.com/rust-lang/rust/pull/155499) +- [Lint against repeated `#[repr(..)]` attributes](https://github.com/rust-lang/rust/pull/157036) +- [Stabilize `extern "custom"`](https://github.com/rust-lang/rust/pull/158504) +- [Extend `dropping_references`, `dropping_copy_types` and `undropped_manually_drops` lints to `drop_in_place`](https://github.com/rust-lang/rust/pull/160229) +- [`unfulfilled_lint_expectations` no longer fires on `#[expect(dead_code)]` inside code that is covered by a dead parent's diagnostic](https://github.com/rust-lang/rust/pull/161005) +- [Turn the error for `repr(align)` fields in a `repr(packed)` type into a deny-by-default lint `aligned_fields_in_packed`](https://github.com/rust-lang/rust/pull/162160) +- [volatile: allow accesses to non-AM memory to trap](https://github.com/rust-lang/rust/pull/160564/) + + + + +Compiler +-------- +- [Stabilize `-Cprofile-sample-use`](https://github.com/rust-lang/rust/pull/155942) +- [Enable next solver by default in orphanck](https://github.com/rust-lang/rust/pull/160668) + + + + +Platform Support +---------------- +- [`i686-pc-windows-gnu` is now a tier 2 without host tools target](https://github.com/rust-lang/rust/pull/161681) +- [Promote `wasm32-wasip3` to Tier 2](https://github.com/rust-lang/rust/pull/161940) +- [Add new Tier 3 target `powerpc64-sony-ps3`](https://github.com/rust-lang/rust/pull/162072) + + +Refer to Rust's [platform support page][platform-support-doc] +for more information on Rust's tiered platform support. + +[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html + + + +Libraries +--------- +- [Stabilize custom allocators](https://github.com/rust-lang/rust/pull/156882) +- [Map `ENOTSUP` to `ErrorKind::Unsupported`](https://github.com/rust-lang/rust/pull/158580) +- [Fix soundness issues in `std::sys::pal::sgx::waitqueue::unsafe_list`](https://github.com/rust-lang/rust/pull/161334) + + + + +Stabilized APIs +--------------- + +- [`impl PartialEq> for Vec`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#impl-PartialEq%3CCow%3C'_,+%5BU%5D%3E%3E-for-Vec%3CT,+A%3E) +- [`impl PartialEq> for &[T]`](https://doc.rust-lang.org/stable/std/primitive.slice.html#impl-PartialEq%3CCow%3C'_,+%5BU%5D%3E%3E-for-%26%5BT%5D) +- [`impl PartialEq> for &mut [T]`](https://doc.rust-lang.org/stable/std/primitive.slice.html#impl-PartialEq%3CCow%3C'_,+%5BU%5D%3E%3E-for-%26mut+%5BT%5D) +- [`std::alloc::Allocator`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html) +- [`std::alloc::Global`](https://doc.rust-lang.org/stable/std/alloc/struct.Global.html) +- [`std::alloc::System`](https://doc.rust-lang.org/stable/std/alloc/struct.System.html) +- [`impl Allocator for Global`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-Global) +- [`impl Allocator for System`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-System) +- [`impl Allocator for &A`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-%26A) +- [`impl Allocator for Box`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-Box%3CT,+A%3E) +- [`impl Allocator for &mut A`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-%26mut+A) +- [`impl Allocator for Arc`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-Arc%3CT,+A%3E) +- [`impl Allocator for Rc`](https://doc.rust-lang.org/stable/std/alloc/trait.Allocator.html#impl-Allocator-for-Rc%3CT,+A%3E) +- [`Box::new_in`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.new_in) +- [`Box::from_raw_in`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.from_raw_in) +- [`Box::from_non_null_in`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.from_non_null_in) +- [`Box::into_raw_with_allocator`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.into_raw_with_allocator) +- [`Box::into_non_null_with_allocator`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.into_non_null_with_allocator) +- [`Box::allocator`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.allocator) +- [`Vec::new_in`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.new_in) +- [`Vec::with_capacity_in`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.with_capacity_in) +- [`Vec::from_raw_parts_in`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.from_raw_parts_in) +- [`Vec::from_parts_in`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.from_parts_in) +- [`Vec::into_raw_parts_with_allocator`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.into_raw_parts_with_allocator) +- [`Vec::into_parts_with_allocator`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.into_parts_with_allocator) +- [`Vec::allocator`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.allocator) +- [`Child::main_thread_handle`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.ChildExt.html#tymethod.main_thread_handle) +- [`impl Default for std::sync::Once`](https://doc.rust-lang.org/stable/std/sync/struct.Once.html#impl-Default-for-Once) +- [`bool::toggle`](https://doc.rust-lang.org/stable/std/primitive.bool.html#method.toggle) +- [`Box::take`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.take) +- [`Box::map`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.map) +- [`Rc::map`](https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.map) +- [`Arc::map`](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.map) +- [`impl AsRef for !`](https://doc.rust-lang.org/stable/std/primitive.never.html#impl-AsRef-for-!) +- [`impl AsMut for !`](https://doc.rust-lang.org/stable/std/primitive.never.html#impl-AsMut-for-!) +- [`core::mem::DropGuard`](https://doc.rust-lang.org/stable/core/mem/struct.DropGuard.html) +- [`core::mem::conjure_zst`](https://doc.rust-lang.org/stable/core/mem/fn.conjure_zst.html) +- [`UnsafeCell::replace`](https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.replace) +- [`UnsafeCell::as_ref_unchecked`](https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.as_ref_unchecked) +- [`UnsafeCell::as_mut_unchecked`](https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.as_mut_unchecked) +- [`str::trim_prefix`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_prefix) +- [`str::trim_suffix`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.trim_suffix) +- [`[T]::trim_prefix`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.trim_prefix) +- [`[T]::trim_suffix`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.trim_suffix) +- [`Path::trim_prefix`](https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.trim_prefix) +- [`Vec::from_fn`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.from_fn) +- [`os::windows::process::CommandExt::show_window`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html#tymethod.show_window) + + + +Cargo +----- +- Introduced Cargo's own linting system: some Cargo warnings are now emitted as lints that users can control in the `[lints.cargo]` table. This includes a new built-in unused dependency check via the `cargo::unused_dependencies` lint. [docs](https://doc.rust-lang.org/stable/cargo/reference/lints.html) [#17298](https://github.com/rust-lang/cargo/pull/17298) +- Introduced minimum publish age configurations, also known as dependency cooldowns. When the relevant config is set, the resolver ignores versions published more recently than that, unless they are already in `Cargo.lock`. ([RFC 3923](https://rust-lang.github.io/rfcs/3923-cargo-min-publish-age.html)) [docs](https://doc.rust-lang.org/stable/cargo/reference/resolver.html#publish-age) [#17335](https://github.com/rust-lang/cargo/pull/17335) +- cargo-install: now uses the existing lockfile in the `.crate` tarball by default. `--locked` in cargo install becomes a no-op. [#17388](https://github.com/rust-lang/cargo/pull/17388) +- Cargo now uses a new directory layout for intermediate build artifacts. Tools that inspect the build directory may need to use [Cargo’s JSON messages](https://doc.rust-lang.org/stable/cargo/reference/external-tools.html#json-messages) to locate build artifacts instead of relying on the build directory layout. The layout is not a stable interface and is subject to change. ([build cache doc](https://doc.rust-lang.org/stable/cargo/reference/build-cache.html)) [#17354](https://github.com/rust-lang/cargo/pull/17354) + +Rustdoc +----- +- [Add new `invalid_markdown_table` rustdoc lint](https://github.com/rust-lang/rust/pull/159583) + + + +Compatibility Notes +------------------- +- [Closures now more precisely capture variables used in `if let`. This may cause new errors](https://github.com/rust-lang/rust/pull/154210) +- [Check dyn-compatibility of trait objects in more places](https://github.com/rust-lang/rust/pull/154992) +- [`Infallible` is now a type alias to `!`](https://github.com/rust-lang/rust/pull/155499) +- [The never type fallback was changed to `!` on all editions](https://github.com/rust-lang/rust/pull/155499) +- [`box` patterns are no longer syntactically allowed](https://github.com/rust-lang/rust/pull/156749) +- [Report Query Cycle errors in more cases when computing the layout of enums with explicit discriminants](https://github.com/rust-lang/rust/pull/157562) +- [Always escape grapheme extenders in `str::escape_debug`](https://github.com/rust-lang/rust/pull/158303) +- [Make let-else respect `macro_rules` `expr` metavariable grouping](https://github.com/rust-lang/rust/pull/158515) +- [`Iterator::{min,max}(_by_key)` changed which `Ord` methods they use.](https://github.com/rust-lang/rust/pull/160203) This cannot change behaviour (other than being potentially faster) for types correctly following the [`Ord` rules](https://doc.rust-lang.org/std/cmp/trait.Ord.html), but may impact types with inconsistent trait implementations. +- [Emit an error when trying to enable SSE/AVX on an x86 (32bit or 64bit) softfloat target](https://github.com/rust-lang/rust/pull/160302) +- [Require windowed (and exception) for Xtensa ABI](https://github.com/rust-lang/rust/pull/160643) +- [windows-gnullvm: always link libunwind statically](https://github.com/rust-lang/rust/pull/160712) +- [From version 1.94 up to 1.100 a number of ARMv7-A hardfloat targets required the `VFPv3-D32` FPU as a minimum, as they erroneously had the `d32` feature in their baseline list of features. Breakage introduced as a result of correcting this can be fixed by passing `-Ctarget-feature=+d32` to Rust.](https://github.com/rust-lang/rust/pull/160911) +- [Change "Rust" ABI on x86 to use SSE registers if they are always-available for the current target](https://github.com/rust-lang/rust/pull/161583) +- [Make the `ambiguous_glob_imported_traits` lint fire in slightly more cases](https://github.com/rust-lang/rust/pull/161805) +- [Make `+fix-cortex-a53-835769` a default feature for `aarch64-unknown-fuchsia`](https://github.com/rust-lang/rust/pull/161886) +- [Some impls on `Box` have been generalised to arbitrary allocators, which may cause new type inference errors](https://github.com/rust-lang/rust/pull/161946) +- [The standard library now uses Unicode version 18.0.0](https://doc.rust-lang.org/stable/std/primitive.char.html#associatedconstant.UNICODE_VERSION) +- [WASI SDK version was bumped from 33 to 34](https://github.com/rust-lang/rust/pull/163809) +- [On ARM targets, `-Ctarget-feature`/`-Ctarget-cpu` values that would alter the ABI are rejected as hard errors now.](https://github.com/rust-lang/rust/pull/161280) + + + +Other +----- + +- [Test harness now allows passing `--test-threads` and `--color` multiple times, with later arguments overriding earlier ones](https://github.com/rust-lang/rust/pull/161312) + Version 1.99.1 (2026-10-15) =========================== diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index cd52ab3098cb4..13c297c836002 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -23,7 +23,7 @@ use tracing::{debug, instrument}; use super::trait_goals::TraitGoalProvenVia; use super::{has_only_region_constraints, inspect}; use crate::delegate::SolverDelegate; -use crate::solve::assembly::structural_traits::AmbiguousOrRerunNonErased; +use crate::solve::assembly::structural_traits::NoUniqueSolutionOrRerunNonErased; use crate::solve::inspect::ProbeKind; use crate::solve::{ BuiltinImplSource, CandidateSource, CanonicalResponse, Certainty, EvalCtxt, Goal, GoalSource, @@ -157,10 +157,13 @@ where ecx.add_goals(GoalSource::ImplWhereBound, requirements)?; ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } - Err(AmbiguousOrRerunNonErased::Ambiguous) => { + Err(NoUniqueSolutionOrRerunNonErased::Ambiguous) => { ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS) } - Err(AmbiguousOrRerunNonErased::RerunNonErased(rerun)) => Err(rerun.into()), + Err(NoUniqueSolutionOrRerunNonErased::NoSolution(no_solution)) => { + Err(no_solution.into()) + } + Err(NoUniqueSolutionOrRerunNonErased::RerunNonErased(rerun)) => Err(rerun.into()), } }) } diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index a7e02f07661c6..52285f8e0eff0 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -889,7 +889,7 @@ pub(in crate::solve) fn predicates_for_object_candidate( param_env: I::ParamEnv, trait_ref: ty::TraitRef, object_bounds: I::BoundExistentialPredicates, -) -> Result>, AmbiguousOrRerunNonErased> +) -> Result>, NoUniqueSolutionOrRerunNonErased> where D: SolverDelegate, I: Interner, @@ -935,7 +935,8 @@ where // show up in the bounds, but just ones that come from substituting // `Self` with the dyn type. let proj = proj.with_self_ty(cx, trait_ref.self_ty()); - replace_projection_with.entry(proj.def_id()).or_default().push(bound.rebind(proj)); + let bound = ecx.normalize(param_env, Unnormalized::new_wip(bound.rebind(proj)))?; + replace_projection_with.entry(proj.def_id()).or_default().push(bound); } } @@ -992,13 +993,14 @@ where /// Try to replace an alias with the term present in the projection bounds of the self type. /// Returns `Ok` if this alias is not eligible to be replaced, or bail with + /// `Err(NoSolution)` if the alias is ill-formed or cannot be normalized, or bail with /// `Err(Ambiguous)` if it's uncertain which projection bound to replace the term with due /// to multiple bounds applying, or with `Err(RerunNonErased)` if we have to rerun the /// goal in original `TypingMode`. fn try_eagerly_replace_alias( &mut self, alias_term: ty::AliasTerm, - ) -> Result, AmbiguousOrRerunNonErased> { + ) -> Result, NoUniqueSolutionOrRerunNonErased> { if alias_term.self_ty() != self.self_ty { return Ok(None); } @@ -1007,6 +1009,12 @@ where return Ok(None); }; + // We don't normalize this inside `predicates_for_object_candidates` but here + // because we structurally match the projection here with the bounds so we + // don't want the projection itself is replaced by infer var but only its + // args. + let alias_term = self.ecx.normalize(self.param_env, Unnormalized::new_wip(alias_term))?; + // This is quite similar to the `projection_may_match` we use in unsizing, // but here we want to unify a projection predicate against an alias term // so we can replace it with the projection predicate's term. @@ -1018,7 +1026,7 @@ where // If there's more than one projection that we can unify here, then we // need to stall until inference constrains things so that there's only // one choice. - return Err(AmbiguousOrRerunNonErased::Ambiguous); + return Err(NoUniqueSolutionOrRerunNonErased::Ambiguous); } matching_projection = Some(source_projection) } @@ -1040,15 +1048,29 @@ where } } -pub(crate) enum AmbiguousOrRerunNonErased { +pub(crate) enum NoUniqueSolutionOrRerunNonErased { /// Marker for bailing with ambiguity. Ambiguous, + NoSolution(NoSolution), RerunNonErased(RerunNonErased), } -impl From for AmbiguousOrRerunNonErased { +impl From for NoUniqueSolutionOrRerunNonErased { fn from(rerun: RerunNonErased) -> Self { - AmbiguousOrRerunNonErased::RerunNonErased(rerun) + NoUniqueSolutionOrRerunNonErased::RerunNonErased(rerun) + } +} + +impl From for NoUniqueSolutionOrRerunNonErased { + fn from(value: NoSolutionOrRerunNonErased) -> Self { + match value { + NoSolutionOrRerunNonErased::NoSolution(no_solution) => { + NoUniqueSolutionOrRerunNonErased::NoSolution(no_solution) + } + NoSolutionOrRerunNonErased::RerunNonErased(rerun) => { + NoUniqueSolutionOrRerunNonErased::RerunNonErased(rerun) + } + } } } @@ -1057,7 +1079,7 @@ where D: SolverDelegate, I: Interner, { - type Error = AmbiguousOrRerunNonErased; + type Error = NoUniqueSolutionOrRerunNonErased; fn cx(&self) -> I { self.ecx.cx() diff --git a/src/doc/rustc-dev-guide/src/appendix/reading-club.md b/src/doc/rustc-dev-guide/src/appendix/reading-club.md index ec71ad21018b2..e147698b29528 100644 --- a/src/doc/rustc-dev-guide/src/appendix/reading-club.md +++ b/src/doc/rustc-dev-guide/src/appendix/reading-club.md @@ -2,7 +2,7 @@ The dev-guide is large, dense, and often written by subject-matter-experts. Occasionally, maintainers and anyone else who's interested will read through existing chapters to try and understand them. -This appendex indexes those Zulip discussions. +This appendix indexes those Zulip discussions. - [February 26, 2024: Compiler architecture, queries, bootstrap, serialization, and rustdoc][2024-02-26] - [March 11, 2024: Bootstrap deep dive][2024-03-11] diff --git a/tests/crashes/155761-1.rs b/tests/crashes/155761-1.rs deleted file mode 100644 index ed871ebf71910..0000000000000 --- a/tests/crashes/155761-1.rs +++ /dev/null @@ -1,30 +0,0 @@ -//@ known-bug: #155761 -//@compile-flags: -Znext-solver - -// A regression test for https://github.com/rust-lang/rust/issues/151329. -// Ensures we do not trigger an ICE when normalization fails for a -// projection on a trait object, even if the projection has the same -// trait id as the object's bound. - -// ICE again after moving to eager normalization in the next solver. -// #155761 has a simplified variant which causes ICE without eager normalization. - -trait Foo { - type V; -} - -trait Callback: Fn(&T, &T::V) {} - -struct Bar { - callback: Box>, -} - -impl Bar> { - fn event(&self) { - (self.callback)(any(), any()); - } -} - -fn any() {} - -fn main() {} diff --git a/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.rs b/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.rs new file mode 100644 index 0000000000000..11548a55aa4d1 --- /dev/null +++ b/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.rs @@ -0,0 +1,20 @@ +//@ compile-flags: -Znext-solver + +// Regression test for + +trait Foo { + type V; +} + +trait Callback: Fn(T::V) {} +struct Bar { + callback: Box>, +} +impl Bar { + //~^ ERROR: missing generics + fn event(self) { + (self.callback)(loop {}) + } +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.stderr b/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.stderr new file mode 100644 index 0000000000000..314fc95b632be --- /dev/null +++ b/tests/ui/traits/next-solver/ill-formed-proj-bound-on-trait-obj-no-ice.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for struct `Bar` + --> $DIR/ill-formed-proj-bound-on-trait-obj-no-ice.rs:13:6 + | +LL | impl Bar { + | ^^^ expected 1 generic argument + | +note: struct defined here, with 1 generic parameter: `T` + --> $DIR/ill-formed-proj-bound-on-trait-obj-no-ice.rs:10:8 + | +LL | struct Bar { + | ^^^ - +help: add missing generic argument + | +LL | impl Bar { + | +++ +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr new file mode 100644 index 0000000000000..8d1e04ac22dd8 --- /dev/null +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.current.stderr @@ -0,0 +1,58 @@ +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 + | +LL | impl Bar> { + | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ +note: required by a bound in `Bar` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 + | +LL | struct Bar { + | ^^^ required by this bound in `Bar` + +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:23:14 + | +LL | fn event(&self) { + | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ +note: required by a bound in `Bar` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 + | +LL | struct Bar { + | ^^^ required by this bound in `Bar` + +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:26:9 + | +LL | (self.callback)(any(), any()); + | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:26:9 + | +LL | (self.callback)(any(), any()); + | ^^^^^^^^^^^^^^^-------------- + | | + | call expression requires function + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0618. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr new file mode 100644 index 0000000000000..a1de6b1eb549d --- /dev/null +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.next.stderr @@ -0,0 +1,58 @@ +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:20:14 + | +LL | impl Bar> { + | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ +note: required by a bound in `Bar` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 + | +LL | struct Bar { + | ^^^ required by this bound in `Bar` + +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:23:14 + | +LL | fn event(&self) { + | ^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ +note: required by a bound in `Bar` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:16:15 + | +LL | struct Bar { + | ^^^ required by this bound in `Bar` + +error[E0277]: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:26:9 + | +LL | (self.callback)(any(), any()); + | ^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback + 'static)` + | +help: this trait has no implementations, consider adding one + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:10:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0618]: expected function, found `Box<(dyn Callback<(dyn Callback + 'static), Output = ()> + 'static)>` + --> $DIR/object-projection-with-unsatisfied-bound-2.rs:26:9 + | +LL | (self.callback)(any(), any()); + | ^^^^^^^^^^^^^^^-------------- + | | + | call expression requires function + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0618. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs new file mode 100644 index 0000000000000..f0a3e218e5a01 --- /dev/null +++ b/tests/ui/traits/next-solver/object-projection-with-unsatisfied-bound-2.rs @@ -0,0 +1,35 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +// A regression test for https://github.com/rust-lang/rust/issues/151329. +// Ensures we do not trigger an ICE when normalization fails for a +// projection on a trait object, even if the projection has the same +// trait id as the object's bound. + +trait Foo { + type V; +} + +trait Callback: Fn(&T, &T::V) {} + +struct Bar { + callback: Box>, +} + +impl Bar> { + //[current]~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + //[next]~^^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + fn event(&self) { + //[current]~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + //[next]~^^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + (self.callback)(any(), any()); + //[current]~^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + //[next]~^^ ERROR: the trait bound `(dyn Callback + 'static): Foo` is not satisfied + //~| ERROR: expected function + } +} + +fn any() {} + +fn main() {}