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

Possible bug in lifetime checker of rustc 1.62 #17

Closed
NobodyXu opened this issue Jul 6, 2022 · 11 comments
Closed

Possible bug in lifetime checker of rustc 1.62 #17

NobodyXu opened this issue Jul 6, 2022 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@NobodyXu
Copy link
Member

NobodyXu commented Jul 6, 2022

I found that rustc rejects when I added this commit that changes nothing related to the error.

The code where error resides worked just fine without this commit or on 1.61 or earlier.

@jonhoo Could this be a bug in the rustc?

P.S. It failed on my MacOS M1 but succeeded in the CI... Really strange.
I also experienced clippy reports the lifetime error but cargo does not even without this commit.

I really have no idea what is going on.

@NobodyXu NobodyXu added the bug Something isn't working label Jul 6, 2022
@NobodyXu NobodyXu changed the title Bug in lifetime checker of rustc 1.62 Possible bug in lifetime checker of rustc 1.62 Jul 6, 2022
@jonhoo
Copy link

jonhoo commented Jul 6, 2022

From what I can tell, the error is in the lint that checks for valid links in documentation, not a rustc error per se. My guess is that you're running into the backwards-incompatibility from rust-lang/rust#97030 where Rust 1.62.0+ will actually interpret the documentation of private macros whereas earlier versions would not (and thus would not error on bad links there either).

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

@jonhoo I actually encountered such lifetime error in src/fs/mod.rs, but I cannot reproduce it for now.

I will close this since it cannot be reproduced, but if I encounter it again in the future, I will capture the entire output from cargo and as much information as possible.

@NobodyXu NobodyXu closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2022
@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

@jonhoo I finally was able to reproduce it in bug:

❯ ../check.sh
+++ realpath ../check.sh
++ dirname /Users/nobodyxu/Dev/openssh-sftp-client/check.sh
+ cd /Users/nobodyxu/Dev/openssh-sftp-client
+ for workspace in openssh-sftp-error openssh-sftp-client-lowlevel
+ cd openssh-sftp-error
+ run_check
+ cargo fmt --all -- --check
+ cargo clippy --all --no-deps
   Compiling sftp-test-common v0.1.0 (/Users/nobodyxu/Dev/openssh-sftp-client/sftp-test-common)
    Checking openssh-sftp-error v0.1.0 (/Users/nobodyxu/Dev/openssh-sftp-client/openssh-sftp-error)
    Checking openssh-sftp-client-lowlevel v0.1.0 (/Users/nobodyxu/Dev/openssh-sftp-client/openssh-sftp-cl
ient-lowlevel)
    Checking openssh-sftp-client v0.10.3 (/Users/nobodyxu/Dev/openssh-sftp-client)
error: lifetime may not live long enough
  --> src/fs/mod.rs:73:78
   |
73 |       async fn open_dir_impl(&mut self, path: &Path) -> Result<Dir<'_>, Error> {
   |  ____________________________-________________-________________________________^
   | |                            |                |
   | |                            |                let's call the lifetime of this reference `'1`
   | |                            let's call the lifetime of this reference `'2`
74 | |         let path = self.concat_path_if_needed(path);
75 | |
76 | |         self.write_end
...  |
79 | |             .map(|handle| Dir(OwnedHandle::new(self.write_end.clone(), handle)))
80 | |     }
   | |_____^ associated function was supposed to return data with lifetime `'1` but it is returning data
with lifetime `'2`

error: lifetime may not live long enough
  --> src/fs/mod.rs:73:78
   |
73 |       async fn open_dir_impl(&mut self, path: &Path) -> Result<Dir<'_>, Error> {
   |  ____________________________-________________-________________________________^
   | |                            |                |
   | |                            |                let's call the lifetime of this reference `'1`
   | |                            let's call the lifetime of this reference `'2`
74 | |         let path = self.concat_path_if_needed(path);
75 | |
76 | |         self.write_end
...  |
79 | |             .map(|handle| Dir(OwnedHandle::new(self.write_end.clone(), handle)))
80 | |     }
   | |_____^ associated function was supposed to return data with lifetime `'2` but it is returning data
with lifetime `'1`

error: lifetime may not live long enough
  --> src/fs/mod.rs:76:9
   |
