Use bool instead of Option<bool> and print it's value only when true

This commit is contained in:
Martin Asquino 2019-11-02 19:33:34 -03:00
parent dc3848a6a3
commit ccf8817d18
9 changed files with 6 additions and 79 deletions

View file

@ -96,7 +96,6 @@ mod tests {
insert: "the_field",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###
@ -129,7 +128,6 @@ mod tests {
kind: Method,
lookup: "foo",
detail: "fn foo(self)",
deprecated: false,
},
CompletionItem {
label: "the_field",
@ -141,7 +139,6 @@ mod tests {
documentation: Documentation(
"This is the_field",
),
deprecated: false,
},
]
"###
@ -171,7 +168,6 @@ mod tests {
kind: Method,
lookup: "foo",
detail: "fn foo(&self)",
deprecated: false,
},
CompletionItem {
label: "the_field",
@ -180,7 +176,6 @@ mod tests {
insert: "the_field",
kind: Field,
detail: "(u32, i32)",
deprecated: false,
},
]
"###
@ -226,7 +221,6 @@ mod tests {
kind: Method,
lookup: "the_method",
detail: "fn the_method(&self)",
deprecated: false,
},
]
"###
@ -256,7 +250,6 @@ mod tests {
kind: Method,
lookup: "the_method",
detail: "fn the_method(&self)",
deprecated: false,
},
]
"###
@ -286,7 +279,6 @@ mod tests {
kind: Method,
lookup: "the_method",
detail: "fn the_method(&self)",
deprecated: false,
},
]
"###
@ -339,7 +331,6 @@ mod tests {
kind: Method,
lookup: "the_method",
detail: "fn the_method(&self)",
deprecated: false,
},
]
"###
@ -410,7 +401,6 @@ mod tests {
kind: Method,
lookup: "blah",
detail: "pub fn blah(&self)",
deprecated: false,
},
]
"###
@ -437,7 +427,6 @@ mod tests {
insert: "the_field",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###

View file

@ -45,7 +45,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "macro_rules! foo",
deprecated: false,
},
]"##
);
@ -87,7 +86,6 @@ mod tests {
documentation: Documentation(
"Creates a [`Vec`] containing the arguments.\n\n- Create a [`Vec`] containing a given list of elements:\n\n```\nlet v = vec![1, 2, 3];\nassert_eq!(v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```",
),
deprecated: false,
},
]"##
);
@ -123,7 +121,6 @@ mod tests {
documentation: Documentation(
"Foo\n\nNot call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`.\nCall as `let _=foo! { hello world };`",
),
deprecated: false,
},
CompletionItem {
label: "main()",
@ -133,7 +130,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
]
"###

View file

@ -308,7 +308,6 @@ mod tests {
documentation: Documentation(
"Bar Variant with i32",
),
deprecated: false,
},
CompletionItem {
label: "Foo",
@ -320,7 +319,6 @@ mod tests {
documentation: Documentation(
"Foo Variant",
),
deprecated: false,
},
]"###
);
@ -356,7 +354,6 @@ mod tests {
documentation: Documentation(
"Bar Variant with i32 and u32",
),
deprecated: false,
},
CompletionItem {
label: "Foo",
@ -368,7 +365,6 @@ mod tests {
documentation: Documentation(
"Foo Variant (empty)",
),
deprecated: false,
},
CompletionItem {
label: "S",
@ -380,7 +376,6 @@ mod tests {
documentation: Documentation(
"",
),
deprecated: false,
},
]"###
);
@ -416,7 +411,6 @@ mod tests {
documentation: Documentation(
"An associated method",
),
deprecated: false,
},
]
"###
@ -451,7 +445,6 @@ mod tests {
documentation: Documentation(
"An associated const",
),
deprecated: false,
},
]"###
);
@ -485,7 +478,6 @@ mod tests {
documentation: Documentation(
"An associated type",
),
deprecated: false,
},
]"###
);
@ -521,7 +513,6 @@ mod tests {
documentation: Documentation(
"An associated method",
),
deprecated: false,
},
]
"###
@ -558,7 +549,6 @@ mod tests {
documentation: Documentation(
"An associated method",
),
deprecated: false,
},
]
"###
@ -618,7 +608,6 @@ mod tests {
documentation: Documentation(
"A trait method",
),
deprecated: false,
},
]
"###
@ -655,7 +644,6 @@ mod tests {
documentation: Documentation(
"A trait method",
),
deprecated: false,
},
]
"###
@ -692,7 +680,6 @@ mod tests {
documentation: Documentation(
"A trait method",
),
deprecated: false,
},
]
"###
@ -724,7 +711,6 @@ mod tests {
kind: Function,
lookup: "bar",
detail: "fn bar()",
deprecated: false,
},
CompletionItem {
label: "foo()",
@ -734,7 +720,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo()",
deprecated: false,
},
]
"###
@ -765,7 +750,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "#[macro_export]\nmacro_rules! foo",
deprecated: false,
},
CompletionItem {
label: "main()",
@ -775,7 +759,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
]
"###

View file

@ -78,7 +78,6 @@ mod tests {
insert: "the_field",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);
@ -105,7 +104,6 @@ mod tests {
insert: "a",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);
@ -132,7 +130,6 @@ mod tests {
insert: "b",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);
@ -158,7 +155,6 @@ mod tests {
insert: "a",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);

View file

@ -52,7 +52,6 @@ mod tests {
insert: "foo",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);
@ -82,7 +81,6 @@ mod tests {
insert: "bar",
kind: Field,
detail: "()",
deprecated: false,
},
CompletionItem {
label: "foo",
@ -91,7 +89,6 @@ mod tests {
insert: "foo",
kind: Field,
detail: "u32",
deprecated: false,
},
]
"###);

View file

