File: implicit-const-deref.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (19 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//! Test that we get an error about structural equality rather than a type error when attempting to
//! use const patterns of library pointer types. Currently there aren't any smart pointers that can
//! be used in constant patterns, but we still need to make sure we don't implicitly dereference the
//! scrutinee and end up with a type error; this would prevent us from reporting that only constants
//! supporting structural equality can be used as patterns.
#![feature(deref_patterns)]
#![allow(incomplete_features)]

const EMPTY: Vec<()> = Vec::new();

fn main() {
    // FIXME(inline_const_pat): if `inline_const_pat` is reinstated, there should be a case here for
    // inline const block patterns as well; they're checked differently than named constants.
    match vec![()] {
        EMPTY => {}
        //~^ ERROR: constant of non-structural type `Vec<()>` in a pattern
        _ => {}
    }
}