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

nll type annotations in multisegment path #55093

Merged
merged 19 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: user substs: Canonical { variables: [], value: [u32] }
error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } }
--> $DIR/dump-adt-brace-struct.rs:28:5
|
LL | SomeStruct::<u32> { t: 22 }; //~ ERROR [u32]
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/nll/user-annotations/dump-fn-method.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
error: user substs: Canonical { variables: [], value: [u32] }
error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } }
--> $DIR/dump-fn-method.rs:36:13
|
LL | let x = foo::<u32>; //~ ERROR [u32]
| ^^^^^^^^^^

error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, u32, ?1] }
error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, u32, ?1], user_self_ty: None } }
--> $DIR/dump-fn-method.rs:42:13
|
LL | let x = <_ as Bazoom<u32>>::method::<_>; //~ ERROR [?0, u32, ?1]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: user substs: Canonical { variables: [], value: [u8, u16, u32] }
error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u8, u16, u32], user_self_ty: None } }
--> $DIR/dump-fn-method.rs:46:13
|
LL | let x = <u8 as Bazoom<u16>>::method::<u32>; //~ ERROR [u8, u16, u32]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, ?1, u32] }
error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, ?1, u32], user_self_ty: None } }
--> $DIR/dump-fn-method.rs:54:5
|
LL | y.method::<u32>(44, 66); //~ ERROR [?0, ?1, u32]
Expand Down
19 changes: 19 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(nll)]

// Check that substitutions given on the self type (here, `A`) carry
// through to NLL.

struct A<'a> { x: &'a u32 }

impl<'a> A<'a> {
fn new<'b, T>(x: &'a u32, y: T) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a 'b here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I see the same thing occuring in the other tests. To be honest I had thought that we didn't allow unreferenced lifetimes in generic binders ... but I guess that is just a lint, when it comes to lifetimes...?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy and paste error, I think

Self { x }
}
}

fn foo<'a>() {
let v = 22;
let x = A::<'a>::new(&v, 22);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you and I mirrored each other on our respective PR's; there should be an //~ ERROR on this line, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eep yes, will add.

}

fn main() {}
17 changes: 17 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-1.rs:16:26
|
LL | let x = A::<'a>::new(&v, 22);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8...
--> $DIR/method-ufcs-inherent-1.rs:14:8
|
LL | fn foo<'a>() {
| ^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
19 changes: 19 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(nll)]

// Check that substitutions given on the self type (here, `A`) can be
// used in combination with annotations given for method arguments.

struct A<'a> { x: &'a u32 }

impl<'a> A<'a> {
fn new<'b, T>(x: &'a u32, y: T) -> Self {
Self { x }
}
}

fn foo<'a>() {
let v = 22;
let x = A::<'a>::new::<&'a u32>(&v, &v);
}

fn main() {}
31 changes: 31 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-2.rs:16:37
|
LL | let x = A::<'a>::new::<&'a u32>(&v, &v);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8...
--> $DIR/method-ufcs-inherent-2.rs:14:8
|
LL | fn foo<'a>() {
| ^^

error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-2.rs:16:41
|
LL | let x = A::<'a>::new::<&'a u32>(&v, &v);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8...
--> $DIR/method-ufcs-inherent-2.rs:14:8
|
LL | fn foo<'a>() {
| ^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0597`.
19 changes: 19 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(nll)]

// Check that inherent methods invoked with `<T>::new` style
// carry their annotations through to NLL.

struct A<'a> { x: &'a u32 }

impl<'a> A<'a> {
fn new<'b, T>(x: &'a u32, y: T) -> Self {
Self { x }
}
}

fn foo<'a>() {
let v = 22;
let x = <A<'a>>::new(&v, 22);
}

fn main() {}
17 changes: 17 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-3.rs:16:26
|
LL | let x = <A<'a>>::new(&v, 22);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8...
--> $DIR/method-ufcs-inherent-3.rs:14:8
|
LL | fn foo<'a>() {
| ^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
20 changes: 20 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![feature(nll)]

// Check that inherent methods invoked with `<T>::new` style
// carry their annotations through to NLL in connection with
// method type parameters.

struct A<'a> { x: &'a u32 }

impl<'a> A<'a> {
fn new<'b, T>(x: &'a u32, y: T) -> Self {
Self { x }
}
}

fn foo<'a>() {
let v = 22;
let x = <A<'a>>::new::<&'a u32>(&v, &v);
}

fn main() {}
31 changes: 31 additions & 0 deletions src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-4.rs:17:37
|
LL | let x = <A<'a>>::new::<&'a u32>(&v, &v);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8...
--> $DIR/method-ufcs-inherent-4.rs:15:8
|
LL | fn foo<'a>() {
| ^^

error[E0597]: `v` does not live long enough
--> $DIR/method-ufcs-inherent-4.rs:17:41
|
LL | let x = <A<'a>>::new::<&'a u32>(&v, &v);
| ^^ borrowed value does not live long enough
LL | }
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8...
--> $DIR/method-ufcs-inherent-4.rs:15:8
|
LL | fn foo<'a>() {
| ^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0597`.