@ -155,7 +155,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux(x: i32)",
deprecated: false,
},
CompletionItem {
label: "x",
@ -219,7 +218,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux()",
deprecated: false,
},
]
"###
@ -248,7 +246,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux()",
deprecated: false,
},
CompletionItem {
label: "x",
@ -289,7 +286,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux<T>()",
deprecated: false,
},
]
"###
@ -395,7 +391,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux()",
deprecated: false,
},
]
"###
@ -455,7 +450,6 @@ mod tests {
kind: Function,
lookup: "quux",
detail: "fn quux()",
deprecated: false,
},
]
"###
@ -488,7 +482,6 @@ mod tests {
kind: Function,
lookup: "x",
detail: "fn x()",
deprecated: false,
},
]
"###
@ -527,7 +520,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo()",
deprecated: false,
},
]
"###
@ -592,7 +584,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo()",
deprecated: false,
},
CompletionItem {
label: "std",
@ -648,7 +639,6 @@ mod tests {
insert: "bar!($0)",
kind: Macro,
detail: "macro_rules! bar",
deprecated: false,
},
CompletionItem {
label: "baz!",
@ -657,7 +647,6 @@ mod tests {
insert: "baz!($0)",
kind: Macro,
detail: "#[macro_export]\nmacro_rules! baz",
deprecated: false,
},
CompletionItem {
label: "foo!",
@ -666,7 +655,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "macro_rules! foo",
deprecated: false,
},
CompletionItem {
label: "m1",
@ -690,7 +678,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
]
"###
@ -721,7 +708,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "macro_rules! foo",
deprecated: false,
},
CompletionItem {
label: "foo()",
@ -731,7 +717,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo()",
deprecated: false,
},
]
"###
@ -762,7 +747,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "macro_rules! foo",
deprecated: false,
},
CompletionItem {
label: "main()",
@ -772,7 +756,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
]
"###
@ -803,7 +786,6 @@ mod tests {
insert: "foo!($0)",
kind: Macro,
detail: "macro_rules! foo",
deprecated: false,
},
CompletionItem {
label: "main()",
@ -813,7 +795,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
]
"###

View file

@ -46,7 +46,7 @@ pub struct CompletionItem {
documentation: Option<Documentation>,
/// Whether this item is marked as deprecated
deprecated: Option<bool>,
deprecated: bool,
}
// We use custom debug for CompletionItem to make `insta`'s diffs more readable.
@ -73,8 +73,8 @@ impl fmt::Debug for CompletionItem {
if let Some(documentation) = self.documentation() {
s.field("documentation", &documentation);
}
if let Some(deprecated) = self.deprecated {
s.field("deprecated", &deprecated);
if self.deprecated {
s.field("deprecated", &true);
}
s.finish()
}
@ -174,7 +174,7 @@ impl CompletionItem {
self.kind
}
pub fn deprecated(&self) -> Option<bool> {
pub fn deprecated(&self) -> bool {
self.deprecated
}
}
@ -220,7 +220,7 @@ impl Builder {
lookup: self.lookup,
kind: self.kind,
completion_kind: self.completion_kind,
deprecated: self.deprecated,
deprecated: self.deprecated.unwrap_or(false),
}
}
pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder {

View file

@ -335,7 +335,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
CompletionItem {
label: "something_deprecated()",
@ -382,7 +381,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
CompletionItem {
label: "no_args()",
@ -392,7 +390,6 @@ mod tests {
kind: Function,
lookup: "no_args",
detail: "fn no_args()",
deprecated: false,
},
]
"###
@ -414,7 +411,6 @@ mod tests {
kind: Function,
lookup: "main",
detail: "fn main()",
deprecated: false,
},
CompletionItem {
label: "with_args(…)",
@ -424,7 +420,6 @@ mod tests {
kind: Function,
lookup: "with_args",
detail: "fn with_args(x: i32, y: String)",
deprecated: false,
},
]
"###
@ -451,7 +446,6 @@ mod tests {
kind: Method,
lookup: "foo",
detail: "fn foo(&self)",
deprecated: false,
},
]
"###
@ -476,7 +470,6 @@ mod tests {
insert: "foo",
kind: Function,
detail: "pub fn foo()",
deprecated: false,
},
]"#
);
@ -502,7 +495,6 @@ mod tests {
insert: "frobnicate",
kind: Function,
detail: "fn frobnicate()",
deprecated: false,
},
CompletionItem {
label: "main",
@ -511,7 +503,6 @@ mod tests {
insert: "main",
kind: Function,
detail: "fn main()",
deprecated: false,
},
]"#
);
@ -534,7 +525,6 @@ mod tests {
insert: "new",
kind: Function,
detail: "fn new() -> Foo",
deprecated: false,
},
]"#
);
@ -568,7 +558,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo(xs: Ve)",
deprecated: false,
},
]
"###
@ -598,7 +587,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo(xs: Ve)",
deprecated: false,
},
]
"###
@ -627,7 +615,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo(xs: Ve)",
deprecated: false,
},
]
"###
@ -656,7 +643,6 @@ mod tests {
kind: Function,
lookup: "foo",
detail: "fn foo(xs: Ve<i128>)",
deprecated: false,
},
]
"###
@ -687,7 +673,6 @@ mod tests {
insert: "frobnicate",
kind: Macro,
detail: "#[macro_export]\nmacro_rules! frobnicate",
deprecated: false,
},
]
"###

View file

@ -127,7 +127,7 @@ impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
text_edit: Some(text_edit),
additional_text_edits: Some(additional_text_edits),
documentation: self.documentation().map(|it| it.conv()),
deprecated: self.deprecated(),
deprecated: Some(self.deprecated()),
..Default::default()
};
res.insert_text_format = Some(match self.insert_text_format() {