diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ddabea700d374..e493f41aed375 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -19,7 +19,7 @@ use super::{ SelectionResult, TraitObligation, TraitQueryMode, }; -use crate::infer::{InferCtxt, InferOk, TypeFreshener}; +use crate::infer::{InferCtxt, InferOk}; use crate::traits::error_reporting::TypeErrCtxtExt; use crate::traits::project::ProjectAndUnifyResult; use crate::traits::project::ProjectionCacheKeyExt; @@ -95,13 +95,6 @@ impl IntercrateAmbiguityCause { pub struct SelectionContext<'cx, 'tcx> { infcx: &'cx InferCtxt<'tcx>, - /// Freshener used specifically for entries on the obligation - /// stack. This ensures that all entries on the stack at one time - /// will have the same set of placeholder entries, which is - /// important for checking for trait bounds that recursively - /// require themselves. - freshener: TypeFreshener<'cx, 'tcx>, - /// During coherence we have to assume that other crates may add /// additional impls which we currently don't know about. /// @@ -217,7 +210,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> { SelectionContext { infcx, - freshener: infcx.freshener_keep_static(), intercrate: false, intercrate_ambiguity_causes: None, query_mode: TraitQueryMode::Standard, @@ -2251,7 +2243,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { previous_stack: TraitObligationStackList<'o, 'tcx>, obligation: &'o TraitObligation<'tcx>, ) -> TraitObligationStack<'o, 'tcx> { - let fresh_trait_pred = obligation.predicate.fold_with(&mut self.freshener); + let fresh_trait_pred = + obligation.predicate.fold_with(&mut self.infcx.freshener_keep_static()); let dfn = previous_stack.cache.next_dfn(); let depth = previous_stack.depth() + 1; diff --git a/src/test/ui/coherence/issue-100191-2.rs b/src/test/ui/coherence/issue-100191-2.rs index 1c8316f87fa07..99a52c1640a77 100644 --- a/src/test/ui/coherence/issue-100191-2.rs +++ b/src/test/ui/coherence/issue-100191-2.rs @@ -1,5 +1,3 @@ -//~ ERROR overflow evaluating the requirement `T: Trait<_>` - #![feature(specialization, with_negative_coherence)] #![allow(incomplete_features)] @@ -8,5 +6,6 @@ pub trait Trait {} default impl Trait for U {} impl Trait<::Item> for T {} +//~^ ERROR conflicting implementations of trait `Trait<_>` fn main() {} diff --git a/src/test/ui/coherence/issue-100191-2.stderr b/src/test/ui/coherence/issue-100191-2.stderr index d50c220bcfd48..dd11883fa9f56 100644 --- a/src/test/ui/coherence/issue-100191-2.stderr +++ b/src/test/ui/coherence/issue-100191-2.stderr @@ -1,14 +1,12 @@ -error[E0275]: overflow evaluating the requirement `T: Trait<_>` - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_100191_2`) -note: required for `T` to implement `Trait<_>` - --> $DIR/issue-100191-2.rs:8:20 +error[E0119]: conflicting implementations of trait `Trait<_>` + --> $DIR/issue-100191-2.rs:8:1 | LL | default impl Trait for U {} - | ^^^^^^^^ ^ - = note: 128 redundant requirements hidden - = note: required for `T` to implement `Trait<_>` + | --------------------------------- first implementation here +LL | +LL | impl Trait<::Item> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/issues/issue-69683.rs b/src/test/ui/issues/issue-69683.rs index 7a76e9ef205ff..692e990851985 100644 --- a/src/test/ui/issues/issue-69683.rs +++ b/src/test/ui/issues/issue-69683.rs @@ -27,7 +27,6 @@ where fn main() { let b: [u8; 3] = [0u8; 3]; - 0u16.foo(b); //~ ERROR type annotations needed - //~^ ERROR type annotations needed + 0u16.foo(b); //~ ERROR mismatched types //>::foo(0u16, b); } diff --git a/src/test/ui/issues/issue-69683.stderr b/src/test/ui/issues/issue-69683.stderr index 193de1a35cf1a..c876c162f3ab0 100644 --- a/src/test/ui/issues/issue-69683.stderr +++ b/src/test/ui/issues/issue-69683.stderr @@ -1,43 +1,17 @@ -error[E0284]: type annotations needed - --> $DIR/issue-69683.rs:30:10 +error[E0308]: mismatched types + --> $DIR/issue-69683.rs:30:14 | LL | 0u16.foo(b); - | ^^^ + | --- ^ expected `u8`, found array `[u8; 3]` + | | + | arguments to this function are incorrect | - = note: cannot satisfy `>::Array == [u8; 3]` -help: try using a fully qualified path to specify the expected types +note: associated function defined here + --> $DIR/issue-69683.rs:17:8 | -LL | >::foo(0u16, b); - | +++++++++++++++++++++ ~ - -error[E0283]: type annotations needed - --> $DIR/issue-69683.rs:30:10 - | -LL | 0u16.foo(b); - | ^^^ - | -note: multiple `impl`s satisfying `u8: Element<_>` found - --> $DIR/issue-69683.rs:5:1 - | -LL | impl Element<()> for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl, S> Element<[S; 3]> for T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `Foo::foo` - --> $DIR/issue-69683.rs:15:9 - | -LL | u8: Element, - | ^^^^^^^^^^ required by this bound in `Foo::foo` -LL | { LL | fn foo(self, x: >::Array); - | --- required by a bound in this -help: try using a fully qualified path to specify the expected types - | -LL | >::foo(0u16, b); - | +++++++++++++++++++++ ~ + | ^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0283, E0284. -For more information about an error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/partialeq_help.stderr b/src/test/ui/partialeq_help.stderr index fdff94f425c8a..e1e89c33b29ac 100644 --- a/src/test/ui/partialeq_help.stderr +++ b/src/test/ui/partialeq_help.stderr @@ -5,10 +5,13 @@ LL | a == b; | ^^ no implementation for `&T == T` | = help: the trait `PartialEq` is not implemented for `&T` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn foo(a: &T, b: T) where &T: PartialEq { - | ++++++++++++++++++++++ + = help: the following other types implement trait `PartialEq`: + <&A as PartialEq<&B>> + <&A as PartialEq<&mut B>> + <&mut A as PartialEq<&B>> + <&mut A as PartialEq<&mut B>> + <*const T as PartialEq> + <*mut T as PartialEq> error[E0277]: can't compare `&T` with `T` --> $DIR/partialeq_help.rs:6:7 @@ -17,10 +20,13 @@ LL | a == b; | ^^ no implementation for `&T == T` | = help: the trait `PartialEq` is not implemented for `&T` -help: consider extending the `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn foo2(a: &T, b: T) where &T: PartialEq { - | ++++++++++++++++ + = help: the following other types implement trait `PartialEq`: + <&A as PartialEq<&B>> + <&A as PartialEq<&mut B>> + <&mut A as PartialEq<&B>> + <&mut A as PartialEq<&mut B>> + <*const T as PartialEq> + <*mut T as PartialEq> error: aborting due to 2 previous errors diff --git a/src/test/ui/specialization/issue-45814.rs b/src/test/ui/specialization/issue-45814.rs index 8ee5d3e2e58da..498fa0e5c4eca 100644 --- a/src/test/ui/specialization/issue-45814.rs +++ b/src/test/ui/specialization/issue-45814.rs @@ -1,5 +1,3 @@ -//~ ERROR overflow evaluating the requirement `T: Trait<_>` - #![feature(specialization)] #![allow(incomplete_features)] @@ -8,5 +6,6 @@ pub trait Trait {} default impl Trait for U {} impl Trait<::Item> for T {} +//~^ ERROR conflicting implementations of trait `Trait<_>` fn main() {} diff --git a/src/test/ui/specialization/issue-45814.stderr b/src/test/ui/specialization/issue-45814.stderr index 419345addc2fc..557d974d2cd89 100644 --- a/src/test/ui/specialization/issue-45814.stderr +++ b/src/test/ui/specialization/issue-45814.stderr @@ -1,14 +1,12 @@ -error[E0275]: overflow evaluating the requirement `T: Trait<_>` - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_45814`) -note: required for `T` to implement `Trait<_>` - --> $DIR/issue-45814.rs:8:20 +error[E0119]: conflicting implementations of trait `Trait<_>` + --> $DIR/issue-45814.rs:8:1 | LL | default impl Trait for U {} - | ^^^^^^^^ ^ - = note: 128 redundant requirements hidden - = note: required for `T` to implement `Trait<_>` + | --------------------------------- first implementation here +LL | +LL | impl Trait<::Item> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/traits/issue-18400.rs b/src/test/ui/traits/issue-18400.rs index fdd11512da3a3..92129481abfa2 100644 --- a/src/test/ui/traits/issue-18400.rs +++ b/src/test/ui/traits/issue-18400.rs @@ -22,5 +22,5 @@ fn main() { let bits: &[_] = &[0, 1]; 0.contains(bits); - //~^ ERROR overflow + //~^ ERROR can't call method `contains` on ambiguous numeric type `{integer} } diff --git a/src/test/ui/traits/issue-18400.stderr b/src/test/ui/traits/issue-18400.stderr index 4394e6f7e05fb..d9f37d0a3221f 100644 --- a/src/test/ui/traits/issue-18400.stderr +++ b/src/test/ui/traits/issue-18400.stderr @@ -1,18 +1,14 @@ -error[E0275]: overflow evaluating the requirement `_: Sized` +error[E0689]: can't call method `contains` on ambiguous numeric type `{integer}` --> $DIR/issue-18400.rs:24:7 | LL | 0.contains(bits); | ^^^^^^^^ | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_18400`) -note: required for `{integer}` to implement `Set<&[_]>` - --> $DIR/issue-18400.rs:6:16 +help: you must specify a concrete type for this numeric value, like `i32` | -LL | impl<'a, T, S> Set<&'a [T]> for S where - | ^^^^^^^^^^^^ ^ - = note: 128 redundant requirements hidden - = note: required for `{integer}` to implement `Set<&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[&[_]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]>` +LL | 0_i32.contains(bits); + | ~~~~~ error: aborting due to previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0689`.