mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Replace doc_comments_and_attrs
with collect_attrs
This commit is contained in:
parent
19387d3077
commit
9337519df5
@ -59,7 +59,7 @@ use hir_def::{
|
||||
Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId, TraitAliasId, TraitId,
|
||||
TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
|
||||
};
|
||||
use hir_expand::{name::name, MacroCallKind};
|
||||
use hir_expand::{attrs::collect_attrs, name::name, MacroCallKind};
|
||||
use hir_ty::{
|
||||
all_super_traits, autoderef, check_orphan_rules,
|
||||
consteval::{try_const_usize, unknown_const_as_generic, ConstEvalError, ConstExt},
|
||||
@ -81,7 +81,7 @@ use once_cell::unsync::Lazy;
|
||||
use rustc_hash::FxHashSet;
|
||||
use stdx::{impl_from, never};
|
||||
use syntax::{
|
||||
ast::{self, HasAttrs as _, HasDocComments, HasName},
|
||||
ast::{self, HasAttrs as _, HasName},
|
||||
AstNode, AstPtr, SmolStr, SyntaxNode, SyntaxNodePtr, TextRange, T,
|
||||
};
|
||||
use triomphe::Arc;
|
||||
@ -974,10 +974,9 @@ fn precise_macro_call_location(
|
||||
// Compute the precise location of the macro name's token in the derive
|
||||
// list.
|
||||
let token = (|| {
|
||||
let derive_attr = node
|
||||
.doc_comments_and_attrs()
|
||||
let derive_attr = collect_attrs(&node)
|
||||
.nth(derive_attr_index.ast_index())
|
||||
.and_then(Either::left)?;
|
||||
.and_then(|x| Either::left(x.1))?;
|
||||
let token_tree = derive_attr.meta()?.token_tree()?;
|
||||
let group_by = token_tree
|
||||
.syntax()
|
||||
@ -1002,10 +1001,9 @@ fn precise_macro_call_location(
|
||||
}
|
||||
MacroCallKind::Attr { ast_id, invoc_attr_index, .. } => {
|
||||
let node = ast_id.to_node(db.upcast());
|
||||
let attr = node
|
||||
.doc_comments_and_attrs()
|
||||
let attr = collect_attrs(&node)
|
||||
.nth(invoc_attr_index.ast_index())
|
||||
.and_then(Either::left)
|
||||
.and_then(|x| Either::left(x.1))
|
||||
.unwrap_or_else(|| {
|
||||
panic!("cannot find attribute #{}", invoc_attr_index.ast_index())
|
||||
});
|
||||
|
@ -44,6 +44,21 @@ extern crate core;
|
||||
extern crate self as foo;
|
||||
struct Foo;
|
||||
use foo::Foo as Bar;
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_panic_with_inner_attribute_in_presence_of_unresolved_crate() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
#[macro_use] extern crate doesnotexist;
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unresolved extern crate
|
||||
mod _test_inner {
|
||||
#![empty_attr]
|
||||
//^^^^^^^^^^^^^^ error: unresolved macro `empty_attr`
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user