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

unresolvedReference on many inherent methods from libcore on nightly rust (as of at least 2022-03-31's nightly) #11876

Closed
thomcc opened this issue Apr 2, 2022 · 3 comments · Fixed by #11881
Assignees
Labels
Broken Window Bugs / technical debt to be addressed immediately

Comments

@thomcc
Copy link
Member

thomcc commented Apr 2, 2022

This is the issue version of this zulip thread. There may be more info in it: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Unresolved.20reference.20to.20slice.20methods.2E .

Rust analyzer is failing to resolve references of slice methods, and other things from libcore on some fairly simple code. Here's a screenshot (the red text with an underline is from the unresolvedReference scope in https://github.com/matklad/pale-fire):

Screen Shot 2022-04-01 at 5 54 14 PM

This screenshot is taken from https://github.com/thomcc/envparse/blob/e2002f9fd30eca8f3cba9ff3ef121333b5feb2b3/src/parse.rs#L81-L100 , which reproduces the issue, at least at that checkout. It seems like slices, strs, Option, primitive numbers (not complete list, seems like a lot of things from libcore), don't have any of their inherent methods according to rust-analyzer.

An exception is that things that come from traits appear to be understood by r-a even if those traits/impls are from libcore. (And more broadly everything else from libcore is present, like types, traits, enum variants, constants, etc are all present)

I've tired on the both the unstable (rust-analyzer version: 0fe74175e 2022-04-02 nightly) and stable (rust-analyzer version: bc08b8eff 2022-03-28 stable) versions of rust-analyzer.

I'm using the following version of Visual Studio Code (insider version):

Version: 1.67.0-insider (Universal)
Commit: 8b7086afdbfd42bf6e7b8c0bb586530bf7cf1396
Date: 2022-04-01T05:16:51.251Z
Electron: 17.3.0
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Darwin arm64 21.4.0

And in case it matters, my rust version is:

$ rustc -Vv
rustc 1.61.0-nightly (0677edc86 2022-03-31)
binary: rustc
commit-hash: 0677edc86e342f333d4828b0ee1ef395a4e70fe5
commit-date: 2022-03-31
host: aarch64-apple-darwin
release: 1.61.0-nightly
LLVM version: 14.0.0
@thomcc
Copy link
Member Author

thomcc commented Apr 2, 2022

Oh, this seems to only be present on nightly rust. If I rustup default beta and restart my editor the problem goes away. Hrm.

@thomcc thomcc changed the title unresolvedReference on many inherent methods from libcore unresolvedReference on many inherent methods from libcore on nightly rust (as of at least 2022-03-31's nightly) Apr 2, 2022
@bjorn3
Copy link
Member

bjorn3 commented Apr 2, 2022

Probably caused by rust-lang/rust#94963.

@oslac
Copy link

oslac commented Apr 2, 2022

image

I have similar issues. parse and unwrap both "resolve" to {unknown} at line 7, while everything else works (like the to_stringmethod at line 10 is correctly resolved).

rustc 1.61.0-nightly (0677edc86 2022-03-31)
binary: rustc
commit-hash: 0677edc86e342f333d4828b0ee1ef395a4e70fe5
commit-date: 2022-03-31
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
rust-analyzer version: 0fe74175e 2022-04-02 nightly
Version: 1.67.0-insider
Commit: 8b7086afdbfd42bf6e7b8c0bb586530bf7cf1396
Date: 2022-04-01T05:20:13.110Z
Electron: 17.3.0
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Linux x64 5.13.0-39-generic snap

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Apr 2, 2022
@flodiebold flodiebold self-assigned this Apr 2, 2022
bors bot added a commit that referenced this issue Apr 2, 2022
11881: fix: Don't rely on lang items to find primitive impls r=flodiebold a=flodiebold

rustc has removed the use of lang items to mark the primitive impls, so just look through the crate graph for them (this should be fine performance-wise since we cache the crates that contain these impls).

Fixes #11876.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
@bors bors bot closed this as completed in b898808 Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants