rust/src/test/compile-fail/issue-9957.rs
Alex Crichton 4a78364d49 Forbid unnecessary visibility on view items
For `use` statements, this means disallowing qualifiers when in functions and
disallowing `priv` outside of functions.

For `extern mod` statements, this means disallowing everything everywhere. It
may have been envisioned for `pub extern mod foo` to be a thing, but it
currently doesn't do anything (resolve doesn't pick it up), so better to err on
the side of forwards-compatibility and forbid it entirely for now.

Closes #9957
2014-01-18 10:46:32 -08:00

24 lines
887 B
Rust

// Copyright 2014 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.
pub extern mod std; //~ ERROR: `pub` visibility is not allowed
priv extern mod std; //~ ERROR: unnecessary visibility qualifier
extern mod std;
pub use std::bool;
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
use std::bool;
fn main() {
pub use std::bool; //~ ERROR: imports in functions are never reachable
priv use std::bool; //~ ERROR: unnecessary visibility qualifier
use std::bool;
}