Skip to content

Commit 6b84f7d

Browse files
Don't warn on lifetime generic no_mangle functions.
1 parent 5d2512e commit 6b84f7d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/librustc_lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
11141114
it.name);
11151115
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
11161116
}
1117-
if generics.is_parameterized() {
1117+
if generics.is_type_parameterized() {
11181118
cx.span_lint(NO_MANGLE_GENERIC_ITEMS,
11191119
it.span,
1120-
"generic functions must be mangled");
1120+
"functions generic over types must be mangled");
11211121
}
11221122
}
11231123
}

src/test/compile-fail/generic-no-mangle.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
#![deny(no_mangle_generic_items)]
1212

1313
#[no_mangle]
14-
pub fn foo<T>() {} //~ ERROR generic functions must be mangled
14+
pub fn foo<T>() {} //~ ERROR functions generic over types must be mangled
1515

1616
#[no_mangle]
17-
pub extern fn bar<T>() {} //~ ERROR generic functions must be mangled
17+
pub extern fn bar<T>() {} //~ ERROR functions generic over types must be mangled
18+
19+
#[no_mangle]
20+
pub fn baz(x: &i32) -> &i32 { x }
21+
22+
#[no_mangle]
23+
pub fn qux<'a>(x: &'a i32) -> &i32 { x }
1824

1925
fn main() {}

0 commit comments

Comments
 (0)