aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/path.rs')
-rw-r--r--crates/ra_hir_def/src/path.rs95
1 files changed, 32 insertions, 63 deletions
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index c1376af36..1e9eb14ea 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -76,10 +76,7 @@ impl Path {
76 } 76 }
77 } 77 }
78 78
79 pub(crate) fn from_simple_segments( 79 pub fn from_simple_segments(kind: PathKind, segments: impl IntoIterator<Item = Name>) -> Path {
80 kind: PathKind,
81 segments: impl IntoIterator<Item = Name>,
82 ) -> Path {
83 Path { 80 Path {
84 kind, 81 kind,
85 segments: segments 82 segments: segments
@@ -296,64 +293,36 @@ impl From<Name> for Path {
296 } 293 }
297} 294}
298 295
299pub mod known { 296pub use hir_expand::name as __name;
300 use hir_expand::name::name; 297
301 298#[macro_export]
302 use super::{Path, PathKind}; 299macro_rules! __known_path {
303 300 (std::iter::IntoIterator) => {};
304 macro_rules! P { 301 (std::result::Result) => {};
305 ($start:ident $(:: $seg:ident)*) => { Path::from_simple_segments(PathKind::Abs, vec![name![$start], $(name![$seg],)*]) }; 302 (std::ops::Range) => {};
306 } 303 (std::ops::RangeFrom) => {};
307 304 (std::ops::RangeFull) => {};
308 pub fn std_iter_into_iterator() -> Path { 305 (std::ops::RangeTo) => {};
309 P![std::iter::IntoIterator] 306 (std::ops::RangeToInclusive) => {};
310 } 307 (std::ops::RangeInclusive) => {};
311 308 (std::boxed::Box) => {};
312 pub fn std_ops_try() -> Path { 309 (std::future::Future) => {};
313 P![std::ops::Try] 310 (std::ops::Try) => {};
314 } 311 (std::ops::Neg) => {};
315 312 (std::ops::Not) => {};
316 pub fn std_ops_range() -> Path { 313 ($path:path) => {
317 P![std::ops::Range] 314 compile_error!("Please register your known path in the path module")
318 } 315 };
319 316}
320 pub fn std_ops_range_from() -> Path {
321 P![std::ops::RangeFrom]
322 }
323
324 pub fn std_ops_range_full() -> Path {
325 P![std::ops::RangeFull]
326 }
327
328 pub fn std_ops_range_inclusive() -> Path {
329 P![std::ops::RangeInclusive]
330 }
331
332 pub fn std_ops_range_to() -> Path {
333 P![std::ops::RangeTo]
334 }
335
336 pub fn std_ops_range_to_inclusive() -> Path {
337 P![std::ops::RangeToInclusive]
338 }
339
340 pub fn std_ops_neg() -> Path {
341 P![std::ops::Neg]
342 }
343
344 pub fn std_ops_not() -> Path {
345 P![std::ops::Not]
346 }
347
348 pub fn std_result_result() -> Path {
349 P![std::result::Result]
350 }
351
352 pub fn std_future_future() -> Path {
353 P![std::future::Future]
354 }
355 317
356 pub fn std_boxed_box() -> Path { 318#[macro_export]
357 P![std::boxed::Box] 319macro_rules! __path {
358 } 320 ($start:ident $(:: $seg:ident)*) => ({
321 $crate::__known_path!($start $(:: $seg)*);
322 $crate::path::Path::from_simple_segments($crate::path::PathKind::Abs, vec![
323 $crate::path::__name![$start], $($crate::path::__name![$seg],)*
324 ])
325 });
359} 326}
327
328pub use crate::__path as path;