10240: internal: Revert attributed items inlay hints r=Veykril a=Veykril

Reverts #10231 as the implementation there is actually wrong
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-09-14 18:31:59 +00:00 committed by GitHub
commit 726a2aa211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 98 deletions

View file

@ -184,14 +184,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.descend_into_macros(token)
}
pub fn descend_node_at_offset<N: ast::AstNode>(
&self,
node: &SyntaxNode,
offset: TextSize,
) -> Option<N> {
self.imp.descend_node_at_offset(node, offset).flatten().find_map(N::cast)
}
pub fn hir_file_for(&self, syntax_node: &SyntaxNode) -> HirFileId {
self.imp.find_file(syntax_node.clone()).file_id
}

View file

@ -62,24 +62,11 @@ pub(crate) fn inlay_hints(
let _p = profile::span("inlay_hints");
let sema = Semantics::new(db);
let file = sema.parse(file_id);
let file = file.syntax();
let mut res = Vec::new();
let mut queue = vec![file.syntax().preorder()];
while let Some(mut preorder) = queue.pop() {
while let Some(event) = preorder.next() {
let node = match event {
syntax::WalkEvent::Enter(node) => node,
syntax::WalkEvent::Leave(_) => continue,
};
if let Some(node) =
ast::Item::cast(node.clone()).and_then(|item| sema.expand_attr_macro(&item))
{
preorder.skip_subtree();
queue.push(node.preorder());
continue;
}
for node in file.descendants() {
if let Some(expr) = ast::Expr::cast(node.clone()) {
get_chaining_hints(&mut res, &sema, config, &expr);
match expr {
@ -95,7 +82,6 @@ pub(crate) fn inlay_hints(
get_bind_pat_hints(&mut res, &sema, config, it);
}
}
}
res
}
@ -1485,67 +1471,4 @@ fn main() {
"#]],
);
}
#[test]
fn hints_in_attr_call() {
// chaining hints do not currently work as macros lose all whitespace information
check_expect(
TEST_CONFIG,
r#"
//- proc_macros: identity, input_replace
struct Struct;
impl Struct {
fn chain(self) -> Self {
self
}
}
#[proc_macros::identity]
fn main() {
let strukt = Struct;
strukt
.chain()
.chain()
.chain();
Struct::chain(strukt);
}
#[proc_macros::input_replace(
fn not_main() {
let strukt = Struct;
strukt
.chain()
.chain()
.chain();
Struct::chain(strukt);
}
)]
fn main() {}
"#,
expect![[r#"
[
InlayHint {
range: 297..303,
kind: TypeHint,
label: "Struct",
},
InlayHint {
range: 415..421,
kind: ParameterHint,
label: "self",
},
InlayHint {
range: 125..131,
kind: TypeHint,
label: "Struct",
},
InlayHint {
range: 223..229,
kind: ParameterHint,
label: "self",
},
]
"#]],
);
}
}