mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Merge pull request #20000 from tadeokondrak/lifetime-repeat-macro
Some checks failed
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
autopublish / publish (push) Has been cancelled
release / dist (aarch64-apple-darwin) (push) Has been cancelled
release / dist (x86_64-apple-darwin) (push) Has been cancelled
release / dist (aarch64-unknown-linux-gnu) (push) Has been cancelled
release / dist (arm-unknown-linux-gnueabihf) (push) Has been cancelled
release / dist (x86_64-unknown-linux-gnu) (push) Has been cancelled
release / dist (aarch64-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-pc-windows-msvc) (push) Has been cancelled
release / dist (i686-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-unknown-linux-musl) (push) Has been cancelled
release / publish (push) Has been cancelled
Some checks failed
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
autopublish / publish (push) Has been cancelled
release / dist (aarch64-apple-darwin) (push) Has been cancelled
release / dist (x86_64-apple-darwin) (push) Has been cancelled
release / dist (aarch64-unknown-linux-gnu) (push) Has been cancelled
release / dist (arm-unknown-linux-gnueabihf) (push) Has been cancelled
release / dist (x86_64-unknown-linux-gnu) (push) Has been cancelled
release / dist (aarch64-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-pc-windows-msvc) (push) Has been cancelled
release / dist (i686-pc-windows-msvc) (push) Has been cancelled
release / dist (x86_64-unknown-linux-musl) (push) Has been cancelled
release / publish (push) Has been cancelled
Allow lifetime repeats in macros: $($x)'a*
This commit is contained in:
commit
a207299344
8 changed files with 63 additions and 14 deletions
|
|
@ -2029,3 +2029,25 @@ fn f() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifetime_repeat() {
|
||||
check(
|
||||
r#"
|
||||
macro_rules! m {
|
||||
($($x:expr)'a*) => (stringify!($($x)'b*));
|
||||
}
|
||||
fn f() {
|
||||
let _ = m!(0 'a 1 'a 2);
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
macro_rules! m {
|
||||
($($x:expr)'a*) => (stringify!($($x)'b*));
|
||||
}
|
||||
fn f() {
|
||||
let _ = stringify!(0 'b 1 'b 2);
|
||||
}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ macro_rules! m {
|
|||
($(x),*) => ();
|
||||
($(x)_*) => ();
|
||||
($(x)i*) => ();
|
||||
($(x)'a*) => ();
|
||||
($(x)'_*) => ();
|
||||
($($i:ident)*) => ($_);
|
||||
($($true:ident)*) => ($true);
|
||||
($($false:ident)*) => ($false);
|
||||
|
|
@ -28,6 +30,8 @@ macro_rules! m {
|
|||
($(x),*) => ();
|
||||
($(x)_*) => ();
|
||||
($(x)i*) => ();
|
||||
($(x)'a*) => ();
|
||||
($(x)'_*) => ();
|
||||
($($i:ident)*) => ($_);
|
||||
($($true:ident)*) => ($true);
|
||||
($($false:ident)*) => ($false);
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ macro_rules! delegate_impl {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl <> Data for &'amut G where G: Data {}
|
||||
impl <> Data for &'a mut G where G: Data {}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,14 +302,15 @@ fn pretty_print_macro_expansion(
|
|||
(_, T!['{']) => " ",
|
||||
(T![;] | T!['{'] | T!['}'], _) => "\n",
|
||||
(_, T!['}']) => "\n",
|
||||
(IDENT | LIFETIME_IDENT, IDENT | LIFETIME_IDENT) => " ",
|
||||
_ if prev_kind.is_keyword(Edition::CURRENT)
|
||||
&& curr_kind.is_keyword(Edition::CURRENT) =>
|
||||
_ if (prev_kind.is_any_identifier()
|
||||
|| prev_kind == LIFETIME_IDENT
|
||||
|| prev_kind.is_literal())
|
||||
&& (curr_kind.is_any_identifier()
|
||||
|| curr_kind == LIFETIME_IDENT
|
||||
|| curr_kind.is_literal()) =>
|
||||
{
|
||||
" "
|
||||
}
|
||||
(IDENT, _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
|
||||
(_, IDENT) if prev_kind.is_keyword(Edition::CURRENT) => " ",
|
||||
(T![>], IDENT) => " ",
|
||||
(T![>], _) if curr_kind.is_keyword(Edition::CURRENT) => " ",
|
||||
(T![->], _) | (_, T![->]) => " ",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue