Skip to content

Commit 0d64633

Browse files
authored
Merge pull request #19509 from snprajwal/remove-assistid-none
fix(ide-assists): remove `AssistKind::None`
2 parents c7845a6 + 094407a commit 0d64633

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

crates/ide-assists/src/handlers/toggle_ignore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ pub(crate) fn toggle_ignore(acc: &mut Assists, ctx: &AssistContext<'_>) -> Optio
3030

3131
match has_ignore_attribute(&func) {
3232
None => acc.add(
33-
AssistId::none("toggle_ignore"),
33+
AssistId::refactor("toggle_ignore"),
3434
"Ignore this test",
3535
attr.syntax().text_range(),
3636
|builder| builder.insert(attr.syntax().text_range().end(), "\n#[ignore]"),
3737
),
3838
Some(ignore_attr) => acc.add(
39-
AssistId::none("toggle_ignore"),
39+
AssistId::refactor("toggle_ignore"),
4040
"Re-enable this test",
4141
ignore_attr.syntax().text_range(),
4242
|builder| {

crates/ide-db/src/assists.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ pub enum Command {
4343

4444
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4545
pub enum AssistKind {
46-
// FIXME: does the None variant make sense? Probably not.
47-
None,
48-
4946
QuickFix,
5047
Generate,
5148
Refactor,
@@ -61,7 +58,7 @@ impl AssistKind {
6158
}
6259

6360
match self {
64-
AssistKind::None | AssistKind::Generate => true,
61+
AssistKind::Generate => true,
6562
AssistKind::Refactor => matches!(
6663
other,
6764
AssistKind::RefactorExtract
@@ -74,7 +71,6 @@ impl AssistKind {
7471

7572
pub fn name(&self) -> &str {
7673
match self {
77-
AssistKind::None => "None",
7874
AssistKind::QuickFix => "QuickFix",
7975
AssistKind::Generate => "Generate",
8076
AssistKind::Refactor => "Refactor",
@@ -90,7 +86,6 @@ impl FromStr for AssistKind {
9086

9187
fn from_str(s: &str) -> Result<Self, Self::Err> {
9288
match s {
93-
"None" => Ok(AssistKind::None),
9489
"QuickFix" => Ok(AssistKind::QuickFix),
9590
"Generate" => Ok(AssistKind::Generate),
9691
"Refactor" => Ok(AssistKind::Refactor),
@@ -108,10 +103,6 @@ impl FromStr for AssistKind {
108103
pub struct AssistId(pub &'static str, pub AssistKind, pub Option<usize>);
109104

110105
impl AssistId {
111-
pub fn none(id: &'static str) -> AssistId {
112-
AssistId(id, AssistKind::None, None)
113-
}
114-
115106
pub fn quick_fix(id: &'static str) -> AssistId {
116107
AssistId(id, AssistKind::QuickFix, None)
117108
}

crates/ide/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl Analysis {
753753
frange: FileRange,
754754
) -> Cancellable<Vec<Assist>> {
755755
let include_fixes = match &assist_config.allowed {
756-
Some(it) => it.iter().any(|&it| it == AssistKind::None || it == AssistKind::QuickFix),
756+
Some(it) => it.iter().any(|&it| it == AssistKind::QuickFix),
757757
None => true,
758758
};
759759

crates/proc-macro-srv/src/dylib/version.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn read_dylib_info(obj: &object::File<'_>) -> io::Result<RustCInfo> {
2727
let mut items = ver_str.split_whitespace();
2828
let tag = items.next().ok_or_else(|| err!("version format error"))?;
2929
if tag != "rustc" {
30-
return Err(err!("version format error (No rustc tag)"));
30+
return Err(err!("no rustc tag"));
3131
}
3232

3333
let version_part = items.next().ok_or_else(|| err!("no version string"))?;
@@ -83,7 +83,7 @@ fn read_section<'a>(obj: &object::File<'a>, section_name: &str) -> io::Result<&'
8383
/// A proc macro crate binary's ".rustc" section has following byte layout:
8484
/// * [b'r',b'u',b's',b't',0,0,0,5] is the first 8 bytes
8585
/// * ff060000 734e6150 is followed, it's the snappy format magic bytes,
86-
/// means bytes from here(including this sequence) are compressed in
86+
/// means bytes from here (including this sequence) are compressed in
8787
/// snappy compression format. Version info is inside here, so decompress
8888
/// this.
8989
///
@@ -110,15 +110,15 @@ pub fn read_version(obj: &object::File<'_>) -> io::Result<String> {
110110
));
111111
}
112112
let version = u32::from_be_bytes([dot_rustc[4], dot_rustc[5], dot_rustc[6], dot_rustc[7]]);
113-
// Last supported version is:
113+
// Last version with breaking changes is:
114114
// https://github.com/rust-lang/rust/commit/b94cfefc860715fb2adf72a6955423d384c69318
115115
let (mut metadata_portion, bytes_before_version) = match version {
116116
8 => {
117117
let len_bytes = &dot_rustc[8..12];
118118
let data_len = u32::from_be_bytes(len_bytes.try_into().unwrap()) as usize;
119119
(&dot_rustc[12..data_len + 12], 13)
120120
}
121-
9 => {
121+
9 | 10 => {
122122
let len_bytes = &dot_rustc[8..16];
123123
let data_len = u64::from_le_bytes(len_bytes.try_into().unwrap()) as usize;
124124
(&dot_rustc[16..data_len + 12], 17)

crates/rust-analyzer/src/lsp/from_proto.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub(crate) fn file_range_uri(
103103

104104
pub(crate) fn assist_kind(kind: lsp_types::CodeActionKind) -> Option<AssistKind> {
105105
let assist_kind = match &kind {
106-
k if k == &lsp_types::CodeActionKind::EMPTY => AssistKind::None,
107106
k if k == &lsp_types::CodeActionKind::QUICKFIX => AssistKind::QuickFix,
108107
k if k == &lsp_types::CodeActionKind::REFACTOR => AssistKind::Refactor,
109108
k if k == &lsp_types::CodeActionKind::REFACTOR_EXTRACT => AssistKind::RefactorExtract,

crates/rust-analyzer/src/lsp/to_proto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ pub(crate) fn call_hierarchy_item(
14771477

14781478
pub(crate) fn code_action_kind(kind: AssistKind) -> lsp_types::CodeActionKind {
14791479
match kind {
1480-
AssistKind::None | AssistKind::Generate => lsp_types::CodeActionKind::EMPTY,
1480+
AssistKind::Generate => lsp_types::CodeActionKind::EMPTY,
14811481
AssistKind::QuickFix => lsp_types::CodeActionKind::QUICKFIX,
14821482
AssistKind::Refactor => lsp_types::CodeActionKind::REFACTOR,
14831483
AssistKind::RefactorExtract => lsp_types::CodeActionKind::REFACTOR_EXTRACT,

0 commit comments

Comments
 (0)