Skip to content

Commit be193a0

Browse files
committed
Fixed lifetime variable scoping bug
1 parent 73236af commit be193a0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ macro_rules! __lazy_static_internal {
119119
impl $crate::__Deref for $N {
120120
type Target = $T;
121121
#[allow(unsafe_code)]
122-
fn deref<'a>(&'a self) -> &'a $T {
122+
fn deref(&self) -> &$T {
123123
unsafe {
124124
#[inline(always)]
125125
fn __static_ref_initialize() -> $T { $e }

tests/test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,12 @@ fn pre_init() {
147147
lazy_static::initialize(&PRE_INIT);
148148
assert_eq!(PRE_INIT_FLAG.load(SeqCst), true);
149149
}
150+
151+
lazy_static! {
152+
static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f };
153+
}
154+
155+
#[test]
156+
fn lifetime_name() {
157+
let _ = LIFETIME_NAME;
158+
}

0 commit comments

Comments
 (0)