diff options
| author | bors <bors@rust-lang.org> | 2017-10-03 02:26:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-10-03 02:26:27 +0000 |
| commit | 67ed4891db42841c7b7c00f5dce6effb7209a007 (patch) | |
| tree | 37d714d981090c0c017a82cb2dcd7c43d64c8ba5 | |
| parent | bdcb7fbbcaa27c6b6d84d74d6250cc3dabe5befe (diff) | |
| parent | b989101a558f0c2963a6a42b068c81f8b4606988 (diff) | |
| download | rust-67ed4891db42841c7b7c00f5dce6effb7209a007.tar.gz rust-67ed4891db42841c7b7c00f5dce6effb7209a007.zip | |
Auto merge of #44966 - zackmdavis:no_mangle_no_snake, r=aturon
make non_snake_case lint allow extern no-mangle functions Resolves #31924. r? @sfackler
| -rw-r--r-- | src/librustc_lint/bad_style.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-31924-non-snake-ffi.rs | 18 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index cbc012a65fa..027ed84faf0 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -13,6 +13,7 @@ use rustc::ty; use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; +use syntax::abi::Abi; use syntax::ast; use syntax::attr; use syntax_pos::Span; @@ -250,7 +251,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { _ => (), } } - FnKind::ItemFn(name, ..) => { + FnKind::ItemFn(name, _, _, _, abi, _, attrs) => { + // Skip foreign-ABI #[no_mangle] functions (Issue #31924) + if abi != Abi::Rust && attr::find_by_name(attrs, "no_mangle").is_some() { + return; + } self.check_snake_case(cx, "function", &name.as_str(), Some(span)) } FnKind::Closure(_) => (), diff --git a/src/test/compile-fail/issue-31924-non-snake-ffi.rs b/src/test/compile-fail/issue-31924-non-snake-ffi.rs new file mode 100644 index 00000000000..d9ce1159c0e --- /dev/null +++ b/src/test/compile-fail/issue-31924-non-snake-ffi.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![deny(non_snake_case)] + +#[no_mangle] +pub extern "C" fn SparklingGenerationForeignFunctionInterface() {} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful |
