Reorder fullfillment errors to keep more interesting ones first

In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
This commit is contained in:
Esteban Küber 2023-08-14 13:09:53 +00:00
parent 2817ece19c
commit 91b9ffeab0
76 changed files with 337 additions and 431 deletions

View File

@ -368,7 +368,7 @@ fn check_opaque_type_well_formed<'tcx>(
if errors.is_empty() {
Ok(definition_ty)
} else {
Err(infcx.err_ctxt().report_fulfillment_errors(&errors))
Err(infcx.err_ctxt().report_fulfillment_errors(errors))
}
}

View File

@ -743,7 +743,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
}
// Attempting to call a trait method?

View File

@ -327,7 +327,7 @@ fn check_opaque_meets_bounds<'tcx>(
// version.
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
let guar = infcx.err_ctxt().report_fulfillment_errors(&errors);
let guar = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(guar);
}
match origin {
@ -1512,6 +1512,6 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let errors = fulfillment_cx.select_all_or_error(&infcx);
debug!(?errors);
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
}
}

View File

@ -323,7 +323,7 @@ fn compare_method_predicate_entailment<'tcx>(
// FIXME(-Ztrait-solver=next): Not needed when the hack below is removed.
let errors = ocx.select_where_possible();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
@ -394,7 +394,7 @@ fn compare_method_predicate_entailment<'tcx>(
});
}
CheckImpliedWfMode::Skip => {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
}
@ -874,7 +874,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
// RPITs.
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
@ -2050,7 +2050,7 @@ fn compare_const_predicate_entailment<'tcx>(
// version.
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors));
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}
let outlives_env = OutlivesEnvironment::new(param_env);
@ -2143,7 +2143,7 @@ fn compare_type_predicate_entailment<'tcx>(
// version.
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
@ -2358,7 +2358,7 @@ pub(super) fn check_type_bounds<'tcx>(
// version.
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}

View File

@ -158,7 +158,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
error = true;
}
// now we can take the return type of the given main function

View File

@ -588,7 +588,7 @@ pub fn check_function_signature<'tcx>(
Ok(()) => {
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
return;
}
}

View File

@ -116,7 +116,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
let errors = wfcx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
return;
}

View File

@ -261,7 +261,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
}
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
}
// Finally, resolve all regions.
@ -470,7 +470,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
ocx.register_obligation(obligation);
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
}
// Finally, resolve all regions.

View File

@ -196,7 +196,7 @@ fn get_impl_args(
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
let guar = ocx.infcx.err_ctxt().report_fulfillment_errors(&errors);
let guar = ocx.infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(guar);
}

View File

@ -3010,7 +3010,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// There should be at least one error reported. If not, we
// will still delay a span bug in `report_fulfillment_errors`.
Ok::<_, NoSolution>((
self.err_ctxt().report_fulfillment_errors(&errors),
self.err_ctxt().report_fulfillment_errors(errors),
impl_trait_ref.args.type_at(1),
element_ty,
))

View File

@ -564,7 +564,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !errors.is_empty() {
self.adjust_fulfillment_errors_for_expr_obligation(&mut errors);
self.err_ctxt().report_fulfillment_errors(&errors);
self.err_ctxt().report_fulfillment_errors(errors);
}
}
@ -577,7 +577,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !result.is_empty() {
mutate_fulfillment_errors(&mut result);
self.adjust_fulfillment_errors_for_expr_obligation(&mut result);
self.err_ctxt().report_fulfillment_errors(&result);
self.err_ctxt().report_fulfillment_errors(result);
}
}
@ -1477,7 +1477,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
Ok(normalized_ty) => normalized_ty,
Err(errors) => {
let guar = self.err_ctxt().report_fulfillment_errors(&errors);
let guar = self.err_ctxt().report_fulfillment_errors(errors);
return Ty::new_error(self.tcx,guar);
}
}

View File

@ -2373,7 +2373,7 @@ impl CheckAttrVisitor<'_> {
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
self.abort.set(true);
}
}

View File

