1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 const CONST_REF: &[u8; 3] = b"foo";
14 const CONST_REF_DEFAULT: &'static [u8; 3] = b"bar";
15 const CONST_REF: &'static [u8; 3];
19 const CONST_REF: &'static [u8; 3] = b"jjj";
23 const CONST_REF_DEFAULT: &'static [u8; 3] = b"ggg";
24 const CONST_REF: &'static [u8; 3] = b"fff";
27 // Check that (associated and free) const references are not mistaken for a
28 // non-reference pattern (in which case they would be auto-dereferenced, making
29 // the types mismatched).
31 fn const_ref() -> bool {
39 fn associated_const_ref() -> bool {
40 match (b"bar", b"jjj", b"ggg", b"fff") {
41 (i32::CONST_REF_DEFAULT, i32::CONST_REF, i64::CONST_REF_DEFAULT, i64::CONST_REF) => true,
48 assert!(associated_const_ref());