diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-01 12:46:59 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-01 12:46:59 +0100 |
commit | 4f63e79eb30a0695675a560dfe7ebae6f1dd8a94 (patch) | |
tree | 6de19b3c128809cd56641f70873c35f17974aced /crates/ide_db/src | |
parent | 71117e6812f87e014bc8e984e195a75e222ac227 (diff) | |
parent | f96c1a0414ee302fe96503d89f2998483345c8a9 (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/ide_db/src')
-rw-r--r-- | crates/ide_db/src/helpers/famous_defs_fixture.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs index 29ae12dcf..312851966 100644 --- a/crates/ide_db/src/helpers/famous_defs_fixture.rs +++ b/crates/ide_db/src/helpers/famous_defs_fixture.rs | |||
@@ -128,17 +128,19 @@ pub mod option { | |||
128 | } | 128 | } |
129 | 129 | ||
130 | pub mod prelude { | 130 | pub mod prelude { |
131 | pub use crate::{ | 131 | pub mod rust_2018 { |
132 | cmp::Ord, | 132 | pub use crate::{ |
133 | convert::{From, Into}, | 133 | cmp::Ord, |
134 | default::Default, | 134 | convert::{From, Into}, |
135 | iter::{IntoIterator, Iterator}, | 135 | default::Default, |
136 | ops::{Fn, FnMut, FnOnce}, | 136 | iter::{IntoIterator, Iterator}, |
137 | option::Option::{self, *}, | 137 | ops::{Fn, FnMut, FnOnce}, |
138 | }; | 138 | option::Option::{self, *}, |
139 | }; | ||
140 | } | ||
139 | } | 141 | } |
140 | #[prelude_import] | 142 | #[prelude_import] |
141 | pub use prelude::*; | 143 | pub use prelude::rust_2018::*; |
142 | //- /libstd.rs crate:std deps:core | 144 | //- /libstd.rs crate:std deps:core |
143 | //! Signatures of traits, types and functions from the std lib for use in tests. | 145 | //! Signatures of traits, types and functions from the std lib for use in tests. |
144 | 146 | ||
@@ -148,4 +150,4 @@ mod return_keyword {} | |||
148 | /// Docs for prim_str | 150 | /// Docs for prim_str |
149 | mod prim_str {} | 151 | mod prim_str {} |
150 | 152 | ||
151 | pub use core::ops; \ No newline at end of file | 153 | pub use core::ops; |