Repository: rust-lang/rust-analyzer
Pull request #13225 (2022-09-12 17:22:31)

fixup: remove unnecessary `Option`
Fixup for #13223, two things:

- `normalize_projection_query()` (and consequently `HirDatabase::normalize_projection()`) never returns `None` (well, it used to when I first wrote it...), so just return `Ty` instead of `Option<Ty>`
- When chalk cannot normalize projection uniquely, `normalize_trait_assoc_type()` used to return `None` before #13223, but not anymore because of the first point. I restored the behavior so its callers work as before.


Patch:
diff --git a/crates/hir-def/src/find_path.rs b/crates/hir-def/src/find_path.rs
index f46054e8cc..89e961f84f 100644
--- a/crates/hir-def/src/find_path.rs
+++ b/crates/hir-def/src/find_path.rs
@@ -16,14 +16,9 @@ use crate::{
 
 /// Find a path that can be used to refer to a certain item. This can depend on
 /// *from where* you're referring to the item, hence the `from` parameter.
-pub fn find_path(
-    db: &dyn DefDatabase,
-    item: ItemInNs,
-    from: ModuleId,
-    prefer_core: bool,
-) -> Option<ModPath> {
+pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> {
     let _p = profile::span("find_path");
-    find_path_inner(db, item, from, None, prefer_core)
+    find_path_inner(db, item, from, None)
 }
 
 pub fn find_path_prefixed(
@@ -31,10 +26,9 @@ pub fn find_path_prefixed(
     item: ItemInNs,
     from: ModuleId,
     prefix_kind: PrefixKind,
-    prefer_core: bool,
 ) -> Option<ModPath> {
     let _p = profile::span("find_path_prefixed");
-    find_path_inner(db, item, from, Some(prefix_kind), prefer_core)
+    find_path_inner(db, item, from, Some(prefix_kind))
 }
 
 const MAX_PATH_LEN: usize = 15;
@@ -106,22 +100,12 @@ fn find_path_inner(
     item: ItemInNs,
     from: ModuleId,
     prefixed: Option<PrefixKind>,
-    prefer_core: bool,
 ) -> Option<ModPath> {
     // FIXME: Do fast path for std/core libs?
 
     let mut visited_modules = FxHashSet::default();
     let def_map = from.def_map(db);
-    find_path_inner_(
-        db,
-        &def_map,
-        from,
-        item,
-        MAX_PATH_LEN,
-        prefixed,
-        &mut visited_modules,
-        prefer_core,
-    )
+    find_path_inner_(db, &def_map, from, item, MAX_PATH_LEN, prefixed, &mut visited_modules)
 }
 
 fn find_path_inner_(
@@ -132,7 +116,6 @@ fn find_path_inner_(
     max_len: usize,
     mut prefixed: Option<PrefixKind>,
     visited_modules: &mut FxHashSet<ModuleId>,
-    prefer_core: bool,
 ) -> Option<ModPath> {
     if max_len == 0 {
         return None;
@@ -208,9 +191,7 @@ fn find_path_inner_(
     // Recursive case:
     // - if the item is an enum variant, refer to it via the enum
     if let Some(ModuleDefId::EnumVariantId(variant)) = item.as_module_def_id() {
-        if let Some(mut path) =
-            find_path(db, ItemInNs::Types(variant.parent.into()), from, prefer_core)
-        {
+        if let Some(mut path) = find_path(db, ItemInNs::Types(variant.parent.into()), from) {
             let data = db.enum_data(variant.parent);
             path.push_segment(data.variants[variant.local_id].name.clone());
             return Some(path);
@@ -221,7 +202,7 @@ fn find_path_inner_(
     }
 
     // - otherwise, look for modules containing (reexporting) it and import it from one of those
-    let prefer_no_std = prefer_core || db.crate_supports_no_std(crate_root.krate);
+    let prefer_no_std = db.crate_supports_no_std(crate_root.krate);
     let mut best_path = None;
     let mut best_path_len = max_len;
 
@@ -242,7 +223,6 @@ fn find_path_inner_(
                 best_path_len - 1,
                 prefixed,
                 visited_modules,
-                prefer_core,
             ) {
                 path.push_segment(name);
 
@@ -273,7 +253,6 @@ fn find_path_inner_(
                     best_path_len - 1,
                     prefixed,
                     visited_modules,
-                    prefer_core,
                 )?;
                 cov_mark::hit!(partially_imported);
                 path.push_segment(info.path.segments.last()?.clone());
@@ -449,8 +428,7 @@ mod tests {
             .take_types()
             .unwrap();
 
-        let found_path =
-            find_path_inner(&db, ItemInNs::Types(resolved), module, prefix_kind, false);
+        let found_path = find_path_inner(&db, ItemInNs::Types(resolved), module, prefix_kind);
         assert_eq!(found_path, Some(mod_path), "{:?}", prefix_kind);
     }
 
diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs
index dd5639f00d..69283e55a4 100644
--- a/crates/hir-ty/src/db.rs
+++ b/crates/hir-ty/src/db.rs
@@ -156,7 +156,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
         &self,
         projection: crate::ProjectionTy,
         env: Arc<crate::TraitEnvironment>,
-    ) -> Option<crate::Ty>;
+    ) -> Ty;
 
     #[salsa::invoke(trait_solve_wait)]
     #[salsa::transparent]
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index 874abdaea8..d2f9c2b8b1 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -533,7 +533,6 @@ impl HirDisplay for Ty {
                             f.db.upcast(),
                             ItemInNs::Types((*def_id).into()),
                             module_id,
-                            false,
                         ) {
                             write!(f, "{}", path)?;
                         } else {
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index e37763e8ea..10ffde87ee 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -673,6 +673,10 @@ impl<'a> InferenceContext<'a> {
         )
     }
 
+    fn resolve_obligations_as_possible(&mut self) {
+        self.table.resolve_obligations_as_possible();
+    }
+
     fn push_obligation(&mut self, o: DomainGoal) {
         self.table.register_obligation(o.cast(Interner));
     }
@@ -692,6 +696,7 @@ impl<'a> InferenceContext<'a> {
     }
 
     fn resolve_ty_shallow(&mut self, ty: &Ty) -> Ty {
+        self.resolve_obligations_as_possible();
         self.table.resolve_ty_shallow(ty)
     }
 
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index dbf2750032..9a63d5013b 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -914,10 +914,22 @@ fn iterate_trait_method_candidates(
     let db = table.db;
     let env = table.trait_env.clone();
     let self_is_array = matches!(self_ty.kind(Interner), chalk_ir::TyKind::Array(..));
+    // if ty is `dyn Trait`, the trait doesn't need to be in scope
+    let inherent_trait =
+        self_ty.dyn_trait().into_iter().flat_map(|t| all_super_traits(db.upcast(), t));
+    let env_traits = matches!(self_ty.kind(Interner), TyKind::Placeholder(_))
+        // if we have `T: Trait` in the param env, the trait doesn't need to be in scope
+        .then(|| {
+            env.traits_in_scope_from_clauses(self_ty.clone())
+                .flat_map(|t| all_super_traits(db.upcast(), t))
+        })
+        .into_iter()
+        .flatten();
+    let traits = inherent_trait.chain(env_traits).chain(traits_in_scope.iter().copied());
 
     let canonical_self_ty = table.canonicalize(self_ty.clone()).value;
 
-    'traits: for &t in traits_in_scope {
+    'traits: for t in traits {
         let data = db.trait_data(t);
 
         // Traits annotated with `#[rustc_skip_array_during_method_dispatch]` are skipped during
@@ -967,43 +979,6 @@ fn iterate_inherent_methods(
 ) -> ControlFlow<()> {
     let db = table.db;
     let env = table.trait_env.clone();
-
-    // For trait object types and placeholder types with trait bounds, the methods of the trait and
-    // its super traits are considered inherent methods. This matters because these methods have
-    // higher priority than the other traits' methods, which would be considered in
-    // `iterate_trait_method_candidates()` only after this function.
-    match self_ty.kind(Interner) {
-        TyKind::Placeholder(_) => {
-            let env = table.trait_env.clone();
-            let traits = env
-                .traits_in_scope_from_clauses(self_ty.clone())
-                .flat_map(|t| all_super_traits(db.upcast(), t));
-            iterate_inherent_trait_methods(
-                self_ty,
-                table,
-                name,
-                receiver_ty,
-                receiver_adjustments.clone(),
-                callback,
-                traits,
-            )?;
-        }
-        TyKind::Dyn(_) => {
-            let principal_trait = self_ty.dyn_trait().unwrap();
-            let traits = all_super_traits(db.upcast(), principal_trait);
-            iterate_inherent_trait_methods(
-                self_ty,
-                table,
-                name,
-                receiver_ty,
-                receiver_adjustments.clone(),
-                callback,
-                traits.into_iter(),
-            )?;
-        }
-        _ => {}
-    }
-
     let def_crates = match def_crates(db, self_ty, env.krate) {
         Some(k) => k,
         None => return ControlFlow::Continue(()),
@@ -1045,28 +1020,6 @@ fn iterate_inherent_methods(
     }
     return ControlFlow::Continue(());
 
-    fn iterate_inherent_trait_methods(
-        self_ty: &Ty,
-        table: &mut InferenceTable<'_>,
-        name: Option<&Name>,
-        receiver_ty: Option<&Ty>,
-        receiver_adjustments: Option<ReceiverAdjustments>,
-        callback: &mut dyn FnMut(ReceiverAdjustments, AssocItemId) -> ControlFlow<()>,
-        traits: impl Iterator<Item = TraitId>,
-    ) -> ControlFlow<()> {
-        let db = table.db;
-        for t in traits {
-            let data = db.trait_data(t);
-            for &(_, item) in data.items.iter() {
-                // We don't pass `visible_from_module` as all trait items should be visible.
-                if is_valid_candidate(table, name, receiver_ty, item, self_ty, None) {
-                    callback(receiver_adjustments.clone().unwrap_or_default(), item)?;
-                }
-            }
-        }
-        ControlFlow::Continue(())
-    }
-
     fn impls_for_self_ty(
         impls: &InherentImpls,
         self_ty: &Ty,
diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs
index aaff894b34..372c3a3cca 100644
--- a/crates/hir-ty/src/traits.rs
+++ b/crates/hir-ty/src/traits.rs
@@ -69,10 +69,10 @@ pub(crate) fn normalize_projection_query(
     db: &dyn HirDatabase,
     projection: ProjectionTy,
     env: Arc<TraitEnvironment>,
-) -> Option<Ty> {
-    let mut table = InferenceTable::new(db, env.clone());
+) -> Ty {
+    let mut table = InferenceTable::new(db, env);
     let ty = table.normalize_projection_ty(projection);
-    Some(table.resolve_completely(ty))
+    table.resolve_completely(ty)
 }
 
 /// Solve a trait goal using Chalk.
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 7dd891c86e..c981ffbc78 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -581,13 +581,8 @@ impl Module {
 
     /// Finds a path that can be used to refer to the given item from within
     /// this module, if possible.
-    pub fn find_use_path(
-        self,
-        db: &dyn DefDatabase,
-        item: impl Into<ItemInNs>,
-        prefer_core: bool,
-    ) -> Option<ModPath> {
-        hir_def::find_path::find_path(db, item.into().into(), self.into(), prefer_core)
+    pub fn find_use_path(self, db: &dyn DefDatabase, item: impl Into<ItemInNs>) -> Option<ModPath> {
+        hir_def::find_path::find_path(db, item.into().into(), self.into())
     }
 
     /// Finds a path that can be used to refer to the given item from within
@@ -597,15 +592,8 @@ impl Module {
         db: &dyn DefDatabase,
         item: impl Into<ItemInNs>,
         prefix_kind: PrefixKind,
-        prefer_core: bool,
     ) -> Option<ModPath> {
-        hir_def::find_path::find_path_prefixed(
-            db,
-            item.into().into(),
-            self.into(),
-            prefix_kind,
-            prefer_core,
-        )
+        hir_def::find_path::find_path_prefixed(db, item.into().into(), self.into(), prefix_kind)
     }
 }
 
@@ -2892,7 +2880,12 @@ impl Type {
             })
             .build();
 
-        db.normalize_projection(projection, self.env.clone()).map(|ty| self.derived(ty))
+        let ty = db.normalize_projection(projection, self.env.clone());
+        if ty.is_unknown() {
+            None
+        } else {
+            Some(self.derived(ty))
+        }
     }
 
     pub fn is_copy(&self, db: &dyn HirDatabase) -> bool {
diff --git a/crates/ide-assists/src/assist_config.rs b/crates/ide-assists/src/assist_config.rs
index fe2dfca6d5..d4d148c774 100644
--- a/crates/ide-assists/src/assist_config.rs
+++ b/crates/ide-assists/src/assist_config.rs
@@ -13,5 +13,4 @@ pub struct AssistConfig {
     pub snippet_cap: Option<SnippetCap>,
     pub allowed: Option<Vec<AssistKind>>,
     pub insert_use: InsertUseConfig,
-    pub prefer_core: bool,
 }
diff --git a/crates/ide-assists/src/handlers/add_missing_match_arms.rs b/crates/ide-assists/src/handlers/add_missing_match_arms.rs
index d4e21b778c..1a7919a5a1 100644
--- a/crates/ide-assists/src/handlers/add_missing_match_arms.rs
+++ b/crates/ide-assists/src/handlers/add_missing_match_arms.rs
@@ -87,7 +87,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>)
             .into_iter()
             .filter_map(|variant| {
                 Some((
-                    build_pat(ctx.db(), module, variant, ctx.config.prefer_core)?,
+                    build_pat(ctx.db(), module, variant)?,
                     variant.should_be_hidden(ctx.db(), module.krate()),
                 ))
             })
@@ -132,9 +132,8 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>)
                 let is_hidden = variants
                     .iter()
                     .any(|variant| variant.should_be_hidden(ctx.db(), module.krate()));
-                let patterns = variants.into_iter().filter_map(|variant| {
-                    build_pat(ctx.db(), module, variant, ctx.config.prefer_core)
-                });
+                let patterns =
+                    variants.into_iter().filter_map(|variant| build_pat(ctx.db(), module, variant));
 
                 (ast::Pat::from(make::tuple_pat(patterns)), is_hidden)
             })
@@ -350,16 +349,10 @@ fn resolve_tuple_of_enum_def(
         .collect()
 }
 
-fn build_pat(
-    db: &RootDatabase,
-    module: hir::Module,
-    var: ExtendedVariant,
-    prefer_core: bool,
-) -> Option<ast::Pat> {
+fn build_pat(db: &RootDatabase, module: hir::Module, var: ExtendedVariant) -> Option<ast::Pat> {
     match var {
         ExtendedVariant::Variant(var) => {
-            let path =
-                mod_path_to_ast(&module.find_use_path(db, ModuleDef::from(var), prefer_core)?);
+            let path = mod_path_to_ast(&module.find_use_path(db, ModuleDef::from(var))?);
 
             // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though
             let pat: ast::Pat = match var.source(db)?.value.kind() {
diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs
index 88a6b8558c..949cf3167a 100644
--- a/crates/ide-assists/src/handlers/auto_import.rs
+++ b/crates/ide-assists/src/handlers/auto_import.rs
@@ -89,11 +89,8 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
 // ```
 pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
     let (import_assets, syntax_under_caret) = find_importable_node(ctx)?;
-    let mut proposed_imports = import_assets.search_for_imports(
-        &ctx.sema,
-        ctx.config.insert_use.prefix_kind,
-        ctx.config.prefer_core,
-    );
+    let mut proposed_imports =
+        import_assets.search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind);
     if proposed_imports.is_empty() {
         return None;
     }
diff --git a/crates/ide-assists/src/handlers/convert_into_to_from.rs b/crates/ide-assists/src/handlers/convert_into_to_from.rs
index e0c0e9a484..30f6dd41a1 100644
--- a/crates/ide-assists/src/handlers/convert_into_to_from.rs
+++ b/crates/ide-assists/src/handlers/convert_into_to_from.rs
@@ -50,7 +50,7 @@ pub(crate) fn convert_into_to_from(acc: &mut Assists, ctx: &AssistContext<'_>) -
             _ => return None,
         };
 
-        mod_path_to_ast(&module.find_use_path(ctx.db(), src_type_def, ctx.config.prefer_core)?)
+        mod_path_to_ast(&module.find_use_path(ctx.db(), src_type_def)?)
     };
 
     let dest_type = match &ast_trait {
diff --git a/crates/ide-assists/src/handlers/extract_function.rs b/crates/ide-assists/src/handlers/extract_function.rs
index 749d94d5a9..52a55ead3a 100644
--- a/crates/ide-assists/src/handlers/extract_function.rs
+++ b/crates/ide-assists/src/handlers/extract_function.rs
@@ -152,7 +152,6 @@ pub(crate) fn extract_function(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
                         ctx.sema.db,
                         ModuleDef::from(control_flow_enum),
                         ctx.config.insert_use.prefix_kind,
-                        ctx.config.prefer_core,
                     );
 
                     if let Some(mod_path) = mod_path {
diff --git a/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
index 431f7b3c0f..ddc2052e7a 100644
--- a/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -409,7 +409,6 @@ fn process_references(
                     ctx.sema.db,
                     *enum_module_def,
                     ctx.config.insert_use.prefix_kind,
-                    ctx.config.prefer_core,
                 );
                 if let Some(mut mod_path) = mod_path {
                     mod_path.pop_segment();
diff --git a/crates/ide-assists/src/handlers/generate_deref.rs b/crates/ide-assists/src/handlers/generate_deref.rs
index cf4ed84281..b484635121 100644
--- a/crates/ide-assists/src/handlers/generate_deref.rs
+++ b/crates/ide-assists/src/handlers/generate_deref.rs
@@ -58,8 +58,7 @@ fn generate_record_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<(
 
     let module = ctx.sema.to_def(&strukt)?.module(ctx.db());
     let trait_ = deref_type_to_generate.to_trait(&ctx.sema, module.krate())?;
-    let trait_path =
-        module.find_use_path(ctx.db(), ModuleDef::Trait(trait_), ctx.config.prefer_core)?;
+    let trait_path = module.find_use_path(ctx.db(), ModuleDef::Trait(trait_))?;
 
     let field_type = field.ty()?;
     let field_name = field.name()?;
@@ -99,8 +98,7 @@ fn generate_tuple_deref(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()
 
     let module = ctx.sema.to_def(&strukt)?.module(ctx.db());
     let trait_ = deref_type_to_generate.to_trait(&ctx.sema, module.krate())?;
-    let trait_path =
-        module.find_use_path(ctx.db(), ModuleDef::Trait(trait_), ctx.config.prefer_core)?;
+    let trait_path = module.find_use_path(ctx.db(), ModuleDef::Trait(trait_))?;
 
     let field_type = field.ty()?;
     let target = field.syntax().text_range();
diff --git a/crates/ide-assists/src/handlers/generate_new.rs b/crates/ide-assists/src/handlers/generate_new.rs
index ceb7dac0fe..6c93875e9e 100644
--- a/crates/ide-assists/src/handlers/generate_new.rs
+++ b/crates/ide-assists/src/handlers/generate_new.rs
@@ -60,11 +60,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
 
                 let item_in_ns = hir::ItemInNs::from(hir::ModuleDef::from(ty.as_adt()?));
 
-                let type_path = current_module.find_use_path(
-                    ctx.sema.db,
-                    item_for_path_search(ctx.sema.db, item_in_ns)?,
-                    ctx.config.prefer_core,
-                )?;
+                let type_path = current_module
+                    .find_use_path(ctx.sema.db, item_for_path_search(ctx.sema.db, item_in_ns)?)?;
 
                 let expr = use_trivial_constructor(
                     &ctx.sema.db,
diff --git a/crates/ide-assists/src/handlers/move_format_string_arg.rs b/crates/ide-assists/src/handlers/move_format_string_arg.rs
deleted file mode 100644
index 92b2fa79d7..0000000000
--- a/crates/ide-assists/src/handlers/move_format_string_arg.rs
+++ /dev/null
@@ -1,268 +0,0 @@
-use crate::{AssistContext, Assists};
-use ide_db::{
-    assists::{AssistId, AssistKind},
-    syntax_helpers::{
-        format_string::is_format_string,
-        format_string_exprs::{parse_format_exprs, Arg},
-    },
-};
-use itertools::Itertools;
-use syntax::{ast, AstNode, AstToken, NodeOrToken, SyntaxKind::COMMA, TextRange};
-
-// Assist: move_format_string_arg
-//
-// Move an expression out of a format string.
-//
-// ```
-// macro_rules! format_args {
-//     ($lit:literal $(tt:tt)*) => { 0 },
-// }
-// macro_rules! print {
-//     ($($arg:tt)*) => (std::io::_print(format_args!($($arg)*)));
-// }
-//
-// fn main() {
-//     print!("{x + 1}$0");
-// }
-// ```
-// ->
-// ```
-// macro_rules! format_args {
-//     ($lit:literal $(tt:tt)*) => { 0 },
-// }
-// macro_rules! print {
-//     ($($arg:tt)*) => (std::io::_print(format_args!($($arg)*)));
-// }
-//
-// fn main() {
-//     print!("{}"$0, x + 1);
-// }
-// ```
-
-pub(crate) fn move_format_string_arg(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
-    let fmt_string = ctx.find_token_at_offset::<ast::String>()?;
-    let tt = fmt_string.syntax().parent().and_then(ast::TokenTree::cast)?;
-
-    let expanded_t = ast::String::cast(
-        ctx.sema.descend_into_macros_with_kind_preference(fmt_string.syntax().clone()),
-    )?;
-    if !is_format_string(&expanded_t) {
-        return None;
-    }
-
-    let (new_fmt, extracted_args) = parse_format_exprs(fmt_string.text()).ok()?;
-    if extracted_args.is_empty() {
-        return None;
-    }
-
-    acc.add(
-        AssistId(
-            "move_format_string_arg",
-            // if there aren't any expressions, then make the assist a RefactorExtract
-            if extracted_args.iter().filter(|f| matches!(f, Arg::Expr(_))).count() == 0 {
-                AssistKind::RefactorExtract
-            } else {
-                AssistKind::QuickFix
-            },
-        ),
-        "Extract format args",
-        tt.syntax().text_range(),
-        |edit| {
-            let fmt_range = fmt_string.syntax().text_range();
-
-            // Replace old format string with new format string whose arguments have been extracted
-            edit.replace(fmt_range, new_fmt);
-
-            // Insert cursor at end of format string
-            edit.insert(fmt_range.end(), "$0");
-
-            // Extract existing arguments in macro
-            let tokens =
-                tt.token_trees_and_tokens().filter_map(NodeOrToken::into_token).collect_vec();
-
-            let mut existing_args: Vec<String> = vec![];
-
-            let mut current_arg = String::new();
-            if let [_opening_bracket, format_string, _args_start_comma, tokens @ .., end_bracket] =
-                tokens.as_slice()
-            {
-                for t in tokens {
-                    if t.kind() == COMMA {
-                        existing_args.push(current_arg.trim().into());
-                        current_arg.clear();
-                    } else {
-                        current_arg.push_str(t.text());
-                    }
-                }
-                existing_args.push(current_arg.trim().into());
-
-                // delete everything after the format string till end bracket
-                // we're going to insert the new arguments later
-                edit.delete(TextRange::new(
-                    format_string.text_range().end(),
-                    end_bracket.text_range().start(),
-                ));
-            }
-
-            // Start building the new args
-            let mut existing_args = existing_args.into_iter();
-            let mut args = String::new();
-
-            let mut placeholder_idx = 1;
-
-            for extracted_args in extracted_args {
-                // remove expr from format string
-                args.push_str(", ");
-
-                match extracted_args {
-                    Arg::Ident(s) | Arg::Expr(s) => {
-                        // insert arg
-                        args.push_str(&s);
-                    }
-                    Arg::Placeholder => {
-                        // try matching with existing argument
-                        match existing_args.next() {
-                            Some(ea) => {
-                                args.push_str(&ea);
-                            }
-                            None => {
-                                // insert placeholder
-                                args.push_str(&format!("${placeholder_idx}"));
-                                placeholder_idx += 1;
-                            }
-                        }
-                    }
-                }
-            }
-
-            // Insert new args
-            edit.insert(fmt_range.end(), args);
-        },
-    );
-
-    Some(())
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use crate::tests::check_assist;
-
-    const MACRO_DECL: &'static str = r#"
-macro_rules! format_args {
-    ($lit:literal $(tt:tt)*) => { 0 },
-}
-macro_rules! print {
-    ($($arg:tt)*) => (std::io::_print(format_args!($($arg)*)));
-}
-"#;
-
-    fn add_macro_decl(s: &'static str) -> String {
-        MACRO_DECL.to_string() + s
-    }
-
-    #[test]
-    fn multiple_middle_arg() {
-        check_assist(
-            move_format_string_arg,
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {x + 1:b} {}$0", y + 2, 2);
-}
-"#,
-            ),
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {:b} {}"$0, y + 2, x + 1, 2);
-}
-"#,
-            ),
-        );
-    }
-
-    #[test]
-    fn single_arg() {
-        check_assist(
-            move_format_string_arg,
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{obj.value:b}$0",);
-}
-"#,
-            ),
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{:b}"$0, obj.value);
-}
-"#,
-            ),
-        );
-    }
-
-    #[test]
-    fn multiple_middle_placeholders_arg() {
-        check_assist(
-            move_format_string_arg,
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {x + 1:b} {} {}$0", y + 2, 2);
-}
-"#,
-            ),
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {:b} {} {}"$0, y + 2, x + 1, 2, $1);
-}
-"#,
-            ),
-        );
-    }
-
-    #[test]
-    fn multiple_trailing_args() {
-        check_assist(
-            move_format_string_arg,
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {x + 1:b} {Struct(1, 2)}$0", 1);
-}
-"#,
-            ),
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {:b} {}"$0, 1, x + 1, Struct(1, 2));
-}
-"#,
-            ),
-        );
-    }
-
-    #[test]
-    fn improper_commas() {
-        check_assist(
-            move_format_string_arg,
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {x + 1:b} {Struct(1, 2)}$0", 1,);
-}
-"#,
-            ),
-            &add_macro_decl(
-                r#"
-fn main() {
-    print!("{} {:b} {}"$0, 1, x + 1, Struct(1, 2));
-}
-"#,
-            ),
-        );
-    }
-}
diff --git a/crates/ide-assists/src/handlers/qualify_method_call.rs b/crates/ide-assists/src/handlers/qualify_method_call.rs
index cb81ebd228..121f8b4a13 100644
--- a/crates/ide-assists/src/handlers/qualify_method_call.rs
+++ b/crates/ide-assists/src/handlers/qualify_method_call.rs
@@ -44,11 +44,8 @@ pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext<'_>) ->
     let current_module = ctx.sema.scope(call.syntax())?.module();
     let target_module_def = ModuleDef::from(resolved_call);
     let item_in_ns = ItemInNs::from(target_module_def);
-    let receiver_path = current_module.find_use_path(
-        ctx.sema.db,
-        item_for_path_search(ctx.sema.db, item_in_ns)?,
-        ctx.config.prefer_core,
-    )?;
+    let receiver_path = current_module
+        .find_use_path(ctx.sema.db, item_for_path_search(ctx.sema.db, item_in_ns)?)?;
 
     let qualify_candidate = QualifyCandidate::ImplMethod(ctx.sema.db, call, resolved_call);
 
diff --git a/crates/ide-assists/src/handlers/qualify_path.rs b/crates/ide-assists/src/handlers/qualify_path.rs
index 232cd39e8b..0c2e9da386 100644
--- a/crates/ide-assists/src/handlers/qualify_path.rs
+++ b/crates/ide-assists/src/handlers/qualify_path.rs
@@ -37,8 +37,7 @@ use crate::{
 // ```
 pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
     let (import_assets, syntax_under_caret) = find_importable_node(ctx)?;
-    let mut proposed_imports =
-        import_assets.search_for_relative_paths(&ctx.sema, ctx.config.prefer_core);
+    let mut proposed_imports = import_assets.search_for_relative_paths(&ctx.sema);
     if proposed_imports.is_empty() {
         return None;
     }
diff --git a/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs
index 04a1366327..d139f78a6f 100644
--- a/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs
+++ b/crates/ide-assists/src/handlers/replace_derive_with_manual_impl.rs
@@ -85,7 +85,7 @@ pub(crate) fn replace_derive_with_manual_impl(
     })
     .flat_map(|trait_| {
         current_module
-            .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_), ctx.config.prefer_core)
+            .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_))
             .as_ref()
             .map(mod_path_to_ast)
             .zip(Some(trait_))
diff --git a/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
index 533e1670a0..2419fa11c1 100644
--- a/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
+++ b/crates/ide-assists/src/handlers/replace_qualified_name_with_use.rs
@@ -67,7 +67,6 @@ pub(crate) fn replace_qualified_name_with_use(
                 ctx.sema.db,
                 module,
                 ctx.config.insert_use.prefix_kind,
-                ctx.config.prefer_core,
             )
         })
         .flatten();
diff --git a/crates/ide-assists/src/lib.rs b/crates/ide-assists/src/lib.rs
index 812d22efbd..e52544db5f 100644
--- a/crates/ide-assists/src/lib.rs
+++ b/crates/ide-assists/src/lib.rs
@@ -136,7 +136,6 @@ mod handlers {
     mod flip_binexpr;
     mod flip_comma;
     mod flip_trait_bound;
-    mod move_format_string_arg;
     mod generate_constant;
     mod generate_default_from_enum_variant;
     mod generate_default_from_new;
@@ -255,7 +254,6 @@ mod handlers {
             merge_imports::merge_imports,
             merge_match_arms::merge_match_arms,
             move_bounds::move_bounds_to_where_clause,
-            move_format_string_arg::move_format_string_arg,
             move_guard::move_arm_cond_to_match_guard,
             move_guard::move_guard_to_arm_body,
             move_module_to_file::move_module_to_file,
diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs
index 89a971e544..55c3e28392 100644
--- a/crates/ide-completion/src/completions.rs
+++ b/crates/ide-completion/src/completions.rs
@@ -551,9 +551,7 @@ fn enum_variants_with_paths(
     }
 
     for variant in variants {
-        if let Some(path) =
-            ctx.module.find_use_path(ctx.db, hir::ModuleDef::from(variant), ctx.config.prefer_core)
-        {
+        if let Some(path) = ctx.module.find_use_path(ctx.db, hir::ModuleDef::from(variant)) {
             // Variants with trivial paths are already added by the existing completion logic,
             // so we should avoid adding these twice
             if path.segments().len() > 1 {
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs
index 1ccf33a96b..588b52cc1e 100644
--- a/crates/ide-completion/src/completions/expr.rs
+++ b/crates/ide-completion/src/completions/expr.rs
@@ -165,11 +165,7 @@ pub(crate) fn complete_expr_path(
                     hir::Adt::Struct(strukt) => {
                         let path = ctx
                             .module
-                            .find_use_path(
-                                ctx.db,
-                                hir::ModuleDef::from(strukt),
-                                ctx.config.prefer_core,
-                            )
+                            .find_use_path(ctx.db, hir::ModuleDef::from(strukt))
                             .filter(|it| it.len() > 1);
 
                         acc.add_struct_literal(ctx, path_ctx, strukt, path, None);
@@ -187,7 +183,7 @@ pub(crate) fn complete_expr_path(
                     hir::Adt::Union(un) => {
                         let path = ctx
                             .module
-                            .find_use_path(ctx.db, hir::ModuleDef::from(un), ctx.config.prefer_core)
+                            .find_use_path(ctx.db, hir::ModuleDef::from(un))
                             .filter(|it| it.len() > 1);
 
                         acc.add_union_literal(ctx, un, path, None);
diff --git a/crates/ide-completion/src/completions/flyimport.rs b/crates/ide-completion/src/completions/flyimport.rs
index 528959943b..f04cc15d7f 100644
--- a/crates/ide-completion/src/completions/flyimport.rs
+++ b/crates/ide-completion/src/completions/flyimport.rs
@@ -262,11 +262,7 @@ fn import_on_the_fly(
 
     acc.add_all(
         import_assets
-            .search_for_imports(
-                &ctx.sema,
-                ctx.config.insert_use.prefix_kind,
-                ctx.config.prefer_core,
-            )
+            .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind)
             .into_iter()
             .filter(ns_filter)
             .filter(|import| {
@@ -310,11 +306,7 @@ fn import_on_the_fly_pat_(
 
     acc.add_all(
         import_assets
-            .search_for_imports(
-                &ctx.sema,
-                ctx.config.insert_use.prefix_kind,
-                ctx.config.prefer_core,
-            )
+            .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind)
             .into_iter()
             .filter(ns_filter)
             .filter(|import| {
@@ -352,7 +344,7 @@ fn import_on_the_fly_method(
     let user_input_lowercased = potential_import_name.to_lowercase();
 
     import_assets
-        .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind, ctx.config.prefer_core)
+        .search_for_imports(&ctx.sema, ctx.config.insert_use.prefix_kind)
         .into_iter()
         .filter(|import| {
             !ctx.is_item_hidden(&import.item_to_import)
diff --git a/crates/ide-completion/src/completions/postfix/format_like.rs b/crates/ide-completion/src/completions/postfix/format_like.rs
index b43bdb9ab9..b273a4cb53 100644
--- a/crates/ide-completion/src/completions/postfix/format_like.rs
+++ b/crates/ide-completion/src/completions/postfix/format_like.rs
@@ -16,11 +16,8 @@
 //
 // image::https://user-images.githubusercontent.com/48062697/113020656-b560f500-917a-11eb-87de-02991f61beb8.gif[]
 
-use ide_db::{
-    syntax_helpers::format_string_exprs::{parse_format_exprs, with_placeholders},
-    SnippetCap,
-};
-use syntax::{ast, AstToken};
+use ide_db::SnippetCap;
+use syntax::ast::{self, AstToken};
 
 use crate::{
     completions::postfix::build_postfix_snippet_builder, context::CompletionContext, Completions,
@@ -46,24 +43,250 @@ pub(crate) fn add_format_like_completions(
     cap: SnippetCap,
     receiver_text: &ast::String,
 ) {
+    let input = match string_literal_contents(receiver_text) {
+        // It's not a string literal, do not parse input.
+        Some(input) => input,
+        None => return,
+    };
+
     let postfix_snippet = match build_postfix_snippet_builder(ctx, cap, dot_receiver) {
         Some(it) => it,
         None => return,
     };
+    let mut parser = FormatStrParser::new(input);
 
-    if let Ok((out, exprs)) = parse_format_exprs(receiver_text.text()) {
-        let exprs = with_placeholders(exprs);
+    if parser.parse().is_ok() {
         for (label, macro_name) in KINDS {
-            let snippet = format!(r#"{}({}, {})"#, macro_name, out, exprs.join(", "));
+            let snippet = parser.to_suggestion(macro_name);
 
             postfix_snippet(label, macro_name, &snippet).add_to(acc);
         }
     }
 }
 
+/// Checks whether provided item is a string literal.
+fn string_literal_contents(item: &ast::String) -> Option<String> {
+    let item = item.text();
+    if item.len() >= 2 && item.starts_with('\"') && item.ends_with('\"') {
+        return Some(item[1..item.len() - 1].to_owned());
+    }
+
+    None
+}
+
+/// Parser for a format-like string. It is more allowing in terms of string contents,
+/// as we expect variable placeholders to be filled with expressions.
+#[derive(Debug)]
+pub(crate) struct FormatStrParser {
+    input: String,
+    output: String,
+    extracted_expressions: Vec<String>,
+    state: State,
+    parsed: bool,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+enum State {
+    NotExpr,
+    MaybeExpr,
+    Expr,
+    MaybeIncorrect,
+    FormatOpts,
+}
+
+impl FormatStrParser {
+    pub(crate) fn new(input: String) -> Self {
+        Self {
+            input,
+            output: String::new(),
+            extracted_expressions: Vec::new(),
+            state: State::NotExpr,
+            parsed: false,
+        }
+    }
+
+    pub(crate) fn parse(&mut self) -> Result<(), ()> {
+        let mut current_expr = String::new();
+
+        let mut placeholder_id = 1;
+
+        // Count of open braces inside of an expression.
+        // We assume that user knows what they're doing, thus we treat it like a correct pattern, e.g.
+        // "{MyStruct { val_a: 0, val_b: 1 }}".
+        let mut inexpr_open_count = 0;
+
+        // We need to escape '\' and '$'. See the comments on `get_receiver_text()` for detail.
+        let mut chars = self.input.chars().peekable();
+        while let Some(chr) = chars.next() {
+            match (self.state, chr) {
+                (State::NotExpr, '{') => {
+                    self.output.push(chr);
+                    self.state = State::MaybeExpr;
+                }
+                (State::NotExpr, '}') => {
+                    self.output.push(chr);
+                    self.state = State::MaybeIncorrect;
+                }
+                (State::NotExpr, _) => {
+                    if matches!(chr, '\\' | '$') {
+                        self.output.push('\\');
+                    }
+                    self.output.push(chr);
+                }
+                (State::MaybeIncorrect, '}') => {
+                    // It's okay, we met "}}".
+                    self.output.push(chr);
+                    self.state = State::NotExpr;
+                }
+                (State::MaybeIncorrect, _) => {
+                    // Error in the string.
+                    return Err(());
+                }
+                (State::MaybeExpr, '{') => {
+                    self.output.push(chr);
+                    self.state = State::NotExpr;
+                }
+                (State::MaybeExpr, '}') => {
+                    // This is an empty sequence '{}'. Replace it with placeholder.
+                    self.output.push(chr);
+                    self.extracted_expressions.push(format!("${}", placeholder_id));
+                    placeholder_id += 1;
+                    self.state = State::NotExpr;
+                }
+                (State::MaybeExpr, _) => {
+                    if matches!(chr, '\\' | '$') {
+                        current_expr.push('\\');
+                    }
+                    current_expr.push(chr);
+                    self.state = State::Expr;
+                }
+                (State::Expr, '}') => {
+                    if inexpr_open_count == 0 {
+                        self.output.push(chr);
+                        self.extracted_expressions.push(current_expr.trim().into());
+                        current_expr = String::new();
+                        self.state = State::NotExpr;
+                    } else {
+                        // We're closing one brace met before inside of the expression.
+                        current_expr.push(chr);
+                        inexpr_open_count -= 1;
+                    }
+                }
+                (State::Expr, ':') if chars.peek().copied() == Some(':') => {
+                    // path separator
+                    current_expr.push_str("::");
+                    chars.next();
+                }
+                (State::Expr, ':') => {
+                    if inexpr_open_count == 0 {
+                        // We're outside of braces, thus assume that it's a specifier, like "{Some(value):?}"
+                        self.output.push(chr);
+                        self.extracted_expressions.push(current_expr.trim().into());
+                        current_expr = String::new();
+                        self.state = State::FormatOpts;
+                    } else {
+                        // We're inside of braced expression, assume that it's a struct field name/value delimiter.
+                        current_expr.push(chr);
+                    }
+                }
+                (State::Expr, '{') => {
+                    current_expr.push(chr);
+                    inexpr_open_count += 1;
+                }
+                (State::Expr, _) => {
+                    if matches!(chr, '\\' | '$') {
+                        current_expr.push('\\');
+                    }
+                    current_expr.push(chr);
+                }
+                (State::FormatOpts, '}') => {
+                    self.output.push(chr);
+                    self.state = State::NotExpr;
+                }
+                (State::FormatOpts, _) => {
+                    if matches!(chr, '\\' | '$') {
+                        self.output.push('\\');
+                    }
+                    self.output.push(chr);
+                }
+            }
+        }
+
+        if self.state != State::NotExpr {
+            return Err(());
+        }
+
+        self.parsed = true;
+        Ok(())
+    }
+
+    pub(crate) fn to_suggestion(&self, macro_name: &str) -> String {
+        assert!(self.parsed, "Attempt to get a suggestion from not parsed expression");
+
+        let expressions_as_string = self.extracted_expressions.join(", ");
+        format!(r#"{}("{}", {})"#, macro_name, self.output, expressions_as_string)
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
+    use expect_test::{expect, Expect};
+
+    fn check(input: &str, expect: &Expect) {
+        let mut parser = FormatStrParser::new((*input).to_owned());
+        let outcome_repr = if parser.parse().is_ok() {
+            // Parsing should be OK, expected repr is "string; expr_1, expr_2".
+            if parser.extracted_expressions.is_empty() {
+                parser.output
+            } else {
+                format!("{}; {}", parser.output, parser.extracted_expressions.join(", "))
+            }
+        } else {
+            // Parsing should fail, expected repr is "-".
+            "-".to_owned()
+        };
+
+        expect.assert_eq(&outcome_repr);
+    }
+
+    #[test]
+    fn format_str_parser() {
+        let test_vector = &[
+            ("no expressions", expect![["no expressions"]]),
+            (r"no expressions with \$0$1", expect![r"no expressions with \\\$0\$1"]),
+            ("{expr} is {2 + 2}", expect![["{} is {}; expr, 2 + 2"]]),
+            ("{expr:?}", expect![["{:?}; expr"]]),
+            ("{expr:1$}", expect![[r"{:1\$}; expr"]]),
+            ("{$0}", expect![[r"{}; \$0"]]),
+            ("{malformed", expect![["-"]]),
+            ("malformed}", expect![["-"]]),
+            ("{{correct", expect![["{{correct"]]),
+            ("correct}}", expect![["correct}}"]]),
+            ("{correct}}}", expect![["{}}}; correct"]]),
+            ("{correct}}}}}", expect![["{}}}}}; correct"]]),
+            ("{incorrect}}", expect![["-"]]),
+            ("placeholders {} {}", expect![["placeholders {} {}; $1, $2"]]),
+            ("mixed {} {2 + 2} {}", expect![["mixed {} {} {}; $1, 2 + 2, $2"]]),
+            (
+                "{SomeStruct { val_a: 0, val_b: 1 }}",
+                expect![["{}; SomeStruct { val_a: 0, val_b: 1 }"]],
+            ),
+            ("{expr:?} is {2.32f64:.5}", expect![["{:?} is {:.5}; expr, 2.32f64"]]),
+            (
+                "{SomeStruct { val_a: 0, val_b: 1 }:?}",
+                expect![["{:?}; SomeStruct { val_a: 0, val_b: 1 }"]],
+            ),
+            ("{     2 + 2        }", expect![["{}; 2 + 2"]]),
+            ("{strsim::jaro_winkle(a)}", expect![["{}; strsim::jaro_winkle(a)"]]),
+            ("{foo::bar::baz()}", expect![["{}; foo::bar::baz()"]]),
+            ("{foo::bar():?}", expect![["{:?}; foo::bar()"]]),
+        ];
+
+        for (input, output) in test_vector {
+            check(input, output)
+        }
+    }
 
     #[test]
     fn test_into_suggestion() {
@@ -79,10 +302,10 @@ mod tests {
         ];
 
         for (kind, input, output) in test_vector {
-            let (parsed_string, exprs) = parse_format_exprs(input).unwrap();
-            let exprs = with_placeholders(exprs);
-            let snippet = format!(r#"{}("{}", {})"#, kind, parsed_string, exprs.join(", "));
-            assert_eq!(&snippet, output);
+            let mut parser = FormatStrParser::new((*input).to_owned());
+            parser.parse().expect("Parsing must succeed");
+
+            assert_eq!(&parser.to_suggestion(*kind), output);
         }
     }
 }
diff --git a/crates/ide-completion/src/config.rs b/crates/ide-completion/src/config.rs
index 54ebce1eb7..80d6af2816 100644
--- a/crates/ide-completion/src/config.rs
+++ b/crates/ide-completion/src/config.rs
@@ -17,7 +17,6 @@ pub struct CompletionConfig {
     pub callable: Option<CallableSnippets>,
     pub snippet_cap: Option<SnippetCap>,
     pub insert_use: InsertUseConfig,
-    pub prefer_core: bool,
     pub snippets: Vec<Snippet>,
 }
 
diff --git a/crates/ide-completion/src/lib.rs b/crates/ide-completion/src/lib.rs
index 7cefb6bb4a..ae1a440d06 100644
--- a/crates/ide-completion/src/lib.rs
+++ b/crates/ide-completion/src/lib.rs
@@ -234,12 +234,7 @@ pub fn resolve_completion_edits(
         );
         let import = items_with_name
             .filter_map(|candidate| {
-                current_module.find_use_path_prefixed(
-                    db,
-                    candidate,
-                    config.insert_use.prefix_kind,
-                    config.prefer_core,
-                )
+                current_module.find_use_path_prefixed(db, candidate, config.insert_use.prefix_kind)
             })
             .find(|mod_path| mod_path.to_string() == full_import_path);
         if let Some(import_path) = import {
diff --git a/crates/ide-completion/src/snippet.rs b/crates/ide-completion/src/snippet.rs
index 2dc62bbdc6..dc1039fa62 100644
--- a/crates/ide-completion/src/snippet.rs
+++ b/crates/ide-completion/src/snippet.rs
@@ -174,12 +174,8 @@ fn import_edits(ctx: &CompletionContext<'_>, requires: &[GreenNode]) -> Option<V
             hir::PathResolution::Def(def) => def.into(),
             _ => return None,
         };
-        let path = ctx.module.find_use_path_prefixed(
-            ctx.db,
-            item,
-            ctx.config.insert_use.prefix_kind,
-            ctx.config.prefer_core,
-        )?;
+        let path =
+            ctx.module.find_use_path_prefixed(ctx.db, item, ctx.config.insert_use.prefix_kind)?;
         Some((path.len() > 1).then(|| LocatedImport::new(path.clone(), item, item, None)))
     };
     let mut res = Vec::with_capacity(requires.len());
diff --git a/crates/ide-db/src/imports/import_assets.rs b/crates/ide-db/src/imports/import_assets.rs
index 53bc516109..26ef86155e 100644
--- a/crates/ide-db/src/imports/import_assets.rs
+++ b/crates/ide-db/src/imports/import_assets.rs
@@ -212,20 +212,18 @@ impl ImportAssets {
         &self,
         sema: &Semantics<'_, RootDatabase>,
         prefix_kind: PrefixKind,
-        prefer_core: bool,
     ) -> Vec<LocatedImport> {
         let _p = profile::span("import_assets::search_for_imports");
-        self.search_for(sema, Some(prefix_kind), prefer_core)
+        self.search_for(sema, Some(prefix_kind))
     }
 
     /// This may return non-absolute paths if a part of the returned path is already imported into scope.
     pub fn search_for_relative_paths(
         &self,
         sema: &Semantics<'_, RootDatabase>,
-        prefer_core: bool,
     ) -> Vec<LocatedImport> {
         let _p = profile::span("import_assets::search_for_relative_paths");
-        self.search_for(sema, None, prefer_core)
+        self.search_for(sema, None)
     }
 
     pub fn path_fuzzy_name_to_exact(&mut self, case_sensitive: bool) {
@@ -244,7 +242,6 @@ impl ImportAssets {
         &self,
         sema: &Semantics<'_, RootDatabase>,
         prefixed: Option<PrefixKind>,
-        prefer_core: bool,
     ) -> Vec<LocatedImport> {
         let _p = profile::span("import_assets::search_for");
 
@@ -255,7 +252,6 @@ impl ImportAssets {
                 item_for_path_search(sema.db, item)?,
                 &self.module_with_candidate,
                 prefixed,
-                prefer_core,
             )
         };
 
@@ -568,12 +564,11 @@ fn get_mod_path(
     item_to_search: ItemInNs,
     module_with_candidate: &Module,
     prefixed: Option<PrefixKind>,
-    prefer_core: bool,
 ) -> Option<ModPath> {
     if let Some(prefix_kind) = prefixed {
-        module_with_candidate.find_use_path_prefixed(db, item_to_search, prefix_kind, prefer_core)
+        module_with_candidate.find_use_path_prefixed(db, item_to_search, prefix_kind)
     } else {
-        module_with_candidate.find_use_path(db, item_to_search, prefer_core)
+        module_with_candidate.find_use_path(db, item_to_search)
     }
 }
 
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index e0bc0f89f0..1ec62a8425 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -38,7 +38,6 @@ pub mod syntax_helpers {
     pub mod node_ext;
     pub mod insert_whitespace_into_node;
     pub mod format_string;
-    pub mod format_string_exprs;
 
     pub use parser::LexedStr;
 }
diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs
index 12d873b4a0..40af9e6fe2 100644
--- a/crates/ide-db/src/path_transform.rs
+++ b/crates/ide-db/src/path_transform.rs
@@ -173,7 +173,6 @@ impl<'a> Ctx<'a> {
                             let found_path = self.target_module.find_use_path(
                                 self.source_scope.db.upcast(),
                                 hir::ModuleDef::Trait(trait_ref),
-                                false,
                             )?;
                             match ast::make::ty_path(mod_path_to_ast(&found_path)) {
                                 ast::Type::PathType(path_ty) => Some(path_ty),
@@ -210,7 +209,7 @@ impl<'a> Ctx<'a> {
                 }
 
                 let found_path =
-                    self.target_module.find_use_path(self.source_scope.db.upcast(), def, false)?;
+                    self.target_module.find_use_path(self.source_scope.db.upcast(), def)?;
                 let res = mod_path_to_ast(&found_path).clone_for_update();
                 if let Some(args) = path.segment().and_then(|it| it.generic_arg_list()) {
                     if let Some(segment) = res.segment() {
diff --git a/crates/ide-db/src/syntax_helpers/format_string_exprs.rs b/crates/ide-db/src/syntax_helpers/format_string_exprs.rs
deleted file mode 100644
index ac6c6e8fee..0000000000
--- a/crates/ide-db/src/syntax_helpers/format_string_exprs.rs
+++ /dev/null
@@ -1,267 +0,0 @@
-//! Tools to work with expressions present in format string literals for the `format_args!` family of macros.
-//! Primarily meant for assists and completions.
-
-/// Enum for represenging extraced format string args.
-/// Can either be extracted expressions (which includes identifiers),
-/// or placeholders `{}`.
-#[derive(Debug, PartialEq, Eq)]
-pub enum Arg {
-    Placeholder,
-    Ident(String),
-    Expr(String),
-}
-
-/**
- Add placeholders like `$1` and `$2` in place of [`Arg::Placeholder`],
- and unwraps the [`Arg::Ident`] and [`Arg::Expr`] enums.
- ```rust
- # use ide_db::syntax_helpers::format_string_exprs::*;
- assert_eq!(with_placeholders(vec![Arg::Ident("ident".to_owned()), Arg::Placeholder, Arg::Expr("expr + 2".to_owned())]), vec!["ident".to_owned(), "$1".to_owned(), "expr + 2".to_owned()])
- ```
-*/
-
-pub fn with_placeholders(args: Vec<Arg>) -> Vec<String> {
-    let mut placeholder_id = 1;
-    args.into_iter()
-        .map(move |a| match a {
-            Arg::Expr(s) | Arg::Ident(s) => s,
-            Arg::Placeholder => {
-                let s = format!("${placeholder_id}");
-                placeholder_id += 1;
-                s
-            }
-        })
-        .collect()
-}
-
-/**
- Parser for a format-like string. It is more allowing in terms of string contents,
- as we expect variable placeholders to be filled with expressions.
-
- Built for completions and assists, and escapes `\` and `$` in output.
- (See the comments on `get_receiver_text()` for detail.)
- Splits a format string that may contain expressions
- like
- ```rust
- assert_eq!(parse("{ident} {} {expr + 42} ").unwrap(), ("{} {} {}", vec![Arg::Ident("ident"), Arg::Placeholder, Arg::Expr("expr + 42")]));
- ```
-*/
-pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
-    #[derive(Debug, Clone, Copy, PartialEq)]
-    enum State {
-        NotArg,
-        MaybeArg,
-        Expr,
-        Ident,
-        MaybeIncorrect,
-        FormatOpts,
-    }
-
-    let mut state = State::NotArg;
-    let mut current_expr = String::new();
-    let mut extracted_expressions = Vec::new();
-    let mut output = String::new();
-
-    // Count of open braces inside of an expression.
-    // We assume that user knows what they're doing, thus we treat it like a correct pattern, e.g.
-    // "{MyStruct { val_a: 0, val_b: 1 }}".
-    let mut inexpr_open_count = 0;
-
-    let mut chars = input.chars().peekable();
-    while let Some(chr) = chars.next() {
-        match (state, chr) {
-            (State::NotArg, '{') => {
-                output.push(chr);
-                state = State::MaybeArg;
-            }
-            (State::NotArg, '}') => {
-                output.push(chr);
-                state = State::MaybeIncorrect;
-            }
-            (State::NotArg, _) => {
-                if matches!(chr, '\\' | '$') {
-                    output.push('\\');
-                }
-                output.push(chr);
-            }
-            (State::MaybeIncorrect, '}') => {
-                // It's okay, we met "}}".
-                output.push(chr);
-                state = State::NotArg;
-            }
-            (State::MaybeIncorrect, _) => {
-                // Error in the string.
-                return Err(());
-            }
-            // Escaped braces `{{`
-            (State::MaybeArg, '{') => {
-                output.push(chr);
-                state = State::NotArg;
-            }
-            (State::MaybeArg, '}') => {
-                // This is an empty sequence '{}'.
-                output.push(chr);
-                extracted_expressions.push(Arg::Placeholder);
-                state = State::NotArg;
-            }
-            (State::MaybeArg, _) => {
-                if matches!(chr, '\\' | '$') {
-                    current_expr.push('\\');
-                }
-                current_expr.push(chr);
-
-                // While Rust uses the unicode sets of XID_start and XID_continue for Identifiers
-                // this is probably the best we can do to avoid a false positive
-                if chr.is_alphabetic() || chr == '_' {
-                    state = State::Ident;
-                } else {
-                    state = State::Expr;
-                }
-            }
-            (State::Ident | State::Expr, '}') => {
-                if inexpr_open_count == 0 {
-                    output.push(chr);
-
-                    if matches!(state, State::Expr) {
-                        extracted_expressions.push(Arg::Expr(current_expr.trim().into()));
-                    } else {
-                        extracted_expressions.push(Arg::Ident(current_expr.trim().into()));
-                    }
-
-                    current_expr = String::new();
-                    state = State::NotArg;
-                } else {
-                    // We're closing one brace met before inside of the expression.
-                    current_expr.push(chr);
-                    inexpr_open_count -= 1;
-                }
-            }
-            (State::Ident | State::Expr, ':') if matches!(chars.peek(), Some(':')) => {
-                // path separator
-                state = State::Expr;
-                current_expr.push_str("::");
-                chars.next();
-            }
-            (State::Ident | State::Expr, ':') => {
-                if inexpr_open_count == 0 {
-                    // We're outside of braces, thus assume that it's a specifier, like "{Some(value):?}"
-                    output.push(chr);
-
-                    if matches!(state, State::Expr) {
-                        extracted_expressions.push(Arg::Expr(current_expr.trim().into()));
-                    } else {
-                        extracted_expressions.push(Arg::Ident(current_expr.trim().into()));
-                    }
-
-                    current_expr = String::new();
-                    state = State::FormatOpts;
-                } else {
-                    // We're inside of braced expression, assume that it's a struct field name/value delimiter.
-                    current_expr.push(chr);
-                }
-            }
-            (State::Ident | State::Expr, '{') => {
-                state = State::Expr;
-                current_expr.push(chr);
-                inexpr_open_count += 1;
-            }
-            (State::Ident | State::Expr, _) => {
-                if !(chr.is_alphanumeric() || chr == '_' || chr == '#') {
-                    state = State::Expr;
-                }
-
-                if matches!(chr, '\\' | '$') {
-                    current_expr.push('\\');
-                }
-                current_expr.push(chr);
-            }
-            (State::FormatOpts, '}') => {
-                output.push(chr);
-                state = State::NotArg;
-            }
-            (State::FormatOpts, _) => {
-                if matches!(chr, '\\' | '$') {
-                    output.push('\\');
-                }
-                output.push(chr);
-            }
-        }
-    }
-
-    if state != State::NotArg {
-        return Err(());
-    }
-
-    Ok((output, extracted_expressions))
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use expect_test::{expect, Expect};
-
-    fn check(input: &str, expect: &Expect) {
-        let (output, exprs) = parse_format_exprs(input).unwrap_or(("-".to_string(), vec![]));
-        let outcome_repr = if !exprs.is_empty() {
-            format!("{}; {}", output, with_placeholders(exprs).join(", "))
-        } else {
-            output
-        };
-
-        expect.assert_eq(&outcome_repr);
-    }
-
-    #[test]
-    fn format_str_parser() {
-        let test_vector = &[
-            ("no expressions", expect![["no expressions"]]),
-            (r"no expressions with \$0$1", expect![r"no expressions with \\\$0\$1"]),
-            ("{expr} is {2 + 2}", expect![["{} is {}; expr, 2 + 2"]]),
-            ("{expr:?}", expect![["{:?}; expr"]]),
-            ("{expr:1$}", expect![[r"{:1\$}; expr"]]),
-            ("{$0}", expect![[r"{}; \$0"]]),
-            ("{malformed", expect![["-"]]),
-            ("malformed}", expect![["-"]]),
-            ("{{correct", expect![["{{correct"]]),
-            ("correct}}", expect![["correct}}"]]),
-            ("{correct}}}", expect![["{}}}; correct"]]),
-            ("{correct}}}}}", expect![["{}}}}}; correct"]]),
-            ("{incorrect}}", expect![["-"]]),
-            ("placeholders {} {}", expect![["placeholders {} {}; $1, $2"]]),
-            ("mixed {} {2 + 2} {}", expect![["mixed {} {} {}; $1, 2 + 2, $2"]]),
-            (
-                "{SomeStruct { val_a: 0, val_b: 1 }}",
-                expect![["{}; SomeStruct { val_a: 0, val_b: 1 }"]],
-            ),
-            ("{expr:?} is {2.32f64:.5}", expect![["{:?} is {:.5}; expr, 2.32f64"]]),
-            (
-                "{SomeStruct { val_a: 0, val_b: 1 }:?}",
-                expect![["{:?}; SomeStruct { val_a: 0, val_b: 1 }"]],
-            ),
-            ("{     2 + 2        }", expect![["{}; 2 + 2"]]),
-            ("{strsim::jaro_winkle(a)}", expect![["{}; strsim::jaro_winkle(a)"]]),
-            ("{foo::bar::baz()}", expect![["{}; foo::bar::baz()"]]),
-            ("{foo::bar():?}", expect![["{:?}; foo::bar()"]]),
-        ];
-
-        for (input, output) in test_vector {
-            check(input, output)
-        }
-    }
-
-    #[test]
-    fn arg_type() {
-        assert_eq!(
-            parse_format_exprs("{_ident} {r#raw_ident} {expr.obj} {name {thing: 42} } {}")
-                .unwrap()
-                .1,
-            vec![
-                Arg::Ident("_ident".to_owned()),
-                Arg::Ident("r#raw_ident".to_owned()),
-                Arg::Expr("expr.obj".to_owned()),
-                Arg::Expr("name {thing: 42}".to_owned()),
-                Arg::Placeholder
-            ]
-        );
-    }
-}
diff --git a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
index 06073ca1b2..a21db5b2ce 100644
--- a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
+++ b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
@@ -137,7 +137,6 @@ pub(crate) fn json_in_items(
                                         sema.db,
                                         it,
                                         config.insert_use.prefix_kind,
-                                        config.prefer_core,
                                     ) {
                                         insert_use(
                                             &scope,
@@ -153,7 +152,6 @@ pub(crate) fn json_in_items(
                                         sema.db,
                                         it,
                                         config.insert_use.prefix_kind,
-                                        config.prefer_core,
                                     ) {
                                         insert_use(
                                             &scope,
diff --git a/crates/ide-diagnostics/src/handlers/missing_fields.rs b/crates/ide-diagnostics/src/handlers/missing_fields.rs
index 5a81a55d82..edb1fc0919 100644
--- a/crates/ide-diagnostics/src/handlers/missing_fields.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_fields.rs
@@ -124,7 +124,6 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
                         let type_path = current_module?.find_use_path(
                             ctx.sema.db,
                             item_for_path_search(ctx.sema.db, item_in_ns)?,
-                            ctx.config.prefer_core,
                         )?;
 
                         use_trivial_constructor(
diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs
index 22e644bb59..61e63ea7a9 100644
--- a/crates/ide-diagnostics/src/lib.rs
+++ b/crates/ide-diagnostics/src/lib.rs
@@ -150,7 +150,6 @@ pub struct DiagnosticsConfig {
     pub expr_fill_default: ExprFillDefaultMode,
     // FIXME: We may want to include a whole `AssistConfig` here
     pub insert_use: InsertUseConfig,
-    pub prefer_core: bool,
 }
 
 impl DiagnosticsConfig {
@@ -171,7 +170,6 @@ impl DiagnosticsConfig {
                 group: false,
                 skip_glob_imports: false,
             },
-            prefer_core: false,
         }
     }
 }
diff --git a/crates/ide-ssr/src/matching.rs b/crates/ide-ssr/src/matching.rs
index 57b5ab6abd..e3a837ddcd 100644
--- a/crates/ide-ssr/src/matching.rs
+++ b/crates/ide-ssr/src/matching.rs
@@ -648,10 +648,9 @@ impl Match {
             .module();
         for (path, resolved_path) in &template.resolved_paths {
             if let hir::PathResolution::Def(module_def) = resolved_path.resolution {
-                let mod_path =
-                    module.find_use_path(sema.db, module_def, false).ok_or_else(|| {
-                        match_error!("Failed to render template path `{}` at match location")
-                    })?;
+                let mod_path = module.find_use_path(sema.db, module_def).ok_or_else(|| {
+                    match_error!("Failed to render template path `{}` at match location")
+                })?;
                 self.rendered_template_paths.insert(path.clone(), mod_path);
             }
         }
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index ba4c330bf3..210c5c7fac 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -158,7 +158,6 @@ pub(crate) fn resolve_annotation(db: &RootDatabase, mut annotation: Annotation)
                 &Semantics::new(db),
                 FilePosition { file_id, offset: annotation.range.start() },
                 None,
-                false,
             )
             .map(|result| {
                 result
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 065b48378b..0552330814 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -425,11 +425,8 @@ impl Analysis {
         &self,
         position: FilePosition,
         search_scope: Option<SearchScope>,
-        exclude_imports: bool,
     ) -> Cancellable<Option<Vec<ReferenceSearchResult>>> {
-        self.with_db(|db| {
-            references::find_all_refs(&Semantics::new(db), position, search_scope, exclude_imports)
-        })
+        self.with_db(|db| references::find_all_refs(&Semantics::new(db), position, search_scope))
     }
 
     /// Finds all methods and free functions for the file. Does not return tests!
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 5b410c454d..99614b645e 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -54,7 +54,6 @@ pub(crate) fn find_all_refs(
     sema: &Semantics<'_, RootDatabase>,
     position: FilePosition,
     search_scope: Option<SearchScope>,
-    exclude_imports: bool,
 ) -> Option<Vec<ReferenceSearchResult>> {
     let _p = profile::span("find_all_refs");
     let syntax = sema.parse(position.file_id).syntax().clone();
@@ -80,10 +79,6 @@ pub(crate) fn find_all_refs(
                 retain_adt_literal_usages(&mut usages, def, sema);
             }
 
-            if exclude_imports {
-                filter_import_references(&mut usages);
-            }
-
             let references = usages
                 .into_iter()
                 .map(|(file_id, refs)| {
@@ -117,17 +112,6 @@ pub(crate) fn find_all_refs(
     }
 }
 
-fn filter_import_references(usages: &mut UsageSearchResult) {
-    for (_file_id, refs) in &mut usages.references {
-        refs.retain(|it| match it.name.as_name_ref() {
-            Some(name_ref) => {
-                !name_ref.syntax().ancestors().any(|it_ref| matches!(it_ref.kind(), USE))
-            }
-            None => true,
-        });
-    }
-}
-
 pub(crate) fn find_defs<'a>(
     sema: &'a Semantics<'_, RootDatabase>,
     syntax: &SyntaxNode,
@@ -1110,7 +1094,7 @@ impl Foo {
 
     fn check_with_scope(ra_fixture: &str, search_scope: Option<SearchScope>, expect: Expect) {
         let (analysis, pos) = fixture::position(ra_fixture);
-        let refs = analysis.find_all_refs(pos, search_scope, false).unwrap().unwrap();
+        let refs = analysis.find_all_refs(pos, search_scope).unwrap().unwrap();
 
         let mut actual = String::new();
         for refs in refs {
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index e0384e67d4..54dcb42d99 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -219,6 +219,7 @@ config_data! {
         files_excludeDirs: Vec<PathBuf> = "[]",
         /// Controls file watching implementation.
         files_watcher: FilesWatcherDef = "\"client\"",
+
         /// Enables highlighting of related references while the cursor is on `break`, `loop`, `while`, or `for` keywords.
         highlightRelated_breakPoints_enable: bool = "true",
         /// Enables highlighting of all exit points while the cursor is on any `return`, `?`, `fn`, or return type arrow (`->`).
@@ -262,8 +263,6 @@ config_data! {
         imports_group_enable: bool                           = "true",
         /// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
         imports_merge_glob: bool           = "true",
-        /// Prefer to use imports of the core crate over the std crate.
-        imports_prefer_core: bool                     = "false",
         /// The path structure for newly inserted paths to use.
         imports_prefix: ImportPrefixDef               = "\"plain\"",
 
@@ -360,9 +359,6 @@ config_data! {
         /// this is rust-analyzer itself, but we override this in tests).
         procMacro_server: Option<PathBuf>          = "null",
 
-        /// Exclude imports from find-all-references.
-        references_excludeImports: bool = "false",
-
         /// Command to be executed instead of 'cargo' for runnables.
         runnables_command: Option<String> = "null",
         /// Additional arguments to be passed to cargo for runnables such as
@@ -922,7 +918,6 @@ impl Config {
                 ExprFillDefaultDef::Default => ExprFillDefaultMode::Default,
             },
             insert_use: self.insert_use_config(),
-            prefer_core: self.data.imports_prefer_core,
         }
     }
 
@@ -1138,7 +1133,6 @@ impl Config {
                 CallableCompletionDef::None => None,
             },
             insert_use: self.insert_use_config(),
-            prefer_core: self.data.imports_prefer_core,
             snippet_cap: SnippetCap::new(try_or_def!(
                 self.caps
                     .text_document
@@ -1153,10 +1147,6 @@ impl Config {
         }
     }
 
-    pub fn find_all_refs_exclude_imports(&self) -> bool {
-        self.data.references_excludeImports
-    }
-
     pub fn snippet_cap(&self) -> bool {
         self.experimental("snippetTextEdit")
     }
@@ -1166,7 +1156,6 @@ impl Config {
             snippet_cap: SnippetCap::new(self.experimental("snippetTextEdit")),
             allowed: None,
             insert_use: self.insert_use_config(),
-            prefer_core: self.data.imports_prefer_core,
         }
     }
 
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 7b486744da..e79cf3d3fd 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1012,9 +1012,7 @@ pub(crate) fn handle_references(
     let _p = profile::span("handle_references");
     let position = from_proto::file_position(&snap, params.text_document_position)?;
 
-    let exclude_imports = snap.config.find_all_refs_exclude_imports();
-
-    let refs = match snap.analysis.find_all_refs(position, None, exclude_imports)? {
+    let refs = match snap.analysis.find_all_refs(position, None)? {
         None => return Ok(None),
         Some(refs) => refs,
     };
@@ -1654,9 +1652,7 @@ fn show_ref_command_link(
     position: &FilePosition,
 ) -> Option<lsp_ext::CommandLinkGroup> {
     if snap.config.hover_actions().references && snap.config.client_commands().show_reference {
-        if let Some(ref_search_res) =
-            snap.analysis.find_all_refs(*position, None, false).unwrap_or(None)
-        {
+        if let Some(ref_search_res) = snap.analysis.find_all_refs(*position, None).unwrap_or(None) {
             let uri = to_proto::url(snap, position.file_id);
             let line_index = snap.file_line_index(position.file_id).ok()?;
             let position = to_proto::position(&line_index, position.offset);
diff --git a/crates/rust-analyzer/src/integrated_benchmarks.rs b/crates/rust-analyzer/src/integrated_benchmarks.rs
index 5dbb64d7df..e49a98685a 100644
--- a/crates/rust-analyzer/src/integrated_benchmarks.rs
+++ b/crates/rust-analyzer/src/integrated_benchmarks.rs
@@ -145,7 +145,6 @@ fn integrated_completion_benchmark() {
                 skip_glob_imports: true,
             },
             snippets: Vec::new(),
-            prefer_core: false,
         };
         let position =
             FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
@@ -183,7 +182,6 @@ fn integrated_completion_benchmark() {
                 skip_glob_imports: true,
             },
             snippets: Vec::new(),
-            prefer_core: false,
         };
         let position =
             FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index 2b02c64b66..72b9257264 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -353,11 +353,6 @@ Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-i
 --
 Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
 --
-[[rust-analyzer.imports.prefer.core]]rust-analyzer.imports.prefer.core (default: `false`)::
-+
---
-Prefer to use imports of the core crate over the std crate.
---
 [[rust-analyzer.imports.prefix]]rust-analyzer.imports.prefix (default: `"plain"`)::
 +
 --
@@ -551,11 +546,6 @@ This config takes a map of crate names with the exported proc-macro names to ign
 Internal config, path to proc-macro server executable (typically,
 this is rust-analyzer itself, but we override this in tests).
 --
-[[rust-analyzer.references.excludeImports]]rust-analyzer.references.excludeImports (default: `false`)::
-+
---
-Exclude imports from find-all-references.
---
 [[rust-analyzer.runnables.command]]rust-analyzer.runnables.command (default: `null`)::
 +
 --
diff --git a/editors/code/package.json b/editors/code/package.json
index cfba00d3ed..767c5875bf 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -206,6 +206,11 @@
                 "title": "Show RA Version",
                 "category": "rust-analyzer"
             },
+            {
+                "command": "rust-analyzer.toggleInlayHints",
+                "title": "Toggle inlay hints",
+                "category": "rust-analyzer"
+            },
             {
                 "command": "rust-analyzer.openDocs",
                 "title": "Open docs under cursor",
@@ -798,11 +803,6 @@
                     "default": true,
                     "type": "boolean"
                 },
-                "rust-analyzer.imports.prefer.core": {
-                    "markdownDescription": "Prefer to use imports of the core crate over the std crate.",
-                    "default": false,
-                    "type": "boolean"
-                },
                 "rust-analyzer.imports.prefix": {
                     "markdownDescription": "The path structure for newly inserted paths to use.",
                     "default": "plain",
@@ -1036,11 +1036,6 @@
                         "string"
                     ]
                 },
-                "rust-analyzer.references.excludeImports": {
-                    "markdownDescription": "Exclude imports from find-all-references.",
-                    "default": false,
-                    "type": "boolean"
-                },
                 "rust-analyzer.runnables.command": {
                     "markdownDescription": "Command to be executed instead of 'cargo' for runnables.",
                     "default": null,
@@ -1638,6 +1633,10 @@
                     "command": "rust-analyzer.serverVersion",
                     "when": "inRustProject"
                 },
+                {
+                    "command": "rust-analyzer.toggleInlayHints",
+                    "when": "inRustProject"
+                },
                 {
                     "command": "rust-analyzer.openDocs",
                     "when": "inRustProject"
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index b9ad525e36..a21b304bbd 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -321,6 +321,30 @@ export function serverVersion(ctx: Ctx): Cmd {
     };
 }
 
+export function toggleInlayHints(_ctx: Ctx): Cmd {
+    return async () => {
+        const config = vscode.workspace.getConfiguration("editor.inlayHints", {
+            languageId: "rust",
+        });
+
+        const value = config.get("enabled");
+        let stringValue;
+        if (typeof value === "string") {
+            stringValue = value;
+        } else {
+            stringValue = value ? "on" : "off";
+        }
+        const nextValues: Record<string, string> = {
+            on: "off",
+            off: "on",
+            onUnlessPressed: "offUnlessPressed",
+            offUnlessPressed: "onUnlessPressed",
+        };
+        const nextValue = nextValues[stringValue] ?? "on";
+        await config.update("enabled", nextValue, vscode.ConfigurationTarget.Global);
+    };
+}
+
 // Opens the virtual file that will show the syntax tree
 //
 // The contents of the file come from the `TextDocumentContentProvider`
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 41bde4195e..e9b62e0cc2 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -180,6 +180,7 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) {
 
     ctx.registerCommand("ssr", commands.ssr);
     ctx.registerCommand("serverVersion", commands.serverVersion);
+    ctx.registerCommand("toggleInlayHints", commands.toggleInlayHints);
 
     // Internal commands which are invoked by the server.
     ctx.registerCommand("runSingle", commands.runSingle);


Test patch:
diff --git a/crates/hir-ty/src/tests/method_resolution.rs b/crates/hir-ty/src/tests/method_resolution.rs
index ac8edb841a..81588a7c4f 100644
--- a/crates/hir-ty/src/tests/method_resolution.rs
+++ b/crates/hir-ty/src/tests/method_resolution.rs
@@ -1218,40 +1218,6 @@ fn main() {
     );
 }
 
-#[test]
-fn dyn_trait_method_priority() {
-    check_types(
-        r#"
-//- minicore: from
-trait Trait {
-    fn into(&self) -> usize { 0 }
-}
-
-fn foo(a: &dyn Trait) {
-    let _ = a.into();
-      //^usize
-}
-        "#,
-    );
-}
-
-#[test]
-fn trait_method_priority_for_placeholder_type() {
-    check_types(
-        r#"
-//- minicore: from
-trait Trait {
-    fn into(&self) -> usize { 0 }
-}
-
-fn foo<T: Trait>(a: &T) {
-    let _ = a.into();
-      //^usize
-}
-        "#,
-    );
-}
-
 #[test]
 fn autoderef_visibility_field() {
     check(
diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs
index 4e589dc86a..9cd66c6b3b 100644
--- a/crates/ide-assists/src/tests.rs
+++ b/crates/ide-assists/src/tests.rs
@@ -29,7 +29,6 @@ pub(crate) const TEST_CONFIG: AssistConfig = AssistConfig {
         group: true,
         skip_glob_imports: true,
     },
-    prefer_core: false,
 };
 
 pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) {
diff --git a/crates/ide-assists/src/tests/generated.rs b/crates/ide-assists/src/tests/generated.rs
index 3a696635af..227e2300f9 100644
--- a/crates/ide-assists/src/tests/generated.rs
+++ b/crates/ide-assists/src/tests/generated.rs
@@ -1591,37 +1591,6 @@ fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
     )
 }
 
-#[test]
-fn doctest_move_format_string_arg() {
-    check_doc_test(
-        "move_format_string_arg",
-        r#####"
-macro_rules! format_args {
-    ($lit:literal $(tt:tt)*) => { 0 },
-}
-macro_rules! print {
-    ($($arg:tt)*) => (std::io::_print(format_args!($($arg)*)));
-}
-
-fn main() {
-    print!("{x + 1}$0");
-}
-"#####,
-        r#####"
-macro_rules! format_args {
-    ($lit:literal $(tt:tt)*) => { 0 },
-}
-macro_rules! print {
-    ($($arg:tt)*) => (std::io::_print(format_args!($($arg)*)));
-}
-
-fn main() {
-    print!("{}"$0, x + 1);
-}
-"#####,
-    )
-}
-
 #[test]
 fn doctest_move_from_mod_rs() {
     check_doc_test(
diff --git a/crates/ide-completion/src/tests.rs b/crates/ide-completion/src/tests.rs
index d24c914856..cf826648dc 100644
--- a/crates/ide-completion/src/tests.rs
+++ b/crates/ide-completion/src/tests.rs
@@ -66,7 +66,6 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
     enable_private_editable: false,
     callable: Some(CallableSnippets::FillArguments),
     snippet_cap: SnippetCap::new(true),
-    prefer_core: false,
     insert_use: InsertUseConfig {
         granularity: ImportGranularity::Crate,
         prefix_kind: PrefixKind::Plain,