Skip to content

Lint for the reserved ABI of bool #46176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/librustc_binaryen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
//! only supports one operation, creating a module from LLVM's assembly format
//! and then serializing that module to a wasm module.

#![deny(warnings)]

// We are the compiler, so we can use anything for FFI.
// Don't do this at home :)
#![allow(improper_ctypes)]

extern crate libc;

use std::slice;
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,13 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
stable ABI")
}

ty::TyBool => {
FfiUnsafe("found Rust type `bool` in foreign module, \
while its ABI is reserved for future change")
}

// Primitive types with a stable representation.
ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::TyNever => FfiSafe,
ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::TyNever => FfiSafe,

ty::TySlice(_) => {
FfiUnsafe("found Rust slice type in foreign module, \
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#![allow(non_snake_case)]
#![allow(dead_code)]

// We are the compiler, so we can use anything for FFI.
// Don't do this at home :)
#![allow(improper_ctypes)]

#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
Expand Down
18 changes: 18 additions & 0 deletions src/test/compile-fail/bool-abi-reserved.rs
Original file line number Diff line number Diff line change
@@ -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.

#![deny(improper_ctypes)]
#![allow(dead_code)]

extern {
fn zf(x: bool); //~ ERROR found Rust type `bool` in foreign module
}

pub fn main() { }
8 changes: 8 additions & 0 deletions src/test/ui/lint/unreachable_pub-pub_crate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ warning: unreachable `pub` item
|
= help: or consider exporting it for use by other crates

warning: found Rust type `bool` in foreign module, while its ABI is reserved for future change
--> $DIR/unreachable_pub-pub_crate.rs:52:30
|
52 | pub fn catalyze() -> bool;
| ^^^^
|
= note: #[warn(improper_ctypes)] on by default

warning: unreachable `pub` item
--> $DIR/unreachable_pub-pub_crate.rs:52:9
|
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/lint/unreachable_pub.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ warning: unreachable `pub` item
|
= help: or consider exporting it for use by other crates

warning: found Rust type `bool` in foreign module, while its ABI is reserved for future change
--> $DIR/unreachable_pub.rs:47:30
|
47 | pub fn catalyze() -> bool;
| ^^^^
|
= note: #[warn(improper_ctypes)] on by default

warning: unreachable `pub` item
--> $DIR/unreachable_pub.rs:47:9
|
Expand Down