Better diagnostics and recovery for const in extern blocks
This commit is contained in:
parent
ff0513c697
commit
a965beef8f
3 changed files with 39 additions and 12 deletions
19
src/test/ui/extern-const.rs
Normal file
19
src/test/ui/extern-const.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -Z continue-parse-after-error
|
||||
|
||||
extern "C" {
|
||||
const C: u8; //~ ERROR extern items cannot be `const`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = C;
|
||||
}
|
||||
8
src/test/ui/extern-const.stderr
Normal file
8
src/test/ui/extern-const.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: extern items cannot be `const`
|
||||
--> $DIR/extern-const.rs:14:5
|
||||
|
|
||||
14 | const C: u8; //~ ERROR extern items cannot be `const`
|
||||
| ^^^^^ use `static` instead
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue