Skip to content

Commit 4ab691a

Browse files
committedOct 20, 2018
17905 also no longer errors, thanks to IHLE
But its test was written in an outdated way that hits a different error despite IHLE, so keep a variant around for that case.

File tree

4 files changed

+76
-12
lines changed

4 files changed

+76
-12
lines changed
 

‎src/test/ui/issues/issue-17905-2.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[derive(Debug)]
12+
struct Pair<T, V> (T, V);
13+
14+
impl Pair<
15+
&str,
16+
isize
17+
> {
18+
fn say(self: &Pair<&str, isize>) {
19+
println!("{:?}", self);
20+
}
21+
}
22+
23+
fn main() {
24+
let result = &Pair("shane", 1);
25+
result.say();
26+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
error[E0308]: mismatched method receiver
2+
--> $DIR/issue-17905-2.rs:18:18
3+
|
4+
LL | fn say(self: &Pair<&str, isize>) {
5+
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
6+
|
7+
= note: expected type `Pair<&'_ str, _>`
8+
found type `Pair<&str, _>`
9+
note: the anonymous lifetime #2 defined on the method body at 18:5...
10+
--> $DIR/issue-17905-2.rs:18:5
11+
|
12+
LL | / fn say(self: &Pair<&str, isize>) {
13+
LL | | println!("{:?}", self);
14+
LL | | }
15+
| |_____^
16+
note: ...does not necessarily outlive the lifetime '_ as defined on the impl at 15:5
17+
--> $DIR/issue-17905-2.rs:15:5
18+
|
19+
LL | &str,
20+
| ^
21+
22+
error[E0308]: mismatched method receiver
23+
--> $DIR/issue-17905-2.rs:18:18
24+
|
25+
LL | fn say(self: &Pair<&str, isize>) {
26+
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
27+
|
28+
= note: expected type `Pair<&'_ str, _>`
29+
found type `Pair<&str, _>`
30+
note: the lifetime '_ as defined on the impl at 15:5...
31+
--> $DIR/issue-17905-2.rs:15:5
32+
|
33+
LL | &str,
34+
| ^
35+
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 18:5
36+
--> $DIR/issue-17905-2.rs:18:5
37+
|
38+
LL | / fn say(self: &Pair<&str, isize>) {
39+
LL | | println!("{:?}", self);
40+
LL | | }
41+
| |_____^
42+
43+
error: aborting due to 2 previous errors
44+
45+
For more information about this error, try `rustc --explain E0308`.

‎src/test/ui/issues/issue-17905.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-pass
12+
1113
#[derive(Debug)]
1214
struct Pair<T, V> (T, V);
1315

1416
impl Pair<
15-
&str, //~ ERROR missing lifetime specifier
17+
&str,
1618
isize
1719
> {
18-
fn say(self: &Pair<&str, isize>) {
19-
println!("{}", self);
20+
fn say(&self) {
21+
println!("{:?}", self);
2022
}
2123
}
2224

‎src/test/ui/issues/issue-17905.stderr

-9
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.