From 991d0190968662f23220d8aefaf28bd03b1dbe41 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 8 Oct 2020 09:30:01 +0300 Subject: Use TextRange::contains_inclusive in fixes check --- crates/ide/src/diagnostics.rs | 6 ++---- crates/ide/src/diagnostics/fixes.rs | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index add102ff2..b30cdb6ed 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -257,8 +257,7 @@ mod tests { assert_eq_text!(&after, &actual); assert!( - fix.fix_trigger_range.start() <= file_position.offset - && fix.fix_trigger_range.end() >= file_position.offset, + fix.fix_trigger_range.contains_inclusive(file_position.offset), "diagnostic fix range {:?} does not touch cursor position {:?}", fix.fix_trigger_range, file_position.offset @@ -288,8 +287,7 @@ mod tests { assert_eq_text!(&after, &actual); assert!( - fix.fix_trigger_range.start() <= file_position.offset - && fix.fix_trigger_range.end() >= file_position.offset, + fix.fix_trigger_range.contains_inclusive(file_position.offset), "diagnostic fix range {:?} does not touch cursor position {:?}", fix.fix_trigger_range, file_position.offset diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index b47fe0469..0c75e50b0 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -111,7 +111,8 @@ impl DiagnosticWithFix for IncorrectCase { let offset = name_node.syntax().text_range().start(); let file_position = FilePosition { file_id, offset }; - let rename_changes = rename_with_semantics(sema, file_position, &self.suggested_text)?; + let rename_changes = + rename_with_semantics(sema, file_position, &self.suggested_text).ok()?; let label = format!("Rename to {}", self.suggested_text); Some(Fix::new(&label, rename_changes.info, rename_changes.range)) -- cgit v1.2.3