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

Extend E0623 for fn items #44516

Merged
merged 8 commits into from
Sep 14, 2017
Merged

Extend E0623 for fn items #44516

merged 8 commits into from
Sep 14, 2017

Conversation

gaurikholkar-zz
Copy link

@gaurikholkar-zz gaurikholkar-zz commented Sep 12, 2017

This fixes #44516
The below example now gives

error[E0623]: lifetime mismatch
 --> gg.rs:3:10
  |
2 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  |                               ---      --- these two types are declared with different lifetimes...
3 |   y.push(z);
  |          ^ ...but data from `z` flows into `y` here

error: aborting due to previous error

r? @nikomatsakis
cc @arielb1

self.depth -= 1;
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

Trailing whitespace

[00:04:19] tidy error: /checkout/src/librustc/infer/error_reporting/different_lifetimes.rs:213: trailing whitespace

BTW you could run the tidy test locally using

./x.py test src/tools/tidy

Copy link
Contributor

Choose a reason for hiding this comment

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

You also need to handle TyTraitObject (aka the Fn in Box<Fn<(&u8, &u8)>>).

Copy link
Author

Choose a reason for hiding this comment

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

yeah at it :)

Copy link
Author

Choose a reason for hiding this comment

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

@arielb1 need an example to test

y.b = x;
=======
x = y.b;
>>>>>>> Adding E0623 for structs
Copy link
Member

Choose a reason for hiding this comment

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

????

Copy link
Contributor

Choose a reason for hiding this comment

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

ERROR: merge conflict marker in file

@arielb1 arielb1 assigned arielb1 and unassigned nikomatsakis Sep 12, 2017
@arielb1 arielb1 added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 12, 2017
hir::TyBareFn(_) => {
self.depth += 1;
intravisit::walk_ty(self, arg);
self.depth -= 1;
Copy link
Member

Choose a reason for hiding this comment

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

No such field depth. Do you mean the depth of the de Bruijn index or something?

[00:06:31] error[E0609]: no field `depth` on type `&mut infer::error_reporting::different_lifetimes::FindNestedTypeVisitor<'a, 'gcx, 'tcx>`
[00:06:31]    --> /checkout/src/librustc/infer/error_reporting/different_lifetimes.rs:208:22
[00:06:31]     |
[00:06:31] 208 |                 self.depth += 1;
[00:06:31]     |                      ^^^^^
[00:06:31] 
[00:06:31] error[E0609]: no field `depth` on type `&mut infer::error_reporting::different_lifetimes::FindNestedTypeVisitor<'a, 'gcx, 'tcx>`
[00:06:31]    --> /checkout/src/librustc/infer/error_reporting/different_lifetimes.rs:210:22
[00:06:31]     |
[00:06:31] 210 |                 self.depth -= 1;
[00:06:31]     |                      ^^^^^
[00:06:31] 
[00:06:41] error: aborting due to 2 previous errors
[00:06:41] 
[00:06:41] error: Could not compile `rustc`.

15 | fn foo(mut x: Ref) {
| ---
| |
| these two types are declared with different lifetimes...
Copy link
Member

Choose a reason for hiding this comment

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

Test case differs from actual output.

 error[E0623]: lifetime mismatch
   --> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:11
    |
 15 | fn foo(mut x: Ref) {
    |               ---
    |               |
-   |               these two types are declared with different lifetimes...
+   |               this type was declared with multiple lifetimes...
 16 |     x.a = x.b;
    |           ^^^ ...but data with one lifetime flows into the other here

@@ -0,0 +1,10 @@
error[E0623]: lifetime mismatch
--> src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs:11:10
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

 error[E0623]: lifetime mismatch
-  --> src/test/ui/lifetime-errors/ex3-both-anon-regions-using-fn-items.rs:11:10
+  --> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:10
    |
 10 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
    |                               ---      --- these two types are declared with different lifetimes...
 11 |   y.push(z);
    |          ^ ...but data from `z` flows into `y` here
 
 error: aborting due to previous error

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2017

@bors r+

@bors
Copy link
Contributor

bors commented Sep 13, 2017

📌 Commit e71eef1 has been approved by arielb1

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2017

I think this doesn't handle the case of structs

struct Ref<'a>(&'a ());
fn foo(x:fn(Ref, Ref), y: Vec<&u8>, z: &u8) {
  y.push(z);
}

@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2017

@bors p=1

This is blocking further work

@gaurikholkar-zz
Copy link
Author

gaurikholkar-zz commented Sep 13, 2017

@arielb1 it does though

error[E0623]: lifetime mismatch
 --> kk.rs:4:10
  |
3 | fn foo(x:fn(Ref, Ref), y: Vec<&u8>, z: &u8) {
  |             ---  --- these two types are declared with different lifetimes...
4 |   y.push(z);
  |          ^ ...but data from `z` flows into `y` here

error: aborting due to previous error

bors added a commit that referenced this pull request Sep 13, 2017
Extend E0623 for fn items

This fixes #44516
The below example now gives
```
error[E0623]: lifetime mismatch
 --> gg.rs:3:10
  |
2 | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
  |                               ---      --- these two types are declared with different lifetimes...
3 |   y.push(z);
  |          ^ ...but data from `z` flows into `y` here

error: aborting due to previous error
```

r? @nikomatsakis
cc @arielb1
@bors
Copy link
Contributor

bors commented Sep 13, 2017

⌛ Testing commit e71eef1 with merge 9421141...

@bors
Copy link
Contributor

bors commented Sep 14, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: arielb1
Pushing 9421141 to master...

@@ -0,0 +1,8 @@

fn foo(x: fn(&u8, &u8), y: Vec<&u8>, z: &u8) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you accidentially left this file in the root dir?

Copy link
Author

Choose a reason for hiding this comment

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

Oh yeah. I'm open a PR for that or I have an ongoing PR, I'll make sure to delete that.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in #44549. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants