diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 7 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index b2381bd97..44d6f6808 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -57,7 +57,7 @@ pub(crate) struct AssistCtx<'a> { | |||
57 | should_compute_edit: bool, | 57 | should_compute_edit: bool, |
58 | } | 58 | } |
59 | 59 | ||
60 | impl<'a> Clone for AssistCtx<'a> { | 60 | impl Clone for AssistCtx<'_> { |
61 | fn clone(&self) -> Self { | 61 | fn clone(&self) -> Self { |
62 | AssistCtx { | 62 | AssistCtx { |
63 | db: self.db, | 63 | db: self.db, |
@@ -80,8 +80,7 @@ impl<'a> AssistCtx<'a> { | |||
80 | label: impl Into<String>, | 80 | label: impl Into<String>, |
81 | f: impl FnOnce(&mut ActionBuilder), | 81 | f: impl FnOnce(&mut ActionBuilder), |
82 | ) -> Option<Assist> { | 82 | ) -> Option<Assist> { |
83 | let label = AssistLabel { label: label.into(), id }; | 83 | let label = AssistLabel::new(label.into(), id); |
84 | assert!(label.label.chars().nth(0).unwrap().is_uppercase()); | ||
85 | 84 | ||
86 | let assist = if self.should_compute_edit { | 85 | let assist = if self.should_compute_edit { |
87 | let action = { | 86 | let action = { |
@@ -103,7 +102,7 @@ impl<'a> AssistCtx<'a> { | |||
103 | label: impl Into<String>, | 102 | label: impl Into<String>, |
104 | f: impl FnOnce() -> Vec<ActionBuilder>, | 103 | f: impl FnOnce() -> Vec<ActionBuilder>, |
105 | ) -> Option<Assist> { | 104 | ) -> Option<Assist> { |
106 | let label = AssistLabel { label: label.into(), id }; | 105 | let label = AssistLabel::new(label.into(), id); |
107 | let assist = if self.should_compute_edit { | 106 | let assist = if self.should_compute_edit { |
108 | let actions = f(); | 107 | let actions = f(); |
109 | assert!(!actions.is_empty(), "Assist cannot have no"); | 108 | assert!(!actions.is_empty(), "Assist cannot have no"); |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index b71df7e5d..d476088a2 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -34,6 +34,14 @@ pub struct AssistLabel { | |||
34 | pub id: AssistId, | 34 | pub id: AssistId, |
35 | } | 35 | } |
36 | 36 | ||
37 | impl AssistLabel { | ||
38 | pub(crate) fn new(label: String, id: AssistId) -> AssistLabel { | ||
39 | // FIXME: make fields private, so that this invariant can't be broken | ||
40 | assert!(label.chars().nth(0).unwrap().is_uppercase()); | ||
41 | AssistLabel { label: label.into(), id } | ||
42 | } | ||
43 | } | ||
44 | |||
37 | #[derive(Debug, Clone)] | 45 | #[derive(Debug, Clone)] |
38 | pub struct AssistAction { | 46 | pub struct AssistAction { |
39 | pub label: Option<String>, | 47 | pub label: Option<String>, |