aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-12-13 20:43:53 +0000
committerFlorian Diebold <[email protected]>2019-12-13 21:33:37 +0000
commit259c42f00e2e85594c7373166bc8467ce375a045 (patch)
treee3c3c855a4bcb7ba425f9d788a9a383a529557c3 /crates/ra_hir_def/src/path.rs
parent169fe4932f84f396965a4814c44e31061673937c (diff)
Add macros for known names and paths
Diffstat (limited to 'crates/ra_hir_def/src/path.rs')
-rw-r--r--crates/ra_hir_def/src/path.rs45
1 files changed, 20 insertions, 25 deletions
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 50f0cad94..36ad27867 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -6,7 +6,7 @@ use std::{iter, sync::Arc};
6use either::Either; 6use either::Either;
7use hir_expand::{ 7use hir_expand::{
8 hygiene::Hygiene, 8 hygiene::Hygiene,
9 name::{self, AsName, Name}, 9 name::{AsName, Name, N},
10}; 10};
11use ra_db::CrateId; 11use ra_db::CrateId;
12use ra_syntax::{ 12use ra_syntax::{
@@ -276,7 +276,7 @@ impl GenericArgs {
276 } 276 }
277 if let Some(ret_type) = ret_type { 277 if let Some(ret_type) = ret_type {
278 let type_ref = TypeRef::from_ast_opt(ret_type.type_ref()); 278 let type_ref = TypeRef::from_ast_opt(ret_type.type_ref());
279 bindings.push((name::OUTPUT_TYPE, type_ref)) 279 bindings.push((N![Output], type_ref))
280 } 280 }
281 if args.is_empty() && bindings.is_empty() { 281 if args.is_empty() && bindings.is_empty() {
282 None 282 None
@@ -297,68 +297,63 @@ impl From<Name> for Path {
297} 297}
298 298
299pub mod known { 299pub mod known {
300 use hir_expand::name; 300 use hir_expand::name::N;
301 301
302 use super::{Path, PathKind}; 302 use super::{Path, PathKind};
303 303
304 macro_rules! P {
305 ($start:ident $(:: $seg:ident)*) => { Path::from_simple_segments(PathKind::Abs, vec![N![$start], $(N![$seg],)*]) };
306 }
307
304 pub fn std_iter_into_iterator() -> Path { 308 pub fn std_iter_into_iterator() -> Path {
305 Path::from_simple_segments( 309 P![std::iter::IntoIterator]
306 PathKind::Abs,
307 vec![name::STD, name::ITER, name::INTO_ITERATOR_TYPE],
308 )
309 } 310 }
310 311
311 pub fn std_ops_try() -> Path { 312 pub fn std_ops_try() -> Path {
312 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY_TYPE]) 313 P![std::ops::Try]
313 } 314 }
314 315
315 pub fn std_ops_range() -> Path { 316 pub fn std_ops_range() -> Path {
316 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TYPE]) 317 P![std::ops::Range]
317 } 318 }
318 319
319 pub fn std_ops_range_from() -> Path { 320 pub fn std_ops_range_from() -> Path {
320 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FROM_TYPE]) 321 P![std::ops::RangeFrom]
321 } 322 }
322 323
323 pub fn std_ops_range_full() -> Path { 324 pub fn std_ops_range_full() -> Path {
324 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FULL_TYPE]) 325 P![std::ops::RangeFull]
325 } 326 }
326 327
327 pub fn std_ops_range_inclusive() -> Path { 328 pub fn std_ops_range_inclusive() -> Path {
328 Path::from_simple_segments( 329 P![std::ops::RangeInclusive]
329 PathKind::Abs,
330 vec![name::STD, name::OPS, name::RANGE_INCLUSIVE_TYPE],
331 )
332 } 330 }
333 331
334 pub fn std_ops_range_to() -> Path { 332 pub fn std_ops_range_to() -> Path {
335 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TO_TYPE]) 333 P![std::ops::RangeTo]
336 } 334 }
337 335
338 pub fn std_ops_range_to_inclusive() -> Path { 336 pub fn std_ops_range_to_inclusive() -> Path {
339 Path::from_simple_segments( 337 P![std::ops::RangeToInclusive]
340 PathKind::Abs,
341 vec![name::STD, name::OPS, name::RANGE_TO_INCLUSIVE_TYPE],
342 )
343 } 338 }
344 339
345 pub fn std_ops_neg() -> Path { 340 pub fn std_ops_neg() -> Path {
346 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::NEG_TYPE]) 341 P![std::ops::Neg]
347 } 342 }
348 343
349 pub fn std_ops_not() -> Path { 344 pub fn std_ops_not() -> Path {
350 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::NOT_TYPE]) 345 P![std::ops::Not]
351 } 346 }
352 347
353 pub fn std_result_result() -> Path { 348 pub fn std_result_result() -> Path {
354 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::RESULT, name::RESULT_TYPE]) 349 P![std::result::Result]
355 } 350 }
356 351
357 pub fn std_future_future() -> Path { 352 pub fn std_future_future() -> Path {
358 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::FUTURE, name::FUTURE_TYPE]) 353 P![std::future::Future]
359 } 354 }
360 355
361 pub fn std_boxed_box() -> Path { 356 pub fn std_boxed_box() -> Path {
362 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::BOXED, name::BOX_TYPE]) 357 P![std::boxed::Box]
363 } 358 }
364} 359}