diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs index f748ce9ad63f..c2e5eefe1017 100644 --- a/crates/ide-completion/src/completions/expr.rs +++ b/crates/ide-completion/src/completions/expr.rs @@ -293,9 +293,17 @@ pub(crate) fn complete_expr_path( [..] => acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases), } } + // synthetic names currently leak out as we lack synthetic hygiene, so filter them + // out here + ScopeDef::Local(_) => { + if !name.as_str().starts_with('<') { + acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases) + } + } _ if scope_def_applicable(def) => { acc.add_path_resolution(ctx, path_ctx, name, def, doc_aliases) } + _ => (), }); diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs index 183490c2ed84..3705e2c73d64 100644 --- a/crates/ide-completion/src/context.rs +++ b/crates/ide-completion/src/context.rs @@ -754,6 +754,11 @@ impl<'a> CompletionContext<'a> { let mut locals = FxHashMap::default(); scope.process_all_names(&mut |name, scope| { if let ScopeDef::Local(local) = scope { + // synthetic names currently leak out as we lack synthetic hygiene, so filter them + // out here + if name.as_str().starts_with('<') { + return; + } locals.insert(name, local); } }); diff --git a/crates/ide-completion/src/tests/expression.rs b/crates/ide-completion/src/tests/expression.rs index a9db1d953189..304661486864 100644 --- a/crates/ide-completion/src/tests/expression.rs +++ b/crates/ide-completion/src/tests/expression.rs @@ -1785,3 +1785,75 @@ fn foo() { "#]], ); } + +#[test] +fn hide_ragennew_synthetic_identifiers() { + check_empty( + r#" +//- minicore: iterator +fn bar() { + for i in [0; 10] { + r$0 + } +} + "#, + expect![[r#" + en Option Option<{unknown}> + en Result Result<{unknown}, {unknown}> + fn bar() fn() + lc i i32 + ma const_format_args!(…) macro_rules! const_format_args + ma format_args!(…) macro_rules! format_args + ma format_args_nl!(…) macro_rules! format_args_nl + ma panic!(…) macro_rules! panic + ma print!(…) macro_rules! print + md core + md result (use core::result) + md rust_2015 (use core::prelude::rust_2015) + md rust_2018 (use core::prelude::rust_2018) + md rust_2021 (use core::prelude::rust_2021) + tt Clone + tt Copy + tt IntoIterator + tt Iterator + ta Result (use core::fmt::Result) + ev Err(…) Err(E) + ev None None + ev Ok(…) Ok(T) + ev Some(…) Some(T) + bt u32 u32 + kw async + kw break + kw const + kw continue + kw crate:: + kw enum + kw extern + kw false + kw fn + kw for + kw if + kw if let + kw impl + kw let + kw loop + kw match + kw mod + kw return + kw self:: + kw static + kw struct + kw trait + kw true + kw type + kw union + kw unsafe + kw use + kw while + kw while let + sn macro_rules + sn pd + sn ppd + "#]], + ); +}