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