mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-24 02:53:35 +00:00
fix: ide: exclude sized in go-to actions
This commit is contained in:
parent
2fdd1ac510
commit
3132a9e7fc
3 changed files with 24 additions and 3 deletions
|
@ -44,7 +44,7 @@ use hir_def::{
|
|||
generics::{LifetimeParamData, TypeOrConstParamData, TypeParamProvenance},
|
||||
hir::{BindingAnnotation, BindingId, ExprOrPatId, LabelId, Pat},
|
||||
item_tree::ItemTreeNode,
|
||||
lang_item::{LangItem, LangItemTarget},
|
||||
lang_item::LangItemTarget,
|
||||
layout::ReprOptions,
|
||||
macro_id_to_def_id,
|
||||
nameres::{self, diagnostics::DefDiagnostic, ModuleOrigin},
|
||||
|
@ -114,6 +114,7 @@ pub use {
|
|||
data::adt::StructKind,
|
||||
find_path::PrefixKind,
|
||||
import_map,
|
||||
lang_item::LangItem,
|
||||
nameres::ModuleSource,
|
||||
path::{ModPath, PathKind},
|
||||
type_ref::{Mutability, TypeRef},
|
||||
|
|
|
@ -6,7 +6,7 @@ mod tests;
|
|||
use std::iter;
|
||||
|
||||
use either::Either;
|
||||
use hir::{HasSource, Semantics};
|
||||
use hir::{db::DefDatabase, HasSource, LangItem, Semantics};
|
||||
use ide_db::{
|
||||
base_db::FileRange,
|
||||
defs::{Definition, IdentClass, OperatorClass},
|
||||
|
@ -353,7 +353,14 @@ fn goto_type_action_for_def(db: &RootDatabase, def: Definition) -> Option<HoverA
|
|||
};
|
||||
|
||||
if let Definition::GenericParam(hir::GenericParam::TypeParam(it)) = def {
|
||||
it.trait_bounds(db).into_iter().for_each(|it| push_new_def(it.into()));
|
||||
let krate = it.module(db).krate();
|
||||
let sized_trait =
|
||||
db.lang_item(krate.into(), LangItem::Sized).and_then(|lang_item| lang_item.as_trait());
|
||||
|
||||
it.trait_bounds(db)
|
||||
.into_iter()
|
||||
.filter(|&it| Some(it.into()) != sized_trait)
|
||||
.for_each(|it| push_new_def(it.into()));
|
||||
} else {
|
||||
let ty = match def {
|
||||
Definition::Local(it) => it.ty(db),
|
||||
|
|
|
@ -2098,6 +2098,19 @@ fn main() { let s$0t = S{ f1:Arg(0) }; }
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hover_generic_excludes_sized_go_to_action() {
|
||||
check_actions(
|
||||
r#"
|
||||
//- minicore: sized
|
||||
struct S<T$0>(T);
|
||||
"#,
|
||||
expect![[r#"
|
||||
[]
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hover_generic_struct_has_flattened_goto_type_actions() {
|
||||
check_actions(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue