mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Add support for Rust 2021.
This commit is contained in:
parent
56a7bf7ede
commit
4833972067
6 changed files with 12 additions and 6 deletions
|
@ -190,10 +190,11 @@ pub struct CrateData {
|
|||
pub proc_macro: Vec<ProcMacro>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum Edition {
|
||||
Edition2018,
|
||||
Edition2015,
|
||||
Edition2018,
|
||||
Edition2021,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -393,6 +394,7 @@ impl FromStr for Edition {
|
|||
let res = match s {
|
||||
"2015" => Edition::Edition2015,
|
||||
"2018" => Edition::Edition2018,
|
||||
"2021" => Edition::Edition2021,
|
||||
_ => return Err(ParseEditionError { invalid_input: s.to_string() }),
|
||||
};
|
||||
Ok(res)
|
||||
|
@ -404,6 +406,7 @@ impl fmt::Display for Edition {
|
|||
f.write_str(match self {
|
||||
Edition::Edition2015 => "2015",
|
||||
Edition::Edition2018 => "2018",
|
||||
Edition::Edition2021 => "2021",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ impl TestAttr {
|
|||
|
||||
const RUSTDOC_FENCE: &str = "```";
|
||||
const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUNNABLE: &[&str] =
|
||||
&["", "rust", "should_panic", "edition2015", "edition2018"];
|
||||
&["", "rust", "should_panic", "edition2015", "edition2018", "edition2021"];
|
||||
|
||||
fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool {
|
||||
attrs.docs().map_or(false, |doc| {
|
||||
|
|
|
@ -55,7 +55,7 @@ type RangesMap = BTreeMap<TextSize, TextSize>;
|
|||
|
||||
const RUSTDOC_FENCE: &'static str = "```";
|
||||
const RUSTDOC_FENCE_TOKENS: &[&'static str] =
|
||||
&["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"];
|
||||
&["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018", "edition2021"];
|
||||
|
||||
/// Extracts Rust code from documentation comments as well as a mapping from
|
||||
/// the extracted source code back to the original source ranges.
|
||||
|
|
|
@ -139,6 +139,8 @@ enum EditionData {
|
|||
Edition2015,
|
||||
#[serde(rename = "2018")]
|
||||
Edition2018,
|
||||
#[serde(rename = "2021")]
|
||||
Edition2021,
|
||||
}
|
||||
|
||||
impl From<EditionData> for Edition {
|
||||
|
@ -146,6 +148,7 @@ impl From<EditionData> for Edition {
|
|||
match data {
|
||||
EditionData::Edition2015 => Edition::Edition2015,
|
||||
EditionData::Edition2018 => Edition::Edition2018,
|
||||
EditionData::Edition2021 => Edition::Edition2021,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const RUSTDOC_FENCE: &str = "```";
|
||||
const RUSTDOC_CODE_BLOCK_ATTRIBUTES_RUST_SPECIFIC: &[&str] =
|
||||
&["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018"];
|
||||
&["", "rust", "should_panic", "ignore", "no_run", "compile_fail", "edition2015", "edition2018", "edition2021"];
|
||||
|
||||
pub(crate) fn format_docs(src: &str) -> String {
|
||||
let mut processed_lines = Vec::new();
|
||||
|
|
|
@ -339,7 +339,7 @@ interface Crate {
|
|||
/// Path to the root module of the crate.
|
||||
root_module: string;
|
||||
/// Edition of the crate.
|
||||
edition: "2015" | "2018";
|
||||
edition: "2015" | "2018" | "2021";
|
||||
/// Dependencies
|
||||
deps: Dep[];
|
||||
/// Should this crate be treated as a member of current "workspace".
|
||||
|
|
Loading…
Reference in a new issue