-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #106935 - TaKO8Ki:fix-104440, r=cjgillot
Fix `SingleUseLifetime` ICE Fixes #104440 cc: ``@matthiaskrgr``
- Loading branch information
Showing
5 changed files
with
174 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#![feature(decl_macro, rustc_attrs)] | ||
#![deny(single_use_lifetimes)] | ||
|
||
mod type_params { | ||
macro m($T:ident) { | ||
fn f<$T: Clone, T: PartialEq>(t1: $T, t2: T) -> ($T, bool) { | ||
(t1.clone(), t2 == t2) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "semitransparent"] | ||
macro n($T:ident) { | ||
fn g<$T: Clone>(t1: $T, t2: T) -> (T, $T) { | ||
(t1.clone(), t2.clone()) | ||
} | ||
fn h<T: Clone>(t1: $T, t2: T) -> (T, $T) { | ||
(t1.clone(), t2.clone()) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "transparent"] | ||
macro p($T:ident) { | ||
fn j<$T: Clone>(t1: $T, t2: T) -> (T, $T) { | ||
(t1.clone(), t2.clone()) | ||
} | ||
fn k<T: Clone>(t1: $T, t2: T) -> (T, $T) { | ||
(t1.clone(), t2.clone()) | ||
} | ||
} | ||
|
||
m!(T); | ||
n!(T); | ||
p!(T); | ||
} | ||
|
||
mod lifetime_params { | ||
macro m($a:lifetime) { | ||
fn f<'b, 'c, $a: 'b, 'a: 'c>(t1: &$a(), t2: &'a ()) -> (&'b (), &'c ()) { //~ ERROR lifetime parameter `'a` only used once | ||
(t1, t2) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "semitransparent"] | ||
macro n($a:lifetime) { | ||
fn g<$a>(t1: &$a(), t2: &'a ()) -> (&'a (), &$a ()) { | ||
(t1, t2) | ||
} | ||
fn h<'a>(t1: &$a(), t2: &'a ()) -> (&'a (), &$a ()) { | ||
(t1, t2) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "transparent"] | ||
macro p($a:lifetime) { | ||
fn j<$a>(t1: &$a(), t2: &'a ()) -> (&'a (), &$a ()) { | ||
(t1, t2) | ||
} | ||
fn k<'a>(t1: &$a(), t2: &'a ()) -> (&'a (), &$a ()) { | ||
(t1, t2) | ||
} | ||
} | ||
|
||
m!('a); //~ ERROR lifetime parameter `'a` only used once | ||
n!('a); | ||
p!('a); | ||
} | ||
|
||
mod const_params { | ||
macro m($C:ident) { | ||
fn f<const $C: usize, const C: usize>(t1: [(); $C], t2: [(); C]) -> ([(); $C], [(); C]) { | ||
(t1, t2) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "semitransparent"] | ||
macro n($C:ident) { | ||
fn g<const $C: usize>(t1: [(); $C], t2: [(); C]) -> ([(); C], [(); $C]) { | ||
(t1, t2) | ||
} | ||
fn h<const C: usize>(t1: [(); $C], t2: [(); C]) -> ([(); C], [(); $C]) { | ||
(t1, t2) | ||
} | ||
} | ||
|
||
#[rustc_macro_transparency = "transparent"] | ||
macro p($C:ident) { | ||
fn j<const $C: usize>(t1: [(); $C], t2: [(); C]) -> ([(); C], [(); $C]) { | ||
(t1, t2) | ||
} | ||
fn k<const C: usize>(t1: [(); $C], t2: [(); C]) -> ([(); C], [(); $C]) { | ||
(t1, t2) | ||
} | ||
} | ||
|
||
m!(C); | ||
n!(C); | ||
p!(C); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error: lifetime parameter `'a` only used once | ||
--> $DIR/issue-104440.rs:63:8 | ||
| | ||
LL | m!('a); | ||
| ^^ | ||
| | | ||
| this lifetime... | ||
| ...is used only here | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-104440.rs:2:9 | ||
| | ||
LL | #![deny(single_use_lifetimes)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: lifetime parameter `'a` only used once | ||
--> $DIR/issue-104440.rs:38:30 | ||
| | ||
LL | fn f<'b, 'c, $a: 'b, 'a: 'c>(t1: &$a(), t2: &'a ()) -> (&'b (), &'c ()) { | ||
| ^^ this lifetime... -- ...is used only here | ||
... | ||
LL | m!('a); | ||
| ------ in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
|