72 |   impl<'s> Fs<'s> {
   |        -- lifetime `'s` defined here
73 |       async fn open_dir_impl(&mut self, path: &Path) -> Result<Dir<'_>, Error> {
   |                                               - let's call the lifetime of this reference `'1`
...
76 | /         self.write_end
77 | |             .send_request(|write_end, id| Ok(write_end.send_opendir_request(id, path)?.wait()))
78 | |             .await
79 | |             .map(|handle| Dir(OwnedHandle::new(self.write_end.clone(), handle)))
   | |________________________________________________________________________________^ associated functi
on was supposed to return data with lifetime `'1` but it is returning data with lifetime `'s`

error: could not compile `openssh-sftp-client` due to 3 previous errors


@NobodyXu NobodyXu reopened this Jul 7, 2022
@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

./run_tests.sh did not give any error.

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

rustc -vV:

rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: aarch64-apple-darwin
release: 1.62.0
LLVM version: 14.0.5

uname -a:

Darwin Jiahaos-Air.nifi 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.1
21.3~4/RELEASE_ARM64_T8101 arm64

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

@jonhoo I was also able to reproduce that on this commit once I changed create_dir implementation to this:

    /// Creates a new, empty directory at the provided path.
    pub async fn create_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error> {
        async fn inner(this: &mut Fs<'_>, path: &Path) -> Result<(), Error> {
            this.dir_builder().create(path).await
        }

        inner(self, path.as_ref()).await
    }

then I would get:

   Compiling openssh-sftp-client v0.10.3 (/Users/nobodyxu/Dev/openssh-sftp-client)
error: lifetime may not live long enough
  --> src/fs/mod.rs:75:86
   |
75 |           async fn inner<'s>(this: &mut Fs<'s>, path: &Path) -> Result<Dir<'s>, Error> {
   |  ________________________--___________________________-________________________________^
   | |                        |                            |
   | |                        |                            let's call the lifetime of this reference `'1`
   | |                        lifetime `'s` defined here
76 | |             let path = this.concat_path_if_needed(path);
77 | |
78 | |             this.write_end
...  |
81 | |                 .map(|handle| Dir(OwnedHandle::new(this.write_end.clone(), handle)))
82 | |         }
   | |_________^ function was supposed to return data with lifetime `'s` but it is returning data with lif
etime `'1`

error: lifetime may not live long enough
  --> src/fs/mod.rs:78:13
   |
75 |           async fn inner<'s>(this: &mut Fs<'s>, path: &Path) -> Result<Dir<'s>, Error> {
   |                          --                           - let's call the lifetime of this reference `'1
`
   |                          |
   |                          lifetime `'s` defined here
...
78 | /             this.write_end
79 | |                 .send_request(|write_end, id| Ok(write_end.send_opendir_request(id, path)?.wait()))
80 | |                 .await
81 | |                 .map(|handle| Dir(OwnedHandle::new(this.write_end.clone(), handle)))
   | |____________________________________________________________________________________^ function was s
upposed to return data with lifetime `'1` but it is returning data with lifetime `'s`

error: could not compile `openssh-sftp-client` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

Hmmm, once I removed target, it seems to be working just fine again.

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

I encountered it again in commit.

Once I modify src/file/mod.rs, it gives me error in fs/mod.rs again:

error: lifetime may not live long enough
  --> src/fs/mod.rs:75:86
   |
75 |           async fn inner<'s>(this: &mut Fs<'s>, path: &Path) -> Result<Dir<'s>, Error> {
   |  ________________________--________-___________________________________________________^
   | |                        |         |
   | |                        |         let's call the lifetime of this reference `'1`
   | |                        lifetime `'s` defined here
76 | |             let path = this.concat_path_if_needed(path);
77 | |
78 | |             this.write_end
...  |
81 | |                 .map(|handle| Dir(OwnedHandle::new(this.write_end.clone(), handle)))
82 | |         }
   | |_________^ function was supposed to return data with lifetime `'s` but it is returning data with lif
etime `'1`

error: could not compile `openssh-sftp-client` due to previous error
warning: build failed, waiting for other jobs to finish...

@jonhoo And once again, if I remove target/, everything works just fine.

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 7, 2022

This appears that 1.62 has problem with caching build artifacts in target.
Every time this happens, I just need to remove target/ to fix it.

Edit:

Could this be a problem with MacOS?
Like a corruption happens somewhere in the system.

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 8, 2022

This might just be bugs in MacOS.

I restarted my MacBook yesterday and it hasn't yet happened today.

@NobodyXu
Copy link
Member Author

NobodyXu commented Jul 8, 2022

Closing this since rebooting seemed to fix the issue.

@NobodyXu NobodyXu closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants