Skip to content

Commit 4c4b61b

Browse files
committed
add a feature gate test
Implicit deref patterns allow previously ill-typed programs. Make sure they're still ill-typed without the feature gate. I've thrown in a test for `deref!(_)` too, though it seems it refers to `deref_patterns` as a library feature.
1 parent ff0d4bc commit 4c4b61b

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// gate-test-deref_patterns
2+
3+
fn main() {
4+
match Box::new(0) {
5+
deref!(0) => {}
6+
//~^ ERROR: use of unstable library feature `deref_patterns`: placeholder syntax for deref patterns
7+
_ => {}
8+
}
9+
10+
match Box::new(0) {
11+
0 => {}
12+
//~^ ERROR: mismatched types
13+
_ => {}
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0658]: use of unstable library feature `deref_patterns`: placeholder syntax for deref patterns
2+
--> $DIR/needs-gate.rs:5:9
3+
|
4+
LL | deref!(0) => {}
5+
| ^^^^^
6+
|
7+
= note: see issue #87121 <https://github.com/rust-lang/rust/issues/87121> for more information
8+
= help: add `#![feature(deref_patterns)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0308]: mismatched types
12+
--> $DIR/needs-gate.rs:11:9
13+
|
14+
LL | match Box::new(0) {
15+
| ----------- this expression has type `Box<{integer}>`
16+
LL | 0 => {}
17+
| ^ expected `Box<{integer}>`, found integer
18+
|
19+
= note: expected struct `Box<{integer}>`
20+
found type `{integer}`
21+
help: consider dereferencing to access the inner value using the Deref trait
22+
|
23+
LL | match *Box::new(0) {
24+
| +
25+
26+
error: aborting due to 2 previous errors
27+
28+
Some errors have detailed explanations: E0308, E0658.
29+
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)