aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-01 12:46:59 +0100
committerGitHub <[email protected]>2021-06-01 12:46:59 +0100
commit4f63e79eb30a0695675a560dfe7ebae6f1dd8a94 (patch)
tree6de19b3c128809cd56641f70873c35f17974aced /crates/hir_def/src/nameres/tests
parent71117e6812f87e014bc8e984e195a75e222ac227 (diff)
parentf96c1a0414ee302fe96503d89f2998483345c8a9 (diff)
Merge #9097
9097: feat: Implement per-edition preludes r=jonas-schievink a=jonas-schievink Part of https://github.com/rust-analyzer/rust-analyzer/issues/9056 Our previous implementation was incorrect (presumably because of the misleading comment in libstd [here](https://github.com/rust-lang/rust/blob/a7890c7952bdc9445eb6c63dc671fa7a1ab0260d/library/std/src/lib.rs#L339-L343)). `#[prelude_import]` does not define the prelude, it can only override the implicit prelude for the current crate. This PR fixes that, which also makes the prelude imports in `rustc_span` work. Closes https://github.com/rust-analyzer/rust-analyzer/issues/8815. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r--crates/hir_def/src/nameres/tests/macros.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs
index 3065efd65..371618438 100644
--- a/crates/hir_def/src/nameres/tests/macros.rs
+++ b/crates/hir_def/src/nameres/tests/macros.rs
@@ -264,7 +264,7 @@ fn prelude_is_macro_use() {
264 cov_mark::check!(prelude_is_macro_use); 264 cov_mark::check!(prelude_is_macro_use);
265 check( 265 check(
266 r#" 266 r#"
267//- /main.rs crate:main deps:foo 267//- /main.rs crate:main deps:std
268structs!(Foo); 268structs!(Foo);
269structs_priv!(Bar); 269structs_priv!(Bar);
270structs_outside!(Out); 270structs_outside!(Out);
@@ -276,21 +276,20 @@ mod bar;
276structs!(Baz); 276structs!(Baz);
277crate::structs!(MacroNotResolved3); 277crate::structs!(MacroNotResolved3);
278 278
279//- /lib.rs crate:foo 279//- /lib.rs crate:std
280#[prelude_import] 280pub mod prelude {
281use self::prelude::*; 281 pub mod rust_2018 {
282
283mod prelude {
284 #[macro_export]
285 macro_rules! structs {
286 ($i:ident) => { struct $i; }
287 }
288
289 mod priv_mod {
290 #[macro_export] 282 #[macro_export]
291 macro_rules! structs_priv { 283 macro_rules! structs {
292 ($i:ident) => { struct $i; } 284 ($i:ident) => { struct $i; }
293 } 285 }
286
287 mod priv_mod {
288 #[macro_export]
289 macro_rules! structs_priv {
290 ($i:ident) => { struct $i; }
291 }
292 }
294 } 293 }
295} 294}
296 295
@@ -617,12 +616,11 @@ fn macro_dollar_crate_is_correct_in_indirect_deps() {
617foo!(); 616foo!();
618 617
619//- /std.rs crate:std deps:core 618//- /std.rs crate:std deps:core
620#[prelude_import]
621use self::prelude::*;
622
623pub use core::foo; 619pub use core::foo;
624 620
625mod prelude {} 621pub mod prelude {
622 pub mod rust_2018 {}
623}
626 624
627#[macro_use] 625#[macro_use]
628mod std_macros; 626mod std_macros;