mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Merge pull request #18670 from Veykril/push-ylomnylswnxm
internal: Drop proc-macro server support for ~1.66.0 and older toolchains
This commit is contained in:
commit
acd469681f
2 changed files with 30 additions and 48 deletions
|
@ -42,7 +42,7 @@ use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use span::{EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, TextRange};
|
use span::{EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SyntaxContextId, TextRange};
|
||||||
|
|
||||||
use crate::msg::{ENCODE_CLOSE_SPAN_VERSION, EXTENDED_LEAF_DATA};
|
use crate::msg::EXTENDED_LEAF_DATA;
|
||||||
|
|
||||||
pub type SpanDataIndexMap =
|
pub type SpanDataIndexMap =
|
||||||
indexmap::IndexSet<Span, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
|
indexmap::IndexSet<Span, std::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
|
||||||
|
@ -145,11 +145,7 @@ impl FlatTree {
|
||||||
w.write(subtree);
|
w.write(subtree);
|
||||||
|
|
||||||
FlatTree {
|
FlatTree {
|
||||||
subtree: if version >= ENCODE_CLOSE_SPAN_VERSION {
|
subtree: write_vec(w.subtree, SubtreeRepr::write),
|
||||||
write_vec(w.subtree, SubtreeRepr::write_with_close_span)
|
|
||||||
} else {
|
|
||||||
write_vec(w.subtree, SubtreeRepr::write)
|
|
||||||
},
|
|
||||||
literal: if version >= EXTENDED_LEAF_DATA {
|
literal: if version >= EXTENDED_LEAF_DATA {
|
||||||
write_vec(w.literal, LiteralRepr::write_with_kind)
|
write_vec(w.literal, LiteralRepr::write_with_kind)
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,11 +179,7 @@ impl FlatTree {
|
||||||
w.write(subtree);
|
w.write(subtree);
|
||||||
|
|
||||||
FlatTree {
|
FlatTree {
|
||||||
subtree: if version >= ENCODE_CLOSE_SPAN_VERSION {
|
subtree: write_vec(w.subtree, SubtreeRepr::write),
|
||||||
write_vec(w.subtree, SubtreeRepr::write_with_close_span)
|
|
||||||
} else {
|
|
||||||
write_vec(w.subtree, SubtreeRepr::write)
|
|
||||||
},
|
|
||||||
literal: if version >= EXTENDED_LEAF_DATA {
|
literal: if version >= EXTENDED_LEAF_DATA {
|
||||||
write_vec(w.literal, LiteralRepr::write_with_kind)
|
write_vec(w.literal, LiteralRepr::write_with_kind)
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,11 +202,7 @@ impl FlatTree {
|
||||||
span_data_table: &SpanDataIndexMap,
|
span_data_table: &SpanDataIndexMap,
|
||||||
) -> tt::Subtree<Span> {
|
) -> tt::Subtree<Span> {
|
||||||
Reader {
|
Reader {
|
||||||
subtree: if version >= ENCODE_CLOSE_SPAN_VERSION {
|
subtree: read_vec(self.subtree, SubtreeRepr::read),
|
||||||
read_vec(self.subtree, SubtreeRepr::read_with_close_span)
|
|
||||||
} else {
|
|
||||||
read_vec(self.subtree, SubtreeRepr::read)
|
|
||||||
},
|
|
||||||
literal: if version >= EXTENDED_LEAF_DATA {
|
literal: if version >= EXTENDED_LEAF_DATA {
|
||||||
read_vec(self.literal, LiteralRepr::read_with_kind)
|
read_vec(self.literal, LiteralRepr::read_with_kind)
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,11 +224,7 @@ impl FlatTree {
|
||||||
|
|
||||||
pub fn to_subtree_unresolved(self, version: u32) -> tt::Subtree<TokenId> {
|
pub fn to_subtree_unresolved(self, version: u32) -> tt::Subtree<TokenId> {
|
||||||
Reader {
|
Reader {
|
||||||
subtree: if version >= ENCODE_CLOSE_SPAN_VERSION {
|
subtree: read_vec(self.subtree, SubtreeRepr::read),
|
||||||
read_vec(self.subtree, SubtreeRepr::read_with_close_span)
|
|
||||||
} else {
|
|
||||||
read_vec(self.subtree, SubtreeRepr::read)
|
|
||||||
},
|
|
||||||
literal: if version >= EXTENDED_LEAF_DATA {
|
literal: if version >= EXTENDED_LEAF_DATA {
|
||||||
read_vec(self.literal, LiteralRepr::read_with_kind)
|
read_vec(self.literal, LiteralRepr::read_with_kind)
|
||||||
} else {
|
} else {
|
||||||
|
@ -273,26 +257,7 @@ fn write_vec<T, F: Fn(T) -> [u32; N], const N: usize>(xs: Vec<T>, f: F) -> Vec<u
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SubtreeRepr {
|
impl SubtreeRepr {
|
||||||
fn write(self) -> [u32; 4] {
|
fn write(self) -> [u32; 5] {
|
||||||
let kind = match self.kind {
|
|
||||||
tt::DelimiterKind::Invisible => 0,
|
|
||||||
tt::DelimiterKind::Parenthesis => 1,
|
|
||||||
tt::DelimiterKind::Brace => 2,
|
|
||||||
tt::DelimiterKind::Bracket => 3,
|
|
||||||
};
|
|
||||||
[self.open.0, kind, self.tt[0], self.tt[1]]
|
|
||||||
}
|
|
||||||
fn read([open, kind, lo, len]: [u32; 4]) -> SubtreeRepr {
|
|
||||||
let kind = match kind {
|
|
||||||
0 => tt::DelimiterKind::Invisible,
|
|
||||||
1 => tt::DelimiterKind::Parenthesis,
|
|
||||||
2 => tt::DelimiterKind::Brace,
|
|
||||||
3 => tt::DelimiterKind::Bracket,
|
|
||||||
other => panic!("bad kind {other}"),
|
|
||||||
};
|
|
||||||
SubtreeRepr { open: TokenId(open), close: TokenId(!0), kind, tt: [lo, len] }
|
|
||||||
}
|
|
||||||
fn write_with_close_span(self) -> [u32; 5] {
|
|
||||||
let kind = match self.kind {
|
let kind = match self.kind {
|
||||||
tt::DelimiterKind::Invisible => 0,
|
tt::DelimiterKind::Invisible => 0,
|
||||||
tt::DelimiterKind::Parenthesis => 1,
|
tt::DelimiterKind::Parenthesis => 1,
|
||||||
|
@ -301,7 +266,7 @@ impl SubtreeRepr {
|
||||||
};
|
};
|
||||||
[self.open.0, self.close.0, kind, self.tt[0], self.tt[1]]
|
[self.open.0, self.close.0, kind, self.tt[0], self.tt[1]]
|
||||||
}
|
}
|
||||||
fn read_with_close_span([open, close, kind, lo, len]: [u32; 5]) -> SubtreeRepr {
|
fn read([open, close, kind, lo, len]: [u32; 5]) -> SubtreeRepr {
|
||||||
let kind = match kind {
|
let kind = match kind {
|
||||||
0 => tt::DelimiterKind::Invisible,
|
0 => tt::DelimiterKind::Invisible,
|
||||||
1 => tt::DelimiterKind::Parenthesis,
|
1 => tt::DelimiterKind::Parenthesis,
|
||||||
|
|
|
@ -56,8 +56,25 @@ impl ProcMacroProcessSrv {
|
||||||
match srv.version_check() {
|
match srv.version_check() {
|
||||||
Ok(v) if v > CURRENT_API_VERSION => Err(io::Error::new(
|
Ok(v) if v > CURRENT_API_VERSION => Err(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
format!( "The version of the proc-macro server ({v}) in your Rust toolchain is newer than the version supported by your rust-analyzer ({CURRENT_API_VERSION}).
|
format!(
|
||||||
This will prevent proc-macro expansion from working. Please consider updating your rust-analyzer to ensure compatibility with your current toolchain."
|
"The version of the proc-macro server ({v}) in your Rust toolchain \
|
||||||
|
is newer than the version supported by your rust-analyzer ({CURRENT_API_VERSION}).
|
||||||
|
\
|
||||||
|
This will prevent proc-macro expansion from working. \
|
||||||
|
Please consider updating your rust-analyzer to ensure compatibility with your \
|
||||||
|
current toolchain."
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Ok(v) if v < RUST_ANALYZER_SPAN_SUPPORT => Err(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
format!(
|
||||||
|
"The version of the proc-macro server ({v}) in your Rust toolchain \
|
||||||
|
is too old and no longer supported by your rust-analyzer which requires\
|
||||||
|
version {RUST_ANALYZER_SPAN_SUPPORT} or higher.
|
||||||
|
\
|
||||||
|
This will prevent proc-macro expansion from working. \
|
||||||
|
Please consider updating your toolchain or downgrading your rust-analyzer \
|
||||||
|
to ensure compatibility with your current toolchain."
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
|
@ -72,10 +89,10 @@ impl ProcMacroProcessSrv {
|
||||||
tracing::info!("Proc-macro server span mode: {:?}", srv.mode);
|
tracing::info!("Proc-macro server span mode: {:?}", srv.mode);
|
||||||
Ok(srv)
|
Ok(srv)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => Err(io::Error::new(
|
||||||
tracing::info!(%e, "proc-macro version check failed, restarting and assuming version 0");
|
io::ErrorKind::Other,
|
||||||
create_srv(false)
|
format!("Failed to fetch proc-macro server version: {e}"),
|
||||||
}
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue