Remove dead test code
This commit is contained in:
parent
d2f8eae2ec
commit
d085ade631
@ -191,9 +191,9 @@ pub(crate) fn struct_data_with_diagnostics_query(
|
||||
let krate = loc.container.krate;
|
||||
let item_tree = loc.id.item_tree(db);
|
||||
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
|
||||
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();
|
||||
let cfg_options = db.crate_graph()[krate].cfg_options.clone();
|
||||
|
||||
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
||||
let attrs = item_tree.attrs(db, krate, ModItem::from(loc.id.value).into());
|
||||
|
||||
let mut flags = StructFlags::NO_FLAGS;
|
||||
if attrs.by_key("rustc_has_incoherent_inherent_impls").exists() {
|
||||
@ -248,9 +248,9 @@ pub(crate) fn union_data_with_diagnostics_query(
|
||||
let krate = loc.container.krate;
|
||||
let item_tree = loc.id.item_tree(db);
|
||||
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
|
||||
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();
|
||||
let cfg_options = db.crate_graph()[krate].cfg_options.clone();
|
||||
|
||||
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
||||
let attrs = item_tree.attrs(db, krate, ModItem::from(loc.id.value).into());
|
||||
let mut flags = StructFlags::NO_FLAGS;
|
||||
if attrs.by_key("rustc_has_incoherent_inherent_impls").exists() {
|
||||
flags |= StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPL;
|
||||
|
@ -298,7 +298,6 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: The def site spans here are wrong, those should point to the name, not the whole ast node
|
||||
match id {
|
||||
MacroId::Macro2Id(it) => {
|
||||
let loc: Macro2Loc = it.lookup(db);
|
||||
@ -310,9 +309,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
||||
local_inner: false,
|
||||
allow_internal_unsafe: loc.allow_internal_unsafe,
|
||||
span: db
|
||||
.span_map(loc.id.file_id())
|
||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||
span: makro.def_site,
|
||||
edition: loc.edition,
|
||||
}
|
||||
}
|
||||
@ -328,9 +325,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||
allow_internal_unsafe: loc
|
||||
.flags
|
||||
.contains(MacroRulesLocFlags::ALLOW_INTERNAL_UNSAFE),
|
||||
span: db
|
||||
.span_map(loc.id.file_id())
|
||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||
span: makro.def_site,
|
||||
edition: loc.edition,
|
||||
}
|
||||
}
|
||||
@ -348,6 +343,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||
),
|
||||
local_inner: false,
|
||||
allow_internal_unsafe: false,
|
||||
// FIXME: This is wrong, this should point to the name
|
||||
span: db
|
||||
.span_map(loc.id.file_id())
|
||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||
|
@ -790,7 +790,6 @@ pub struct MacroCall {
|
||||
pub path: Interned<ModPath>,
|
||||
pub ast_id: FileAstId<ast::MacroCall>,
|
||||
pub expand_to: ExpandTo,
|
||||
// FIXME: We need to move this out. It invalidates the item tree when typing inside the macro call.
|
||||
pub call_site: Span,
|
||||
}
|
||||
|
||||
@ -799,6 +798,7 @@ pub struct MacroRules {
|
||||
/// The name of the declared macro.
|
||||
pub name: Name,
|
||||
pub ast_id: FileAstId<ast::MacroRules>,
|
||||
pub def_site: Span,
|
||||
}
|
||||
|
||||
/// "Macros 2.0" macro definition.
|
||||
@ -807,6 +807,7 @@ pub struct Macro2 {
|
||||
pub name: Name,
|
||||
pub visibility: RawVisibilityId,
|
||||
pub ast_id: FileAstId<ast::MacroDef>,
|
||||
pub def_site: Span,
|
||||
}
|
||||
|
||||
impl Use {
|
||||
|
@ -572,20 +572,22 @@ fn lower_macro_call(&mut self, m: &ast::MacroCall) -> Option<FileItemTreeId<Macr
|
||||
}
|
||||
|
||||
fn lower_macro_rules(&mut self, m: &ast::MacroRules) -> Option<FileItemTreeId<MacroRules>> {
|
||||
let name = m.name().map(|it| it.as_name())?;
|
||||
let name = m.name()?;
|
||||
let def_site = self.span_map().span_for_range(name.syntax().text_range());
|
||||
let ast_id = self.source_ast_id_map.ast_id(m);
|
||||
|
||||
let res = MacroRules { name, ast_id };
|
||||
let res = MacroRules { name: name.as_name(), ast_id, def_site };
|
||||
Some(id(self.data().macro_rules.alloc(res)))
|
||||
}
|
||||
|
||||
fn lower_macro_def(&mut self, m: &ast::MacroDef) -> Option<FileItemTreeId<Macro2>> {
|
||||
let name = m.name().map(|it| it.as_name())?;
|
||||
let name = m.name()?;
|
||||
let def_site = self.span_map().span_for_range(name.syntax().text_range());
|
||||
|
||||
let ast_id = self.source_ast_id_map.ast_id(m);
|
||||
let visibility = self.lower_visibility(m);
|
||||
|
||||
let res = Macro2 { name, ast_id, visibility };
|
||||
let res = Macro2 { name: name.as_name(), ast_id, visibility, def_site };
|
||||
Some(id(self.data().macro_defs.alloc(res)))
|
||||
}
|
||||
|
||||
|
@ -498,13 +498,23 @@ fn print_mod_item(&mut self, item: ModItem) {
|
||||
wln!(self, "{}!(...);", path.display(self.db.upcast()));
|
||||
}
|
||||
ModItem::MacroRules(it) => {
|
||||
let MacroRules { name, ast_id } = &self.tree[it];
|
||||
self.print_ast_id(ast_id.erase());
|
||||
let MacroRules { name, ast_id, def_site } = &self.tree[it];
|
||||
let _ = writeln!(
|
||||
self,
|
||||
"// AstId: {:?}, Span: {}",
|
||||
ast_id.erase().into_raw(),
|
||||
def_site,
|
||||
);
|
||||
wln!(self, "macro_rules! {} {{ ... }}", name.display(self.db.upcast()));
|
||||
}
|
||||
ModItem::Macro2(it) => {
|
||||
let Macro2 { name, visibility, ast_id } = &self.tree[it];
|
||||
self.print_ast_id(ast_id.erase());
|
||||
let Macro2 { name, visibility, ast_id, def_site } = &self.tree[it];
|
||||
let _ = writeln!(
|
||||
self,
|
||||
"// AstId: {:?}, Span: {}",
|
||||
ast_id.erase().into_raw(),
|
||||
def_site,
|
||||
);
|
||||
self.print_visibility(*visibility);
|
||||
wln!(self, "macro {} {{ ... }}", name.display(self.db.upcast()));
|
||||
}
|
||||
|
@ -272,10 +272,10 @@ macro_rules! m {
|
||||
m!();
|
||||
"#,
|
||||
expect![[r#"
|
||||
// AstId: 1
|
||||
// AstId: 1, Span: 0:1@13..14#0
|
||||
macro_rules! m { ... }
|
||||
|
||||
// AstId: 2
|
||||
// AstId: 2, Span: 0:2@10..12#0
|
||||
pub macro m2 { ... }
|
||||
|
||||
// AstId: 3, Span: 0:3@0..1#0, ExpandTo: Items
|
||||
|
@ -269,7 +269,8 @@ fn test_quote_hash_token_tree() {
|
||||
let t = format!("{quoted:#?}");
|
||||
expect![[r#"
|
||||
SUBTREE $$ 937550:0@0..0#0 937550:0@0..0#0
|
||||
IDENT hello 937550:0@0..0#0"#]].assert_eq(&t);
|
||||
IDENT hello 937550:0@0..0#0"#]]
|
||||
.assert_eq(&t);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -207,7 +207,7 @@ pub fn completions(
|
||||
CompletionAnalysis::String { original, expanded: Some(expanded) } => {
|
||||
completions::extern_abi::complete_extern_abi(acc, ctx, expanded);
|
||||
completions::format_string::format_string(acc, ctx, original, expanded);
|
||||
completions::env_vars::complete_cargo_env_vars(acc, ctx,original, expanded);
|
||||
completions::env_vars::complete_cargo_env_vars(acc, ctx, original, expanded);
|
||||
}
|
||||
CompletionAnalysis::UnexpandedAttrTT {
|
||||
colon_prefix,
|
||||
|
@ -8,7 +8,12 @@
|
||||
|
||||
#[test]
|
||||
fn test_derive_empty() {
|
||||
assert_expand("DeriveEmpty", r#"struct S;"#, expect!["SUBTREE $$ 1 1"], expect!["SUBTREE $$ 42:2@0..100#0 42:2@0..100#0"]);
|
||||
assert_expand(
|
||||
"DeriveEmpty",
|
||||
r#"struct S;"#,
|
||||
expect!["SUBTREE $$ 1 1"],
|
||||
expect!["SUBTREE $$ 42:2@0..100#0 42:2@0..100#0"],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -194,21 +194,6 @@ pub fn insert(self, value: V) -> &'a mut V {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct A(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct B(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct C(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct D(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct E(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct F(i32);
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct J(i32);
|
||||
|
||||
#[test]
|
||||
fn test_varieties() {
|
||||
fn assert_send<T: Send>() {}
|
||||
|
Loading…
Reference in New Issue
Block a user