diff options
Diffstat (limited to 'crates/hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 93f30f23d..fc2c50fb8 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -500,7 +500,7 @@ impl DefCollector<'_> { | |||
500 | let (per_ns, _) = self.def_map.resolve_path( | 500 | let (per_ns, _) = self.def_map.resolve_path( |
501 | self.db, | 501 | self.db, |
502 | self.def_map.root, | 502 | self.def_map.root, |
503 | &path, | 503 | path, |
504 | BuiltinShadowMode::Other, | 504 | BuiltinShadowMode::Other, |
505 | ); | 505 | ); |
506 | 506 | ||
@@ -722,7 +722,7 @@ impl DefCollector<'_> { | |||
722 | if import.is_extern_crate { | 722 | if import.is_extern_crate { |
723 | let res = self.def_map.resolve_name_in_extern_prelude( | 723 | let res = self.def_map.resolve_name_in_extern_prelude( |
724 | self.db, | 724 | self.db, |
725 | &import | 725 | import |
726 | .path | 726 | .path |
727 | .as_ident() | 727 | .as_ident() |
728 | .expect("extern crate should have been desugared to one-element path"), | 728 | .expect("extern crate should have been desugared to one-element path"), |
@@ -1351,7 +1351,7 @@ impl ModCollector<'_, '_> { | |||
1351 | let imports = Import::from_use( | 1351 | let imports = Import::from_use( |
1352 | self.def_collector.db, | 1352 | self.def_collector.db, |
1353 | krate, | 1353 | krate, |
1354 | &self.item_tree, | 1354 | self.item_tree, |
1355 | ItemTreeId::new(self.file_id, import_id), | 1355 | ItemTreeId::new(self.file_id, import_id), |
1356 | ); | 1356 | ); |
1357 | self.def_collector.unresolved_imports.extend(imports.into_iter().map( | 1357 | self.def_collector.unresolved_imports.extend(imports.into_iter().map( |
@@ -1368,7 +1368,7 @@ impl ModCollector<'_, '_> { | |||
1368 | import: Import::from_extern_crate( | 1368 | import: Import::from_extern_crate( |
1369 | self.def_collector.db, | 1369 | self.def_collector.db, |
1370 | krate, | 1370 | krate, |
1371 | &self.item_tree, | 1371 | self.item_tree, |
1372 | ItemTreeId::new(self.file_id, import_id), | 1372 | ItemTreeId::new(self.file_id, import_id), |
1373 | ), | 1373 | ), |
1374 | status: PartialResolvedImport::Unresolved, | 1374 | status: PartialResolvedImport::Unresolved, |
@@ -1889,7 +1889,7 @@ impl ModCollector<'_, '_> { | |||
1889 | self.def_collector.def_map.with_ancestor_maps( | 1889 | self.def_collector.def_map.with_ancestor_maps( |
1890 | self.def_collector.db, | 1890 | self.def_collector.db, |
1891 | self.module_id, | 1891 | self.module_id, |
1892 | &mut |map, module| map[module].scope.get_legacy_macro(&name), | 1892 | &mut |map, module| map[module].scope.get_legacy_macro(name), |
1893 | ) | 1893 | ) |
1894 | }) | 1894 | }) |
1895 | }, | 1895 | }, |
@@ -1992,8 +1992,8 @@ mod tests { | |||
1992 | collector.def_map | 1992 | collector.def_map |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | fn do_resolve(code: &str) -> DefMap { | 1995 | fn do_resolve(not_ra_fixture: &str) -> DefMap { |
1996 | let (db, _file_id) = TestDB::with_single_file(&code); | 1996 | let (db, _file_id) = TestDB::with_single_file(not_ra_fixture); |
1997 | let krate = db.test_crate(); | 1997 | let krate = db.test_crate(); |
1998 | 1998 | ||
1999 | let edition = db.crate_graph()[krate].edition; | 1999 | let edition = db.crate_graph()[krate].edition; |
@@ -2005,24 +2005,37 @@ mod tests { | |||
2005 | fn test_macro_expand_will_stop_1() { | 2005 | fn test_macro_expand_will_stop_1() { |
2006 | do_resolve( | 2006 | do_resolve( |
2007 | r#" | 2007 | r#" |
2008 | macro_rules! foo { | 2008 | macro_rules! foo { |
2009 | ($($ty:ty)*) => { foo!($($ty)*); } | 2009 | ($($ty:ty)*) => { foo!($($ty)*); } |
2010 | } | 2010 | } |
2011 | foo!(KABOOM); | 2011 | foo!(KABOOM); |
2012 | "#, | 2012 | "#, |
2013 | ); | ||
2014 | do_resolve( | ||
2015 | r#" | ||
2016 | macro_rules! foo { | ||
2017 | ($($ty:ty)*) => { foo!(() $($ty)*); } | ||
2018 | } | ||
2019 | foo!(KABOOM); | ||
2020 | "#, | ||
2013 | ); | 2021 | ); |
2014 | } | 2022 | } |
2015 | 2023 | ||
2016 | #[ignore] // this test does succeed, but takes quite a while :/ | 2024 | #[ignore] |
2017 | #[test] | 2025 | #[test] |
2018 | fn test_macro_expand_will_stop_2() { | 2026 | fn test_macro_expand_will_stop_2() { |
2027 | // FIXME: this test does succeed, but takes quite a while: 90 seconds in | ||
2028 | // the release mode. That's why the argument is not an ra_fixture -- | ||
2029 | // otherwise injection highlighting gets stuck. | ||
2030 | // | ||
2031 | // We need to find a way to fail this faster. | ||
2019 | do_resolve( | 2032 | do_resolve( |
2020 | r#" | 2033 | r#" |
2021 | macro_rules! foo { | 2034 | macro_rules! foo { |
2022 | ($($ty:ty)*) => { foo!($($ty)* $($ty)*); } | 2035 | ($($ty:ty)*) => { foo!($($ty)* $($ty)*); } |
2023 | } | 2036 | } |
2024 | foo!(KABOOM); | 2037 | foo!(KABOOM); |
2025 | "#, | 2038 | "#, |
2026 | ); | 2039 | ); |
2027 | } | 2040 | } |
2028 | } | 2041 | } |