Auto merge of #71451 - estebank:suggest-super-trait-constraint, r=nikomatsakis
Suggest adding super trait constraints
This commit is contained in:
commit
750db09fa8
|
@ -15,7 +15,7 @@ use rustc_middle::ty::{
|
|||
self, suggest_constraining_type_param, AdtKind, DefIdTree, Infer, InferTy, ToPredicate, Ty,
|
||||
TyCtxt, TypeFoldable, WithConstness,
|
||||
};
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
||||
use std::fmt;
|
||||
|
||||
|
@ -156,7 +156,7 @@ fn predicate_constraint(generics: &hir::Generics<'_>, pred: String) -> (Span, St
|
|||
(
|
||||
generics.where_clause.span_for_predicates_or_empty_place().shrink_to_hi(),
|
||||
format!(
|
||||
"{} {} ",
|
||||
"{} {}",
|
||||
if !generics.where_clause.predicates.is_empty() { "," } else { " where" },
|
||||
pred,
|
||||
),
|
||||
|
@ -173,7 +173,13 @@ fn suggest_restriction(
|
|||
fn_sig: Option<&hir::FnSig<'_>>,
|
||||
projection: Option<&ty::ProjectionTy<'_>>,
|
||||
trait_ref: ty::PolyTraitRef<'_>,
|
||||
super_traits: Option<(&Ident, &hir::GenericBounds<'_>)>,
|
||||
) {
|
||||
// When we are dealing with a trait, `super_traits` will be `Some`:
|
||||
// Given `trait T: A + B + C {}`
|
||||
// - ^^^^^^^^^ GenericBounds
|
||||
// |
|
||||
// &Ident
|
||||
let span = generics.where_clause.span_for_predicates_or_empty_place();
|
||||
if span.from_expansion() || span.desugaring_kind().is_some() {
|
||||
return;
|
||||
|
@ -262,10 +268,28 @@ fn suggest_restriction(
|
|||
);
|
||||
} else {
|
||||
// Trivial case: `T` needs an extra bound: `T: Bound`.
|
||||
let (sp, sugg) =
|
||||
predicate_constraint(generics, trait_ref.without_const().to_predicate().to_string());
|
||||
let appl = Applicability::MachineApplicable;
|
||||
err.span_suggestion(sp, &format!("consider further restricting {}", msg), sugg, appl);
|
||||
let (sp, suggestion) = match super_traits {
|
||||
None => {
|
||||
predicate_constraint(generics, trait_ref.without_const().to_predicate().to_string())
|
||||
}
|
||||
Some((ident, bounds)) => match bounds {
|
||||
[.., bound] => (
|
||||
bound.span().shrink_to_hi(),
|
||||
format!(" + {}", trait_ref.print_only_trait_path().to_string()),
|
||||
),
|
||||
[] => (
|
||||
ident.span.shrink_to_hi(),
|
||||
format!(": {}", trait_ref.print_only_trait_path().to_string()),
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
err.span_suggestion_verbose(
|
||||
sp,
|
||||
&format!("consider further restricting {}", msg),
|
||||
suggestion,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,13 +312,35 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let mut hir_id = body_id;
|
||||
while let Some(node) = self.tcx.hir().find(hir_id) {
|
||||
match node {
|
||||
hir::Node::Item(hir::Item {
|
||||
ident,
|
||||
kind: hir::ItemKind::Trait(_, _, generics, bounds, _),
|
||||
..
|
||||
}) if self_ty == self.tcx.types.self_param => {
|
||||
assert!(param_ty);
|
||||
// Restricting `Self` for a single method.
|
||||
suggest_restriction(
|
||||
&generics,
|
||||
"`Self`",
|
||||
err,
|
||||
None,
|
||||
projection,
|
||||
trait_ref,
|
||||
Some((ident, bounds)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
hir::Node::TraitItem(hir::TraitItem {
|
||||
generics,
|
||||
kind: hir::TraitItemKind::Fn(..),
|
||||
..
|
||||
}) if param_ty && self_ty == self.tcx.types.self_param => {
|
||||
}) if self_ty == self.tcx.types.self_param => {
|
||||
assert!(param_ty);
|
||||
// Restricting `Self` for a single method.
|
||||
suggest_restriction(&generics, "`Self`", err, None, projection, trait_ref);
|
||||
suggest_restriction(
|
||||
&generics, "`Self`", err, None, projection, trait_ref, None,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -319,6 +365,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
Some(fn_sig),
|
||||
projection,
|
||||
trait_ref,
|
||||
None,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -336,6 +383,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
None,
|
||||
projection,
|
||||
trait_ref,
|
||||
None,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,13 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterato
|
|||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator`
|
||||
| |
|
||||
| `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
||||
| ^^^^^ `<<T as Case1>::C as std::iter::Iterator>::Item` is not an iterator
|
||||
|
|
||||
= help: the trait `std::iter::Iterator` is not implemented for `<<T as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as std::iter::Iterator>::Item: std::iter::Iterator {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
||||
|
@ -32,11 +34,13 @@ LL | Send + Iterator<Item:
|
|||
| ---- required by this bound in `Case1`
|
||||
...
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Send`
|
||||
| |
|
||||
| `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
| ^^^^^ `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent between threads safely
|
||||
|
|
||||
= help: the trait `std::marker::Send` is not implemented for `<<T as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Send {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
||||
|
@ -48,11 +52,13 @@ LL | > + Sync>;
|
|||
| ---- required by this bound in `Case1`
|
||||
...
|
||||
LL | fn assume_case1<T: Case1>() {
|
||||
| ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync`
|
||||
| |
|
||||
| `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
| ^^^^^ `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared between threads safely
|
||||
|
|
||||
= help: the trait `std::marker::Sync` is not implemented for `<<T as Case1>::C as std::iter::Iterator>::Item`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn assume_case1<T: Case1>() where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug`
|
||||
--> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20
|
||||
|
|
|
@ -14,7 +14,7 @@ pub trait GetToInt
|
|||
}
|
||||
|
||||
fn foo<G>(g: G) -> isize
|
||||
where G : GetToInt, <G as GetToInt>::R: ToInt
|
||||
where G : GetToInt, <G as GetToInt>::R: ToInt
|
||||
{
|
||||
ToInt::to_int(&g.get()) //~ ERROR E0277
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ error[E0277]: the trait bound `<G as GetToInt>::R: ToInt` is not satisfied
|
|||
LL | fn to_int(&self) -> isize;
|
||||
| -------------------------- required by `ToInt::to_int`
|
||||
...
|
||||
LL | where G : GetToInt
|
||||
| - help: consider further restricting the associated type: `, <G as GetToInt>::R: ToInt`
|
||||
LL | {
|
||||
LL | ToInt::to_int(&g.get())
|
||||
| ^^^^^^^^ the trait `ToInt` is not implemented for `<G as GetToInt>::R`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | where G : GetToInt, <G as GetToInt>::R: ToInt
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ trait Get {
|
|||
}
|
||||
|
||||
trait Other {
|
||||
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
||||
fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
||||
//~^ ERROR the trait bound `Self: Get` is not satisfied
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ error[E0277]: the trait bound `Self: Get` is not satisfied
|
|||
--> $DIR/associated-types-for-unimpl-trait.rs:10:5
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
|
||||
| | |
|
||||
| | help: consider further restricting `Self`: `where Self: Get`
|
||||
| the trait `Get` is not implemented for `Self`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ error[E0277]: the trait bound `Self: Get` is not satisfied
|
|||
--> $DIR/associated-types-no-suitable-supertrait-2.rs:17:5
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
|
||||
| | |
|
||||
| | help: consider further restricting `Self`: `where Self: Get`
|
||||
| the trait `Get` is not implemented for `Self`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ error[E0277]: the trait bound `Self: Get` is not satisfied
|
|||
--> $DIR/associated-types-no-suitable-supertrait.rs:17:5
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^
|
||||
| | |
|
||||
| | help: consider further restricting `Self`: `where Self: Get`
|
||||
| the trait `Get` is not implemented for `Self`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `(T, U): Get` is not satisfied
|
||||
--> $DIR/associated-types-no-suitable-supertrait.rs:22:5
|
||||
|
|
|
@ -7,7 +7,7 @@ trait Get {
|
|||
}
|
||||
|
||||
trait Other {
|
||||
fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get ;
|
||||
fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get;
|
||||
//~^ ERROR E0277
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,12 @@ error[E0277]: the trait bound `Self: Get` is not satisfied
|
|||
--> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:10:5
|
||||
|
|
||||
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| | |
|
||||
| | help: consider further restricting `Self`: `where Self: Get`
|
||||
| the trait `Get` is not implemented for `Self`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ trait Get {
|
|||
fn get(&self) -> <Self as Get>::Value;
|
||||
}
|
||||
|
||||
fn foo<T:Get>(t: T) where <T as Get>::Value: std::marker::Sized {
|
||||
fn foo<T:Get>(t: T) where <T as Get>::Value: std::marker::Sized {
|
||||
let x = t.get(); //~ ERROR the size for values of type
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
error[E0277]: the size for values of type `<T as Get>::Value` cannot be known at compilation time
|
||||
--> $DIR/associated-types-unsized.rs:10:9
|
||||
|
|
||||
LL | fn foo<T:Get>(t: T) {
|
||||
| - help: consider further restricting the associated type: `where <T as Get>::Value: std::marker::Sized`
|
||||
LL | let x = t.get();
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
|
@ -10,6 +8,10 @@ LL | let x = t.get();
|
|||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: all local variables must have a statically known size
|
||||
= help: unsized locals are gated as an unstable feature
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn foo<T:Get>(t: T) where <T as Get>::Value: std::marker::Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -85,25 +85,29 @@ error[E0277]: the trait bound `<Self as Foo2<T>>::Baz: std::clone::Clone` is not
|
|||
--> $DIR/defaults-suitability.rs:72:15
|
||||
|
|
||||
LL | trait Foo2<T> {
|
||||
| -------------- help: consider further restricting the associated type: `where <Self as Foo2<T>>::Baz: std::clone::Clone`
|
||||
| |
|
||||
| required by `Foo2`
|
||||
| ------------- required by `Foo2`
|
||||
LL | type Bar: Clone = Vec<Self::Baz>;
|
||||
| ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo2<T>>::Baz`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo2<T>>::Baz>`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait Foo2<T> where <Self as Foo2<T>>::Baz: std::clone::Clone {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `<Self as Foo25<T>>::Baz: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:81:15
|
||||
|
|
||||
LL | trait Foo25<T: Clone> {
|
||||
| ---------------------- help: consider further restricting the associated type: `where <Self as Foo25<T>>::Baz: std::clone::Clone`
|
||||
| |
|
||||
| required by `Foo25`
|
||||
| --------------------- required by `Foo25`
|
||||
LL | type Bar: Clone = Vec<Self::Baz>;
|
||||
| ^^^^^ the trait `std::clone::Clone` is not implemented for `<Self as Foo25<T>>::Baz`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<<Self as Foo25<T>>::Baz>`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait Foo25<T: Clone> where <Self as Foo25<T>>::Baz: std::clone::Clone {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: std::clone::Clone` is not satisfied
|
||||
--> $DIR/defaults-suitability.rs:90:16
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | trait UncheckedCopy: Sized {
|
|||
...
|
||||
LL | type Output: Copy
|
||||
| ^^^^ the trait `std::marker::Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:25:7
|
||||
|
@ -17,6 +22,10 @@ LL | + AddAssign<&'static str>
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
|
||||
|
|
||||
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-1.rs:23:7
|
||||
|
@ -26,6 +35,11 @@ LL | trait UncheckedCopy: Sized {
|
|||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::ops::Deref {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `Self` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:28:7
|
||||
|
@ -38,6 +52,10 @@ LL | + Display = Self;
|
|||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `Self`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::fmt::Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `T` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-1.rs:41:9
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | trait UncheckedCopy: Sized {
|
|||
...
|
||||
LL | type Output: Copy
|
||||
| ^^^^ the trait `std::marker::Copy` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: cannot add-assign `&'static str` to `Self`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:25:7
|
||||
|
@ -17,6 +22,10 @@ LL | + AddAssign<&'static str>
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `Self += &'static str`
|
||||
|
|
||||
= help: the trait `std::ops::AddAssign<&'static str>` is not implemented for `Self`
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::ops::AddAssign<&'static str> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: std::ops::Deref` is not satisfied
|
||||
--> $DIR/defaults-unsound-62211-2.rs:23:7
|
||||
|
@ -26,6 +35,11 @@ LL | trait UncheckedCopy: Sized {
|
|||
...
|
||||
LL | + Deref<Target = str>
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Deref` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::ops::Deref {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `Self` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:28:7
|
||||
|
@ -38,6 +52,10 @@ LL | + Display = Self;
|
|||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `Self`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait UncheckedCopy: Sized + std::fmt::Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `T` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/defaults-unsound-62211-2.rs:41:9
|
||||
|
|
|
@ -8,6 +8,10 @@ LL | type This = Self;
|
|||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `Self`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait MyTrait: std::marker::Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
use std::ops::{Add, Sub, Mul, Div};
|
||||
|
||||
trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> {}
|
||||
//~^ ERROR the size for values of type `Self` cannot be known at compilation time
|
||||
|
||||
impl<T> ArithmeticOps for T where T: Add<Output=T> + Sub<Output=T> + Mul<Output=T> + Div<Output=T> {
|
||||
// Nothing to implement, since T already supports the other traits.
|
||||
// It has the functions it needs already
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,21 @@
|
|||
error[E0277]: the size for values of type `Self` cannot be known at compilation time
|
||||
--> $DIR/trait-with-supertraits-needing-sized-self.rs:3:22
|
||||
|
|
||||
LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> {}
|
||||
| ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
::: $SRC_DIR/libcore/ops/arith.rs:LL:COL
|
||||
|
|
||||
LL | pub trait Add<Rhs = Self> {
|
||||
| --- required by this bound in `std::ops::Add`
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `Self`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | trait ArithmeticOps: Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + std::marker::Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
|
@ -11,7 +11,7 @@ LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self> {
|
|||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self>, Self: std::marker::Sized {
|
||||
LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self>, Self: std::marker::Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider relaxing the implicit `Sized` restriction
|
||||
|
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
error[E0277]: `<P as Process<'_>>::Item` is not an iterator
|
||||
--> $DIR/issue-22872.rs:20:40
|
||||
|
|
||||
LL | fn push_process<P>(process: P) where P: Process<'static> {
|
||||
| - help: consider further restricting the associated type: `, <P as Process<'_>>::Item: std::iter::Iterator`
|
||||
LL | let _: Box<dyn for<'b> Wrap<'b>> = Box::new(Wrapper(process));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `<P as Process<'_>>::Item` is not an iterator
|
||||
|
|
||||
= help: the trait `std::iter::Iterator` is not implemented for `<P as Process<'_>>::Item`
|
||||
= note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper<P>`
|
||||
= note: required for the cast to the object type `dyn for<'b> Wrap<'b>`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn push_process<P>(process: P) where P: Process<'static>, <P as Process<'_>>::Item: std::iter::Iterator {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,14 +2,16 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation
|
|||
--> $DIR/issue-27078.rs:5:12
|
||||
|
|
||||
LL | fn foo(self) -> &'static i32 {
|
||||
| ^^^^ - help: consider further restricting `Self`: `where Self: std::marker::Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
| ^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `Self`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: all local variables must have a statically known size
|
||||
= help: unsized locals are gated as an unstable feature
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn foo(self) -> &'static i32 where Self: std::marker::Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,14 +2,16 @@ error[E0277]: the size for values of type `<Self as std::ops::Deref>::Target` ca
|
|||
--> $DIR/issue-42312.rs:4:12
|
||||
|
|
||||
LL | fn baz(_: Self::Target) where Self: Deref {}
|
||||
| ^ - help: consider further restricting the associated type: `, <Self as std::ops::Deref>::Target: std::marker::Sized`
|
||||
| |
|
||||
| doesn't have a size known at compile-time
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `std::marker::Sized` is not implemented for `<Self as std::ops::Deref>::Target`
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
|
||||
= note: all function arguments must have a statically known size
|
||||
= help: unsized locals are gated as an unstable feature
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn baz(_: Self::Target) where Self: Deref, <Self as std::ops::Deref>::Target: std::marker::Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time
|
||||
--> $DIR/issue-42312.rs:8:10
|
||||
|
|
|
@ -10,7 +10,7 @@ LL | fn qux(_: impl std::fmt::Debug) {}
|
|||
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
|
||||
help: introduce a type parameter with a trait bound instead of using `impl Trait`
|
||||
|
|
||||
LL | fn foo<I: Iterator>(constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
LL | fn foo<I: Iterator>(constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
|
@ -25,7 +25,7 @@ LL | fn qux(_: impl std::fmt::Debug) {}
|
|||
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
|
||||
help: introduce a type parameter with a trait bound instead of using `impl Trait`
|
||||
|
|
||||
LL | fn bar<T, I: Iterator>(t: T, constraints: I) where T: std::fmt::Debug, <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
LL | fn bar<T, I: Iterator>(t: T, constraints: I) where T: std::fmt::Debug, <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
|
@ -40,7 +40,7 @@ LL | fn qux(_: impl std::fmt::Debug) {}
|
|||
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
|
||||
help: introduce a type parameter with a trait bound instead of using `impl Trait`
|
||||
|
|
||||
LL | fn baz<I: Iterator>(t: impl std::fmt::Debug, constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
LL | fn baz<I: Iterator>(t: impl std::fmt::Debug, constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
|
@ -55,7 +55,7 @@ LL | fn qux(_: impl std::fmt::Debug) {}
|
|||
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
|
||||
help: introduce a type parameter with a trait bound instead of using `impl Trait`
|
||||
|
|
||||
LL | fn bat<I, T: std::fmt::Debug, U: Iterator>(t: T, constraints: U, _: I) where <U as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
LL | fn bat<I, T: std::fmt::Debug, U: Iterator>(t: T, constraints: U, _: I) where <U as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: `<impl Iterator + std::fmt::Debug as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
|
||||
|
@ -70,7 +70,7 @@ LL | fn qux(_: impl std::fmt::Debug) {}
|
|||
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator + std::fmt::Debug as std::iter::Iterator>::Item`
|
||||
help: introduce a type parameter with a trait bound instead of using `impl Trait`
|
||||
|
|
||||
LL | fn bak<I: Iterator + std::fmt::Debug>(constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
LL | fn bak<I: Iterator + std::fmt::Debug>(constraints: I) where <I as std::iter::Iterator>::Item: std::fmt::Debug {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
|
|
@ -8,9 +8,12 @@ LL | type Assoc: Child<Self::Ty>;
|
|||
| --------------- required by this bound in `Parent`
|
||||
...
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> {
|
||||
| ^^^^^^ - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>`
|
||||
| |
|
||||
| the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
|
||||
| ^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied
|
||||
--> $DIR/missing-assoc-type-bound-restriction.rs:20:18
|
||||
|
@ -21,13 +24,14 @@ LL | type Ty;
|
|||
LL | type Assoc: Child<Self::Ty>;
|
||||
| --------------- required by this bound in `Parent`
|
||||
...
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> {
|
||||
| - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>`
|
||||
...
|
||||
LL | type Assoc = ChildWrapper<T::Assoc>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
|
||||
|
|
||||
= note: required because of the requirements on the impl of `Child<A>` for `ChildWrapper<<T as Parent>::Assoc>`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied
|
||||
--> $DIR/missing-assoc-type-bound-restriction.rs:20:5
|
||||
|
@ -38,11 +42,13 @@ LL | type Ty;
|
|||
LL | type Assoc: Child<Self::Ty>;
|
||||
| --------------- required by this bound in `Parent`
|
||||
...
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> {
|
||||
| - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>`
|
||||
...
|
||||
LL | type Assoc = ChildWrapper<T::Assoc>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Child<A>` is not implemented for `<T as Parent>::Assoc`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> where <T as Parent>::Assoc: Child<A> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -4,10 +4,13 @@ error[E0277]: the trait bound `Self: Tr<U>` is not satisfied
|
|||
LL | fn op(_: T) -> Self;
|
||||
| -------------------- required by `Tr::op`
|
||||
...
|
||||
LL | fn test<U>(u: U) -> Self {
|
||||
| - help: consider further restricting `Self`: `where Self: Tr<U>`
|
||||
LL | Tr::op(u)
|
||||
| ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn test<U>(u: U) -> Self where Self: Tr<U> {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: Tr<U>` is not satisfied
|
||||
--> $DIR/type-params-in-different-spaces-2.rs:16:9
|
||||
|
@ -15,10 +18,13 @@ error[E0277]: the trait bound `Self: Tr<U>` is not satisfied
|
|||
LL | fn op(_: T) -> Self;
|
||||
| -------------------- required by `Tr::op`
|
||||
...
|
||||
LL | fn test<U>(u: U) -> Self {
|
||||
| - help: consider further restricting `Self`: `where Self: Tr<U>`
|
||||
LL | Tr::op(u)
|
||||
| ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn test<U>(u: U) -> Self where Self: Tr<U> {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ trait Trait {
|
|||
type AssocType;
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
fn bar<T:Trait+Send>() where <T as Trait>::AssocType: std::marker::Send {
|
||||
fn bar<T:Trait+Send>() where <T as Trait>::AssocType: std::marker::Send {
|
||||
is_send::<T::AssocType>(); //~ ERROR E0277
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
error[E0277]: `<T as Trait>::AssocType` cannot be sent between threads safely
|
||||
--> $DIR/typeck-default-trait-impl-assoc-type.rs:11:5
|
||||
|
|
||||
LL | fn bar<T:Trait+Send>() {
|
||||
| - help: consider further restricting the associated type: `where <T as Trait>::AssocType: std::marker::Send`
|
||||
LL | is_send::<T::AssocType>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ `<T as Trait>::AssocType` cannot be sent between threads safely
|
||||
...
|
||||
|
@ -10,6 +8,10 @@ LL | fn is_send<T:Send>() {
|
|||
| ---- required by this bound in `is_send`
|
||||
|
|
||||
= help: the trait `std::marker::Send` is not implemented for `<T as Trait>::AssocType`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn bar<T:Trait+Send>() where <T as Trait>::AssocType: std::marker::Send {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@ error[E0277]: the trait bound `<Self as SomeTrait>::Type1: std::marker::Copy` is
|
|||
|
|
||||
LL | struct IsCopy<T:Copy> { x: T }
|
||||
| ---- required by this bound in `IsCopy`
|
||||
LL |
|
||||
LL | trait SomeTrait {
|
||||
| - help: consider further restricting the associated type: `where <Self as SomeTrait>::Type1: std::marker::Copy`
|
||||
LL | type Type1;
|
||||
...
|
||||
LL | type Type2 = IsCopy<Self::Type1>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `<Self as SomeTrait>::Type1`
|
||||
|
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | trait SomeTrait where <Self as SomeTrait>::Type1: std::marker::Copy {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar(&self, x: &Bar<Self>) {
|
||||
| ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar(&self, x: &Bar<Self>) where Self: std::cmp::Eq {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar(&self) -> Bar<Self> {
|
||||
| ^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar(&self) -> Bar<Self> where Self: std::cmp::Eq {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | trait Bar<T:Eq+?Sized> { }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar<A>(&self) where A: Bar<Self> {
|
||||
| ^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar<A>(&self) where A: Bar<Self>, Self: std::cmp::Eq {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar(&self, x: &Bar<Self>);
|
||||
| ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar(&self, x: &Bar<Self>) where Self: std::cmp::Eq;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar(&self) -> &Bar<Self>;
|
||||
| ^^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar(&self) -> &Bar<Self> where Self: std::cmp::Eq;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,9 +5,12 @@ LL | struct Bar<T:Eq+?Sized> { value: Box<T> }
|
|||
| -- required by this bound in `Bar`
|
||||
...
|
||||
LL | fn bar(&self) where Self: Sized, Bar<Self>: Copy;
|
||||
| ^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq`
|
||||
| |
|
||||
| the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
| ^^^^ the trait `std::cmp::Eq` is not implemented for `Self`
|
||||
|
|
||||
help: consider further restricting `Self`
|
||||
|
|
||||
LL | fn bar(&self) where Self: Sized, Bar<Self>: Copy, Self: std::cmp::Eq;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Reference in New Issue