-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Suggest using type args directly instead of equality constraint #122591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use rustc_hir::def::{DefKind, Res}; | |
use rustc_hir::def_id::{DefId, LocalDefId}; | ||
use rustc_infer::traits::FulfillmentError; | ||
use rustc_middle::query::Key; | ||
use rustc_middle::ty::GenericParamDefKind; | ||
use rustc_middle::ty::{self, suggest_constraining_type_param}; | ||
use rustc_middle::ty::{AdtDef, Ty, TyCtxt, TypeVisitableExt}; | ||
use rustc_middle::ty::{Binder, TraitRef}; | ||
|
@@ -1200,12 +1201,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |
/// Emits an error regarding forbidden type binding associations | ||
pub fn prohibit_assoc_item_binding( | ||
tcx: TyCtxt<'_>, | ||
span: Span, | ||
segment: Option<(&hir::PathSegment<'_>, Span)>, | ||
binding: &hir::TypeBinding<'_>, | ||
segment: Option<(DefId, &hir::PathSegment<'_>, Span)>, | ||
) -> ErrorGuaranteed { | ||
tcx.dcx().emit_err(AssocTypeBindingNotAllowed { | ||
span, | ||
fn_trait_expansion: if let Some((segment, span)) = segment | ||
let mut err = tcx.dcx().create_err(AssocTypeBindingNotAllowed { | ||
span: binding.span, | ||
fn_trait_expansion: if let Some((_, segment, span)) = segment | ||
&& segment.args().parenthesized == hir::GenericArgsParentheses::ParenSugar | ||
{ | ||
Some(ParenthesizedFnTraitExpansion { | ||
|
@@ -1215,7 +1216,109 @@ pub fn prohibit_assoc_item_binding( | |
} else { | ||
None | ||
}, | ||
}) | ||
}); | ||
|
||
// Emit a suggestion to turn the assoc item binding into a generic arg | ||
// if the relevant item has a generic param whose name matches the binding name; | ||
// otherwise suggest the removal of the binding. | ||
if let Some((def_id, segment, _)) = segment | ||
&& segment.args().parenthesized == hir::GenericArgsParentheses::No | ||
&& let hir::TypeBindingKind::Equality { term } = binding.kind | ||
{ | ||
// Suggests removal of the offending binding | ||
let suggest_removal = |e: &mut Diag<'_>| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: I still need to review this function. I suspect it can be simplified by a lot but let's see. |
||
let bindings = segment.args().bindings; | ||
let args = segment.args().args; | ||
let binding_span = binding.span; | ||
|
||
// Compute the span to remove based on the position | ||
// of the binding. We do that as follows: | ||
// 1. Find the index of the binding in the list of bindings | ||
// 2. Locate the spans preceding and following the binding. | ||
// If it's the first binding the preceding span would be | ||
// that of the last arg | ||
// 3. Using this information work out whether the span | ||
// to remove will start from the end of the preceding span, | ||
// the start of the next span or will simply be the | ||
// span encomassing everything within the generics brackets | ||
|
||
let Some(binding_index) = bindings.iter().position(|b| b.hir_id == binding.hir_id) | ||
else { | ||
bug!("a type binding exists but its HIR ID not found in generics"); | ||
}; | ||
|
||
let preceding_span = if binding_index > 0 { | ||
Some(bindings[binding_index - 1].span) | ||
} else { | ||
args.last().map(|a| a.span()) | ||
}; | ||
|
||
let next_span = if binding_index < bindings.len() - 1 { | ||
Some(bindings[binding_index + 1].span) | ||
} else { | ||
None | ||
}; | ||
|
||
let removal_span = match (preceding_span, next_span) { | ||
(Some(prec), _) => binding_span.with_lo(prec.hi()), | ||
(None, Some(next)) => binding_span.with_hi(next.lo()), | ||
(None, None) => { | ||
let Some(generics_span) = segment.args().span_ext() else { | ||
bug!("a type binding exists but generic span is empty"); | ||
}; | ||
|
||
generics_span | ||
} | ||
}; | ||
|
||
// Now emit the suggestion | ||
if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) { | ||
e.span_suggestion_verbose( | ||
removal_span, | ||
"consider removing this type binding", | ||
suggestion, | ||
Applicability::MaybeIncorrect, | ||
); | ||
} | ||
}; | ||
|
||
// Suggest replacing the associated item binding with a generic argument. | ||
// i.e., replacing `<..., T = A, ...>` with `<..., A, ...>`. | ||
let suggest_direct_use = |e: &mut Diag<'_>, sp: Span| { | ||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(sp) { | ||
gurry marked this conversation as resolved.
Show resolved
Hide resolved
|
||
e.span_suggestion_verbose( | ||
binding.span, | ||
format!("to use `{snippet}` as a generic argument specify it directly"), | ||
snippet, | ||
Applicability::MaybeIncorrect, | ||
); | ||
} | ||
}; | ||
|
||
// Check if the type has a generic param with the | ||
// same name as the assoc type name in type binding | ||
let generics = tcx.generics_of(def_id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
fn f<T>() {
let _: T<X = ()>;
} If it does, we need to add some checks before trying to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this does not ICE |
||
let matching_param = | ||
generics.params.iter().find(|p| p.name.as_str() == binding.ident.as_str()); | ||
|
||
// Now emit the appropriate suggestion | ||
if let Some(matching_param) = matching_param { | ||
match (&matching_param.kind, term) { | ||
(GenericParamDefKind::Type { .. }, hir::Term::Ty(ty)) => { | ||
suggest_direct_use(&mut err, ty.span); | ||
} | ||
(GenericParamDefKind::Const { .. }, hir::Term::Const(c)) => { | ||
let span = tcx.hir().span(c.hir_id); | ||
suggest_direct_use(&mut err, span); | ||
} | ||
_ => suggest_removal(&mut err), | ||
} | ||
} else { | ||
suggest_removal(&mut err); | ||
} | ||
} | ||
|
||
err.emit() | ||
} | ||
|
||
pub(crate) fn fn_trait_to_string( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/issue-102335-ty.rs:2:17 | ||
| | ||
LL | type A: S<C<i32 = u32> = ()>; | ||
LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint | ||
| ^^^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint | ||
| ~~~~~~~~~~~ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/issue-102335-ty.rs:2:17 | ||
| | ||
LL | type A: S<C<i32 = u32> = ()>; | ||
LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint | ||
| ^^^^^^^^^ associated type not allowed here | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
help: consider removing this type binding | ||
| | ||
LL | type A: S<C<i32 = u32> = ()>; // Just one erroneous equality constraint | ||
| ~~~~~~~~~~~ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/issue-102335-ty.rs:8:17 | ||
| | ||
LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints | ||
| ^^^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints | ||
| ~~~~~~~~~~ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/issue-102335-ty.rs:8:17 | ||
| | ||
LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints | ||
| ^^^^^^^^^ associated type not allowed here | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
help: consider removing this type binding | ||
| | ||
LL | type A: S<C<i32 = u32, X = i32> = ()>; // More than one erroneous equality constraints | ||
| ~~~~~~~~~~ | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0229`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,125 @@ | ||
// Test equality constraints on associated types. Check we get an error when an | ||
// equality constraint is used in a qualified path. | ||
// equality constraint is used in an invalid context | ||
|
||
pub trait Foo { | ||
struct Bar; | ||
struct Qux; | ||
|
||
// Tests for a a non generic trait | ||
pub trait Tr1 { | ||
type A; | ||
fn boo(&self) -> <Self as Foo>::A; | ||
fn boo(&self) -> <Self as Tr1>::A; | ||
} | ||
|
||
struct Bar; | ||
|
||
impl Foo for isize { | ||
impl Tr1 for isize { | ||
type A = usize; | ||
fn boo(&self) -> usize { 42 } | ||
} | ||
|
||
fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {} | ||
// Test for when the assoc type is | ||
// specified as an equality constraint | ||
impl Tr1<A = usize> for usize { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR not all trait items implemented, missing: `A` | ||
fn boo(&self) -> usize { 42 } | ||
} | ||
|
||
// Test for a wronngly used equality constraint in a func arg | ||
fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {} | ||
//~^ ERROR associated type bindings are not allowed here | ||
|
||
|
||
|
||
// Tests for a generic trait | ||
trait Tr2<T1, T2, T3> { | ||
} | ||
|
||
// Test for when wrongly specifed equality constraint's ident | ||
// matches some generic param's ident | ||
// (Note: E0229 is emitted only for the first erroneous equality | ||
// constraint (T2) not for any subequent ones (e.g. T3)) | ||
impl Tr2<i32, T2 = Qux, T3 = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
// Test for when equality constraint's ident matches a | ||
// generic param's ident but has different case | ||
impl Tr2<i32, t2 = Qux, T3 = usize> for Qux { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches none of the generic param idents | ||
impl Tr2<i32, X = Qux, Y = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
// Test for when the term in equality constraint is itself generic | ||
struct GenericTerm<T> { _t: T } | ||
impl Tr2<i32, Qux, T3 = GenericTerm<i32>> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 2 generic arguments were supplied | ||
} | ||
|
||
|
||
|
||
// Tests for a trait with a const param | ||
trait Tr3<const N: i32, T2, T3> { | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches the const param's ident | ||
// (Deliberately spread over multiple lines to test that | ||
// our suggestion spans are kosher in the face of such formatting) | ||
impl Tr3<N | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR associated const equality is incomplete | ||
//~| ERROR trait takes 3 generic arguments but 0 generic arguments were supplied | ||
= 42, T2 = Qux, T3 = usize> for Bar { | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches the const param's ident but has a different case | ||
impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR associated const equality is incomplete | ||
//~| ERROR trait takes 3 generic arguments but 0 generic arguments were supplied | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches the const param ident but the constraint is a type arg | ||
impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR trait takes 3 generic arguments but 0 generic arguments were supplied | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches a type param ident but the constraint is a const arg | ||
impl Tr3<42, T2 = 42, T3 = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR associated const equality is incomplete | ||
//~| ERROR trait takes 3 generic arguments but 1 generic argument was supplied | ||
} | ||
|
||
// Test for when equality constraint's ident | ||
// matches none of the param idents | ||
impl Tr3<X = 42, Y = Qux, Z = usize> for Bar { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR associated const equality is incomplete | ||
//~| ERROR trait takes 3 generic arguments but 0 generic arguments were supplied | ||
} | ||
|
||
|
||
|
||
// Test for the case when lifetimes are present | ||
struct St<'a, T> { v: &'a T } | ||
|
||
impl<'a, T> St<'a , T = Qux> { | ||
//~^ ERROR associated type bindings are not allowed here | ||
//~| ERROR struct takes 1 generic argument but 0 generic arguments were supplied | ||
} | ||
|
||
|
||
pub fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,365 @@ | ||
error[E0658]: associated const equality is incomplete | ||
--> $DIR/associated-types-eq-2.rs:76:10 | ||
| | ||
LL | impl Tr3<N | ||
| __________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | = 42, T2 = Qux, T3 = usize> for Bar { | ||
| |____^ | ||
| | ||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information | ||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: associated const equality is incomplete | ||
--> $DIR/associated-types-eq-2.rs:85:10 | ||
| | ||
LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux { | ||
| ^^^^^^ | ||
| | ||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information | ||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: associated const equality is incomplete | ||
--> $DIR/associated-types-eq-2.rs:100:14 | ||
| | ||
LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information | ||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: associated const equality is incomplete | ||
--> $DIR/associated-types-eq-2.rs:108:10 | ||
| | ||
LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar { | ||
| ^^^^^^ | ||
| | ||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information | ||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:16:30 | ||
--> $DIR/associated-types-eq-2.rs:20:10 | ||
| | ||
LL | impl Tr1<A = usize> for usize { | ||
| ^^^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr1<A = usize> for usize { | ||
| ~~~~~~~~~~~ | ||
|
||
error[E0046]: not all trait items implemented, missing: `A` | ||
--> $DIR/associated-types-eq-2.rs:20:1 | ||
| | ||
LL | type A; | ||
| ------ `A` from trait | ||
... | ||
LL | impl Tr1<A = usize> for usize { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `A` in implementation | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:27:31 | ||
| | ||
LL | fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {} | ||
| ^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | fn baz<I: Tr1>(_x: &<I as Tr1<A=Bar>>::A) {} | ||
| ~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied | ||
--> $DIR/associated-types-eq-2.rs:40:6 | ||
| | ||
LL | impl Tr2<i32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^ --- supplied 1 generic argument | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:33:7 | ||
| | ||
LL | trait Tr2<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr2<i32, T2, T3, T2 = Qux, T3 = usize> for Bar { | ||
| ++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:40:15 | ||
| | ||
LL | impl Tr2<i32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `Qux` as a generic argument specify it directly | ||
| | ||
LL | impl Tr2<i32, Qux, T3 = usize> for Bar { | ||
| ~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied | ||
--> $DIR/associated-types-eq-2.rs:47:6 | ||
| | ||
LL | impl Tr2<i32, t2 = Qux, T3 = usize> for Qux { | ||
| ^^^ --- supplied 1 generic argument | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:33:7 | ||
| | ||
LL | trait Tr2<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr2<i32, T2, T3, t2 = Qux, T3 = usize> for Qux { | ||
| ++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:47:15 | ||
| | ||
LL | impl Tr2<i32, t2 = Qux, T3 = usize> for Qux { | ||
| ^^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr2<i32, t2 = Qux, T3 = usize> for Qux { | ||
| ~~~~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied | ||
--> $DIR/associated-types-eq-2.rs:54:6 | ||
| | ||
LL | impl Tr2<i32, X = Qux, Y = usize> for Bar { | ||
| ^^^ --- supplied 1 generic argument | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:33:7 | ||
| | ||
LL | trait Tr2<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr2<i32, T2, T3, X = Qux, Y = usize> for Bar { | ||
| ++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:54:15 | ||
| | ||
LL | impl Tr2<i32, X = Qux, Y = usize> for Bar { | ||
| ^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr2<i32, X = Qux, Y = usize> for Bar { | ||
| ~~~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 2 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:61:6 | ||
| | ||
LL | impl Tr2<i32, Qux, T3 = GenericTerm<i32>> for Bar { | ||
| ^^^ --- --- supplied 2 generic arguments | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `T1`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:33:7 | ||
| | ||
LL | trait Tr2<T1, T2, T3> { | ||
| ^^^ -- -- -- | ||
help: add missing generic argument | ||
| | ||
LL | impl Tr2<i32, Qux, T3, T3 = GenericTerm<i32>> for Bar { | ||
| ++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:61:20 | ||
| | ||
LL | impl Tr2<i32, Qux, T3 = GenericTerm<i32>> for Bar { | ||
| ^^^^^^^^^^^^^^^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `GenericTerm<i32>` as a generic argument specify it directly | ||
| | ||
LL | impl Tr2<i32, Qux, GenericTerm<i32>> for Bar { | ||
| ~~~~~~~~~~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:76:6 | ||
| | ||
LL | impl Tr3<N | ||
| ^^^ expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `N`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:69:7 | ||
| | ||
LL | trait Tr3<const N: i32, T2, T3> { | ||
| ^^^ ------------ -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<N, T2, T3, N | ||
| ++++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:76:10 | ||
| | ||
LL | impl Tr3<N | ||
| __________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | = 42, T2 = Qux, T3 = usize> for Bar { | ||
| |____^ associated type not allowed here | ||
| | ||
help: to use `42` as a generic argument specify it directly | ||
| | ||
LL | impl Tr3<42, T2 = Qux, T3 = usize> for Bar { | ||
| ~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:85:6 | ||
| | ||
LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux { | ||
| ^^^ expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `N`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:69:7 | ||
| | ||
LL | trait Tr3<const N: i32, T2, T3> { | ||
| ^^^ ------------ -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<N, T2, T3, n = 42, T2 = Qux, T3 = usize> for Qux { | ||
| ++++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:85:10 | ||
| | ||
LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux { | ||
| ^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr3<n = 42, T2 = Qux, T3 = usize> for Qux { | ||
| ~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:93:6 | ||
| | ||
LL | impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^ expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `N`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:69:7 | ||
| | ||
LL | trait Tr3<const N: i32, T2, T3> { | ||
| ^^^ ------------ -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<N, T2, T3, N = u32, T2 = Qux, T3 = usize> for Bar { | ||
| ++++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:93:10 | ||
| | ||
LL | impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar { | ||
| ^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr3<N = u32, T2 = Qux, T3 = usize> for Bar { | ||
| ~~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 1 generic argument was supplied | ||
--> $DIR/associated-types-eq-2.rs:100:6 | ||
| | ||
LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { | ||
| ^^^ -- supplied 1 generic argument | ||
| | | ||
| expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `N`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:69:7 | ||
| | ||
LL | trait Tr3<const N: i32, T2, T3> { | ||
| ^^^ ------------ -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<42, T2, T3, T2 = 42, T3 = usize> for Bar { | ||
| ++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:100:14 | ||
| | ||
LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { | ||
| ^^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr3<42, T2 = 42, T3 = usize> for Bar { | ||
| ~~~~~~~~~ | ||
|
||
error[E0107]: trait takes 3 generic arguments but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:108:6 | ||
| | ||
LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar { | ||
| ^^^ expected 3 generic arguments | ||
| | ||
note: trait defined here, with 3 generic parameters: `N`, `T2`, `T3` | ||
--> $DIR/associated-types-eq-2.rs:69:7 | ||
| | ||
LL | trait Tr3<const N: i32, T2, T3> { | ||
| ^^^ ------------ -- -- | ||
help: add missing generic arguments | ||
| | ||
LL | impl Tr3<N, T2, T3, X = 42, Y = Qux, Z = usize> for Bar { | ||
| ++++++++++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:108:10 | ||
| | ||
LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar { | ||
| ^^^^^^ associated type not allowed here | ||
| | ||
help: consider removing this type binding | ||
| | ||
LL | impl Tr3<X = 42, Y = Qux, Z = usize> for Bar { | ||
| ~~~~~~~ | ||
|
||
error[E0107]: struct takes 1 generic argument but 0 generic arguments were supplied | ||
--> $DIR/associated-types-eq-2.rs:119:13 | ||
| | ||
LL | impl<'a, T> St<'a , T = Qux> { | ||
| ^^ expected 1 generic argument | ||
| | ||
note: struct defined here, with 1 generic parameter: `T` | ||
--> $DIR/associated-types-eq-2.rs:117:8 | ||
| | ||
LL | struct St<'a, T> { v: &'a T } | ||
| ^^ - | ||
help: add missing generic argument | ||
| | ||
LL | impl<'a, T> St<'a, T , T = Qux> { | ||
| +++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/associated-types-eq-2.rs:119:21 | ||
| | ||
LL | impl<'a, T> St<'a , T = Qux> { | ||
| ^^^^^^^ associated type not allowed here | ||
| | ||
help: to use `Qux` as a generic argument specify it directly | ||
| | ||
LL | fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {} | ||
| ^^^^^ associated type not allowed here | ||
LL | impl<'a, T> St<'a , Qux> { | ||
| ~~~ | ||
|
||
error: aborting due to 1 previous error | ||
error: aborting due to 27 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0229`. | ||
Some errors have detailed explanations: E0046, E0107, E0229, E0658. | ||
For more information about an error, try `rustc --explain E0046`. |
Uh oh!
There was an error while loading. Please reload this page.