@ -57,7 +57,7 @@ pub fn ensure_wf<'tcx>(
ocx.register_obligation(obligation);
let errors = ocx.select_all_or_error();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(&errors);
infcx.err_ctxt().report_fulfillment_errors(errors);
false
} else {
// looks WF!

View File

@ -218,7 +218,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
def_id: LocalDefId,
) -> Result<FxIndexSet<Ty<'tcx>>, ErrorGuaranteed> {
self.assumed_wf_types(param_env, def_id)
.map_err(|errors| self.infcx.err_ctxt().report_fulfillment_errors(&errors))
.map_err(|errors| self.infcx.err_ctxt().report_fulfillment_errors(errors))
}
pub fn assumed_wf_types(

View File

@ -137,7 +137,7 @@ pub trait TypeErrCtxtExt<'tcx> {
fn report_overflow_no_abort(&self, obligation: PredicateObligation<'tcx>) -> ErrorGuaranteed;
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed;
fn report_fulfillment_errors(&self, errors: Vec<FulfillmentError<'tcx>>) -> ErrorGuaranteed;
fn report_overflow_obligation<T>(
&self,
@ -401,7 +401,10 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
}
impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed {
fn report_fulfillment_errors(
&self,
mut errors: Vec<FulfillmentError<'tcx>>,
) -> ErrorGuaranteed {
#[derive(Debug)]
struct ErrorDescriptor<'tcx> {
predicate: ty::Predicate<'tcx>,
@ -423,6 +426,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
})
.collect();
// Ensure `T: Sized` and `T: WF` obligations come last. This lets us display diagnostics
// with more relevant type information and hide redundant E0282 errors.
errors.sort_by_key(|e| match e.obligation.predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred))
if Some(pred.def_id()) == self.tcx.lang_items().sized_trait() =>
{
1
}
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => 3,
ty::PredicateKind::Coerce(_) => 2,
_ => 0,
});
for (index, error) in errors.iter().enumerate() {
// We want to ignore desugarings here: spans are equivalent even
// if one is the result of a desugaring and the other is not.
@ -476,7 +492,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
for from_expansion in [false, true] {
for (error, suppressed) in iter::zip(errors, &is_suppressed) {
for (error, suppressed) in iter::zip(&errors, &is_suppressed) {
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
self.report_fulfillment_error(error);
}

View File

@ -204,7 +204,7 @@ fn do_normalize_predicates<'tcx>(
let predicates = match fully_normalize(&infcx, cause, elaborated_env, predicates) {
Ok(predicates) => predicates,
Err(errors) => {
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
}
};

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `Vec<T>`
--> $DIR/vector-no-ann.rs:2:9
|
LL | let _foo = Vec::new();
| ^^^^
| ^^^^ ---------- type must be known at this point
|
help: consider giving `_foo` an explicit type, where the type for type parameter `T` is specified
|

View File

@ -1,3 +1,11 @@
error: unconstrained generic constant
--> $DIR/const-argument-if-length.rs:17:10
|
LL | pad: [u8; is_zst::<T>()],
| ^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/const-argument-if-length.rs:15:12
|
@ -22,14 +30,6 @@ help: the `Box` type always has a statically known size and allocates its conten
LL | value: Box<T>,
| ++++ +
error: unconstrained generic constant
--> $DIR/const-argument-if-length.rs:17:10
|
LL | pad: [u8; is_zst::<T>()],
| ^^^^^^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -1,9 +1,18 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/issue-83249.rs:19:9
|
LL | let _ = foo([0; 1]);
| ^
| ^ --- ------ type must be known at this point
| |
| required by a bound introduced by this call
|
= note: cannot satisfy `_: Foo`
= help: the trait `Foo` is implemented for `u8`
note: required by a bound in `foo`
--> $DIR/issue-83249.rs:12:11
|
LL | fn foo<T: Foo>(_: [u8; T::N]) -> T {
| ^^^ required by this bound in `foo`
help: consider giving this pattern a type
|
LL | let _: /* Type */ = foo([0; 1]);
@ -11,4 +20,4 @@ LL | let _: /* Type */ = foo([0; 1]);
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,5 +1,4 @@
fn main() {
let x = "hello".chars().rev().collect();
let x;
//~^ ERROR E0282
//~| ERROR E0283
}

View File

@ -1,47 +1,14 @@
error[E0282]: type annotations needed
--> $DIR/E0282.rs:2:9
|
LL | let x = "hello".chars().rev().collect();
LL | let x;
| ^
|
help: consider giving `x` an explicit type
|
LL | let x: Vec<_> = "hello".chars().rev().collect();
| ++++++++
LL | let x: /* Type */;
| ++++++++++++
error[E0283]: type annotations needed
--> $DIR/E0282.rs:2:9
|
LL | let x = "hello".chars().rev().collect();
| ^ ------- type must be known at this point
|
= note: multiple `impl`s satisfying `_: FromIterator<char>` found in the following crates: `alloc`, `hashbrown`, `std`:
- impl FromIterator<char> for String;
- impl<'a, T> FromIterator<T> for Cow<'a, [T]>
where T: Clone;
- impl<'a> FromIterator<char> for Cow<'a, str>;
- impl<I> FromIterator<I> for Box<[I]>;
- impl<T, S, A> FromIterator<T> for hashbrown::set::HashSet<T, S, A>
where T: Eq, T: Hash, S: BuildHasher, S: Default, A: Default, A: Allocator, A: Clone;
- impl<T, S> FromIterator<T> for HashSet<T, S>
where T: Eq, T: Hash, S: BuildHasher, S: Default;
- impl<T> FromIterator<T> for Arc<[T]>;
- impl<T> FromIterator<T> for BTreeSet<T>
where T: Ord;
- impl<T> FromIterator<T> for BinaryHeap<T>
where T: Ord;
- impl<T> FromIterator<T> for LinkedList<T>;
- impl<T> FromIterator<T> for Rc<[T]>;
- impl<T> FromIterator<T> for Vec<T>;
- impl<T> FromIterator<T> for VecDeque<T>;
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider giving `x` an explicit type
|
LL | let x: Vec<_> = "hello".chars().rev().collect();
| ++++++++
error: aborting due to previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0282`.

View File

@ -32,12 +32,18 @@ LL | fn helper(sel: &Self) -> u8 {
| use of generic parameter from outer item
| refer to the type directly here instead
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/E0401.rs:11:5
|
LL | bfnr(x);
| ^^^^ cannot infer type of the type parameter `U` declared on the function `bfnr`
| ^^^^ cannot infer type of the type parameter `V` declared on the function `bfnr`
|
= note: cannot satisfy `_: Baz<_>`
note: required by a bound in `bfnr`
--> $DIR/E0401.rs:4:19
|
LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
| ^^^^^^ required by this bound in `bfnr`
help: consider specifying the generic arguments
|
LL | bfnr::<U, V, W>(x);
@ -66,5 +72,5 @@ LL | bfnr::<U, V, W>(x);
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0282, E0283, E0401.
For more information about an error, try `rustc --explain E0282`.
Some errors have detailed explanations: E0283, E0401.
For more information about an error, try `rustc --explain E0283`.

View File

@ -44,12 +44,6 @@ LL | for item in *things { *item = 0 }
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
error: the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed
--> $DIR/issue-20605.rs:5:17
|
LL | for item in *things { *item = 0 }
| ^^^^^^^
error[E0277]: the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time
--> $DIR/issue-20605.rs:5:5
|
@ -60,6 +54,12 @@ LL | for item in *things { *item = 0 }
note: required by a bound in `None`
--> $SRC_DIR/core/src/option.rs:LL:COL
error: the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed
--> $DIR/issue-20605.rs:5:17
|
LL | for item in *things { *item = 0 }
| ^^^^^^^
error[E0614]: type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced
--> $DIR/issue-20605.rs:5:27
|

View File

@ -1,9 +1,10 @@
error[E0282]: type annotations needed
error[E0284]: type annotations needed
--> $DIR/issue-91762.rs:24:15
|
LL | ret = <Self::Base as Functor>::fmap(arg);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `fmap`
|
= note: cannot satisfy `<<Self as FunctorExt<T>>::Base as Functor>::With<_> == Self`
help: consider specifying the generic arguments
|
LL | ret = <Self::Base as Functor>::fmap::<T, U>(arg);
@ -11,4 +12,4 @@ LL | ret = <Self::Base as Functor>::fmap::<T, U>(arg);
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0284`.

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `Option<T>`
--> $DIR/inference-failure.rs:8:9
|
LL | let _ = NONE;
| ^
| ^ ---- type must be known at this point
|
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|

View File

@ -36,13 +36,13 @@ fn muh() -> Result<(), impl std::fmt::Debug> {
fn muh2() -> Result<(), impl std::fmt::Debug> {
return Err(From::from("foo"));
//~^ ERROR type annotations needed
//~^ ERROR cannot call associated function on trait
Ok(())
}
fn muh3() -> Result<(), impl std::fmt::Debug> {
Err(From::from("foo"))
//~^ ERROR type annotations needed
//~^ ERROR cannot call associated function on trait
}
fn main() {}

View File

@ -9,28 +9,19 @@ help: consider specifying the generic arguments
LL | Ok::<(), E>(())
| +++++++++
error[E0282]: type annotations needed
--> $DIR/cross-return-site-inference.rs:38:12
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> $DIR/cross-return-site-inference.rs:38:16
|
LL | return Err(From::from("foo"));
| ^^^ cannot infer type of the type parameter `E` declared on the enum `Result`
|
help: consider specifying the generic arguments
|
LL | return Err::<(), E>(From::from("foo"));
| +++++++++
| ^^^^^^^^^^ cannot call associated function of trait
error[E0282]: type annotations needed
--> $DIR/cross-return-site-inference.rs:44:5
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> $DIR/cross-return-site-inference.rs:44:9
|
LL | Err(From::from("foo"))
| ^^^ cannot infer type of the type parameter `E` declared on the enum `Result`
|
help: consider specifying the generic arguments
|
LL | Err::<(), E>(From::from("foo"))
| +++++++++
| ^^^^^^^^^^ cannot call associated function of trait
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0282`.
Some errors have detailed explanations: E0282, E0790.
For more information about an error, try `rustc --explain E0282`.

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `RaceBuilder<T, Never<T>>`
--> $DIR/issue-84073.rs:32:16
|
LL | Race::new(|race| race.when());
| ^^^^
| ^^^^ ---- type must be known at this point
|
help: consider giving this closure parameter an explicit type, where the type for type parameter `T` is specified
|

View File

@ -1,9 +1,11 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/opaque-cast-field-access-in-future.rs:22:17
|
LL | fn run() -> Foo<impl Future<Output = ()>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Future`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,9 +1,11 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/where-allowed-2.rs:3:30
|
LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
| ^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Debug`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `Result<(), E>`
|
LL | let x = |r| {
| ^
LL | let v = r?;
LL | Ok(v)
| ----- type must be known at this point
|
help: consider giving this closure parameter an explicit type, where the type for type parameter `E` is specified
|

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `A<std::result::Result<std::result::Re
--> $DIR/issue-104649.rs:24:9
|
LL | let a = A(Result::Ok(Result::Ok(())));
| ^
| ^ -------------- type must be known at this point
|
help: consider giving `a` an explicit type, where the type for type parameter `E` is specified
|

View File

@ -24,16 +24,15 @@ help: try using a fully qualified path to specify the expected types
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0282]: type annotations needed
--> $DIR/issue-72690.rs:12:6
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:9
|
LL | |x| String::from("x".as_ref());
| ^
| ^^^^^^ cannot infer type for reference `&_`
|
help: consider giving this closure parameter an explicit type
|
LL | |x: /* Type */| String::from("x".as_ref());
| ++++++++++++
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:26
@ -225,5 +224,4 @@ LL | String::from(<str as AsRef<T>>::as_ref("x"));
error: aborting due to 17 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -31,9 +31,7 @@ fn main() {
let x: Baz = Baz { inner: 42 };
// DOESN'T Compile: Multiple options!
let y = x.into();
//~^ ERROR E0282
//~| ERROR E0283
let y = x.into(); //~ ERROR E0283
let y_1: Foo = x.into();
let y_2: Bar = x.into();

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/multiple-impl-apply.rs:34:9
|
LL | let y = x.into();
| ^
|
help: consider giving `y` an explicit type
|
LL | let y: /* Type */ = x.into();
| ++++++++++++
error[E0283]: type annotations needed
--> $DIR/multiple-impl-apply.rs:34:9
|
@ -29,7 +18,6 @@ help: consider giving `y` an explicit type
LL | let y: /* Type */ = x.into();
| ++++++++++++
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -14,6 +14,4 @@ fn main() {
<Struct as Ambiguous<_>>::method();
//~^ ERROR type annotations needed
//~| NOTE cannot infer type of the type parameter `A`
//~| ERROR type annotations needed
//~| NOTE infer type of the type parameter `A`
}

View File

@ -1,9 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/concrete-impl.rs:14:5
|
LL | <Struct as Ambiguous<_>>::method();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous`
error[E0283]: type annotations needed
--> $DIR/concrete-impl.rs:14:5
|
@ -19,7 +13,6 @@ LL |
LL | impl Ambiguous<Two> for Struct {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,9 +1,17 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:10:16
|
LL | (S {}).owo(None)
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
| --- ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
| |
| required by a bound introduced by this call
|
= note: cannot satisfy `_: T`
note: required by a bound in `S::owo`
--> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:6:35
|
LL | fn owo(&self, _: Option<&impl T>) {}
| ^ required by this bound in `S::owo`
help: consider specifying the generic argument
|
LL | (S {}).owo(None::<&_>)
@ -11,4 +19,4 @@ LL | (S {}).owo(None::<&_>)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -9,7 +9,6 @@ fn g() -> Result<Vec<i32>, ()> {
let l = [1, 2, 3, 4];
l.iter().map(f).collect()?
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
}
fn main() {

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/question-mark-type-infer.rs:10:21
|
LL | l.iter().map(f).collect()?
| ^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect`
|
help: consider specifying the generic argument
|
LL | l.iter().map(f).collect::<Vec<_>>()?
| ++++++++++
error[E0283]: type annotations needed
--> $DIR/question-mark-type-infer.rs:10:21
|
@ -23,7 +12,6 @@ help: consider specifying the generic argument
LL | l.iter().map(f).collect::<Vec<_>>()?
| ++++++++++
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -2,9 +2,9 @@ error[E0282]: type annotations needed for `&T`
--> $DIR/issue-12187-1.rs:6:9
|
LL | let &v = new();
| ^^
| ^^ ----- type must be known at this point
|
help: consider giving this pattern a type, where the placeholders `_` are specified
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let &v: &T = new();
| ++++

View File

@ -2,9 +2,9 @@ error[E0282]: type annotations needed for `&T`
--> $DIR/issue-12187-2.rs:6:9
|
LL | let &v = new();
| ^^
| ^^ ----- type must be known at this point
|
help: consider giving this pattern a type, where the placeholders `_` are specified
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let &v: &T = new();
| ++++

View File

@ -1,9 +1,16 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/issue-16966.rs:2:12
|
LL | panic!(std::default::Default::default());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
| -------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| | |
| | cannot infer type
| required by a bound introduced by this call
|
= note: cannot satisfy `_: Any`
note: required by a bound in `begin_panic`
--> $SRC_DIR/std/src/panicking.rs:LL:COL
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `B<T>`
--> $DIR/issue-17551.rs:6:9
|
LL | let foo = B(marker::PhantomData);
| ^^^
| ^^^ ------------------- type must be known at this point
|
help: consider giving `foo` an explicit type, where the type for type parameter `T` is specified
|

View File

@ -11,12 +11,13 @@ LL | x = |c| c + 1;
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
error[E0282]: type annotations needed
error[E0284]: type annotations needed
--> $DIR/issue-24036.rs:9:15
|
LL | 1 => |c| c + 1,
| ^
| ^ - type must be known at this point
|
= note: cannot satisfy `<_ as Add<i32>>::Output == _`
help: consider giving this closure parameter an explicit type
|
LL | 1 => |c: /* Type */| c + 1,
@ -24,5 +25,5 @@ LL | 1 => |c: /* Type */| c + 1,
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0282, E0308.
For more information about an error, try `rustc --explain E0282`.
Some errors have detailed explanations: E0284, E0308.
For more information about an error, try `rustc --explain E0284`.

View File

@ -1,11 +1,3 @@
error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time
--> $DIR/issue-24446.rs:2:17
|
LL | static foo: dyn Fn() -> u32 = || -> u32 {
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
error[E0277]: `(dyn Fn() -> u32 + 'static)` cannot be shared between threads safely
--> $DIR/issue-24446.rs:2:17
|
@ -15,6 +7,14 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 {
= help: the trait `Sync` is not implemented for `(dyn Fn() -> u32 + 'static)`
= note: shared static variables must have a type that implements `Sync`
error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time
--> $DIR/issue-24446.rs:2:17
|
LL | static foo: dyn Fn() -> u32 = || -> u32 {
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -1,3 +1,13 @@
error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
--> $DIR/collect-into-slice.rs:6:38
|
LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ try explicitly collecting into a `Vec<{integer}>`
|
= help: the trait `FromIterator<{integer}>` is not implemented for `[i32]`
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/collect-into-slice.rs:6:9
|
@ -18,16 +28,6 @@ LL | let some_generated_vec = (0..10).collect();
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
--> $DIR/collect-into-slice.rs:6:38
|
LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ try explicitly collecting into a `Vec<{integer}>`
|
= help: the trait `FromIterator<{integer}>` is not implemented for `[i32]`
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a slice of type `&[i32]` cannot be built since we need to store the elements somewhere
--> $DIR/collect-into-slice.rs:18:38
|

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `Vec<T>`
--> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:9
|
LL | let mut x = Vec::new();
| ^^^^^
| ^^^^^ ---------- type must be known at this point
|
help: consider giving `x` an explicit type, where the type for type parameter `T` is specified
|

View File

@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `[_; 3]`
|
LL | let b;
| ^
LL |
LL | [a, b] = Default::default();
| - type must be known at this point
|
help: consider giving `b` an explicit type, where the placeholders `_` are specified
|

View File

@ -1,18 +1,3 @@
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
| ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required for `[i32]` to implement `IntoIterator`
help: consider borrowing here
|
LL | for _ in &v[1..] {
| +
LL | for _ in &mut v[1..] {
| ++++
error[E0277]: `[i32]` is not an iterator
--> $DIR/slice-issue-87994.rs:3:12
|
@ -28,7 +13,22 @@ LL | for _ in &v[1..] {
LL | for _ in &mut v[1..] {
| ++++
error[E0277]: the size for values of type `[K]` cannot be known at compilation time
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
| ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required for `[i32]` to implement `IntoIterator`
help: consider borrowing here
|
LL | for _ in &v[1..] {
| +
LL | for _ in &mut v[1..] {
| ++++
error[E0277]: `[K]` is not an iterator
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {
@ -43,7 +43,7 @@ LL | for i2 in &v2[1..] {
LL | for i2 in &mut v2[1..] {
| ++++
error[E0277]: `[K]` is not an iterator
error[E0277]: the size for values of type `[K]` cannot be known at compilation time
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `Option<T>`
--> $DIR/copy-guessing.rs:20:9
|
LL | let n = None;
| ^
| ^ ---- type must be known at this point
|
help: consider giving `n` an explicit type, where the type for type parameter `T` is specified
|

View File

@ -14,7 +14,5 @@ impl<X> Method<u32> for Thing<X> {
fn main() {
let thing = Thing(true);
thing.method(42);
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
thing.method(42); //~ ERROR type annotations needed
}

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11
|
LL | thing.method(42);
| ^^^^^^
|
help: try using a fully qualified path to specify the expected types
|
LL | <Thing<bool> as Method<T>>::method(thing, 42);
| +++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11
|
@ -28,7 +17,6 @@ help: try using a fully qualified path to specify the expected types
LL | <Thing<bool> as Method<T>>::method(thing, 42);
| +++++++++++++++++++++++++++++++++++ ~
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -35,12 +35,23 @@ help: consider specifying the generic argument
LL | opts.get::<Q>(opt.as_ref());
| +++++
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:13:59
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
| ^^^^
| --- ^^^^
| |
| type must be known at this point
|
= note: multiple `impl`s satisfying `u32: From<_>` found in the `core` crate:
- impl From<Ipv4Addr> for u32;
- impl From<NonZeroU32> for u32;
- impl From<bool> for u32;
- impl From<char> for u32;
- impl From<u16> for u32;
- impl From<u8> for u32;
- impl<T> From<!> for T;
- impl<T> From<T> for T;
help: try using a fully qualified path to specify the expected types
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into(0u32))).collect();
@ -84,5 +95,4 @@ LL | let _: Box<T> = (&()).bar();
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -25,7 +25,6 @@ where T : Convert<U>
fn a() {
test(22, std::default::Default::default());
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
}
fn main() {}

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/multidispatch-convert-ambig-dest.rs:26:5
|
LL | test(22, std::default::Default::default());
| ^^^^ cannot infer type of the type parameter `U` declared on the function `test`
|
help: consider specifying the generic arguments
|
LL | test::<i32, U>(22, std::default::Default::default());
| ++++++++++
error[E0283]: type annotations needed
--> $DIR/multidispatch-convert-ambig-dest.rs:26:5
|
@ -37,7 +26,6 @@ help: consider specifying the generic arguments
LL | test::<i32, U>(22, std::default::Default::default());
| ++++++++++
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -27,6 +27,5 @@ fn main() {
//~| ERROR overflow evaluating the requirement `<() as Foo>::Item well-formed`
//~| ERROR overflow evaluating the requirement `String <: <() as Foo>::Item`
//~| ERROR overflow evaluating the requirement `&<() as Foo>::Item well-formed`
//~| ERROR type annotations needed
println!("{x}");
}

View File

@ -11,25 +11,6 @@ note: required by a bound in `Foo::Item`
LL | type Item: Copy
| ^^^^ required by this bound in `Foo::Item`
error[E0282]: type annotations needed
--> $DIR/alias-bound-unsound.rs:24:5
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^^^ cannot infer type of the type parameter `T` declared on the function `drop`
|
help: consider specifying the generic argument
|
LL | drop::<T>(<() as Foo>::copy_me(&x));
| +++++
error[E0275]: overflow evaluating the requirement `&<() as Foo>::Item well-formed`
--> $DIR/alias-bound-unsound.rs:24:31
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
error[E0275]: overflow evaluating the requirement `String <: <() as Foo>::Item`
--> $DIR/alias-bound-unsound.rs:24:31
|
@ -38,14 +19,6 @@ LL | drop(<() as Foo>::copy_me(&x));
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
error[E0275]: overflow evaluating the requirement `<() as Foo>::Item well-formed`
--> $DIR/alias-bound-unsound.rs:24:10
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
error[E0275]: overflow evaluating the requirement `<() as Foo>::Item == _`
--> $DIR/alias-bound-unsound.rs:24:10
|
@ -63,7 +36,22 @@ LL | drop(<() as Foo>::copy_me(&x));
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
= note: the return type of a function must have a statically known size
error: aborting due to 7 previous errors
error[E0275]: overflow evaluating the requirement `&<() as Foo>::Item well-formed`
--> $DIR/alias-bound-unsound.rs:24:31
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
Some errors have detailed explanations: E0275, E0282.
For more information about an error, try `rustc --explain E0275`.
error[E0275]: overflow evaluating the requirement `<() as Foo>::Item well-formed`
--> $DIR/alias-bound-unsound.rs:24:10
|
LL | drop(<() as Foo>::copy_me(&x));
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`)
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0275`.

View File

@ -1,9 +1,16 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/runaway-impl-candidate-selection.rs:13:22
|
LL | println!("{:?}", iter::<_>());
| ^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `iter`
|
= note: cannot satisfy `_: Iterator`
note: required by a bound in `iter`
--> $DIR/runaway-impl-candidate-selection.rs:8:12
|
LL | fn iter<T: Iterator>() -> <T as Iterator>::Item {
| ^^^^^^^^ required by this bound in `iter`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -27,6 +27,5 @@ fn impls<T: Trait>() {}
fn main() {
impls::<W<_>>();
//~^ ERROR type annotations needed
//~| ERROR overflow evaluating the requirement
//~^ ERROR overflow evaluating the requirement
}

View File

@ -1,9 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/fixpoint-exponential-growth.rs:29:5
|
LL | impls::<W<_>>();
| ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls`
error[E0275]: overflow evaluating the requirement `W<_>: Trait`
--> $DIR/fixpoint-exponential-growth.rs:29:13
|
@ -17,7 +11,6 @@ note: required by a bound in `impls`
LL | fn impls<T: Trait>() {}
| ^^^^^ required by this bound in `impls`
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0275, E0282.
For more information about an error, try `rustc --explain E0275`.
For more information about this error, try `rustc --explain E0275`.

View File

@ -1,9 +1,18 @@
error[E0282]: type annotations needed
error[E0284]: type annotations needed: cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc`
--> $DIR/generalize-proj-new-universe-index-2.rs:74:5
|
LL | bound::<<Rigid as IdHigherRankedBound>::Assoc, <Wrapper<Leaf> as Id>::Assoc, _>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `V` declared on the function `bound`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc == <<Leaf as WithAssoc<_>>::Assoc as Id>::Assoc`
|
note: required by a bound in `bound`
--> $DIR/generalize-proj-new-universe-index-2.rs:69:21
|
LL | fn bound<T: ?Sized, U: ?Sized, V: ?Sized>()
| ----- required by a bound in this function
LL | where
LL | T: WithAssoc<U, Assoc = V>,
| ^^^^^^^^^ required by this bound in `bound`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0284`.

View File

@ -1,9 +1,17 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/normalizes_to_ignores_unnormalizable_candidate.rs:36:5
|
LL | foo(unconstrained())
| ^^^ cannot infer type of the type parameter `T` declared on the function `foo`
| ^^^ --------------- type must be known at this point
| |
| cannot infer type of the type parameter `T` declared on the function `foo`
|
= note: cannot satisfy `_: Trait`
note: required by a bound in `foo`
--> $DIR/normalizes_to_ignores_unnormalizable_candidate.rs:19:11
|
LL | fn foo<T: Trait<Assoc = u8>>(x: T) {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `foo`
help: consider specifying the generic argument
|
LL | foo::<T>(unconstrained())
@ -11,4 +19,4 @@ LL | foo::<T>(unconstrained())
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -15,6 +15,5 @@ fn impls<T: Trait>() {}
fn main() {
impls::<W<_>>();
//~^ ERROR type annotations needed
//~| ERROR overflow evaluating the requirement `W<_>: Trait`
//~^ ERROR overflow evaluating the requirement `W<_>: Trait`
}

View File

@ -1,9 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/exponential-trait-goals.rs:17:5
|
LL | impls::<W<_>>();
| ^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `impls`
error[E0275]: overflow evaluating the requirement `W<_>: Trait`
--> $DIR/exponential-trait-goals.rs:17:13
|
@ -17,7 +11,6 @@ note: required by a bound in `impls`
LL | fn impls<T: Trait>() {}
| ^^^^^ required by this bound in `impls`
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0275, E0282.
For more information about an error, try `rustc --explain E0275`.
For more information about this error, try `rustc --explain E0275`.

View File

@ -23,23 +23,6 @@ LL | where
LL | for<V> V: Sized,
| ^^^^^ required by this bound in `foo`
error[E0277]: the size for values of type `V` cannot be known at compilation time
--> $DIR/bad-sized-cond.rs:20:5
|
LL | bar();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `V`
= note: required for `V` to implement `IntoIterator`
note: required by a bound in `bar`
--> $DIR/bad-sized-cond.rs:12:15
|
LL | pub fn bar()
| --- required by a bound in this function
LL | where
LL | for<V> V: IntoIterator,
| ^^^^^^^^^^^^ required by this bound in `bar`
error[E0277]: `V` is not an iterator
--> $DIR/bad-sized-cond.rs:20:5
|
@ -57,6 +40,23 @@ LL | where
LL | for<V> V: IntoIterator,
| ^^^^^^^^^^^^ required by this bound in `bar`
error[E0277]: the size for values of type `V` cannot be known at compilation time
--> $DIR/bad-sized-cond.rs:20:5
|
LL | bar();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `V`
= note: required for `V` to implement `IntoIterator`
note: required by a bound in `bar`
--> $DIR/bad-sized-cond.rs:12:15
|
LL | pub fn bar()
| --- required by a bound in this function
LL | where
LL | for<V> V: IntoIterator,
| ^^^^^^^^^^^^ required by this bound in `bar`
error: aborting due to 3 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.

View File

@ -18,7 +18,5 @@ where
fn main() {
let a = A(B);
a.method();
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
a.method(); //~ ERROR type annotations needed
}

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7
|
LL | a.method();
| ^^^^^^
|
help: try using a fully qualified path to specify the expected types
|
LL | <A<B> as V<U>>::method(a);
| +++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7
|
@ -35,7 +24,6 @@ help: try using a fully qualified path to specify the expected types
LL | <A<B> as V<U>>::method(a);
| +++++++++++++++++++++++ ~
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/suggest-fully-qualified-closure.rs:23:7
|
LL | q.lol(||());
| ^^^
|
help: try using a fully qualified path to specify the expected types
|
LL | <Qqq as MyTrait<T>>::lol::<{closure@}>(&q, ||());
| +++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-closure.rs:23:7
|
@ -28,7 +17,6 @@ help: try using a fully qualified path to specify the expected types
LL | <Qqq as MyTrait<T>>::lol::<{closure@}>(&q, ||());
| +++ ~
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -42,9 +42,7 @@ impl<T> DerefMut for DerefsTo<T> {
fn main() {
let mut thing = Thing;
thing.method();
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
thing.method(); //~ ERROR type annotations needed
thing.mut_method(); //~ ERROR type annotations needed
thing.by_self(); //~ ERROR type annotations needed

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11
|
LL | thing.method();
| ^^^^^^
|
help: try using a fully qualified path to specify the expected types
|
LL | <Thing as Method<T>>::method(&thing);
| ++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11
|
@ -29,7 +18,7 @@ LL | <Thing as Method<T>>::method(&thing);
| ++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:48:11
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:46:11
|
LL | thing.mut_method();
| ^^^^^^^^^^
@ -48,7 +37,7 @@ LL | <Thing as Method<T>>::mut_method(&mut thing);
| +++++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:49:11
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:47:11
|
LL | thing.by_self();
| ^^^^^^^
@ -67,7 +56,7 @@ LL | <&Thing as MethodRef<T>>::by_self(&thing);
| +++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:52:14
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:50:14
|
LL | deref_to.method();
| ^^^^^^
@ -86,7 +75,7 @@ LL | <Thing as Method<T>>::method(&deref_to);
| ++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:53:14
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:51:14
|
LL | deref_to.mut_method();
| ^^^^^^^^^^
@ -105,7 +94,7 @@ LL | <Thing as Method<T>>::mut_method(&mut deref_to);
| +++++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:54:14
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:52:14
|
LL | deref_to.by_self();
| ^^^^^^^
@ -124,7 +113,7 @@ LL | <&Thing as MethodRef<T>>::by_self(&deref_to);
| +++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:57:20
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:55:20
|
LL | deref_deref_to.method();
| ^^^^^^
@ -143,7 +132,7 @@ LL | <Thing as Method<T>>::method(&deref_deref_to);
| ++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:58:20
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:56:20
|
LL | deref_deref_to.mut_method();
| ^^^^^^^^^^
@ -162,7 +151,7 @@ LL | <Thing as Method<T>>::mut_method(&mut deref_deref_to);
| +++++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:59:20
--> $DIR/suggest-fully-qualified-path-with-adjustment.rs:57:20
|
LL | deref_deref_to.by_self();
| ^^^^^^^
@ -180,7 +169,6 @@ help: try using a fully qualified path to specify the expected types
LL | <&Thing as MethodRef<T>>::by_self(&deref_deref_to);
| +++++++++++++++++++++++++++++++++++ ~
error: aborting due to 10 previous errors
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -42,9 +42,7 @@ impl<T> DerefMut for DerefsTo<T> {
fn main() {
let mut ref_thing = &Thing;
ref_thing.method();
//~^ ERROR type annotations needed
//~| ERROR type annotations needed
ref_thing.method(); //~ ERROR type annotations needed
ref_thing.by_self(); //~ ERROR type annotations needed
let mut mut_thing = &mut Thing;

View File

@ -1,14 +1,3 @@
error[E0282]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15
|
LL | ref_thing.method();
| ^^^^^^
|
help: try using a fully qualified path to specify the expected types
|
LL | <Thing as Method<T>>::method(ref_thing);
| +++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15
|
@ -29,7 +18,7 @@ LL | <Thing as Method<T>>::method(ref_thing);
| +++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:48:15
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:46:15
|
LL | ref_thing.by_self();
| ^^^^^^^
@ -48,7 +37,7 @@ LL | <&Thing as MethodRef<T>>::by_self(ref_thing);
| ++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:51:15
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:49:15
|
LL | mut_thing.method();
| ^^^^^^
@ -67,7 +56,7 @@ LL | <Thing as Method<T>>::method(mut_thing);
| +++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:52:15
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:50:15
|
LL | mut_thing.mut_method();
| ^^^^^^^^^^
@ -86,7 +75,7 @@ LL | <Thing as Method<T>>::mut_method(mut_thing);
| +++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:53:15
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:51:15
|
LL | mut_thing.by_self();
| ^^^^^^^
@ -105,7 +94,7 @@ LL | <&Thing as MethodRef<T>>::by_self(mut_thing);
| ++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:56:14
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:54:14
|
LL | deref_to.method();
| ^^^^^^
@ -124,7 +113,7 @@ LL | <Thing as Method<T>>::method(deref_to);
| +++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:57:14
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:55:14
|
LL | deref_to.mut_method();
| ^^^^^^^^^^
@ -143,7 +132,7 @@ LL | <Thing as Method<T>>::mut_method(deref_to);
| +++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:58:14
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:56:14
|
LL | deref_to.by_self();
| ^^^^^^^
@ -162,7 +151,7 @@ LL | <&Thing as MethodRef<T>>::by_self(deref_to);
| ++++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:61:20
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:59:20
|
LL | deref_deref_to.method();
| ^^^^^^
@ -181,7 +170,7 @@ LL | <Thing as Method<T>>::method(deref_deref_to);
| +++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:62:20
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:60:20
|
LL | deref_deref_to.mut_method();
| ^^^^^^^^^^
@ -200,7 +189,7 @@ LL | <Thing as Method<T>>::mut_method(deref_deref_to);
| +++++++++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:63:20
--> $DIR/suggest-fully-qualified-path-without-adjustment.rs:61:20
|
LL | deref_deref_to.by_self();
| ^^^^^^^
@ -218,7 +207,6 @@ help: try using a fully qualified path to specify the expected types
LL | <&Thing as MethodRef<T>>::by_self(deref_deref_to);
| ++++++++++++++++++++++++++++++++++ ~
error: aborting due to 12 previous errors
error: aborting due to 11 previous errors
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,9 +1,14 @@
error[E0282]: type annotations needed
error[E0283]: type annotations needed
--> $DIR/sort_by_key.rs:3:40
|
LL | lst.sort_by_key(|&(v, _)| v.iter().sum());
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
| ----------- ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
| |
| type must be known at this point
|
= note: cannot satisfy `_: Ord`
note: required by a bound in `slice::<impl [T]>::sort_by_key`
--> $SRC_DIR/alloc/src/slice.rs:LL:COL
help: consider specifying the generic argument
|
LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
@ -11,4 +16,4 @@ LL | lst.sort_by_key(|&(v, _)| v.iter().sum::<S>());
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
For more information about this error, try `rustc --explain E0283`.

View File

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `Vec<_>`
--> $DIR/cannot_infer_local_or_vec.rs:2:9
|
LL | let x = vec![];
| ^
| ^ ------ type must be known at this point
|
help: consider giving `x` an explicit type, where the placeholders `_` are specified
|

View File

@ -14,6 +14,15 @@ help: consider further restricting type parameter `U`
LL | fn foo<T,U>() where T: ExtraCopy<U>, U: std::marker::Copy
| ++++++++++++++++++++++
error[E0038]: the trait `Copy` cannot be made into an object
--> $DIR/wf-fn-where-clause.rs:12:16
|
LL | fn bar() where Vec<dyn Copy>:, {}
| ^^^^^^^^^^^^^ `Copy` cannot be made into an object
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error[E0277]: the size for values of type `(dyn Copy + 'static)` cannot be known at compilation time
--> $DIR/wf-fn-where-clause.rs:12:16
|
@ -34,15 +43,6 @@ LL | struct Vec<T> {
LL | t: T,
| - ...if indirection were used here: `Box<T>`
error[E0038]: the trait `Copy` cannot be made into an object
--> $DIR/wf-fn-where-clause.rs:12:16
|
LL | fn bar() where Vec<dyn Copy>:, {}
| ^^^^^^^^^^^^^ `Copy` cannot be made into an object
|
= note: the trait cannot be made into an object because it requires `Self: Sized`
= note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0277.