-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement portability lints for 16 and 128 bits
- Loading branch information
1 parent
b28e45e
commit 2d83bfd
Showing
4 changed files
with
201 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2016 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. | ||
|
||
#![allow(unused)] | ||
#![deny(nonportable_16_32)] | ||
|
||
fn check() { | ||
let _: usize = 0u32.into(); | ||
//~^ ERROR conversion `u32` -> `usize` is not portable between 32-bit and 16-bit platforms | ||
let _: usize = Into::into(0u32); | ||
//~^ ERROR conversion `u32` -> `usize` is not portable between 32-bit and 16-bit platforms | ||
let _: usize = From::from(0u32); | ||
//~^ ERROR conversion `u32` -> `usize` is not portable between 32-bit and 16-bit platforms | ||
|
||
let _: isize = 0i32.into(); | ||
//~^ ERROR conversion `i32` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
let _: isize = Into::into(0i32); | ||
//~^ ERROR conversion `i32` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
let _: isize = From::from(0i32); | ||
//~^ ERROR conversion `i32` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
|
||
let _: isize = 0u16.into(); | ||
//~^ ERROR conversion `u16` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
let _: isize = Into::into(0u16); | ||
//~^ ERROR conversion `u16` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
let _: isize = From::from(0u16); | ||
//~^ ERROR conversion `u16` -> `isize` is not portable between 32-bit and 16-bit platforms | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2016 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. | ||
|
||
#![allow(unused)] | ||
#![deny(nonportable_64_128)] | ||
|
||
fn check() { | ||
let _: u64 = 0usize.into(); | ||
//~^ ERROR conversion `usize` -> `u64` is not portable between 64-bit and 128-bit platforms | ||
let _: u64 = Into::into(0usize); | ||
//~^ ERROR conversion `usize` -> `u64` is not portable between 64-bit and 128-bit platforms | ||
let _: u64 = From::from(0usize); | ||
//~^ ERROR conversion `usize` -> `u64` is not portable between 64-bit and 128-bit platforms | ||
|
||
let _: i64 = 0isize.into(); | ||
//~^ ERROR conversion `isize` -> `i64` is not portable between 64-bit and 128-bit platforms | ||
let _: i64 = Into::into(0isize); | ||
//~^ ERROR conversion `isize` -> `i64` is not portable between 64-bit and 128-bit platforms | ||
let _: i64 = From::from(0isize); | ||
//~^ ERROR conversion `isize` -> `i64` is not portable between 64-bit and 128-bit platforms | ||
} | ||
|
||
fn main() {} |