Skip to content

Commit

Permalink
Don't warn on lifetime generic no_mangle functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed May 28, 2017
1 parent 5d2512e commit 6b84f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/librustc_lint/builtin.rs
Expand Up @@ -1114,10 +1114,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
it.name);
cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
}
if generics.is_parameterized() {
if generics.is_type_parameterized() {
cx.span_lint(NO_MANGLE_GENERIC_ITEMS,
it.span,
"generic functions must be mangled");
"functions generic over types must be mangled");
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/test/compile-fail/generic-no-mangle.rs
Expand Up @@ -11,9 +11,15 @@
#![deny(no_mangle_generic_items)]

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

#[no_mangle]
pub extern fn bar<T>() {} //~ ERROR generic functions must be mangled
pub extern fn bar<T>() {} //~ ERROR functions generic over types must be mangled

#[no_mangle]
pub fn baz(x: &i32) -> &i32 { x }

#[no_mangle]
pub fn qux<'a>(x: &'a i32) -> &i32 { x }

fn main() {}

0 comments on commit 6b84f7d

Please sign in to comment.