Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct E0619 span re method call receivers whose type must be known #48028

Merged
merged 1 commit into from
Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let rcvr = &args[0];
let rcvr_t = self.check_expr_with_needs(&rcvr, needs);
// no need to check for bot/err -- callee does that
let rcvr_t = self.structurally_resolved_type(expr.span, rcvr_t);
let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);

let method = match self.lookup_method(rcvr_t,
segment,
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/span/issue-42234-unknown-receiver-type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// When the type of a method call's receiver is unknown, the span should point
// to the receiver (and not the entire call, as was previously the case before
// the fix of which this tests).

fn shines_a_beacon_through_the_darkness() {
let x: Option<_> = None;
x.unwrap().method_that_could_exist_on_some_type();
//~^ ERROR 17:5: 17:15: the type of this value must be known in this context
}

fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
.sum::<_>()
.to_string()
}

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/span/issue-42234-unknown-receiver-type.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0619]: the type of this value must be known in this context
--> $DIR/issue-42234-unknown-receiver-type.rs:17:5
|
17 | x.unwrap().method_that_could_exist_on_some_type();
| ^^^^^^^^^^

error[E0619]: the type of this value must be known in this context
--> $DIR/issue-42234-unknown-receiver-type.rs:22:5
|
22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
23 | | .sum::<_>()
| |___________________^

error: aborting due to 2 previous errors