Skip to content

Commit b8af79d

Browse files
committed
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.
1 parent a219b32 commit b8af79d

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//@ check-pass
2+
#![allow(non_camel_case_types)]
3+
#![allow(unused)]
4+
5+
// Ensure that primitives do not interfere with user types of similar names
6+
7+
macro_rules! make_ty_mod {
8+
($modname:ident, $ty:tt) => {
9+
mod $modname {
10+
struct $ty {
11+
a: i32,
12+
}
13+
14+
fn assignment() {
15+
let $ty = ();
16+
}
17+
18+
fn access(a: $ty) -> i32 {
19+
a.a
20+
}
21+
}
22+
};
23+
}
24+
25+
make_ty_mod!(check_f16, f16);
26+
make_ty_mod!(check_f32, f32);
27+
make_ty_mod!(check_f64, f64);
28+
make_ty_mod!(check_f128, f128);
29+
30+
fn main() {}

tests/ui/resolve/primitive-f128.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ check-pass
2+
#![feature(f128)]
3+
4+
// Same as the feature gate test but ensure we can use the types
5+
6+
const A: f128 = 10.0;
7+
8+
pub fn main() {
9+
let a: f128 = 100.0;
10+
let b = 0.0f128;
11+
foo(1.23);
12+
}
13+
14+
fn foo(a: f128) {}
15+
16+
struct Bar {
17+
a: f128,
18+
}

tests/ui/resolve/primitive-f16.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ check-pass
2+
#![feature(f16)]
3+
4+
// Same as the feature gate test but ensure we can use the types
5+
6+
const A: f16 = 10.0;
7+
8+
pub fn main() {
9+
let a: f16 = 100.0;
10+
let b = 0.0f16;
11+
foo(1.23);
12+
}
13+
14+
fn foo(a: f16) {}
15+
16+
struct Bar {
17+
a: f16,
18+
}

0 commit comments

Comments
 (0)