Skip to content

Commit 77d096a

Browse files
committed
Auto merge of #42282 - Mark-Simulacrum:issue-40342, r=arielb1
Don't warn on lifetime generic no_mangle functions. Fixes #40342.
2 parents 0c4fb24 + 6b84f7d commit 77d096a

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
@@ -1075,10 +1075,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
10751075
it.name);
10761076
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
10771077
}
1078-
if generics.is_parameterized() {
1078+
if generics.is_type_parameterized() {
10791079
cx.span_lint(NO_MANGLE_GENERIC_ITEMS,
10801080
it.span,
1081-
"generic functions must be mangled");
1081+
"functions generic over types must be mangled");
10821082
}
10831083
}
10841084
}

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)