Skip to content

Commit 1bc946b

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 1bc946b

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-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-usage.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//@ check-pass
2+
#![feature(f128)]
3+
#![feature(f16)]
4+
5+
// Same as the feature gate tests but ensure we can use the types
6+
mod m1 {
7+
const A: f128 = 10.0;
8+
9+
pub fn ffoo() {
10+
let a: f128 = 100.0;
11+
let b = 0.0f128;
12+
bar(1.23);
13+
}
14+
15+
fn bar(a: f128) {}
16+
17+
struct Bar {
18+
a: f128,
19+
}
20+
}
21+
22+
mod m2 {
23+
const A: f16 = 10.0;
24+
25+
pub fn foo() {
26+
let a: f16 = 100.0;
27+
let b = 0.0f16;
28+
bar(1.23);
29+
}
30+
31+
fn bar(a: f16) {}
32+
33+
struct Bar {
34+
a: f16,
35+
}
36+
}
37+
38+
fn main() {}

0 commit comments

Comments
 (0)