mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-19 11:35:16 +00:00
Implement next trait solver
This commit is contained in:
parent
44bdfdf768
commit
9418a3f2df
109 changed files with 19148 additions and 1317 deletions
|
|
@ -1384,14 +1384,15 @@ fn baz() {
|
|||
fn skip_iter() {
|
||||
check_no_kw(
|
||||
r#"
|
||||
//- minicore: iterator
|
||||
//- minicore: iterator, clone, builtin_impls
|
||||
fn foo() {
|
||||
[].$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
me clone() (as Clone) fn(&self) -> Self
|
||||
me into_iter() (as IntoIterator) fn(self) -> <Self as IntoIterator>::IntoIter
|
||||
me clone() (as Clone) fn(&self) -> Self
|
||||
me fmt(…) (use core::fmt::Debug) fn(&self, &mut Formatter<'_>) -> Result<(), Error>
|
||||
me into_iter() (as IntoIterator) fn(self) -> <Self as IntoIterator>::IntoIter
|
||||
"#]],
|
||||
);
|
||||
check_no_kw(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ mod snippet;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use base_db::salsa;
|
||||
use ide_db::{
|
||||
FilePosition, FxHashSet, RootDatabase,
|
||||
imports::insert_use::{self, ImportScope},
|
||||
|
|
@ -228,7 +229,7 @@ pub fn completions(
|
|||
{
|
||||
let acc = &mut completions;
|
||||
|
||||
match analysis {
|
||||
salsa::attach(db, || match analysis {
|
||||
CompletionAnalysis::Name(name_ctx) => completions::complete_name(acc, ctx, name_ctx),
|
||||
CompletionAnalysis::NameRef(name_ref_ctx) => {
|
||||
completions::complete_name_ref(acc, ctx, name_ref_ctx)
|
||||
|
|
@ -256,7 +257,7 @@ pub fn completions(
|
|||
);
|
||||
}
|
||||
CompletionAnalysis::UnexpandedAttrTT { .. } | CompletionAnalysis::String { .. } => (),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Some(completions.into())
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ mod visibility;
|
|||
|
||||
use base_db::SourceDatabase;
|
||||
use expect_test::Expect;
|
||||
use hir::PrefixKind;
|
||||
use hir::{PrefixKind, setup_tracing};
|
||||
use ide_db::{
|
||||
FilePosition, RootDatabase, SnippetCap,
|
||||
imports::insert_use::{ImportGranularity, InsertUseConfig},
|
||||
|
|
@ -120,6 +120,8 @@ fn completion_list_with_config_raw(
|
|||
include_keywords: bool,
|
||||
trigger_character: Option<char>,
|
||||
) -> Vec<CompletionItem> {
|
||||
let _tracing = setup_tracing();
|
||||
|
||||
// filter out all but one built-in type completion for smaller test outputs
|
||||
let items = get_all_items(config, ra_fixture, trigger_character);
|
||||
items
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use base_db::salsa;
|
||||
use expect_test::{Expect, expect};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -19,25 +20,29 @@ fn check_with_config(
|
|||
let (ctx, analysis) = crate::context::CompletionContext::new(&db, position, &config).unwrap();
|
||||
|
||||
let mut acc = crate::completions::Completions::default();
|
||||
if let CompletionAnalysis::Name(NameContext { kind: NameKind::IdentPat(pat_ctx), .. }) =
|
||||
&analysis
|
||||
{
|
||||
crate::completions::flyimport::import_on_the_fly_pat(&mut acc, &ctx, pat_ctx);
|
||||
}
|
||||
if let CompletionAnalysis::NameRef(name_ref_ctx) = &analysis {
|
||||
match &name_ref_ctx.kind {
|
||||
NameRefKind::Path(path) => {
|
||||
crate::completions::flyimport::import_on_the_fly_path(&mut acc, &ctx, path);
|
||||
}
|
||||
NameRefKind::DotAccess(dot_access) => {
|
||||
crate::completions::flyimport::import_on_the_fly_dot(&mut acc, &ctx, dot_access);
|
||||
}
|
||||
NameRefKind::Pattern(pattern) => {
|
||||
crate::completions::flyimport::import_on_the_fly_pat(&mut acc, &ctx, pattern);
|
||||
}
|
||||
_ => (),
|
||||
salsa::attach(ctx.db, || {
|
||||
if let CompletionAnalysis::Name(NameContext { kind: NameKind::IdentPat(pat_ctx), .. }) =
|
||||
&analysis
|
||||
{
|
||||
crate::completions::flyimport::import_on_the_fly_pat(&mut acc, &ctx, pat_ctx);
|
||||
}
|
||||
}
|
||||
if let CompletionAnalysis::NameRef(name_ref_ctx) = &analysis {
|
||||
match &name_ref_ctx.kind {
|
||||
NameRefKind::Path(path) => {
|
||||
crate::completions::flyimport::import_on_the_fly_path(&mut acc, &ctx, path);
|
||||
}
|
||||
NameRefKind::DotAccess(dot_access) => {
|
||||
crate::completions::flyimport::import_on_the_fly_dot(
|
||||
&mut acc, &ctx, dot_access,
|
||||
);
|
||||
}
|
||||
NameRefKind::Pattern(pattern) => {
|
||||
crate::completions::flyimport::import_on_the_fly_pat(&mut acc, &ctx, pattern);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect.assert_eq(&super::render_completion_list(Vec::from(acc)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -677,6 +677,7 @@ fn bar() -> Bar {
|
|||
expect![[r#"
|
||||
fn foo() (as Foo) fn() -> Self
|
||||
ex Bar
|
||||
ex Bar::foo()
|
||||
ex bar()
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -706,6 +707,7 @@ fn bar() -> Bar {
|
|||
fn bar() fn()
|
||||
fn foo() (as Foo) fn() -> Self
|
||||
ex Bar
|
||||
ex Bar::foo()
|
||||
ex bar()
|
||||
"#]],
|
||||
);
|
||||
|
|
@ -734,6 +736,7 @@ fn bar() -> Bar {
|
|||
expect![[r#"
|
||||
fn foo() (as Foo) fn() -> Self
|
||||
ex Bar
|
||||
ex Bar::foo()
|
||||
ex bar()
|
||||
"#]],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue