use try_structurally_resolve_type for method receiver
We'll still error due to the `opt_bad_ty` of `method_autoderef_steps`. This slightly worsens the span of `infer_var.method()` which is now the same as for `Box::new(infer_var).method()`. Unlike `structurally_resolve_type`, `probe_op` does not check whether the infcx is already tainted, so this results in 2 previously not emitted errors.
This commit is contained in:
parent
70f6493f26
commit
6b379b560d
23 changed files with 54 additions and 36 deletions
|
|
@ -1633,8 +1633,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
expected: Expectation<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
let rcvr_t = self.check_expr(rcvr);
|
||||
// no need to check for bot/err -- callee does that
|
||||
let rcvr_t = self.structurally_resolve_type(rcvr.span, rcvr_t);
|
||||
let rcvr_t = self.try_structurally_resolve_type(rcvr.span, rcvr_t);
|
||||
|
||||
match self.lookup_method(rcvr_t, segment, segment.ident.span, expr, rcvr, args) {
|
||||
Ok(method) => {
|
||||
|
|
|
|||
|
|
@ -486,6 +486,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ty::Infer(ty::TyVar(_)) => {
|
||||
let raw_ptr_call = bad_ty.reached_raw_pointer
|
||||
&& !self.tcx.features().arbitrary_self_types();
|
||||
// FIXME: Ideally we'd use the span of the self-expr here,
|
||||
// not of the method path.
|
||||
let mut err = self.err_ctxt().emit_inference_failure_err(
|
||||
self.body_id,
|
||||
span,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | needs_foo(|x| {
|
|||
| ^
|
||||
...
|
||||
LL | x.to_string();
|
||||
| - type must be known at this point
|
||||
| --------- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let mut iter = foo(n - 1, m);
|
|||
| ^^^^^^^^
|
||||
LL |
|
||||
LL | assert_eq!(iter.get(), 1);
|
||||
| ---- type must be known at this point
|
||||
| --- type must be known at this point
|
||||
|
|
||||
help: consider giving `iter` an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let x = my_foo();
|
|||
| ^
|
||||
LL |
|
||||
LL | x.my_debug();
|
||||
| - type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving `x` an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let x = my_foo();
|
|||
| ^
|
||||
LL |
|
||||
LL | x.my_debug();
|
||||
| - type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving `x` an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | Thunk::new(|mut cont| {
|
|||
| ^^^^^^^^
|
||||
LL |
|
||||
LL | cont.reify_as();
|
||||
| ---- type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -19,7 +19,7 @@ LL | Thunk::new(|mut cont| {
|
|||
| ^^^^^^^^
|
||||
LL |
|
||||
LL | cont.reify_as();
|
||||
| ---- type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | Thunk::new(|mut cont| {
|
|||
| ^^^^^^^^
|
||||
LL |
|
||||
LL | cont.reify_as();
|
||||
| ---- type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -19,7 +19,7 @@ LL | Thunk::new(|mut cont| {
|
|||
| ^^^^^^^^
|
||||
LL |
|
||||
LL | cont.reify_as();
|
||||
| ---- type must be known at this point
|
||||
| -------- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/method-resolution4.rs:13:9
|
||||
--> $DIR/method-resolution4.rs:13:20
|
||||
|
|
||||
LL | foo(false).next().unwrap();
|
||||
| ^^^^^^^^^^ cannot infer type
|
||||
| ^^^^ cannot infer type
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/recursive-bound-eval.rs:20:13
|
||||
--> $DIR/recursive-bound-eval.rs:20:28
|
||||
|
|
||||
LL | move || recursive_fn().parse()
|
||||
| ^^^^^^^^^^^^^^ cannot infer type
|
||||
| ^^^^^ cannot infer type
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/incompat-call-after-qualified-path-0.rs:21:6
|
||||
|
|
||||
LL | f(|a, b| a.cmp(b));
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/incompat-call-after-qualified-path-1.rs:25:6
|
||||
|
|
||||
LL | f(|a, b| a.cmp(b));
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
|||
LL | let x = panic!();
|
||||
| ^
|
||||
LL | x.clone();
|
||||
| - type must be known at this point
|
||||
| ----- type must be known at this point
|
||||
|
|
||||
help: consider giving `x` an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/branches3.rs:9:10
|
||||
|
|
||||
LL | |s| s.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -13,7 +13,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/branches3.rs:18:10
|
||||
|
|
||||
LL | |s| s.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -24,7 +24,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/branches3.rs:26:10
|
||||
|
|
||||
LL | |s| s.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -35,7 +35,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/branches3.rs:33:10
|
||||
|
|
||||
LL | |s| s.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -8,5 +8,7 @@ struct Ipv4Addr;
|
|||
|
||||
fn main() {
|
||||
let ip = Ipv4Addr;
|
||||
let _ = quote! { $($ip)* }; //~ ERROR the method `quote_into_iter` exists for struct `Ipv4Addr`, but its trait bounds were not satisfied
|
||||
let _ = quote! { $($ip)* };
|
||||
//~^ ERROR the method `quote_into_iter` exists for struct `Ipv4Addr`, but its trait bounds were not satisfied
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ note: the traits `Iterator` and `ToTokens` must be implemented
|
|||
--> $SRC_DIR/proc_macro/src/to_tokens.rs:LL:COL
|
||||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/not-repeatable.rs:11:13
|
||||
|
|
||||
LL | let _ = quote! { $($ip)* };
|
||||
| ^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0599.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ LL | let x = [Foo(PhantomData); 2];
|
|||
| ^
|
||||
LL |
|
||||
LL | extract(x).max(2);
|
||||
| ---------- type must be known at this point
|
||||
| --- type must be known at this point
|
||||
|
|
||||
help: consider giving `x` an explicit type, where the type for type parameter `T` is specified
|
||||
help: consider giving `x` an explicit type, where the placeholders `_` are specified
|
||||
|
|
||||
LL | let x: [Foo<T>; 2] = [Foo(PhantomData); 2];
|
||||
| +++++++++++++
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0282]: type annotations needed
|
|||
LL | let x: Option<_> = None;
|
||||
| ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
|
||||
LL | x.unwrap().method_that_could_exist_on_some_type();
|
||||
| ---------- type must be known at this point
|
||||
| ------------------------------------ type must be known at this point
|
||||
|
|
||||
help: consider specifying the generic argument
|
||||
|
|
||||
|
|
@ -16,6 +16,8 @@ error[E0282]: type annotations needed
|
|||
|
|
||||
LL | .sum::<_>()
|
||||
| ^^^ cannot infer type of the type parameter `S` declared on the method `sum`
|
||||
LL | .to_string()
|
||||
| --------- type must be known at this point
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/closures_in_branches.rs:8:10
|
||||
|
|
||||
LL | |x| x.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
@ -13,7 +13,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/closures_in_branches.rs:22:10
|
||||
|
|
||||
LL | |x| x.len()
|
||||
| ^ - type must be known at this point
|
||||
| ^ --- type must be known at this point
|
||||
|
|
||||
help: consider giving this closure parameter an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/method_resolution_trait_method_from_opaque.rs:28:9
|
||||
--> $DIR/method_resolution_trait_method_from_opaque.rs:28:18
|
||||
|
|
||||
LL | self.bar.next().unwrap();
|
||||
| ^^^^^^^^ cannot infer type
|
||||
| ^^^^ cannot infer type
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LL | let iv = S ^ index.into();
|
|||
| ^^
|
||||
LL |
|
||||
LL | &iv.to_bytes_be();
|
||||
| -- type must be known at this point
|
||||
| ----------- type must be known at this point
|
||||
|
|
||||
help: consider giving `iv` an explicit type
|
||||
|
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ impl Node for Stuff {
|
|||
|
||||
fn iterate<N: Node, G: Graph<N>>(graph: &G) {
|
||||
for node in graph.iter() { //~ ERROR no method named `iter` found
|
||||
node.zomg();
|
||||
node.zomg(); //~ ERROR type annotations needed
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ error[E0599]: no method named `iter` found for reference `&G` in the current sco
|
|||
LL | for node in graph.iter() {
|
||||
| ^^^^ method not found in `&G`
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-13853.rs:28:14
|
||||
|
|
||||
LL | node.zomg();
|
||||
| ^^^^ cannot infer type
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13853.rs:37:13
|
||||
|
|
||||
|
|
@ -37,7 +43,7 @@ help: consider borrowing here
|
|||
LL | iterate(&graph);
|
||||
| +
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0599.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
Some errors have detailed explanations: E0282, E0308, E0599.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue