-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a UI test related to feature-gated primitives
Add a test that `f16` and `f128` are usable with the feature gate enabled, as well as a test that user types with the same name as primitives are not improperly gated.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//@ check-pass | ||
#![allow(non_camel_case_types)] | ||
#![allow(unused)] | ||
|
||
// Ensure that primitives do not interfere with user types of similar names | ||
|
||
macro_rules! make_ty_mod { | ||
($modname:ident, $ty:tt) => { | ||
mod $modname { | ||
struct $ty { | ||
a: i32, | ||
} | ||
|
||
fn assignment() { | ||
let $ty = (); | ||
} | ||
|
||
fn access(a: $ty) -> i32 { | ||
a.a | ||
} | ||
} | ||
}; | ||
} | ||
|
||
make_ty_mod!(check_f16, f16); | ||
make_ty_mod!(check_f32, f32); | ||
make_ty_mod!(check_f64, f64); | ||
make_ty_mod!(check_f128, f128); | ||
|
||
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,18 @@ | ||
//@ check-pass | ||
#![feature(f128)] | ||
|
||
// Same as the feature gate test but ensure we can use the types | ||
|
||
const A: f128 = 10.0; | ||
|
||
pub fn main() { | ||
let a: f128 = 100.0; | ||
let b = 0.0f128; | ||
foo(1.23); | ||
} | ||
|
||
fn foo(a: f128) {} | ||
|
||
struct Bar { | ||
a: f128, | ||
} |
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,18 @@ | ||
//@ check-pass | ||
#![feature(f16)] | ||
|
||
// Same as the feature gate test but ensure we can use the types | ||
|
||
const A: f16 = 10.0; | ||
|
||
pub fn main() { | ||
let a: f16 = 100.0; | ||
let b = 0.0f16; | ||
foo(1.23); | ||
} | ||
|
||
fn foo(a: f16) {} | ||
|
||
struct Bar { | ||
a: f16, | ||
} |