aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-17 09:41:30 +0000
committerGitHub <[email protected]>2020-03-17 09:41:30 +0000
commit6aa432d86b7e4fb691600032ebdf6f2301152447 (patch)
treeaa012212c11e43a95547f553b5116922631f9896 /crates/ra_hir_ty
parentcf4ae9aa591729dde25a7df3fa5c22ca0fd94145 (diff)
parent6c20d7e979b967eb20207414c0a0bf875bbcb98d (diff)
Merge #3580
3580: More error-resilient MBE expansion r=matklad a=flodiebold This is the beginning of an attempt to make macro-by-example expansion more resilient, so that we still get an expansion even if no rule exactly matches, with the goal to make completion work better in macro calls. The general idea is to make everything return `(T, Option<ExpandError>)` instead of `Result<T, ExpandError>`; and then to try each macro arm in turn, and somehow choose the 'best' matching rule if none matches without errors. Finding that 'best' match isn't done yet; I'm currently counting how many tokens were consumed from the args before an error, but it also needs to take into account whether there were further patterns that had nothing to match. I'll continue this later, but I'm interested whether you think this is the right path, @matklad & @edwin0cheng. Co-authored-by: Florian Diebold <[email protected]> Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 3b7022ad5..2e309a379 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -462,7 +462,7 @@ fn main() {
462fn infer_builtin_macros_include() { 462fn infer_builtin_macros_include() {
463 let (db, pos) = TestDB::with_position( 463 let (db, pos) = TestDB::with_position(
464 r#" 464 r#"
465//- /main.rs 465//- /main.rs
466#[rustc_builtin_macro] 466#[rustc_builtin_macro]
467macro_rules! include {() => {}} 467macro_rules! include {() => {}}
468 468
@@ -483,7 +483,7 @@ fn bar() -> u32 {0}
483fn infer_builtin_macros_include_concat() { 483fn infer_builtin_macros_include_concat() {
484 let (db, pos) = TestDB::with_position( 484 let (db, pos) = TestDB::with_position(
485 r#" 485 r#"
486//- /main.rs 486//- /main.rs
487#[rustc_builtin_macro] 487#[rustc_builtin_macro]
488macro_rules! include {() => {}} 488macro_rules! include {() => {}}
489 489
@@ -507,7 +507,7 @@ fn bar() -> u32 {0}
507fn infer_builtin_macros_include_concat_with_bad_env_should_failed() { 507fn infer_builtin_macros_include_concat_with_bad_env_should_failed() {
508 let (db, pos) = TestDB::with_position( 508 let (db, pos) = TestDB::with_position(
509 r#" 509 r#"
510//- /main.rs 510//- /main.rs
511#[rustc_builtin_macro] 511#[rustc_builtin_macro]
512macro_rules! include {() => {}} 512macro_rules! include {() => {}}
513 513
@@ -534,7 +534,7 @@ fn bar() -> u32 {0}
534fn infer_builtin_macros_include_itself_should_failed() { 534fn infer_builtin_macros_include_itself_should_failed() {
535 let (db, pos) = TestDB::with_position( 535 let (db, pos) = TestDB::with_position(
536 r#" 536 r#"
537//- /main.rs 537//- /main.rs
538#[rustc_builtin_macro] 538#[rustc_builtin_macro]
539macro_rules! include {() => {}} 539macro_rules! include {() => {}}
540 540