mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
hide keyword suggestions in non trivial paths
This commit is contained in:
parent
478d435640
commit
7b20904e8b
@ -20,6 +20,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
|
||||
cov_mark::hit!(no_keyword_completion_in_attr_of_expr);
|
||||
return;
|
||||
}
|
||||
if ctx.is_non_trivial_path() {
|
||||
cov_mark::hit!(no_keyword_completion_in_non_trivial_path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Suggest .await syntax for types that implement Future trait
|
||||
if let Some(receiver) = ctx.dot_receiver() {
|
||||
|
@ -353,6 +353,10 @@ impl<'a> CompletionContext<'a> {
|
||||
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: true, .. }))
|
||||
}
|
||||
|
||||
pub(crate) fn is_non_trivial_path(&self) -> bool {
|
||||
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: false, .. }))
|
||||
}
|
||||
|
||||
pub(crate) fn path_qual(&self) -> Option<&ast::Path> {
|
||||
self.path_context.as_ref().and_then(|it| it.qualifier.as_ref())
|
||||
}
|
||||
|
@ -101,25 +101,11 @@ fn in_item_list_after_attr() {
|
||||
|
||||
#[test]
|
||||
fn in_qualified_path() {
|
||||
cov_mark::check!(no_keyword_completion_in_non_trivial_path);
|
||||
check(
|
||||
r#"crate::$0"#,
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw impl
|
||||
kw extern
|
||||
kw use
|
||||
kw trait
|
||||
kw static
|
||||
kw mod
|
||||
kw enum
|
||||
kw struct
|
||||
kw union
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
"##]],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user