From 274d813cff34576d3fe9d343e73669385214d3c3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 19 May 2021 21:05:58 +0200 Subject: Fix derive collection after unresolved attribute fallback --- crates/hir_def/src/nameres/tests/macros.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src/nameres/tests/macros.rs') diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index c37f915ab..b34ba885d 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs @@ -685,6 +685,27 @@ pub trait Clone {} ); } +#[test] +fn builtin_derive_with_unresolved_attributes_fall_back() { + // Tests that we still resolve derives after ignoring an unresolved attribute. + cov_mark::check!(unresolved_attribute_fallback); + let map = compute_crate_def_map( + r#" + //- /main.rs crate:main deps:core + use core::Clone; + + #[derive(Clone)] + #[unresolved] + struct Foo; + + //- /core.rs crate:core + #[rustc_builtin_macro] + pub macro Clone {} + "#, + ); + assert_eq!(map.modules[map.root].scope.impls().len(), 1); +} + #[test] fn macro_expansion_overflow() { cov_mark::check!(macro_expansion_overflow); @@ -842,7 +863,6 @@ fn collects_derive_helpers() { fn resolve_macro_def() { check( r#" -//- /lib.rs pub macro structs($($i:ident),*) { $(struct $i { field: u32 } )* } -- cgit v1.2.3