2014-02-07 19:08:32 +00:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
2012-12-11 01:32:48 +00:00
|
|
|
// 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.
|
|
|
|
|
2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(improper_ctypes)]
|
|
|
|
|
2012-11-01 22:48:37 +00:00
|
|
|
// Crate use statements
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2012-11-01 22:48:37 +00:00
|
|
|
#[cfg(bogus)]
|
|
|
|
use flippity;
|
|
|
|
|
2011-06-30 18:22:10 +00:00
|
|
|
#[cfg(bogus)]
|
2013-03-22 21:00:15 +00:00
|
|
|
static b: bool = false;
|
2011-06-30 18:22:10 +00:00
|
|
|
|
2013-03-22 21:00:15 +00:00
|
|
|
static b: bool = true;
|
2011-06-30 18:22:10 +00:00
|
|
|
|
2013-03-05 22:42:58 +00:00
|
|
|
mod rustrt {
|
|
|
|
#[cfg(bogus)]
|
2013-10-14 12:33:05 +00:00
|
|
|
extern {
|
2013-03-05 22:42:58 +00:00
|
|
|
// This symbol doesn't exist and would be a link error if this
|
2018-05-08 13:10:16 +00:00
|
|
|
// module was codegened
|
2013-03-05 22:42:58 +00:00
|
|
|
pub fn bogus();
|
|
|
|
}
|
2013-05-03 23:25:04 +00:00
|
|
|
|
2013-10-14 12:33:05 +00:00
|
|
|
extern {}
|
2011-06-30 18:22:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2015-03-26 00:06:52 +00:00
|
|
|
type t = isize;
|
2011-06-30 18:22:10 +00:00
|
|
|
|
|
|
|
type t = bool;
|
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2012-01-20 02:31:08 +00:00
|
|
|
enum tg { foo, }
|
2011-06-30 18:22:10 +00:00
|
|
|
|
2012-01-20 02:31:08 +00:00
|
|
|
enum tg { bar, }
|
2011-06-30 18:22:10 +00:00
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2012-08-16 01:46:55 +00:00
|
|
|
struct r {
|
2015-03-26 00:06:52 +00:00
|
|
|
i: isize,
|
2012-09-05 22:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2015-03-26 00:06:52 +00:00
|
|
|
fn r(i:isize) -> r {
|
2012-09-05 22:58:43 +00:00
|
|
|
r {
|
|
|
|
i: i
|
|
|
|
}
|
2012-05-16 03:33:59 +00:00
|
|
|
}
|
2011-06-30 18:22:10 +00:00
|
|
|
|
2012-08-16 01:46:55 +00:00
|
|
|
struct r {
|
2015-03-26 00:06:52 +00:00
|
|
|
i: isize,
|
2012-09-05 22:58:43 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn r(i:isize) -> r {
|
2012-09-05 22:58:43 +00:00
|
|
|
r {
|
|
|
|
i: i
|
|
|
|
}
|
2012-05-16 03:33:59 +00:00
|
|
|
}
|
2011-06-30 18:22:10 +00:00
|
|
|
|
|
|
|
#[cfg(bogus)]
|
|
|
|
mod m {
|
2011-07-27 12:19:39 +00:00
|
|
|
// This needs to parse but would fail in typeck. Since it's not in
|
|
|
|
// the current config it should not be typechecked.
|
2013-01-30 23:56:40 +00:00
|
|
|
pub fn bogus() { return 0; }
|
2011-06-30 18:22:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mod m {
|
2011-07-27 12:19:39 +00:00
|
|
|
// Submodules have slightly different code paths than the top-level
|
|
|
|
// module, so let's make sure this jazz works here as well
|
|
|
|
#[cfg(bogus)]
|
2013-01-30 23:56:40 +00:00
|
|
|
pub fn f() { }
|
2011-06-30 18:22:10 +00:00
|
|
|
|
2013-01-30 23:56:40 +00:00
|
|
|
pub fn f() { }
|
2011-06-30 18:22:10 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 00:38:40 +00:00
|
|
|
// Since the bogus configuration isn't defined main will just be
|
|
|
|
// parsed, but nothing further will be done with it
|
|
|
|
#[cfg(bogus)]
|
2014-10-09 19:17:22 +00:00
|
|
|
pub fn main() { panic!() }
|
2011-06-30 00:38:40 +00:00
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2011-07-27 12:19:39 +00:00
|
|
|
// Exercise some of the configured items in ways that wouldn't be possible
|
|
|
|
// if they had the bogus definition
|
2013-03-29 01:39:09 +00:00
|
|
|
assert!((b));
|
2013-08-17 15:37:42 +00:00
|
|
|
let _x: t = true;
|
2014-11-06 08:05:53 +00:00
|
|
|
let _y: tg = tg::bar;
|
2011-06-30 20:04:02 +00:00
|
|
|
|
2011-07-27 12:19:39 +00:00
|
|
|
test_in_fn_ctxt();
|
2011-06-30 18:22:10 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 20:04:02 +00:00
|
|
|
fn test_in_fn_ctxt() {
|
2011-07-27 12:19:39 +00:00
|
|
|
#[cfg(bogus)]
|
2014-10-09 19:17:22 +00:00
|
|
|
fn f() { panic!() }
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
|
|
|
f();
|
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2015-03-26 00:06:52 +00:00
|
|
|
static i: isize = 0;
|
|
|
|
static i: isize = 1;
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(i, 1);
|
2011-06-30 20:04:02 +00:00
|
|
|
}
|
2011-07-05 20:29:21 +00:00
|
|
|
|
2012-06-26 23:18:37 +00:00
|
|
|
mod test_foreign_items {
|
2013-03-05 22:42:58 +00:00
|
|
|
pub mod rustrt {
|
2013-10-14 12:33:05 +00:00
|
|
|
extern {
|
2013-03-05 22:42:58 +00:00
|
|
|
#[cfg(bogus)]
|
2014-05-22 23:57:53 +00:00
|
|
|
pub fn write() -> String;
|
|
|
|
pub fn write() -> String;
|
2013-03-05 22:42:58 +00:00
|
|
|
}
|
2011-07-27 12:19:39 +00:00
|
|
|
}
|
2011-08-10 16:27:22 +00:00
|
|
|
}
|
2012-07-09 21:02:39 +00:00
|
|
|
|
|
|
|
mod test_use_statements {
|
|
|
|
#[cfg(bogus)]
|
|
|
|
use flippity_foo;
|
2012-11-01 22:48:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mod test_methods {
|
|
|
|
struct Foo {
|
2015-03-26 00:06:52 +00:00
|
|
|
bar: usize
|
2012-11-01 22:48:37 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 19:47:00 +00:00
|
|
|
impl Fooable for Foo {
|
2012-11-01 22:48:37 +00:00
|
|
|
#[cfg(bogus)]
|
2013-03-22 02:07:54 +00:00
|
|
|
fn what(&self) { }
|
2012-11-01 22:48:37 +00:00
|
|
|
|
2013-03-22 02:07:54 +00:00
|
|
|
fn what(&self) { }
|
2012-11-01 22:48:37 +00:00
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2013-03-13 02:32:14 +00:00
|
|
|
fn the(&self) { }
|
2012-11-01 22:48:37 +00:00
|
|
|
|
2013-03-13 02:32:14 +00:00
|
|
|
fn the(&self) { }
|
2012-11-01 22:48:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trait Fooable {
|
|
|
|
#[cfg(bogus)]
|
2013-03-22 02:07:54 +00:00
|
|
|
fn what(&self);
|
2012-11-01 22:48:37 +00:00
|
|
|
|
2013-03-22 02:07:54 +00:00
|
|
|
fn what(&self);
|
2012-11-01 22:48:37 +00:00
|
|
|
|
|
|
|
#[cfg(bogus)]
|
2013-03-13 02:32:14 +00:00
|
|
|
fn the(&self);
|
2012-11-01 22:48:37 +00:00
|
|
|
|
2013-03-13 02:32:14 +00:00
|
|
|
fn the(&self);
|
2012-11-01 22:48:37 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 22:40:56 +00:00
|
|
|
|
|
|
|
#[cfg(any())]
|
|
|
|
mod nonexistent_file; // Check that unconfigured non-inline modules are not loaded or parsed.
|