-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Some rename bugs #18812
Comments
There isn't really something we can do about this. Right now, we don't analyze cfg'ed out code at all. I want to change this, but in this case we have literally no way to know the two
Probably because it's inside a string. I believe it's doable though.
|
In theory, couldn't we add another export with the new name (so that the previous behavior - exporting the struct and the function - is what we get at the end)? |
Sorry, I misunderstood your meaning in that bullet. That is indeed possible I believe. |
(as was said) This is due to the string literal. This won't ever be supported, serde should instead allow using proper paths (without the string literals) there. (the reason for why it uses string literals is that literals were the only allowed t okens in that position back in the day)
This on the other hand I would expect to work, though it depends on what thiserror is doing. It needs to attach the span to the field in its expansion which I believe it might not be doing in which case we can't do anything about this either. |
I've uploaded a minimal reproduction of the panic in Semantic db (you can find it here: https://github.com/Bben01/rust-analyser-rename-bugs/blob/bdc4c6127262974e554bbb147258d053d7949f8d/src/proc_macro_static.rs) The backtrace
thread 'Worker' panicked at crates/hir/src/semantics.rs:1728:13:
Failed to lookup TRAIT@0..14 in this Semantics.
Make sure to use only query nodes, derived from this instance of Semantics.
root node: MACRO_ITEMS@0..101
known nodes: SOURCE_FILE@0..116, MACRO_ITEMS@0..6480, MACRO_ITEMS@0..279, MACRO_ITEMS@0..814, MACRO_ITEMS@0..72
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: hir::semantics::SemanticsImpl::find_file
3: ide_db::defs::NameClass::classify
4: ide_db::search::FindUsages::search
5: hashbrown::raw::RawIterRange<T>::fold_impl
6: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
7: ide::highlight_related::highlight_related
8: ra_salsa::Cancelled::catch
9: rust_analyzer::handlers::request::handle_document_highlight
10: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 19:00:16] Request textDocument/documentHighlight failed.
Message: request handler panicked:
Failed to lookup TRAIT@0..14 in this Semantics.
Make sure to use only query nodes, derived from this instance of Semantics.
root node: MACRO_ITEMS@0..101
known nodes: SOURCE_FILE@0..116, MACRO_ITEMS@0..6480, MACRO_ITEMS@0..279, MACRO_ITEMS@0..814, MACRO_ITEMS@0..72 |
Having looked at the thiserror thing a bit, the spans seem correct, the ident is used within a destruring pattern once, and within a condition. We seem to only pick the one in the condition though, so we lose the actual field association. |
rust-analyzer version: 0.3.2237-standalone (59bc7b4 2024-12-29)
rustc 1.83.0 (90b35a623 2024-11-26)
VSCode version: 1.95.3 (macOS)
Hi,
I worked lately on a renaming tool using r-a, I ran into some edge cases.
I've opened a repo that list what I could minimally reproduce, with one bug per module.
You can find it here: https://github.com/Bben01/rust-analyser-rename-bugs
Here is a summary of the bugs:
offset_of!
macro is not working #18891I am also working on reproducing a crash I got with the semantic db, I will update this issue when I get an example.
The text was updated successfully, but these errors were encountered: