Auto merge of #115219 - estebank:issue-105306, r=compiler-errors

Point at type parameter that introduced unmet bound instead of full HIR node

```
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
  --> $DIR/issue-87199.rs:18:15
   |
LL |     ref_arg::<[i32]>(&[5]);
   |               ^^^^^ doesn't have a size known at compile-time
```
instead of
```
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
  --> $DIR/issue-87199.rs:18:22
   |
LL |     ref_arg::<[i32]>(&[5]);
   |     ---------------- ^^^^ doesn't have a size known at compile-time
   |     |
   |     required by a bound introduced by this call
```

------

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:24
   |
LL |     let _: <S as D>::P<String>;
   |                        ^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
instead of
```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:12
   |
LL |     let _: <S as D>::P<String>;
   |            ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
Fix #105306.
This commit is contained in:
bors 2023-08-26 22:31:53 +00:00
commit e877e2a2c9
46 changed files with 262 additions and 202 deletions

View File

@ -20,10 +20,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
else {
return false;
};
let hir = self.tcx.hir();
let hir::Node::Expr(expr) = hir.get(hir_id) else {
return false;
};
let Some(unsubstituted_pred) = self
.tcx
@ -47,6 +43,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => return false,
};
let direct_param = if let ty::ClauseKind::Trait(pred) = unsubstituted_pred.kind().skip_binder()
&& let ty = pred.trait_ref.self_ty()
&& let ty::Param(_param) = ty.kind()
&& let Some(arg) = predicate_args.get(0)
&& let ty::GenericArgKind::Type(arg_ty) = arg.unpack()
&& arg_ty == ty
{
Some(*arg)
} else {
None
};
let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
predicate_args.iter().find_map(|arg| {
arg.walk().find_map(|arg| {
@ -96,19 +103,34 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.find_ambiguous_parameter_in(def_id, error.root_obligation.predicate);
}
let hir = self.tcx.hir();
let (expr, qpath) = match hir.get(hir_id) {
hir::Node::Expr(expr) => {
if self.closure_span_overlaps_error(error, expr.span) {
return false;
}
let qpath =
if let hir::ExprKind::Path(qpath) = expr.kind { Some(qpath) } else { None };
match &expr.kind {
hir::ExprKind::Path(qpath) => {
(Some(*expr), qpath)
}
hir::Node::Ty(hir::Ty { kind: hir::TyKind::Path(qpath), .. }) => (None, Some(*qpath)),
_ => return false,
};
if let Some(qpath) = qpath {
if let Some(param) = direct_param {
if self.point_at_path_if_possible(error, def_id, param, &qpath) {
return true;
}
}
if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Call(callee, args),
hir_id: call_hir_id,
span: call_span,
..
}) = hir.get_parent(expr.hir_id)
&& callee.hir_id == expr.hir_id
}) = hir.get_parent(hir_id)
&& callee.hir_id == hir_id
{
if self.closure_span_overlaps_error(error, *call_span) {
return false;
@ -138,12 +160,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.into_iter()
.flatten()
{
if self.point_at_path_if_possible(error, def_id, param, qpath) {
if self.point_at_path_if_possible(error, def_id, param, &qpath) {
return true;
}
}
}
hir::ExprKind::MethodCall(segment, receiver, args, ..) => {
match expr.map(|e| e.kind) {
Some(hir::ExprKind::MethodCall(segment, receiver, args, ..)) => {
if let Some(param) = direct_param
&& self.point_at_generic_if_possible(error, def_id, param, segment)
{
error.obligation.cause.map_code(|parent_code| {
ObligationCauseCode::FunctionArgumentObligation {
arg_hir_id: receiver.hir_id,
call_hir_id: hir_id,
parent_code,
}
});
return true;
}
for param in [param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
.into_iter()
.flatten()
@ -175,7 +211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return true;
}
}
hir::ExprKind::Struct(qpath, fields, ..) => {
Some(hir::ExprKind::Struct(qpath, fields, ..)) => {
if let Res::Def(DefKind::Struct | DefKind::Variant, variant_def_id) =
self.typeck_results.borrow().qpath_res(qpath, hir_id)
{
@ -200,7 +236,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
for param in [param_to_point_at, fallback_param_to_point_at, self_param_to_point_at]
for param in [
direct_param,
param_to_point_at,
fallback_param_to_point_at,
self_param_to_point_at,
]
.into_iter()
.flatten()
{
@ -434,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
/**
* Recursively searches for the most-specific blamable expression.
* Recursively searches for the most-specific blameable expression.
* For example, if you have a chain of constraints like:
* - want `Vec<i32>: Copy`
* - because `Option<Vec<i32>>: Copy` needs `Vec<i32>: Copy` because `impl <T: Copy> Copy for Option<T>`

View File

@ -317,7 +317,18 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
fn record_ty(&self, hir_id: hir::HirId, ty: Ty<'tcx>, span: Span) {
// FIXME: normalization and escaping regions
let ty = if !ty.has_escaping_bound_vars() { self.normalize(span, ty) } else { ty };
let ty = if !ty.has_escaping_bound_vars() {
if let ty::Alias(
ty::AliasKind::Projection | ty::AliasKind::Weak,
ty::AliasTy { args, def_id, .. },
) = ty.kind()
{
self.add_required_obligations_for_hir(span, *def_id, args, hir_id);
}
self.normalize(span, ty)
} else {
ty
};
self.write_ty(hir_id, ty)
}

View File

@ -14,12 +14,10 @@ LL | fn foo(i: impl std::fmt::Display) {}
= note: `impl Trait` cannot be explicitly specified as a generic argument
error[E0277]: `()` doesn't implement `std::fmt::Display`
--> $DIR/issue-100154.rs:4:15
--> $DIR/issue-100154.rs:4:11
|
LL | foo::<()>(());
| --------- ^^ `()` cannot be formatted with the default formatter
| |
| required by a bound introduced by this call
| ^^ `()` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `T: Foo<usize>` is not satisfied
--> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:12
--> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:10:13
|
LL | let u: <T as Foo<usize>>::Bar = t.get_bar();
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo<usize>` is not implemented for `T`
| ^ the trait `Foo<usize>` is not implemented for `T`
|
help: consider further restricting this bound
|

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `(): Foo<N>` is not satisfied
--> $DIR/exhaustive-value.rs:262:16
--> $DIR/exhaustive-value.rs:262:6
|
LL | <() as Foo<N>>::test()
| ^ the trait `Foo<N>` is not implemented for `()`
| ^^ the trait `Foo<N>` is not implemented for `()`
|
= help: the following other types implement trait `Foo<N>`:
<() as Foo<0>>

View File

@ -1,10 +1,8 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/unsized-ret.rs:10:27
--> $DIR/unsized-ret.rs:10:11
|
LL | foo::<fn() -> str, _>(None, ());
| --------------------- ^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
| ^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within `fn() -> str`, the trait `Sized` is not implemented for `str`
= note: required because it appears within the type `fn() -> str`
@ -15,12 +13,10 @@ LL | fn foo<F: Fn<T>, T:std::marker::Tuple>(f: Option<F>, t: T) {
| ^^^^^ required by this bound in `foo`
error[E0277]: the size for values of type `(dyn std::fmt::Display + 'a)` cannot be known at compilation time
--> $DIR/unsized-ret.rs:13:66
--> $DIR/unsized-ret.rs:13:11
|
LL | foo::<for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a), _>(None, (&(),));
| ------------------------------------------------------------ ^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within `for<'a> fn(&'a ()) -> (dyn std::fmt::Display + 'a)`, the trait `for<'a> Sized` is not implemented for `(dyn std::fmt::Display + 'a)`
= note: required because it appears within the type `fn(&()) -> dyn Display`

View File

@ -0,0 +1,10 @@
trait Trait {
type P<T: Copy, U: Copy>;
}
impl Trait for () {
type P<T: Copy, U: Copy> = ();
}
fn main() {
let _: <() as Trait>::P<String, String>;
//~^ ERROR the trait bound `String: Copy` is not satisfied
}

View File

@ -0,0 +1,15 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/multiple-type-params-with-unmet-bounds.rs:8:29
|
LL | let _: <() as Trait>::P<String, String>;
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `Trait::P`
--> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15
|
LL | type P<T: Copy, U: Copy>;
| ^^^^ required by this bound in `Trait::P`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/own-bound-span.rs:14:12
--> $DIR/own-bound-span.rs:14:24
|
LL | let _: <S as D>::P<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound in `D::P`
--> $DIR/own-bound-span.rs:4:15

View File

@ -2,7 +2,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -71,7 +71,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -97,7 +97,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -123,7 +123,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -149,7 +149,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -175,7 +175,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
@ -201,7 +201,7 @@ error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:5
|
LL | String::from("x".as_ref());
| ^^^^^^^^^^^^ cannot infer type for reference `&_`
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed
--> $DIR/issue-29147.rs:22:13
--> $DIR/issue-29147.rs:22:14
|
LL | let _ = <S5<_>>::xxx;
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
| ^^^^^ cannot infer type for struct `S5<_>`
|
note: multiple `impl`s satisfying `S5<_>: Foo` found
--> $DIR/issue-29147.rs:18:1

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `(): _A` is not satisfied
--> $DIR/issue-66353.rs:12:14
--> $DIR/issue-66353.rs:12:15
|
LL | _Func::< <() as _A>::AssocT >::func(());
| ^^^^^^^^^^^^^^^^^^ the trait `_A` is not implemented for `()`
| ^^ the trait `_A` is not implemented for `()`
error[E0277]: the trait bound `(): _Func<_>` is not satisfied
--> $DIR/issue-66353.rs:12:41

View File

@ -17,10 +17,12 @@ note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64`
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:29
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:39
|
LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
| ------- ^^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
| |
| required by a bound introduced by this call
|
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`

View File

@ -17,12 +17,10 @@ LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/issue-87199.rs:18:22
--> $DIR/issue-87199.rs:18:15
|
LL | ref_arg::<[i32]>(&[5]);
| ---------------- ^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[i32]`
note: required by a bound in `ref_arg`

View File

@ -1,8 +1,10 @@
error[E0277]: a value of type `f32` cannot be made by summing an iterator over elements of type `{integer}`
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:41
--> $DIR/invalid-iterator-chain-with-int-infer.rs:2:47
|
LL | let x = Some(()).iter().map(|()| 1).sum::<f32>();
| ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>`
| --- ^^^ value of type `f32` cannot be made by summing a `std::iter::Iterator<Item={integer}>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<{integer}>` is not implemented for `f32`
= help: the following other types implement trait `Sum<A>`:

View File

@ -17,10 +17,12 @@ note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:15:27
--> $DIR/invalid-iterator-chain.rs:15:33
|
LL | println!("{}", scores.sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -42,10 +44,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:26:14
--> $DIR/invalid-iterator-chain.rs:26:20
|
LL | .sum::<i32>(),
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -74,10 +78,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
--> $DIR/invalid-iterator-chain.rs:36:14
--> $DIR/invalid-iterator-chain.rs:36:20
|
LL | .sum::<i32>(),
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<f64>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -102,10 +108,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:38:54
--> $DIR/invalid-iterator-chain.rs:38:60
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -123,10 +131,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/invalid-iterator-chain.rs:39:40
--> $DIR/invalid-iterator-chain.rs:39:46
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:

View File

@ -1,14 +1,14 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
|
LL | let _: lazy::Alias<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound on the type alias `Alias`
note: required by a bound in `lazy::Alias`
--> $DIR/auxiliary/lazy.rs:4:19
|
LL | pub type Alias<T: Copy> = Option<T>;
| ^^^^ required by this bound
| ^^^^ required by this bound in `Alias`
error: aborting due to previous error

View File

@ -1,14 +1,14 @@
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
--> $DIR/extern-crate-has-lazy-type-aliases.rs:15:24
|
LL | let _: lazy::Alias<String>;
| ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
| ^^^^^^ the trait `Copy` is not implemented for `String`
|
note: required by a bound on the type alias `Alias`
note: required by a bound in `lazy::Alias`
--> $DIR/auxiliary/lazy.rs:4:19
|
LL | pub type Alias<T: Copy> = Option<T>;
| ^^^^ required by this bound
| ^^^^ required by this bound in `Alias`
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `String: From<()>` is not satisfied
--> $DIR/trailing-where-clause.rs:12:12
--> $DIR/trailing-where-clause.rs:12:18
|
LL | let _: Alias<()>;
| ^^^^^^^^^ the trait `From<()>` is not implemented for `String`
| ^^ the trait `From<()>` is not implemented for `String`
|
= help: the following other types implement trait `From<T>`:
<String as From<char>>
@ -11,11 +11,14 @@ LL | let _: Alias<()>;
<String as From<&str>>
<String as From<&mut str>>
<String as From<&String>>
note: required by a bound on the type alias `Alias`
note: required by a bound in `Alias`
--> $DIR/trailing-where-clause.rs:8:13
|
LL | type Alias<T> = T
| ----- required by a bound in this type alias
LL | where
LL | String: From<T>;
| ^^^^^^^ required by this bound
| ^^^^^^^ required by this bound in `Alias`
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
error[E0277]: the size for values of type `dyn ToString` cannot be known at compilation time
--> $DIR/issue-61525.rs:14:33
--> $DIR/issue-61525.rs:14:19
|
LL | 1.query::<dyn ToString>("")
| ----- ^^ doesn't have a size known at compile-time
| ----- ^^^^^^^^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `E: From<()>` is not satisfied
--> $DIR/never-value-fallback-issue-66757.rs:28:26
--> $DIR/never-value-fallback-issue-66757.rs:28:6
|
LL | <E as From<_>>::from(never);
| -------------------- ^^^^^ the trait `From<()>` is not implemented for `E`
| |
| required by a bound introduced by this call
| ^ the trait `From<()>` is not implemented for `E`
|
= help: the trait `From<!>` is implemented for `E`

View File

@ -13,12 +13,12 @@ LL | fn bop<T: Bop + ?Sized>() where T: Sized {
| ++++++++++++++
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> $DIR/assoc_type_bounds_sized_used.rs:12:13
--> $DIR/assoc_type_bounds_sized_used.rs:12:14
|
LL | fn bop<T: Bop + ?Sized>() {
| - this type parameter needs to be `Sized`
LL | let _ = <T as Bop>::Bar::default();
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| ^ doesn't have a size known at compile-time
|
note: required by a bound in `Bop::Bar`
--> $DIR/assoc_type_bounds_sized_used.rs:8:15

View File

@ -1,8 +1,10 @@
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/sum.rs:4:25
--> $DIR/sum.rs:4:31
|
LL | vec![(), ()].iter().sum::<i32>();
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
@ -19,10 +21,12 @@ note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by multiplying all elements of type `&()` from an iterator
--> $DIR/sum.rs:7:25
--> $DIR/sum.rs:7:35
|
LL | vec![(), ()].iter().product::<i32>();
| ^^^^^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>`
| ------- ^^^ value of type `i32` cannot be made by multiplying all elements from a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Product<&()>` is not implemented for `i32`
= help: the following other types implement trait `Product<A>`:

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `T: Foo` is not satisfied
--> $DIR/assoc-type-const-bound-usage.rs:12:5
--> $DIR/assoc-type-const-bound-usage.rs:12:6
|
LL | <T as Foo>::Assoc::foo();
| ^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
| ^ the trait `Foo` is not implemented for `T`
|
help: consider further restricting this bound
|

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied
--> $DIR/assoc-const-as-fn.rs:14:40
--> $DIR/assoc-const-as-fn.rs:14:6
|
LL | <T as GlUniformScalar>::FACTORY(1, value);
| ------------------------------- ^^^^^ the trait `GlUniformScalar` is not implemented for `T`
| |
| required by a bound introduced by this call
| ^ the trait `GlUniformScalar` is not implemented for `T`
|
help: consider further restricting this bound
|

View File

@ -2,7 +2,9 @@ error[E0277]: `T` cannot be sent between threads safely
--> $DIR/bad-method-typaram-kind.rs:2:13
|
LL | 1.bar::<T>();
| ^ `T` cannot be sent between threads safely
| --- ^ `T` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
= note: consider using `std::sync::Arc<T>`; for more information visit <https://doc.rust-lang.org/book/ch16-03-shared-state.html>
note: required by a bound in `Bar::bar`

View File

@ -5,12 +5,10 @@ LL | <i32 as RefFoo<i32>>::ref_foo(unknown);
| ^^^^^^^ not found in this scope
error[E0277]: the trait bound `for<'a> &'a mut Vec<&'a u32>: Foo<'static, i32>` is not satisfied
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:35
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:17:6
|
LL | <i32 as RefFoo<i32>>::ref_foo(unknown);
| ----------------------------- ^^^^^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>`
| |
| required by a bound introduced by this call
| ^^^ the trait `for<'a> Foo<'static, i32>` is not implemented for `&'a mut Vec<&'a u32>`
|
note: required for `i32` to implement `RefFoo<i32>`
--> $DIR/dont-autoderef-ty-with-escaping-var.rs:9:9

View File

@ -24,12 +24,10 @@ LL | fn with_trait<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
| ++++++++++++++++
error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
--> $DIR/repeated-supertrait-ambig.rs:34:37
--> $DIR/repeated-supertrait-ambig.rs:34:6
|
LL | <dyn CompareToInts>::same_as(c, 22)
| ---------------------------- ^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
| |
| required by a bound introduced by this call
| ^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
|
= help: the following other types implement trait `CompareTo<T>`:
<i64 as CompareTo<i64>>

View File

@ -35,23 +35,12 @@ help: consider specifying the generic argument
LL | opts.get::<Q>(opt.as_ref());
| +++++
error[E0283]: type annotations needed
error[E0282]: type annotations needed
--> $DIR/issue-77982.rs:13:59
|
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
| --------- ^^^^
| |
| required by a bound introduced by this call
| ^^^^
|
= 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();
@ -95,4 +84,5 @@ LL | let _: Box<T> = (&()).bar();
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0283`.
Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.

View File

@ -1,10 +1,8 @@
error[E0277]: expected a `Fn<_>` closure, found `fn() -> str`
--> $DIR/builtin-fn-must-return-sized.rs:15:27
--> $DIR/builtin-fn-must-return-sized.rs:15:11
|
LL | foo::<fn() -> str, _>(None, ());
| --------------------- ^^^^ expected an `Fn<_>` closure, found `fn() -> str`
| |
| required by a bound introduced by this call
| ^^^^^^^^^^^ expected an `Fn<_>` closure, found `fn() -> str`
|
= help: the trait `Fn<_>` is not implemented for `fn() -> str`
note: required by a bound in `foo`

View File

@ -5,10 +5,10 @@ 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:5
--> $DIR/fixpoint-exponential-growth.rs:29:13
|
LL | impls::<W<_>>();
| ^^^^^^^^^^^^^
| ^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`fixpoint_exponential_growth`)
note: required by a bound in `impls`

View File

@ -1,8 +1,8 @@
error[E0275]: overflow evaluating the requirement `(): Trait`
--> $DIR/double-cycle-inductive-coinductive.rs:32:5
--> $DIR/double-cycle-inductive-coinductive.rs:32:19
|
LL | impls_trait::<()>();
| ^^^^^^^^^^^^^^^^^
| ^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`)
note: required by a bound in `impls_trait`
@ -12,10 +12,10 @@ LL | fn impls_trait<T: Trait>() {}
| ^^^^^ required by this bound in `impls_trait`
error[E0275]: overflow evaluating the requirement `(): TraitRev`
--> $DIR/double-cycle-inductive-coinductive.rs:35:5
--> $DIR/double-cycle-inductive-coinductive.rs:35:23
|
LL | impls_trait_rev::<()>();
| ^^^^^^^^^^^^^^^^^^^^^
| ^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`double_cycle_inductive_coinductive`)
note: required by a bound in `impls_trait_rev`

View File

@ -1,8 +1,8 @@
error[E0275]: overflow evaluating the requirement `(): AR`
--> $DIR/inductive-not-on-stack.rs:44:5
--> $DIR/inductive-not-on-stack.rs:44:16
|
LL | impls_ar::<()>();
| ^^^^^^^^^^^^^^
| ^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`)
note: required by a bound in `impls_ar`

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed: cannot satisfy `Foo: Send`
--> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5
--> $DIR/dont-type_of-tait-in-defining-scope.rs:16:18
|
LL | needs_send::<Foo>();
| ^^^^^^^^^^^^^^^^^
| ^^^
|
= note: cannot satisfy `Foo: Send`
note: required by a bound in `needs_send`

View File

@ -5,10 +5,10 @@ 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:5
--> $DIR/exponential-trait-goals.rs:17:13
|
LL | impls::<W<_>>();
| ^^^^^^^^^^^^^
| ^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`exponential_trait_goals`)
note: required by a bound in `impls`

View File

@ -1,8 +1,8 @@
error[E0275]: overflow evaluating the requirement `Inc<Inc<Inc<Inc<Inc<Inc<Inc<...>>>>>>>: Trait`
--> $DIR/global-cache.rs:21:5
--> $DIR/global-cache.rs:21:19
|
LL | impls_trait::<Four<Four<Four<Four<()>>>>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "18"]` attribute to your crate (`global_cache`)
note: required by a bound in `impls_trait`

View File

@ -1,8 +1,8 @@
error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar`
--> $DIR/recursive-self-normalization-2.rs:16:5
--> $DIR/recursive-self-normalization-2.rs:16:17
|
LL | needs_bar::<T::Assoc1>();
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`)
note: required by a bound in `needs_bar`

View File

@ -1,8 +1,8 @@
error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar`
--> $DIR/recursive-self-normalization.rs:12:5
--> $DIR/recursive-self-normalization.rs:12:17
|
LL | needs_bar::<T::Assoc>();
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`)
note: required by a bound in `needs_bar`

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed: cannot satisfy `T: Bar`
--> $DIR/two-projection-param-candidates-are-ambiguous.rs:26:5
--> $DIR/two-projection-param-candidates-are-ambiguous.rs:26:17
|
LL | needs_bar::<T>();
| ^^^^^^^^^^^^^^
| ^
|
= note: cannot satisfy `T: Bar`
= help: the trait `Bar` is implemented for `T`

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> $DIR/no-use.rs:11:26
--> $DIR/no-use.rs:11:6
|
LL | <() as MyTrait>::foo(&());
| -------------------- ^^^ the trait `MyTrait` is not implemented for `()`
| |
| required by a bound introduced by this call
| ^^ the trait `MyTrait` is not implemented for `()`
|
= help: the trait `MyTrait` is implemented for `()`

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `(): MyTrait` is not satisfied
--> $DIR/no-use.rs:11:26
--> $DIR/no-use.rs:11:6
|
LL | <() as MyTrait>::foo(&());
| -------------------- ^^^ the trait `MyTrait` is not implemented for `()`
| |
| required by a bound introduced by this call
| ^^ the trait `MyTrait` is not implemented for `()`
|
= help: the trait `MyTrait` is implemented for `()`

View File

@ -38,10 +38,10 @@ LL + fn check<T: Iterator, U>() {
|
error[E0277]: the trait bound `u64: From<T>` is not satisfied
--> $DIR/suggest-where-clause.rs:15:18
--> $DIR/suggest-where-clause.rs:15:6
|
LL | <u64 as From<T>>::from;
| ^ the trait `From<T>` is not implemented for `u64`
| ^^^ the trait `From<T>` is not implemented for `u64`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
@ -49,10 +49,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<T> {
| ++++++++++++++++++
error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfied
--> $DIR/suggest-where-clause.rs:18:18
--> $DIR/suggest-where-clause.rs:18:6
|
LL | <u64 as From<<T as Iterator>::Item>>::from;
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
| ^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
@ -60,10 +60,10 @@ LL | fn check<T: Iterator, U: ?Sized>() where u64: From<<T as Iterator>::Item> {
| ++++++++++++++++++++++++++++++++++++++
error[E0277]: the trait bound `Misc<_>: From<T>` is not satisfied
--> $DIR/suggest-where-clause.rs:23:22
--> $DIR/suggest-where-clause.rs:23:6
|
LL | <Misc<_> as From<T>>::from;
| ^ the trait `From<T>` is not implemented for `Misc<_>`
| ^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>`
error[E0277]: the size for values of type `[T]` cannot be known at compilation time
--> $DIR/suggest-where-clause.rs:28:20

View File

@ -1,10 +1,8 @@
error[E0277]: the trait bound `(): Marker<u32>` is not satisfied
--> $DIR/issue-90804-incorrect-reference-suggestion.rs:10:17
--> $DIR/issue-90804-incorrect-reference-suggestion.rs:10:13
|
LL | check::<()>(());
| ----------- ^^ the trait `Marker<u32>` is not implemented for `()`
| |
| required by a bound introduced by this call
| ^^ the trait `Marker<u32>` is not implemented for `()`
|
note: required by a bound in `check`
--> $DIR/issue-90804-incorrect-reference-suggestion.rs:7:17

View File

@ -1,10 +1,8 @@
error[E0277]: cannot add `u32` to `i32`
--> $DIR/ufcs-qpath-self-mismatch.rs:4:31
--> $DIR/ufcs-qpath-self-mismatch.rs:4:6
|
LL | <i32 as Add<u32>>::add(1, 2);
| ---------------------- ^ no implementation for `i32 + u32`
| |
| required by a bound introduced by this call
| ^^^ no implementation for `i32 + u32`
|
= help: the trait `Add<u32>` is not implemented for `i32`
= help: the following other types implement trait `Add<Rhs>`:

View File

@ -1,12 +1,10 @@
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized3.rs:7:13
--> $DIR/unsized3.rs:7:10
|
LL | fn f1<X: ?Sized>(x: &X) {
| - this type parameter needs to be `Sized`
LL | f2::<X>(x);
| ------- ^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
| ^ doesn't have a size known at compile-time
|
note: required by a bound in `f2`
--> $DIR/unsized3.rs:10:7
@ -24,14 +22,12 @@ LL | fn f2<X: ?Sized>(x: &X) {
| ++++++++
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized3.rs:18:13
--> $DIR/unsized3.rs:18:10
|
LL | fn f3<X: ?Sized + T>(x: &X) {
| - this type parameter needs to be `Sized`
LL | f4::<X>(x);
| ------- ^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
| ^ doesn't have a size known at compile-time
|
note: required by a bound in `f4`
--> $DIR/unsized3.rs:21:7