2011-06-28 19:53:59 +00:00
|
|
|
// These are attributes of the implicit crate. Really this just needs to parse
|
|
|
|
// for completeness since .rs files linked from .rc files support this
|
|
|
|
// notation to specify their module's attributes
|
|
|
|
#[attr1 = "val"];
|
|
|
|
#[attr2 = "val"];
|
|
|
|
#[attr3];
|
|
|
|
#[attr4(attr5)];
|
|
|
|
|
|
|
|
// Special linkage attributes for the crate
|
|
|
|
#[link(name = "std",
|
|
|
|
vers = "0.1",
|
|
|
|
uuid = "122bed0b-c19b-4b82-b0b7-7ae8aead7297",
|
|
|
|
url = "http://rust-lang.org/src/std")];
|
|
|
|
|
|
|
|
// These are are attributes of the following mod
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2012-09-22 01:10:45 +00:00
|
|
|
mod test_first_item_in_file_mod {
|
|
|
|
#[legacy_exports]; }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
mod test_single_attr_outer {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
const x: int = 10;
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
2012-09-22 01:10:45 +00:00
|
|
|
mod mod1 {
|
|
|
|
#[legacy_exports]; }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
2011-11-17 04:49:38 +00:00
|
|
|
#[abi = "cdecl"]
|
2012-09-22 01:10:45 +00:00
|
|
|
extern mod rustrt {
|
|
|
|
#[legacy_exports]; }
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mod test_multi_attr_outer {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
const x: int = 10;
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2012-09-22 01:10:45 +00:00
|
|
|
mod mod1 {
|
|
|
|
#[legacy_exports]; }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-11-17 04:49:38 +00:00
|
|
|
#[abi = "cdecl"]
|
2012-09-22 01:10:45 +00:00
|
|
|
extern mod rustrt {
|
|
|
|
#[legacy_exports]; }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2012-01-13 10:48:55 +00:00
|
|
|
type t = {x: int};
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mod test_stmt_single_attr_outer {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
fn f() {
|
|
|
|
|
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
const x: int = 10;
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr = "val"]
|
|
|
|
mod mod1 {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
2011-07-27 12:48:34 +00:00
|
|
|
|
2011-06-28 19:53:59 +00:00
|
|
|
#[attr = "val"]
|
2011-11-17 04:49:38 +00:00
|
|
|
#[abi = "cdecl"]
|
2012-07-03 23:11:00 +00:00
|
|
|
extern mod rustrt {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_stmt_multi_attr_outer {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
fn f() {
|
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
const x: int = 10;
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
/* FIXME: Issue #493
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
|
|
|
mod mod1 {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
2011-07-27 12:48:34 +00:00
|
|
|
|
2011-06-28 19:53:59 +00:00
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-11-17 04:49:38 +00:00
|
|
|
#[abi = "cdecl"]
|
2012-07-03 23:11:00 +00:00
|
|
|
extern mod rustrt {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_attr_inner {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
mod m {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
// This is an attribute of mod m
|
|
|
|
#[attr = "val"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_attr_inner_then_outer {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
mod m {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
// This is an attribute of mod m
|
|
|
|
#[attr = "val"];
|
|
|
|
// This is an attribute of fn f
|
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_attr_inner_then_outer_multi {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
mod m {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
// This is an attribute of mod m
|
|
|
|
#[attr1 = "val"];
|
|
|
|
#[attr2 = "val"];
|
|
|
|
// This is an attribute of fn f
|
|
|
|
#[attr1 = "val"]
|
|
|
|
#[attr2 = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_distinguish_syntax_ext {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
|
2012-09-12 00:46:20 +00:00
|
|
|
extern mod std;
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
fn f() {
|
2012-08-23 00:24:52 +00:00
|
|
|
fmt!("test%s", ~"s");
|
2011-06-28 19:53:59 +00:00
|
|
|
#[attr = "val"]
|
2011-07-27 12:19:39 +00:00
|
|
|
fn g() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod test_other_forms {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-06-28 19:53:59 +00:00
|
|
|
#[attr]
|
|
|
|
#[attr(word)]
|
|
|
|
#[attr(attr(word))]
|
2011-07-27 12:19:39 +00:00
|
|
|
#[attr(key1 = "val", key2 = "val", attr)]
|
|
|
|
fn f() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
}
|
|
|
|
|
2012-06-26 23:18:37 +00:00
|
|
|
mod test_foreign_items {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-11-17 04:49:38 +00:00
|
|
|
#[abi = "cdecl"]
|
2012-07-03 23:11:00 +00:00
|
|
|
extern mod rustrt {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-07-05 19:38:53 +00:00
|
|
|
#[attr];
|
|
|
|
|
|
|
|
#[attr]
|
2012-07-18 01:48:15 +00:00
|
|
|
fn get_task_id() -> libc::intptr_t;
|
2011-07-05 19:38:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-06 00:01:23 +00:00
|
|
|
mod test_literals {
|
2012-09-22 01:10:45 +00:00
|
|
|
#[legacy_exports];
|
2011-07-06 00:01:23 +00:00
|
|
|
#[str = "s"];
|
|
|
|
#[char = 'c'];
|
|
|
|
#[int = 100];
|
|
|
|
#[uint = 100u];
|
|
|
|
#[mach_int = 100u32];
|
|
|
|
#[float = 1.0];
|
|
|
|
#[mach_float = 1.0f32];
|
2011-08-24 01:09:30 +00:00
|
|
|
#[nil = ()];
|
2011-07-06 00:01:23 +00:00
|
|
|
#[bool = true];
|
2012-09-22 01:10:45 +00:00
|
|
|
mod m {
|
|
|
|
#[legacy_exports]; }
|
2011-07-06 00:01:23 +00:00
|
|
|
}
|
|
|
|
|
2012-01-16 01:23:59 +00:00
|
|
|
fn test_fn_inner() {
|
|
|
|
#[inner_fn_attr];
|
|
|
|
}
|
|
|
|
|
2011-07-27 12:19:39 +00:00
|
|
|
fn main() { }
|
2011-06-28 19:53:59 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Local Variables:
|
|
|
|
// mode: rust
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// End:
|
|
|
|
//
|