mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #130654 - lcnr:stabilize-coherence-again, r=compiler-errors
stabilize `-Znext-solver=coherence` again r? `@compiler-errors` --- This PR stabilizes the use of the next generation trait solver in coherence checking by enabling `-Znext-solver=coherence` by default. More specifically its use in the *implicit negative overlap check*. The tracking issue for this is https://github.com/rust-lang/rust/issues/114862. Closes #114862. This is a direct copy of #121848 which has been reverted due to a hang in `nalgebra`: #130056. This hang should have been fixed by #130617 and #130821. See the added section in the stabilization report containing user facing changes merged since the original FCP. ## Background ### The next generation trait solver The new solver lives in [`rustc_trait_selection::solve`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/solve/mod.rs) and is intended to replace the existing *evaluate*, *fulfill*, and *project* implementation. It also has a wider impact on the rest of the type system, for example by changing our approach to handling associated types. For a more detailed explanation of the new trait solver, see the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/solve/trait-solving.html). This does not stabilize the current behavior of the new trait solver, only the behavior impacting the implicit negative overlap check. There are many areas in the new solver which are not yet finalized. We are confident that their final design will not conflict with the user-facing behavior observable via coherence. More on that further down. Please check out [the chapter](https://rustc-dev-guide.rust-lang.org/solve/significant-changes.html) summarizing the most significant changes between the existing and new implementations. ### Coherence and the implicit negative overlap check Coherence checking detects any overlapping impls. Overlapping trait impls always error while overlapping inherent impls result in an error if they have methods with the same name. Coherence also results in an error if any other impls could exist, even if they are currently unknown. This affects impls which may get added to upstream crates in a backwards compatible way and impls from downstream crates. Coherence failing to detect overlap is generally considered to be unsound, even if it is difficult to actually get runtime UB this way. It is quite easy to get ICEs due to bugs in coherence. It currently consists of two checks: The [orphan check] validates that impls do not overlap with other impls we do not know about: either because they may be defined in a sibling crate, or because an upstream crate is allowed to add it without being considered a breaking change. The [overlap check] validates that impls do not overlap with other impls we know about. This is done as follows: - Instantiate the generic parameters of both impls with inference variables - Equate the `TraitRef`s of both impls. If it fails there is no overlap. - [implicit negative]: Check whether any of the instantiated `where`-bounds of one of the impls definitely do not hold when using the constraints from the previous step. If a `where`-bound does not hold, there is no overlap. - *explicit negative (still unstable, ignored going forward)*: Check whether the any negated `where`-bounds can be proven, e.g. a `&mut u32: Clone` bound definitely does not hold as an explicit `impl<T> !Clone for &mut T` exists. The overlap check has to *prove that unifying the impls does not succeed*. This means that **incorrectly getting a type error during coherence is unsound** as it would allow impls to overlap: coherence has to be *complete*. Completeness means that we never incorrectly error. This means that during coherence we must only add inference constraints if they are definitely necessary. During ordinary type checking [this does not hold](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=01d93b592bd9036ac96071cbf1d624a9), so the trait solver has to behave differently, depending on whether we're in coherence or not. The implicit negative check only considers goals to "definitely not hold" if they could not be implemented downstream, by a sibling, or upstream in a backwards compatible way. If the goal is is "unknowable" as it may get added in another crate, we add an ambiguous candidate: [source](bea5bebf3d/compiler/rustc_trait_selection/src/solve/assembly/mod.rs (L858-L883)
). [orphan check]:fd80c02c16/compiler/rustc_trait_selection/src/traits/coherence.rs (L566-L579)
[overlap check]:fd80c02c16/compiler/rustc_trait_selection/src/traits/coherence.rs (L92-L98)
[implicit negative]:fd80c02c16/compiler/rustc_trait_selection/src/traits/coherence.rs (L223-L281)
## Motivation Replacing the existing solver in coherence fixes soundness bugs by removing sources of incompleteness in the type system. The new solver separately strengthens coherence, resulting in more impls being disjoint and passing the coherence check. The concrete changes will be elaborated further down. We believe the stabilization to reduce the likelihood of future bugs in coherence as the new implementation is easier to understand and reason about. It allows us to remove the support for coherence and implicit-negative reasoning in the old solver, allowing us to remove some code and simplifying the old trait solver. We will only remove the old solver support once this stabilization has reached stable to make sure we're able to quickly revert in case any unexpected issues are detected before then. Stabilizing the use of the next-generation trait solver expresses our confidence that its current behavior is intended and our work towards enabling its use everywhere will not require any breaking changes to the areas used by coherence checking. We are also confident that we will be able to replace the existing solver everywhere, as maintaining two separate systems adds a significant maintainance burden. ## User-facing impact and reasoning ### Breakage due to improved handling of associated types The new solver fixes multiple issues related to associated types. As these issues caused coherence to consider more types distinct, fixing them results in more overlap errors. This is therefore a breaking change. #### Structurally relating aliases containing bound vars Fixes https://github.com/rust-lang/rust/issues/102048. In the existing solver relating ambiguous projections containing bound variables is structural. This is *incomplete* and allows overlapping impls. These was mostly not exploitable as the same issue also caused impls to not apply when trying to use them. The new solver defers alias-relating to a nested goal, fixing this issue: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence trait Trait {} trait Project { type Assoc<'a>; } impl Project for u32 { type Assoc<'a> = &'a u32; } // Eagerly normalizing `<?infer as Project>::Assoc<'a>` is ambiguous, // so the old solver ended up structurally relating // // (?infer, for<'a> fn(<?infer as Project>::Assoc<'a>)) // // with // // ((u32, fn(&'a u32))) // // Equating `&'a u32` with `<u32 as Project>::Assoc<'a>` failed, even // though these types are equal modulo normalization. impl<T: Project> Trait for (T, for<'a> fn(<T as Project>::Assoc<'a>)) {} impl<'a> Trait for (u32, fn(&'a u32)) {} //[next]~^ ERROR conflicting implementations of trait `Trait` for type `(u32, for<'a> fn(&'a u32))` ``` A crater run did not discover any breakage due to this change. #### Unknowable candidates for higher ranked trait goals This avoids an unsoundness by attempting to normalize in `trait_ref_is_knowable`, fixing https://github.com/rust-lang/rust/issues/114061. This is a side-effect of supporting lazy normalization, as that forces us to attempt to normalize when checking whether a `TraitRef` is knowable: [source](47dd709bed/compiler/rustc_trait_selection/src/solve/assembly/mod.rs (L754-L764)
). ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence trait IsUnit {} impl IsUnit for () {} pub trait WithAssoc<'a> { type Assoc; } // We considered `for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit` // to be knowable, even though the projection is ambiguous. pub trait Trait {} impl<T> Trait for T where T: 'static, for<'a> T: WithAssoc<'a>, for<'a> <T as WithAssoc<'a>>::Assoc: IsUnit, { } impl<T> Trait for Box<T> {} //[next]~^ ERROR conflicting implementations of trait `Trait` ``` The two impls of `Trait` overlap given the following downstream crate: ```rust use dep::*; struct Local; impl WithAssoc<'_> for Box<Local> { type Assoc = (); } ``` There a similar coherence unsoundness caused by our handling of aliases which is fixed separately in https://github.com/rust-lang/rust/pull/117164. This change breaks the [`derive-visitor`](https://crates.io/crates/derive-visitor) crate. I have opened an issue in that repo: nikis05/derive-visitor#16. ### Evaluating goals to a fixpoint and applying inference constraints In the old implementation of the implicit-negative check, each obligation is [checked separately without applying its inference constraints](bea5bebf3d/compiler/rustc_trait_selection/src/traits/coherence.rs (L323-L338)
). The new solver instead [uses a `FulfillmentCtxt`](bea5bebf3d/compiler/rustc_trait_selection/src/traits/coherence.rs (L315-L321)
) for this, which evaluates all obligations in a loop until there's no further inference progress. This is necessary for backwards compatibility as we do not eagerly normalize with the new solver, resulting in constraints from normalization to only get applied by evaluating a separate obligation. This also allows more code to compile: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence trait Mirror { type Assoc; } impl<T> Mirror for T { type Assoc = T; } trait Foo {} trait Bar {} // The self type starts out as `?0` but is constrained to `()` // due to the where-clause below. Because `(): Bar` is known to // not hold, we can prove the impls disjoint. impl<T> Foo for T where (): Mirror<Assoc = T> {} //[current]~^ ERROR conflicting implementations of trait `Foo` for type `()` impl<T> Foo for T where T: Bar {} fn main() {} ``` The old solver does not run nested goals to a fixpoint in evaluation. The new solver does do so, strengthening inference and improving the overlap check: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence trait Foo {} impl<T> Foo for (u8, T, T) {} trait NotU8 {} trait Bar {} impl<T, U: NotU8> Bar for (T, T, U) {} trait NeedsFixpoint {} impl<T: Foo + Bar> NeedsFixpoint for T {} impl NeedsFixpoint for (u8, u8, u8) {} trait Overlap {} impl<T: NeedsFixpoint> Overlap for T {} impl<T, U: NotU8, V> Overlap for (T, U, V) {} //[current]~^ ERROR conflicting implementations of trait `Foo` ``` ### Breakage due to removal of incomplete candidate preference Fixes #107887. In the old solver we incompletely prefer the builtin trait object impl over user defined impls. This can break inference guidance, inferring `?x` in `dyn Trait<u32>: Trait<?x>` to `u32`, even if an explicit impl of `Trait<u64>` also exists. This caused coherence to incorrectly allow overlapping impls, resulting in ICEs and a theoretical unsoundness. See https://github.com/rust-lang/rust/issues/107887#issuecomment-1997261676. This compiles on stable but results in an overlap error with `-Znext-solver=coherence`: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence struct W<T: ?Sized>(*const T); trait Trait<T: ?Sized> { type Assoc; } // This would trigger the check for overlap between automatic and custom impl. // They actually don't overlap so an impl like this should remain possible // forever. // // impl Trait<u64> for dyn Trait<u32> {} trait Indirect {} impl Indirect for dyn Trait<u32, Assoc = ()> {} impl<T: Indirect + ?Sized> Trait<u64> for T { type Assoc = (); } // Incomplete impl where `dyn Trait<u32>: Trait<_>` does not hold, but // `dyn Trait<u32>: Trait<u64>` does. trait EvaluateHack<U: ?Sized> {} impl<T: ?Sized, U: ?Sized> EvaluateHack<W<U>> for T where T: Trait<U, Assoc = ()>, // incompletely constrains `_` to `u32` U: IsU64, T: Trait<U, Assoc = ()>, // incompletely constrains `_` to `u32` { } trait IsU64 {} impl IsU64 for u64 {} trait Overlap<U: ?Sized> { type Assoc: Default; } impl<T: ?Sized + EvaluateHack<W<U>>, U: ?Sized> Overlap<U> for T { type Assoc = Box<u32>; } impl<U: ?Sized> Overlap<U> for dyn Trait<u32, Assoc = ()> { //[next]~^ ERROR conflicting implementations of trait `Overlap<_>` type Assoc = usize; } ``` ### Considering region outlives bounds in the `leak_check` For details on the `leak_check`, see the FCP proposal #119820.[^leak_check] [^leak_check]: which should get moved to the dev-guide :3 In both coherence and during candidate selection, the `leak_check` relies on the region constraints added in `evaluate`. It therefore currently does not register outlives obligations: [source](ccb1415eac/compiler/rustc_trait_selection/src/traits/select/mod.rs (L792-L810)
). This was likely done as a performance optimization without considering its impact on the `leak_check`. This is the case as in the old solver, *evaluatation* and *fulfillment* are split, with evaluation being responsible for candidate selection and fulfillment actually registering all the constraints. This split does not exist with the new solver. The `leak_check` can therefore eagerly detect errors caused by region outlives obligations. This improves both coherence itself and candidate selection: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence trait LeakErr<'a, 'b> {} // Using this impl adds an `'b: 'a` bound which results // in a higher-ranked region error. This bound has been // previously ignored but is now considered. impl<'a, 'b: 'a> LeakErr<'a, 'b> for () {} trait NoOverlapDir<'a> {} impl<'a, T: for<'b> LeakErr<'a, 'b>> NoOverlapDir<'a> for T {} impl<'a> NoOverlapDir<'a> for () {} //[current]~^ ERROR conflicting implementations of trait `NoOverlapDir<'_>` // -------------------------------------- // necessary to avoid coherence unknowable candidates struct W<T>(T); trait GuidesSelection<'a, U> {} impl<'a, T: for<'b> LeakErr<'a, 'b>> GuidesSelection<'a, W<u32>> for T {} impl<'a, T> GuidesSelection<'a, W<u8>> for T {} trait NotImplementedByU8 {} trait NoOverlapInd<'a, U> {} impl<'a, T: GuidesSelection<'a, W<U>>, U> NoOverlapInd<'a, U> for T {} impl<'a, U: NotImplementedByU8> NoOverlapInd<'a, U> for () {} //[current]~^ conflicting implementations of trait `NoOverlapInd<'_, _>` ``` ### Removal of `fn match_fresh_trait_refs` The old solver tries to [eagerly detect unbounded recursion](b14fd2359f/compiler/rustc_trait_selection/src/traits/select/mod.rs (L1196-L1211)
), forcing the affected goals to be ambiguous. This check is only an approximation and has not been added to the new solver. The check is not necessary in the new solver and it would be problematic for caching. As it depends on all goals currently on the stack, using a global cache entry would have to always make sure that doing so does not circumvent this check. This changes some goals to error - or succeed - instead of failing with ambiguity. This allows more code to compile: ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence // Need to use this local wrapper for the impls to be fully // knowable as unknowable candidate result in ambiguity. struct Local<T>(T); trait Trait<U> {} // This impl does not hold, but is ambiguous in the old // solver due to its overflow approximation. impl<U> Trait<U> for Local<u32> where Local<u16>: Trait<U> {} // This impl holds. impl Trait<Local<()>> for Local<u8> {} // In the old solver, `Local<?t>: Trait<Local<?u>>` is ambiguous, // resulting in `Local<?u>: NoImpl`, also being ambiguous. // // In the new solver the first impl does not apply, constraining // `?u` to `Local<()>`, causing `Local<()>: NoImpl` to error. trait Indirect<T> {} impl<T, U> Indirect<U> for T where T: Trait<U>, U: NoImpl {} // Not implemented for `Local<()>` trait NoImpl {} impl NoImpl for Local<u8> {} impl NoImpl for Local<u16> {} // `Local<?t>: Indirect<Local<?u>>` cannot hold, so // these impls do not overlap. trait NoOverlap<U> {} impl<T: Indirect<U>, U> NoOverlap<U> for T {} impl<T, U> NoOverlap<Local<U>> for Local<T> {} //~^ ERROR conflicting implementations of trait `NoOverlap<Local<_>>` ``` ### Non-fatal overflow The old solver immediately emits a fatal error when hitting the recursion limit. The new solver instead returns overflow. This both allows more code to compile and is results in performance and potential future compatability issues. Non-fatal overflow is generally desirable. With fatal overflow, changing the order in which we evaluate nested goals easily causes breakage if we have goal which errors and one which overflows. It is also required to prevent breakage due to the removal of `fn match_fresh_trait_refs`, e.g. [in `typenum`](https://github.com/rust-lang/trait-system-refactor-initiative/issues/73). #### Enabling more code to compile In the below example, the old solver first tried to prove an overflowing goal, resulting in a fatal error. The new solver instead returns ambiguity due to overflow for that goal, causing the implicit negative overlap check to succeed as `Box<u32>: NotImplemented` does not hold. ```rust // revisions: current next //[next] compile-flags: -Znext-solver=coherence //[current] ERROR overflow evaluating the requirement trait Indirect<T> {} impl<T: Overflow<()>> Indirect<T> for () {} trait Overflow<U> {} impl<T, U> Overflow<U> for Box<T> where U: Indirect<Box<Box<T>>>, {} trait NotImplemented {} trait Trait<U> {} impl<T, U> Trait<U> for T where // T: NotImplemented, // causes old solver to succeed U: Indirect<T>, T: NotImplemented, {} impl Trait<()> for Box<u32> {} ``` #### Avoiding hangs with non-fatal overflow Simply returning ambiguity when reaching the recursion limit can very easily result in hangs, e.g. ```rust trait Recur {} impl<T, U> Recur for ((T, U), (U, T)) where (T, U): Recur, (U, T): Recur, {} trait NotImplemented {} impl<T: NotImplemented> Recur for T {} ``` This can happen quite frequently as it's easy to have exponential blowup due to multiple nested goals at each step. As the trait solver is depth-first, this immediately caused a fatal overflow error in the old solver. In the new solver we have to handle the whole proof tree instead, which can very easily hang. To avoid this we restrict the recursion depth after hitting the recursion limit for the first time. We also **ignore all inference constraints from goals resulting in overflow**. This is mostly backwards compatible as any overflow in the old solver resulted in a fatal error. ### sidenote about normalization We return ambiguous nested goals of `NormalizesTo` goals to the caller and ignore their impact when computing the `Certainty` of the current goal. See the [normalization chapter](https://rustc-dev-guide.rust-lang.org/solve/normalization.html) for more details.This means we apply constraints resulting from other nested goals and from equating the impl header when normalizing, even if a nested goal results in overflow. This is necessary to avoid breaking the following example: ```rust trait Trait { type Assoc; } struct W<T: ?Sized>(*mut T); impl<T: ?Sized> Trait for W<W<T>> where W<T>: Trait, { type Assoc = (); } // `W<?t>: Trait<Assoc = u32>` does not hold as // `Assoc` gets normalized to `()`. However, proving // the where-bounds of the impl results in overflow. // // For this to continue to compile we must not discard // constraints from normalizing associated types. trait NoOverlap {} impl<T: Trait<Assoc = u32>> NoOverlap for T {} impl<T: ?Sized> NoOverlap for W<T> {} ``` #### Future compatability concerns Non-fatal overflow results in some unfortunate future compatability concerns. Changing the approach to avoid more hangs by more strongly penalizing overflow can cause breakage as we either drop constraints or ignore candidates necessary to successfully compile. Weakening the overflow penalities instead allows more code to compile and strengthens inference while potentially causing more code to hang. While the current approach is not perfect, we believe it to be good enough. We believe it to apply the necessary inference constraints to avoid breakage and expect there to not be any desirable patterns broken by our current penalities. Similarly we believe the current constraints to avoid most accidental hangs. Ignoring constraints of overflowing goals is especially useful, as it may allow major future optimizations to our overflow handling. See [this summary](https://hackmd.io/ATf4hN0NRY-w2LIVgeFsVg) and the linked documents in case you want to know more. ### changes to performance In general, trait solving during coherence checking is not significant for performance. Enabling the next-generation trait solver in coherence does not impact our compile time benchmarks. We are still unable to compile the benchmark suite when fully enabling the new trait solver. There are rare cases where the new solver has significantly worse performance due to non-fatal overflow, its reliance on fixpoint algorithms and the removal of the `fn match_fresh_trait_refs` approximation. We encountered such issues in [`typenum`](https://crates.io/crates/typenum) and believe it should be [pretty much as bad as it can get](https://github.com/rust-lang/trait-system-refactor-initiative/issues/73). Due to an improved structure and far better caching, we believe that there is a lot of room for improvement and that the new solver will outperform the existing implementation in nearly all cases, sometimes significantly. We have not yet spent any time micro-optimizing the implementation and have many unimplemented major improvements, such as fast-paths for trivial goals. ### Unstable features #### Unsupported unstable features The new solver currently does not support all unstable features, most notably `#![feature(generic_const_exprs)]`, `#![feature(associated_const_equality)]` and `#![feature(adt_const_params)]` are not yet fully supported in the new solver. We are confident that supporting them is possible, but did not consider this to be a priority. This stabilization introduces new ICE when using these features in impl headers. #### fixes to `#![feature(specialization)]` - fixes #105782 - fixes #118987 #### fixes to `#![feature(type_alias_impl_trait)]` - fixes #119272 - https://github.com/rust-lang/rust/issues/105787#issuecomment-1750112388 - fixes #124207 ### Important changes since the original FCP https://github.com/rust-lang/rust/pull/127574 changes the coherence unknowable candidate to only apply if all the super trait bounds may hold. This allows more code to compile and fixes a regression in `pyella` https://github.com/rust-lang/rust/pull/130617 bails with ambiguity if the query response would contain too many non-region inference variables. This should only be triggered in case the result contains a lot of ambiguous aliases in which case further constraining the goal should resolve this. https://github.com/rust-lang/rust/pull/130821 adds caching to a lot of type folders, which is necessary to handle exponentially large types and handles the hang in `nalgebra` together with #130617. ## This does not stabilize the whole solver While this stabilizes the use of the new solver in coherence checking, there are many parts of the solver which will remain fully unstable. We may still adapt these areas while working towards stabilizing the new solver everywhere. We are confident that we are able to do so without negatively impacting coherence. ### goals with a non-empty `ParamEnv` Coherence always uses an empty environment. We therefore do not depend on the behavior of `AliasBound` and `ParamEnv` candidates. We only stabilizes the behavior of user-defined and builtin implementations of traits. There are still many open questions there. ### opaque types in the defining scope The handling of opaque types - `impl Trait` - in both the new and old solver is still not fully figured out. Luckily this can be ignored for now. While opaque types are reachable during coherence checking by using `impl_trait_in_associated_types`, the behavior during coherence is separate and self-contained. The old and new solver fully agree here. ### normalization is hard This stabilizes that we equate associated types involving bound variables using deferred-alias-equality. We also stop eagerly normalizing in coherence, which should not have any user-facing impact. We do not stabilize the normalization behavior outside of coherence, e.g. we currently deeply normalize all types during writeback with the new solver. This may change going forward ### how to replace `select` from the old solver We sometimes depend on getting a single `impl` for a given trait bound, e.g. when resolving a concrete method for codegen/CTFE. We do not depend on this during coherence, so the exact approach here can still be freely changed going forward. ## Acknowledgements This work would not have been possible without `@compiler-errors.` He implemented large chunks of the solver himself but also and did a lot of testing and experimentation, eagerly discovering multiple issues which had a significant impact on our approach. `@BoxyUwU` has also done some amazing work on the solver. Thank you for the endless hours of discussion resulting in the current approach. Especially the way aliases are handled has gone through multiple revisions to get to its current state. There were also many contributions from - and discussions with - other members of the community and the rest of `@rust-lang/types.` This solver builds upon previous improvements to the compiler, as well as lessons learned from `chalk` and `a-mir-formality`. Getting to this point would not have been possible without that and I am incredibly thankful to everyone involved. See the [list of relevant PRs](https://github.com/rust-lang/rust/pulls?q=is%3Apr+is%3Amerged+label%3AWG-trait-system-refactor+-label%3Arollup+closed%3A%3C2024-03-22+).
This commit is contained in:
commit
a0c2aba29a
@ -666,7 +666,7 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
|
||||
}
|
||||
|
||||
fn check_new_solver_banned_features(sess: &Session, features: &Features) {
|
||||
if !sess.opts.unstable_opts.next_solver.is_some_and(|n| n.globally) {
|
||||
if !sess.opts.unstable_opts.next_solver.globally {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -810,7 +810,7 @@ fn test_unstable_options_tracking_hash() {
|
||||
tracked!(mir_opt_level, Some(4));
|
||||
tracked!(move_size_limit, Some(4096));
|
||||
tracked!(mutable_noalias, false);
|
||||
tracked!(next_solver, Some(NextSolverConfig { coherence: true, globally: false }));
|
||||
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
|
||||
tracked!(no_generate_arange_section, true);
|
||||
tracked!(no_jump_tables, true);
|
||||
tracked!(no_link, true);
|
||||
|
@ -3128,11 +3128,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn next_trait_solver_globally(self) -> bool {
|
||||
self.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally)
|
||||
self.sess.opts.unstable_opts.next_solver.globally
|
||||
}
|
||||
|
||||
pub fn next_trait_solver_in_coherence(self) -> bool {
|
||||
self.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.coherence)
|
||||
self.sess.opts.unstable_opts.next_solver.coherence
|
||||
}
|
||||
|
||||
pub fn is_impl_trait_in_trait(self, def_id: DefId) -> bool {
|
||||
|
@ -842,6 +842,11 @@ pub struct NextSolverConfig {
|
||||
/// This is only `true` if `coherence` is also enabled.
|
||||
pub globally: bool,
|
||||
}
|
||||
impl Default for NextSolverConfig {
|
||||
fn default() -> Self {
|
||||
NextSolverConfig { coherence: true, globally: false }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Input {
|
||||
|
@ -403,7 +403,7 @@ mod desc {
|
||||
pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
|
||||
pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
|
||||
pub(crate) const parse_next_solver_config: &str =
|
||||
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
|
||||
"either `globally` (when used without an argument), `coherence` (default) or `no`";
|
||||
pub(crate) const parse_lto: &str =
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
|
||||
pub(crate) const parse_linker_plugin_lto: &str =
|
||||
@ -1123,27 +1123,16 @@ mod parse {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_next_solver_config(
|
||||
slot: &mut Option<NextSolverConfig>,
|
||||
v: Option<&str>,
|
||||
) -> bool {
|
||||
pub(crate) fn parse_next_solver_config(slot: &mut NextSolverConfig, v: Option<&str>) -> bool {
|
||||
if let Some(config) = v {
|
||||
let mut coherence = false;
|
||||
let mut globally = true;
|
||||
for c in config.split(',') {
|
||||
match c {
|
||||
"globally" => globally = true,
|
||||
"coherence" => {
|
||||
globally = false;
|
||||
coherence = true;
|
||||
}
|
||||
*slot = match config {
|
||||
"no" => NextSolverConfig { coherence: false, globally: false },
|
||||
"coherence" => NextSolverConfig { coherence: true, globally: false },
|
||||
"globally" => NextSolverConfig { coherence: true, globally: true },
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
||||
*slot = Some(NextSolverConfig { coherence: coherence || globally, globally });
|
||||
};
|
||||
} else {
|
||||
*slot = Some(NextSolverConfig { coherence: true, globally: true });
|
||||
*slot = NextSolverConfig { coherence: true, globally: true };
|
||||
}
|
||||
|
||||
true
|
||||
@ -1914,7 +1903,7 @@ options! {
|
||||
"the size at which the `large_assignments` lint starts to be emitted"),
|
||||
mutable_noalias: bool = (true, parse_bool, [TRACKED],
|
||||
"emit noalias metadata for mutable references (default: yes)"),
|
||||
next_solver: Option<NextSolverConfig> = (None, parse_next_solver_config, [TRACKED],
|
||||
next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],
|
||||
"enable and configure the next generation trait solver used by rustc"),
|
||||
nll_facts: bool = (false, parse_bool, [UNTRACKED],
|
||||
"dump facts from NLL analysis into side files (default: no)"),
|
||||
|
@ -36,10 +36,8 @@ where
|
||||
if infcx.next_trait_solver() {
|
||||
Box::new(NextFulfillmentCtxt::new(infcx))
|
||||
} else {
|
||||
let new_solver_globally =
|
||||
infcx.tcx.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally);
|
||||
assert!(
|
||||
!new_solver_globally,
|
||||
!infcx.tcx.next_trait_solver_globally(),
|
||||
"using old solver even though new solver is enabled globally"
|
||||
);
|
||||
Box::new(FulfillmentContext::new(infcx))
|
||||
|
@ -1,17 +0,0 @@
|
||||
//@ known-bug: #118987
|
||||
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
|
||||
|
||||
trait Assoc {
|
||||
type Output;
|
||||
}
|
||||
|
||||
default impl<T: Clone> Assoc for T {
|
||||
type Output = bool;
|
||||
}
|
||||
|
||||
impl Assoc for u8 {}
|
||||
|
||||
trait Foo {}
|
||||
|
||||
impl Foo for <u8 as Assoc>::Output {}
|
||||
impl Foo for <u16 as Assoc>::Output {}
|
@ -1,20 +1,20 @@
|
||||
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `Cow<'_, _>`
|
||||
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
|
||||
--> $DIR/associated-types-coherence-failure.rs:21:1
|
||||
|
|
||||
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
|
||||
| ----------------------------------------------------------------------------- first implementation here
|
||||
...
|
||||
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Cow<'_, _>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `&_`
|
||||
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
|
||||
--> $DIR/associated-types-coherence-failure.rs:28:1
|
||||
|
|
||||
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
|
||||
| ----------------------------------------------------------------------------- first implementation here
|
||||
...
|
||||
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
//! used to ICE: #119272
|
||||
|
||||
//@ check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
mod defining_scope {
|
||||
use super::*;
|
||||
pub type Alias<T> = impl Sized;
|
||||
|
||||
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
struct Container<T: Trait<U>, U> {
|
||||
x: <T as Trait<U>>::Assoc,
|
||||
}
|
||||
|
||||
trait Trait<T> {
|
||||
type Assoc;
|
||||
}
|
||||
|
||||
impl<T> Trait<T> for T {
|
||||
type Assoc = Box<u32>;
|
||||
}
|
||||
impl<T> Trait<T> for defining_scope::Alias<T> {
|
||||
type Assoc = usize;
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
|
||||
| ---------------------------------------------- first implementation here
|
||||
LL | impl<'a, T> MyTrait<'a> for &'a T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
|
||||
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
|
||||
| ---------------------------------------------- first implementation here
|
||||
LL | impl<'a, T> MyTrait<'a> for &'a T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
|
||||
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
error[E0592]: duplicate definitions with name `dummy`
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:10:26
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
|
||||
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
|
||||
LL |
|
||||
LL | impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
|
||||
| --------------- other definition for `dummy`
|
||||
|
||||
error[E0592]: duplicate definitions with name `f`
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:16:38
|
||||
|
|
||||
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
|
||||
| ^^^^^^^^^^^ duplicate definitions for `f`
|
||||
LL |
|
||||
LL | impl<X> A<i32, X> { fn f(&self) {} }
|
||||
| ----------- other definition for `f`
|
||||
|
|
||||
= note: downstream crates may implement trait `Bar<_>` for type `i32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0592`.
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
|
||||
// though no impls are found.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0592]: duplicate definitions with name `dummy`
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:10:26
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:7:26
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
|
||||
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
|
||||
@ -8,7 +8,7 @@ LL | impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
|
||||
| --------------- other definition for `dummy`
|
||||
|
||||
error[E0592]: duplicate definitions with name `f`
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:16:38
|
||||
--> $DIR/coherence-overlap-downstream-inherent.rs:13:38
|
||||
|
|
||||
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
|
||||
| ^^^^^^^^^^^ duplicate definitions for `f`
|
@ -1,21 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Sweet`
|
||||
--> $DIR/coherence-overlap-downstream.rs:11:1
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet for T { }
|
||||
| ------------------------- first implementation here
|
||||
LL | impl<T:Fruit> Sweet for T { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`
|
||||
--> $DIR/coherence-overlap-downstream.rs:17:1
|
||||
|
|
||||
LL | impl<X, T> Foo<X> for T where T: Bar<X> {}
|
||||
| --------------------------------------- first implementation here
|
||||
LL | impl<X> Foo<X> for i32 {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32`
|
||||
|
|
||||
= note: downstream crates may implement trait `Bar<_>` for type `i32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
|
||||
// though no impls are found.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Sweet`
|
||||
--> $DIR/coherence-overlap-downstream.rs:11:1
|
||||
--> $DIR/coherence-overlap-downstream.rs:8:1
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet for T { }
|
||||
| ------------------------- first implementation here
|
||||
@ -7,7 +7,7 @@ LL | impl<T:Fruit> Sweet for T { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`
|
||||
--> $DIR/coherence-overlap-downstream.rs:17:1
|
||||
--> $DIR/coherence-overlap-downstream.rs:14:1
|
||||
|
|
||||
LL | impl<X, T> Foo<X> for T where T: Bar<X> {}
|
||||
| --------------------------------------- first implementation here
|
@ -1,14 +0,0 @@
|
||||
error[E0592]: duplicate definitions with name `dummy`
|
||||
--> $DIR/coherence-overlap-issue-23516-inherent.rs:12:25
|
||||
|
|
||||
LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
|
||||
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
|
||||
LL |
|
||||
LL | impl<U:Sugar> Cake<Box<U>> { fn dummy(&self) { } }
|
||||
| --------------- other definition for `dummy`
|
||||
|
|
||||
= note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0592`.
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
|
||||
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
|
||||
// error is reported for the following pair of impls (#23516).
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0592]: duplicate definitions with name `dummy`
|
||||
--> $DIR/coherence-overlap-issue-23516-inherent.rs:12:25
|
||||
--> $DIR/coherence-overlap-issue-23516-inherent.rs:9:25
|
||||
|
|
||||
LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
|
||||
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
|
@ -1,13 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Sweet` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-issue-23516.rs:11:1
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet for T { }
|
||||
| ------------------------- first implementation here
|
||||
LL | impl<U:Sugar> Sweet for Box<U> { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
|
||||
|
|
||||
= note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
|
||||
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
|
||||
// error is reported for the following pair of impls (#23516).
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Sweet` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-issue-23516.rs:11:1
|
||||
--> $DIR/coherence-overlap-issue-23516.rs:8:1
|
||||
|
|
||||
LL | impl<T:Sugar> Sweet for T { }
|
||||
| ------------------------- first implementation here
|
@ -5,6 +5,8 @@ LL | impl<T: DerefMut> Foo for T {}
|
||||
| --------------------------- first implementation here
|
||||
LL | impl<U> Foo for &U {}
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
|
||||
= note: downstream crates may implement trait `std::ops::DerefMut` for type `&_`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-0.rs:27:1
|
||||
|
|
||||
LL | / impl<T> Trait for T
|
||||
LL | | where
|
||||
LL | | T: 'static,
|
||||
LL | | for<'a> T: WithAssoc<'a>,
|
||||
LL | | for<'a> <T as WithAssoc<'a>>::Assoc: WhereBound,
|
||||
| |____________________________________________________- first implementation here
|
||||
...
|
||||
LL | impl<T> Trait for Box<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
|
||||
|
|
||||
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>`
|
||||
= note: downstream crates may implement trait `WhereBound` for type `<std::boxed::Box<_> as WithAssoc<'a>>::Assoc`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -2,9 +2,6 @@
|
||||
// "Coherence incorrectly considers `unnormalizable_projection: Trait` to not hold even if it could"
|
||||
#![crate_type = "lib"]
|
||||
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
trait WhereBound {}
|
||||
impl WhereBound for () {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-0.rs:27:1
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-0.rs:24:1
|
||||
|
|
||||
LL | / impl<T> Trait for T
|
||||
LL | | where
|
@ -1,19 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-1.rs:26:1
|
||||
|
|
||||
LL | / impl<T> Trait for T
|
||||
LL | | where
|
||||
LL | | T: 'static,
|
||||
LL | | for<'a> T: WithAssoc<'a>,
|
||||
LL | | for<'a> Box<<T as WithAssoc<'a>>::Assoc>: WhereBound,
|
||||
| |_________________________________________________________- first implementation here
|
||||
...
|
||||
LL | impl<T> Trait for Box<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
|
||||
|
|
||||
= note: downstream crates may implement trait `WithAssoc<'a>` for type `std::boxed::Box<_>`
|
||||
= note: downstream crates may implement trait `WhereBound` for type `std::boxed::Box<<std::boxed::Box<_> as WithAssoc<'a>>::Assoc>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -2,9 +2,6 @@
|
||||
// "Coherence incorrectly considers `unnormalizable_projection: Trait` to not hold even if it could"
|
||||
#![crate_type = "lib"]
|
||||
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
pub trait WhereBound {}
|
||||
impl WhereBound for () {}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-1.rs:26:1
|
||||
--> $DIR/coherence-overlap-unnormalizable-projection-1.rs:23:1
|
||||
|
|
||||
LL | / impl<T> Trait for T
|
||||
LL | | where
|
@ -1,6 +1,4 @@
|
||||
//@ compile-flags: -Znext-solver=coherence
|
||||
//@ check-pass
|
||||
|
||||
trait Mirror {
|
||||
type Assoc;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
//@ compile-flags: -Znext-solver=coherence
|
||||
|
||||
trait Mirror {
|
||||
type Assoc;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `()`
|
||||
--> $DIR/incoherent-even-though-we-fulfill.rs:17:1
|
||||
--> $DIR/incoherent-even-though-we-fulfill.rs:15:1
|
||||
|
|
||||
LL | impl<T> Foo for T where (): Mirror<Assoc = T> {}
|
||||
| --------------------------------------------- first implementation here
|
||||
|
@ -1,17 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `From<()>` for type `S`
|
||||
--> $DIR/inter-crate-ambiguity-causes-notes.rs:12:1
|
||||
|
|
||||
LL | impl From<()> for S {
|
||||
| ------------------- first implementation here
|
||||
...
|
||||
LL | / impl<I> From<I> for S
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | I: Iterator<Item = ()>,
|
||||
| |___________________________^ conflicting implementation for `S`
|
||||
|
|
||||
= note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `()` in future versions
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
struct S;
|
||||
|
||||
impl From<()> for S {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `From<()>` for type `S`
|
||||
--> $DIR/inter-crate-ambiguity-causes-notes.rs:12:1
|
||||
--> $DIR/inter-crate-ambiguity-causes-notes.rs:9:1
|
||||
|
|
||||
LL | impl From<()> for S {
|
||||
| ------------------- first implementation here
|
@ -5,6 +5,8 @@ LL | impl<T> Bar for T where T: Foo {}
|
||||
| ------------------------------ first implementation here
|
||||
LL | impl<T> Bar for Box<T> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
|
||||
|
|
||||
= note: downstream crates may implement trait `Foo` for type `std::boxed::Box<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -6,6 +6,8 @@ LL | impl<T> Bar for T where T: Foo {}
|
||||
...
|
||||
LL | impl<T> Bar for &T {}
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
|
||||
= note: downstream crates may implement trait `Foo` for type `&_`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -8,6 +8,7 @@ LL | impl<T: ?Sized> FnMarker for fn(&T) {}
|
||||
|
|
||||
= warning: the behavior may change in a future release
|
||||
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
|
||||
= note: downstream crates may implement trait `Marker` for type `&_`
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:4:11
|
||||
|
@ -1,14 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, _)`
|
||||
--> $DIR/normalize-for-errors.rs:17:1
|
||||
|
|
||||
LL | impl<T: Copy, S: Iterator> MyTrait<S> for (T, S::Item) {}
|
||||
| ------------------------------------------------------ first implementation here
|
||||
LL |
|
||||
LL | impl<S: Iterator> MyTrait<S> for (Box<<(MyType,) as Mirror>::Assoc>, S::Item) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(Box<(MyType,)>, _)`
|
||||
|
|
||||
= note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::boxed::Box<(MyType,)>` in future versions
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,7 +1,3 @@
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
struct MyType;
|
||||
trait MyTrait<S> {}
|
||||
|
||||
@ -18,6 +14,6 @@ impl<S: Iterator> MyTrait<S> for (Box<<(MyType,) as Mirror>::Assoc>, S::Item) {}
|
||||
//~^ ERROR conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>,
|
||||
//~| NOTE conflicting implementation for `(Box<(MyType,)>,
|
||||
//~| NOTE upstream crates may add a new impl of trait `std::marker::Copy` for type `std::boxed::Box<(MyType,)>` in future versions
|
||||
//[next]~| NOTE upstream crates may add a new impl of trait `std::clone::Clone` for type `std::boxed::Box<(MyType,)>` in future versions
|
||||
//~| NOTE upstream crates may add a new impl of trait `std::clone::Clone` for type `std::boxed::Box<(MyType,)>` in future versions
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, <_ as Iterator>::Item)`
|
||||
--> $DIR/normalize-for-errors.rs:17:1
|
||||
--> $DIR/normalize-for-errors.rs:13:1
|
||||
|
|
||||
LL | impl<T: Copy, S: Iterator> MyTrait<S> for (T, S::Item) {}
|
||||
| ------------------------------------------------------ first implementation here
|
@ -3,7 +3,7 @@
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
|
||||
--> $DIR/associated-type.rs:31:1
|
||||
--> $DIR/associated-type.rs:32:1
|
||||
|
|
||||
LL | impl<T> Overlap<T> for T {
|
||||
| ------------------------ first implementation here
|
||||
@ -17,7 +17,7 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
|
||||
error[E0284]: type annotations needed: cannot normalize `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc`
|
||||
--> $DIR/associated-type.rs:44:59
|
||||
--> $DIR/associated-type.rs:45:59
|
||||
|
|
||||
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
||||
| ^^^^^^ cannot normalize `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc`
|
||||
|
@ -1,13 +1,9 @@
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, !2_0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. }
|
||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
|
||||
--> $DIR/associated-type.rs:31:1
|
||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
|
||||
--> $DIR/associated-type.rs:32:1
|
||||
|
|
||||
LL | impl<T> Overlap<T> for T {
|
||||
| ------------------------ first implementation here
|
||||
@ -16,7 +12,7 @@ LL | / impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | for<'a> *const T: ToUnit<'a>,
|
||||
| |_________________________________^ conflicting implementation for `for<'a> fn(&'a (), _)`
|
||||
| |_________________________________^ conflicting implementation for `for<'a> fn(&'a (), ())`
|
||||
|
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
//@ revisions: old next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// A (partial) regression test for #105787
|
||||
|
12
tests/ui/coherence/occurs-check/opaques.current.stderr
Normal file
12
tests/ui/coherence/occurs-check/opaques.current.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait<_>`
|
||||
--> $DIR/opaques.rs:28:1
|
||||
|
|
||||
LL | impl<T> Trait<T> for T {
|
||||
| ---------------------- first implementation here
|
||||
...
|
||||
LL | impl<T> Trait<T> for defining_scope::Alias<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait<_>`
|
||||
--> $DIR/opaques.rs:30:1
|
||||
--> $DIR/opaques.rs:28:1
|
||||
|
|
||||
LL | impl<T> Trait<T> for T {
|
||||
| ---------------------- first implementation here
|
||||
@ -8,7 +8,7 @@ LL | impl<T> Trait<T> for defining_scope::Alias<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/opaques.rs:13:23
|
||||
--> $DIR/opaques.rs:11:23
|
||||
|
|
||||
LL | pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
|
@ -1,10 +1,8 @@
|
||||
//@revisions: old next
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// A regression test for #105787
|
||||
|
||||
//@[old] known-bug: #105787
|
||||
//@[old] check-pass
|
||||
#![feature(type_alias_impl_trait)]
|
||||
mod defining_scope {
|
||||
use super::*;
|
||||
@ -28,7 +26,7 @@ impl<T> Trait<T> for T {
|
||||
type Assoc = Box<u32>;
|
||||
}
|
||||
impl<T> Trait<T> for defining_scope::Alias<T> {
|
||||
//[next]~^ ERROR conflicting implementations of trait
|
||||
//~^ ERROR conflicting implementations of trait
|
||||
type Assoc = usize;
|
||||
}
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:17:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait0<Local, T, ()> for Identity<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:26:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait1<Local, T> for Opaque<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0210`.
|
@ -1,8 +1,5 @@
|
||||
// Opaque types never cover type parameters.
|
||||
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
//@ aux-crate:foreign=parametrized-trait.rs
|
||||
//@ edition:2021
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:17:6
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:14:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait0<Local, T, ()> for Identity<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
@ -8,7 +8,7 @@ LL | impl<T> foreign::Trait0<Local, T, ()> for Identity<T> {}
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:26:6
|
||||
--> $DIR/orphan-check-opaque-types-not-covering.rs:23:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait1<Local, T> for Opaque<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
@ -5,9 +5,6 @@
|
||||
// first which would've lead to real-word regressions.
|
||||
|
||||
//@ check-pass
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
//@ aux-crate:foreign=parametrized-trait.rs
|
||||
//@ edition:2021
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-weak-aliases-not-covering.rs:16:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait1<Local, T> for Identity<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
|
|
||||
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
|
||||
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0210`.
|
@ -1,8 +1,5 @@
|
||||
// Weak aliases might not cover type parameters.
|
||||
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
//@ aux-crate:foreign=parametrized-trait.rs
|
||||
//@ edition:2021
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
||||
--> $DIR/orphan-check-weak-aliases-not-covering.rs:16:6
|
||||
--> $DIR/orphan-check-weak-aliases-not-covering.rs:13:6
|
||||
|
|
||||
LL | impl<T> foreign::Trait1<Local, T> for Identity<T> {}
|
||||
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
|
@ -1,27 +0,0 @@
|
||||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/skip-reporting-if-references-err.rs:10:9
|
||||
|
|
||||
LL | impl<T> ToUnit for T {}
|
||||
| ^^^^^^ expected lifetime parameter
|
||||
|
|
||||
help: indicate the anonymous lifetime
|
||||
|
|
||||
LL | impl<T> ToUnit<'_> for T {}
|
||||
| ++++
|
||||
|
||||
error[E0277]: the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
|
||||
--> $DIR/skip-reporting-if-references-err.rs:15:29
|
||||
|
|
||||
LL | impl Overlap for for<'a> fn(<() as ToUnit<'a>>::Unit) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `()`
|
||||
|
||||
error[E0277]: the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
|
||||
--> $DIR/skip-reporting-if-references-err.rs:15:18
|
||||
|
|
||||
LL | impl Overlap for for<'a> fn(<() as ToUnit<'a>>::Unit) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `()`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0726.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
@ -1,8 +1,4 @@
|
||||
// Regression test for #121006.
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
trait ToUnit<'a> {
|
||||
type Unit;
|
||||
}
|
||||
@ -13,7 +9,5 @@ impl<T> ToUnit for T {}
|
||||
trait Overlap {}
|
||||
impl<U> Overlap for fn(U) {}
|
||||
impl Overlap for for<'a> fn(<() as ToUnit<'a>>::Unit) {}
|
||||
//[current]~^ ERROR the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
|
||||
//[current]~| ERROR the trait bound `for<'a> (): ToUnit<'a>` is not satisfied
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0726]: implicit elided lifetime not allowed here
|
||||
--> $DIR/skip-reporting-if-references-err.rs:10:9
|
||||
--> $DIR/skip-reporting-if-references-err.rs:6:9
|
||||
|
|
||||
LL | impl<T> ToUnit for T {}
|
||||
| ^^^^^^ expected lifetime parameter
|
@ -1,13 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Overlap<_>` for type `()`
|
||||
--> $DIR/super-trait-knowable-1.rs:16:1
|
||||
|
|
||||
LL | impl<T, U: Sub<T>> Overlap<T> for U {}
|
||||
| ----------------------------------- first implementation here
|
||||
LL | impl<T> Overlap<T> for () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
|
||||
= note: downstream crates may implement trait `Sub<_>` for type `()`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -3,10 +3,7 @@
|
||||
// We therefore elaborate super trait bounds in the implicit negative
|
||||
// overlap check.
|
||||
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
//@ check-pass
|
||||
|
||||
trait Super {}
|
||||
trait Sub<T>: Super {}
|
||||
@ -14,6 +11,5 @@ trait Sub<T>: Super {}
|
||||
trait Overlap<T> {}
|
||||
impl<T, U: Sub<T>> Overlap<T> for U {}
|
||||
impl<T> Overlap<T> for () {}
|
||||
//[current]~^ ERROR conflicting implementations
|
||||
|
||||
fn main() {}
|
||||
|
@ -9,9 +9,6 @@
|
||||
// which caused the old solver to emit a `Tensor: TensorValue` goal in
|
||||
// `fn normalize_to_error` which then failed, causing this test to pass.
|
||||
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
pub trait TensorValue {
|
||||
|
@ -1,13 +0,0 @@
|
||||
error[E0119]: conflicting implementations of trait `Overlap<_>` for type `()`
|
||||
--> $DIR/super-trait-knowable-3.rs:19:1
|
||||
|
|
||||
LL | impl<T, U: Bound<W<T>>> Overlap<T> for U {}
|
||||
| ---------------------------------------- first implementation here
|
||||
LL | impl<T> Overlap<T> for () {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
|
||||
|
|
||||
= note: downstream crates may implement trait `Sub<_>` for type `()`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -2,10 +2,7 @@
|
||||
// super trait bound is in a nested goal so this would not
|
||||
// compile if we were to only elaborate root goals.
|
||||
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
//@ check-pass
|
||||
|
||||
trait Super {}
|
||||
trait Sub<T>: Super {}
|
||||
@ -17,6 +14,5 @@ impl<T: Sub<U>, U> Bound<W<U>> for T {}
|
||||
trait Overlap<T> {}
|
||||
impl<T, U: Bound<W<T>>> Overlap<T> for U {}
|
||||
impl<T> Overlap<T> for () {}
|
||||
//[current]~^ ERROR conflicting implementations of trait `Overlap<_>` for type `()`
|
||||
|
||||
fn main() {}
|
||||
|
@ -22,6 +22,7 @@ mod v20 {
|
||||
impl v17<512, v0> {
|
||||
pub const fn v21() -> v18 {}
|
||||
//~^ ERROR cannot find type `v18` in this scope
|
||||
//~| ERROR duplicate definitions with name `v21`
|
||||
}
|
||||
|
||||
impl<const v10: usize> v17<v10, v2> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0432]: unresolved import `v20::v13`
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:37:15
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:38:15
|
||||
|
|
||||
LL | pub use v20::{v13, v17};
|
||||
| ^^^
|
||||
@ -23,7 +23,7 @@ LL | pub const fn v21() -> v18 {}
|
||||
| ^^^ help: a type alias with a similar name exists: `v11`
|
||||
|
||||
error[E0412]: cannot find type `v18` in this scope
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:30:31
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:31:31
|
||||
|
|
||||
LL | pub type v11 = [[usize; v4]; v4];
|
||||
| --------------------------------- similarly named type alias `v11` defined here
|
||||
@ -32,7 +32,7 @@ LL | pub const fn v21() -> v18 {
|
||||
| ^^^ help: a type alias with a similar name exists: `v11`
|
||||
|
||||
error[E0422]: cannot find struct, variant or union type `v18` in this scope
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:32:13
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:33:13
|
||||
|
|
||||
LL | pub type v11 = [[usize; v4]; v4];
|
||||
| --------------------------------- similarly named type alias `v11` defined here
|
||||
@ -73,20 +73,29 @@ LL + #![feature(adt_const_params)]
|
||||
|
|
||||
|
||||
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:27:37
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:28:37
|
||||
|
|
||||
LL | impl<const v10: usize> v17<v10, v2> {
|
||||
| ^^
|
||||
|
||||
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0}
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:27:37
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:28:37
|
||||
|
|
||||
LL | impl<const v10: usize> v17<v10, v2> {
|
||||
| ^^
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 9 previous errors; 2 warnings emitted
|
||||
error[E0592]: duplicate definitions with name `v21`
|
||||
--> $DIR/unevaluated-const-ice-119731.rs:23:9
|
||||
|
|
||||
LL | pub const fn v21() -> v18 {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `v21`
|
||||
...
|
||||
LL | pub const fn v21() -> v18 {
|
||||
| ------------------------- other definition for `v21`
|
||||
|
||||
Some errors have detailed explanations: E0412, E0422, E0425, E0432.
|
||||
error: aborting due to 10 previous errors; 2 warnings emitted
|
||||
|
||||
Some errors have detailed explanations: E0412, E0422, E0425, E0432, E0592.
|
||||
For more information about an error, try `rustc --explain E0412`.
|
||||
|
@ -10,6 +10,5 @@ trait Trait {}
|
||||
impl<const N: u32> Trait for A<N> {}
|
||||
|
||||
impl<const N: u32> Trait for A<N> {}
|
||||
//~^ ERROR conflicting implementations of trait `Trait` for type `A<_>`
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -4,16 +4,6 @@ error[E0423]: expected value, found builtin type `u8`
|
||||
LL | struct A<const N: u32 = 1, const M: u32 = u8>;
|
||||
| ^^ not a value
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Trait` for type `A<_>`
|
||||
--> $DIR/unknown-alias-defkind-anonconst-ice-116710.rs:12:1
|
||||
|
|
||||
LL | impl<const N: u32> Trait for A<N> {}
|
||||
| --------------------------------- first implementation here
|
||||
LL |
|
||||
LL | impl<const N: u32> Trait for A<N> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A<_>`
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0119, E0423.
|
||||
For more information about an error, try `rustc --explain E0119`.
|
||||
For more information about this error, try `rustc --explain E0423`.
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0119]: conflicting implementations of trait `LolFrom<&[_]>` for type `LocalType<_>`
|
||||
error[E0119]: conflicting implementations of trait `LolFrom<&[u8]>` for type `LocalType<u8>`
|
||||
--> $DIR/issue-23563.rs:13:1
|
||||
|
|
||||
LL | impl<'a, T> LolFrom<&'a [T]> for LocalType<T> {
|
||||
|
@ -6,6 +6,8 @@ LL | impl<T: std::ops::DerefMut> Foo for T { }
|
||||
LL |
|
||||
LL | impl<T> Foo for &T { }
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
||||
|
|
||||
= note: downstream crates may implement trait `std::ops::DerefMut` for type `&_`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
//@ check-pass
|
||||
|
||||
// The new trait solver does not return region constraints if the goal
|
||||
// is still ambiguous. This causes the following test to fail with ambiguity,
|
||||
// even though `(): LeakCheckFailure<'!a, V>` would return `'!a: 'static`
|
||||
// which would have caused a leak check failure.
|
||||
// is still ambiguous. However, the `'!a = 'static` constraint from
|
||||
// `(): LeakCheckFailure<'!a, V>` is also returned via the canonical
|
||||
// var values, causing this test to compile.
|
||||
|
||||
trait Ambig {}
|
||||
impl Ambig for u32 {}
|
||||
|
@ -11,7 +11,6 @@ type Assoc<'a, T> = <T as ToUnit<'a>>::Unit;
|
||||
impl<T> Overlap<T> for T {}
|
||||
|
||||
impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}
|
||||
//~^ ERROR 13:17: 13:49: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied [E0277]
|
||||
//~| ERROR 13:36: 13:48: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied [E0277]
|
||||
//~^ ERROR conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>`
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,27 +1,18 @@
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, !2_0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
|
||||
error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied
|
||||
--> $DIR/structually-relate-aliases.rs:13:36
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
|
||||
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. }
|
||||
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
|
||||
--> $DIR/structually-relate-aliases.rs:13:1
|
||||
|
|
||||
LL | impl<T> Overlap<T> for T {}
|
||||
| ------------------------ first implementation here
|
||||
LL |
|
||||
LL | impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}
|
||||
| ^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `T`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a> fn(&'a (), _)`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | impl<T: for<'a> ToUnit<'a>> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}
|
||||
| ++++++++++++++++++++
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
|
||||
error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied
|
||||
--> $DIR/structually-relate-aliases.rs:13:17
|
||||
|
|
||||
LL | impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `T`
|
||||
|
|
||||
help: consider restricting type parameter `T`
|
||||
|
|
||||
LL | impl<T: for<'a> ToUnit<'a>> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}
|
||||
| ++++++++++++++++++++
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
--> $DIR/auto-trait-coherence.rs:24:1
|
||||
|
|
||||
LL | impl<T: Send> AnotherTrait for T {}
|
||||
| -------------------------------- first implementation here
|
||||
...
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
//@ revisions: old next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
// Tests that type alias impls traits do not leak auto-traits for
|
||||
// the purposes of coherence checking
|
||||
#![feature(type_alias_impl_trait)]
|
||||
@ -22,8 +19,7 @@ impl<T: Send> AnotherTrait for T {}
|
||||
// (We treat opaque types as "foreign types" that could grow more impls
|
||||
// in the future.)
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//[old]~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
//[next]~^^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
12
tests/ui/impl-trait/auto-trait-coherence.stderr
Normal file
12
tests/ui/impl-trait/auto-trait-coherence.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
--> $DIR/auto-trait-coherence.rs:21:1
|
||||
|
|
||||
LL | impl<T: Send> AnotherTrait for T {}
|
||||
| -------------------------------- first implementation here
|
||||
...
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -5,7 +5,7 @@ type T = impl Sized;
|
||||
struct Foo;
|
||||
|
||||
impl Into<T> for Foo {
|
||||
//~^ ERROR conflicting implementations of trait `Into<T>` for type `Foo`
|
||||
//~^ ERROR conflicting implementations of trait `Into<_>` for type `Foo`
|
||||
fn into(self) -> T {
|
||||
Foo
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
|
||||
error[E0119]: conflicting implementations of trait `Into<_>` for type `Foo`
|
||||
--> $DIR/coherence-treats-tait-ambig.rs:7:1
|
||||
|
|
||||
LL | impl Into<T> for Foo {
|
||||
|
@ -17,7 +17,7 @@ impl<T: std::fmt::Debug> AnotherTrait for T {}
|
||||
|
||||
// This is in error, because we cannot assume that `OpaqueType: !Debug`
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,13 +1,11 @@
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
|
||||
--> $DIR/negative-reasoning.rs:19:1
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug> AnotherTrait for T {}
|
||||
| ------------------------------------------- first implementation here
|
||||
...
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||
|
|
||||
= note: upstream crates may add a new impl of trait `std::marker::FnPtr` for type `OpaqueType` in future versions
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -1,34 +1,35 @@
|
||||
//~ ERROR overflow evaluating the requirement `([isize; 0], _): Sized
|
||||
|
||||
trait Foo<A> {
|
||||
fn get(&self, A: &A) { }
|
||||
fn get(&self, A: &A) {}
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
type Out;
|
||||
}
|
||||
|
||||
impl<T> Foo<T> for [isize;0] {
|
||||
impl<T> Foo<T> for [isize; 0] {
|
||||
// OK, T is used in `Foo<T>`.
|
||||
}
|
||||
|
||||
impl<T,U> Foo<T> for [isize;1] {
|
||||
impl<T, U> Foo<T> for [isize; 1] {
|
||||
//~^ ERROR the type parameter `U` is not constrained
|
||||
}
|
||||
|
||||
impl<T,U> Foo<T> for [isize;2] where T : Bar<Out=U> {
|
||||
impl<T, U> Foo<T> for [isize; 2]
|
||||
where
|
||||
T: Bar<Out = U>,
|
||||
{
|
||||
// OK, `U` is now constrained by the output type parameter.
|
||||
}
|
||||
|
||||
impl<T:Bar<Out=U>,U> Foo<T> for [isize;3] {
|
||||
impl<T: Bar<Out = U>, U> Foo<T> for [isize; 3] {
|
||||
// OK, same as above but written differently.
|
||||
}
|
||||
|
||||
impl<T,U> Foo<T> for U {
|
||||
impl<T, U> Foo<T> for U {
|
||||
//~^ ERROR conflicting implementations of trait `Foo<_>` for type `[isize; 0]`
|
||||
}
|
||||
|
||||
impl<T,U> Bar for T {
|
||||
impl<T, U> Bar for T {
|
||||
//~^ ERROR the type parameter `U` is not constrained
|
||||
|
||||
type Out = U;
|
||||
@ -36,28 +37,33 @@ impl<T,U> Bar for T {
|
||||
// Using `U` in an associated type within the impl is not good enough!
|
||||
}
|
||||
|
||||
impl<T,U> Bar for T
|
||||
where T : Bar<Out=U>
|
||||
impl<T, U> Bar for T
|
||||
where
|
||||
T: Bar<Out = U>,
|
||||
{
|
||||
//~^^^ ERROR the type parameter `U` is not constrained
|
||||
|
||||
//~^^^^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates
|
||||
//~| ERROR conflicting implementations of trait `Bar`
|
||||
// This crafty self-referential attempt is still no good.
|
||||
}
|
||||
|
||||
impl<T,U,V> Foo<T> for T
|
||||
where (T,U): Bar<Out=V>
|
||||
impl<T, U, V> Foo<T> for T
|
||||
where
|
||||
(T, U): Bar<Out = V>,
|
||||
{
|
||||
//~^^^ ERROR the type parameter `U` is not constrained
|
||||
//~^^^^ ERROR the type parameter `U` is not constrained
|
||||
//~| ERROR the type parameter `V` is not constrained
|
||||
//~| ERROR conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]`
|
||||
|
||||
// Here, `V` is bound by an output type parameter, but the inputs
|
||||
// are not themselves constrained.
|
||||
}
|
||||
|
||||
impl<T,U,V> Foo<(T,U)> for T
|
||||
where (T,U): Bar<Out=V>
|
||||
impl<T, U, V> Foo<(T, U)> for T
|
||||
where
|
||||
(T, U): Bar<Out = V>,
|
||||
{
|
||||
//~^^^^ ERROR conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]`
|
||||
// As above, but both T and U ARE constrained.
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
fn main() {}
|
||||
|
@ -1,56 +1,76 @@
|
||||
error[E0119]: conflicting implementations of trait `Foo<_>` for type `[isize; 0]`
|
||||
--> $DIR/impl-unused-tps.rs:27:1
|
||||
--> $DIR/impl-unused-tps.rs:28:1
|
||||
|
|
||||
LL | impl<T> Foo<T> for [isize;0] {
|
||||
| ---------------------------- first implementation here
|
||||
LL | impl<T> Foo<T> for [isize; 0] {
|
||||
| ----------------------------- first implementation here
|
||||
...
|
||||
LL | impl<T,U> Foo<T> for U {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]`
|
||||
LL | impl<T, U> Foo<T> for U {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]`
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `([isize; 0], _): Sized`
|
||||
error[E0119]: conflicting implementations of trait `Bar`
|
||||
--> $DIR/impl-unused-tps.rs:40:1
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`impl_unused_tps`)
|
||||
note: required for `([isize; 0], _)` to implement `Bar`
|
||||
--> $DIR/impl-unused-tps.rs:31:11
|
||||
LL | impl<T, U> Bar for T {
|
||||
| -------------------- first implementation here
|
||||
...
|
||||
LL | / impl<T, U> Bar for T
|
||||
LL | | where
|
||||
LL | | T: Bar<Out = U>,
|
||||
| |____________________^ conflicting implementation
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]`
|
||||
--> $DIR/impl-unused-tps.rs:49:1
|
||||
|
|
||||
LL | impl<T,U> Bar for T {
|
||||
| - ^^^ ^
|
||||
| |
|
||||
| unsatisfied trait bound introduced here
|
||||
= note: 126 redundant requirements hidden
|
||||
= note: required for `([isize; 0], _)` to implement `Bar`
|
||||
LL | impl<T> Foo<T> for [isize; 0] {
|
||||
| ----------------------------- first implementation here
|
||||
...
|
||||
LL | / impl<T, U, V> Foo<T> for T
|
||||
LL | | where
|
||||
LL | | (T, U): Bar<Out = V>,
|
||||
| |_________________________^ conflicting implementation for `[isize; 0]`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]`
|
||||
--> $DIR/impl-unused-tps.rs:61:1
|
||||
|
|
||||
LL | impl<T> Foo<T> for [isize; 0] {
|
||||
| ----------------------------- first implementation here
|
||||
...
|
||||
LL | / impl<T, U, V> Foo<(T, U)> for T
|
||||
LL | | where
|
||||
LL | | (T, U): Bar<Out = V>,
|
||||
| |_________________________^ conflicting implementation for `[isize; 0]`
|
||||
|
||||
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/impl-unused-tps.rs:15:8
|
||||
--> $DIR/impl-unused-tps.rs:13:9
|
||||
|
|
||||
LL | impl<T,U> Foo<T> for [isize;1] {
|
||||
LL | impl<T, U> Foo<T> for [isize; 1] {
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/impl-unused-tps.rs:31:8
|
||||
--> $DIR/impl-unused-tps.rs:32:9
|
||||
|
|
||||
LL | impl<T,U> Bar for T {
|
||||
LL | impl<T, U> Bar for T {
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/impl-unused-tps.rs:39:8
|
||||
--> $DIR/impl-unused-tps.rs:40:9
|
||||
|
|
||||
LL | impl<T,U> Bar for T
|
||||
LL | impl<T, U> Bar for T
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/impl-unused-tps.rs:47:8
|
||||
--> $DIR/impl-unused-tps.rs:49:9
|
||||
|
|
||||
LL | impl<T,U,V> Foo<T> for T
|
||||
LL | impl<T, U, V> Foo<T> for T
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/impl-unused-tps.rs:47:10
|
||||
--> $DIR/impl-unused-tps.rs:49:12
|
||||
|
|
||||
LL | impl<T,U,V> Foo<T> for T
|
||||
LL | impl<T, U, V> Foo<T> for T
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0119, E0207, E0275.
|
||||
Some errors have detailed explanations: E0119, E0207.
|
||||
For more information about an error, try `rustc --explain E0119`.
|
||||
|
@ -1,12 +1,8 @@
|
||||
// Regression test for #48728, an ICE that occurred computing
|
||||
// coherence "help" information.
|
||||
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[next] check-pass
|
||||
|
||||
#[derive(Clone)] //[current]~ ERROR conflicting implementations of trait `Clone`
|
||||
//@ check-pass
|
||||
#[derive(Clone)]
|
||||
struct Node<T: ?Sized>(Box<T>);
|
||||
|
||||
impl<T: Clone + ?Sized> Clone for Node<[T]> {
|
||||
|
@ -1,4 +1,4 @@
|
||||
//@ known-bug: #118987
|
||||
// regression test for #118987
|
||||
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
|
||||
|
||||
trait Assoc {
|
||||
@ -15,3 +15,5 @@ trait Foo {}
|
||||
|
||||
impl Foo for <u8 as Assoc>::Output {}
|
||||
impl Foo for <u16 as Assoc>::Output {}
|
||||
//~^ ERROR the trait bound `u16: Assoc` is not satisfied
|
||||
fn main() {}
|
@ -0,0 +1,21 @@
|
||||
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/default-impl-normalization-ambig-2.rs:2:12
|
||||
|
|
||||
LL | #![feature(specialization)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
|
||||
= help: consider using `min_specialization` instead, which is more stable and complete
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0277]: the trait bound `u16: Assoc` is not satisfied
|
||||
--> $DIR/default-impl-normalization-ambig-2.rs:17:14
|
||||
|
|
||||
LL | impl Foo for <u16 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Assoc` is not implemented for `u16`
|
||||
|
|
||||
= help: the trait `Assoc` is implemented for `u8`
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -1,5 +1,5 @@
|
||||
//@ known-bug: #74299
|
||||
#![feature(specialization)]
|
||||
// regression test for #73299.
|
||||
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
|
||||
|
||||
trait X {
|
||||
type U;
|
||||
@ -18,6 +18,7 @@ trait Y {
|
||||
|
||||
impl Y for <() as X>::U {}
|
||||
impl Y for <i32 as X>::U {}
|
||||
//~^ ERROR conflicting implementations of trait `Y` for type `<() as X>::U`
|
||||
|
||||
fn main() {
|
||||
().f().g();
|
@ -0,0 +1,21 @@
|
||||
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/default-item-normalization-ambig-1.rs:2:12
|
||||
|
|
||||
LL | #![feature(specialization)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
|
||||
= help: consider using `min_specialization` instead, which is more stable and complete
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Y` for type `<() as X>::U`
|
||||
--> $DIR/default-item-normalization-ambig-1.rs:20:1
|
||||
|
|
||||
LL | impl Y for <() as X>::U {}
|
||||
| ----------------------- first implementation here
|
||||
LL | impl Y for <i32 as X>::U {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<() as X>::U`
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -71,7 +71,8 @@ impl<T: Clone> Redundant for T {
|
||||
}
|
||||
|
||||
default impl Redundant for i32 {
|
||||
fn redundant(&self) {} //~ ERROR E0520
|
||||
fn redundant(&self) {}
|
||||
//~^ ERROR `redundant` specializes an item from a parent `impl`, but that item is not marked `default`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,12 @@
|
||||
error[E0119]: conflicting implementations of trait `Overlap` for type `u32`
|
||||
--> $DIR/specialization-default-items-drop-coherence.rs:26:1
|
||||
|
|
||||
LL | impl Overlap for u32 {
|
||||
| -------------------- first implementation here
|
||||
...
|
||||
LL | impl Overlap for <u32 as Default>::Id {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -1,5 +1,5 @@
|
||||
error[E0119]: conflicting implementations of trait `Overlap` for type `u32`
|
||||
--> $DIR/specialization-default-items-drop-coherence.rs:29:1
|
||||
--> $DIR/specialization-default-items-drop-coherence.rs:26:1
|
||||
|
|
||||
LL | impl Overlap for u32 {
|
||||
| -------------------- first implementation here
|
||||
|
@ -1,8 +1,5 @@
|
||||
//@ revisions: classic coherence next
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[coherence] compile-flags: -Znext-solver=coherence
|
||||
//@[classic] check-pass
|
||||
//@[classic] known-bug: #105782
|
||||
|
||||
// Should fail. Default items completely drop candidates instead of ambiguity,
|
||||
// which is unsound during coherence, since coherence requires completeness.
|
||||
@ -27,8 +24,7 @@ impl Overlap for u32 {
|
||||
}
|
||||
|
||||
impl Overlap for <u32 as Default>::Id {
|
||||
//[coherence]~^ ERROR conflicting implementations of trait `Overlap` for type `u32`
|
||||
//[next]~^^ ERROR conflicting implementations of trait `Overlap` for type `u32`
|
||||
//~^ ERROR conflicting implementations of trait `Overlap` for type `u32`
|
||||
type Assoc = Box<usize>;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/specialization-overlap-projection.rs:10:12
|
||||
--> $DIR/specialization-overlap-projection.rs:4:12
|
||||
|
|
||||
LL | #![feature(specialization)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
@ -8,5 +8,23 @@ LL | #![feature(specialization)]
|
||||
= help: consider using `min_specialization` instead, which is more stable and complete
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:19:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
LL | impl Foo for <u8 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:21:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
...
|
||||
LL | impl Foo for <u16 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/specialization-overlap-projection.rs:10:12
|
||||
--> $DIR/specialization-overlap-projection.rs:4:12
|
||||
|
|
||||
LL | #![feature(specialization)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
@ -9,7 +9,7 @@ LL | #![feature(specialization)]
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:25:1
|
||||
--> $DIR/specialization-overlap-projection.rs:19:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
@ -17,7 +17,7 @@ LL | impl Foo for <u8 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:27:1
|
||||
--> $DIR/specialization-overlap-projection.rs:21:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
|
@ -1,13 +1,8 @@
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@[current] check-pass
|
||||
|
||||
// Test that impls on projected self types can resolve overlap, even when the
|
||||
// projections involve specialization, so long as the associated type is
|
||||
// provided by the most specialized impl.
|
||||
|
||||
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
|
||||
#![feature(specialization)]
|
||||
//~^ WARN the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
|
||||
trait Assoc {
|
||||
type Output;
|
||||
@ -23,8 +18,8 @@ impl Assoc for u16 { type Output = u16; }
|
||||
trait Foo {}
|
||||
impl Foo for u32 {}
|
||||
impl Foo for <u8 as Assoc>::Output {}
|
||||
//[next]~^ ERROR conflicting implementations of trait `Foo` for type `u32`
|
||||
//~^ ERROR conflicting implementations of trait `Foo` for type `u32`
|
||||
impl Foo for <u16 as Assoc>::Output {}
|
||||
//[next]~^ ERROR conflicting implementations of trait `Foo` for type `u32`
|
||||
//~^ ERROR conflicting implementations of trait `Foo` for type `u32`
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,30 @@
|
||||
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/specialization-overlap-projection.rs:4:12
|
||||
|
|
||||
LL | #![feature(specialization)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
|
||||
= help: consider using `min_specialization` instead, which is more stable and complete
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:20:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
LL | impl Foo for <u8 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `u32`
|
||||
--> $DIR/specialization-overlap-projection.rs:22:1
|
||||
|
|
||||
LL | impl Foo for u32 {}
|
||||
| ---------------- first implementation here
|
||||
...
|
||||
LL | impl Foo for <u16 as Assoc>::Output {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32`
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
@ -8,5 +8,5 @@ fn mk_opaque() -> OpaqueType {
|
||||
trait AnotherTrait {}
|
||||
impl<T: Send> AnotherTrait for T {}
|
||||
impl AnotherTrait for OpaqueType {}
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait`
|
||||
fn main() {}
|
||||
|
@ -1,10 +1,10 @@
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait`
|
||||
--> $DIR/issue-83613.rs:10:1
|
||||
|
|
||||
LL | impl<T: Send> AnotherTrait for T {}
|
||||
| -------------------------------- first implementation here
|
||||
LL | impl AnotherTrait for OpaqueType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
||||
struct A<T>(B<T>);
|
||||
//~^ ERROR recursive types `A` and `B` have infinite size
|
||||
//~| ERROR `T` is only used recursively
|
||||
@ -7,5 +6,5 @@ struct B<T>(A<A<T>>);
|
||||
trait Foo {}
|
||||
impl<T> Foo for T where T: Send {}
|
||||
impl Foo for B<u8> {}
|
||||
|
||||
//~^ ERROR conflicting implementations of trait `Foo` for type `B<u8>`
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0072]: recursive types `A` and `B` have infinite size
|
||||
--> $DIR/issue-105231.rs:2:1
|
||||
--> $DIR/issue-105231.rs:1:1
|
||||
|
|
||||
LL | struct A<T>(B<T>);
|
||||
| ^^^^^^^^^^^ ---- recursive without indirection
|
||||
@ -16,7 +16,7 @@ LL ~ struct B<T>(Box<A<A<T>>>);
|
||||
|
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/issue-105231.rs:2:15
|
||||
--> $DIR/issue-105231.rs:1:15
|
||||
|
|
||||
LL | struct A<T>(B<T>);
|
||||
| - ^
|
||||
@ -27,7 +27,7 @@ LL | struct A<T>(B<T>);
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error: type parameter `T` is only used recursively
|
||||
--> $DIR/issue-105231.rs:5:17
|
||||
--> $DIR/issue-105231.rs:4:17
|
||||
|
|
||||
LL | struct B<T>(A<A<T>>);
|
||||
| - ^
|
||||
@ -37,16 +37,18 @@ LL | struct B<T>(A<A<T>>);
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
= note: all type parameters must be used in a non-recursive way in order to constrain their variance
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
||||
error[E0119]: conflicting implementations of trait `Foo` for type `B<u8>`
|
||||
--> $DIR/issue-105231.rs:8:1
|
||||
|
|
||||
LL | impl<T> Foo for T where T: Send {}
|
||||
| ------------------------------- first implementation here
|
||||
LL | impl Foo for B<u8> {}
|
||||
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `B<u8>`
|
||||
|
|
||||
= note: overflow evaluating the requirement `B<u8>: Send`
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`)
|
||||
note: required because it appears within the type `B<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<u8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
|
||||
--> $DIR/issue-105231.rs:5:8
|
||||
|
|
||||
LL | struct B<T>(A<A<T>>);
|
||||
| ^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0072, E0275.
|
||||
Some errors have detailed explanations: E0072, E0119.
|
||||
For more information about an error, try `rustc --explain E0072`.
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This must fail coherence.
|
||||
//
|
||||
// Getting this to pass was fairly difficult, so here's an explanation
|
||||
// of what's happening:
|
||||
// of what was previously happening for this to compile:
|
||||
//
|
||||
// Normalizing projections currently tries to replace them with inference variables
|
||||
// while emitting a nested `Projection` obligation. This cannot be done if the projection
|
||||
@ -17,12 +17,6 @@
|
||||
// that to `i32`. We then try to unify `i32` from `impl1` with `u32` from `impl2` which fails,
|
||||
// causing coherence to consider these two impls distinct.
|
||||
|
||||
//@ revisions: classic next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
//@[classic] known-bug: #102048
|
||||
//@[classic] check-pass
|
||||
|
||||
pub trait Trait<T> {}
|
||||
|
||||
pub trait WithAssoc1<'a> {
|
||||
@ -42,7 +36,7 @@ where
|
||||
|
||||
// impl 2
|
||||
impl<T, U> Trait<for<'a> fn(<U as WithAssoc1<'a>>::Assoc, u32)> for (T, U) where
|
||||
U: for<'a> WithAssoc1<'a> //[next]~^ ERROR conflicting implementations of trait
|
||||
U: for<'a> WithAssoc1<'a> //~^ ERROR conflicting implementations of trait
|
||||
{
|
||||
}
|
||||
|
||||
|
16
tests/ui/traits/next-solver/coherence/issue-102048.stderr
Normal file
16
tests/ui/traits/next-solver/coherence/issue-102048.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
error[E0119]: conflicting implementations of trait `Trait<for<'a> fn(<_ as WithAssoc1<'a>>::Assoc, <_ as WithAssoc2<'a>>::Assoc)>` for type `(_, _)`
|
||||
--> $DIR/issue-102048.rs:38:1
|
||||
|
|
||||
LL | / impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
|
||||
LL | | where
|
||||
LL | | T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
|
||||
LL | | U: for<'a> WithAssoc2<'a>,
|
||||
| |______________________________- first implementation here
|
||||
...
|
||||
LL | / impl<T, U> Trait<for<'a> fn(<U as WithAssoc1<'a>>::Assoc, u32)> for (T, U) where
|
||||
LL | | U: for<'a> WithAssoc1<'a>
|
||||
| |_____________________________^ conflicting implementation for `(_, _)`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user