]> git.lizzy.rs Git - rust.git/blob - src/test/ui/hygiene/assoc_item_ctxt.rs
Rollup merge of #49858 - dmizuk:unique-doc-hidden, r=steveklabnik
[rust.git] / src / test / ui / hygiene / assoc_item_ctxt.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-pretty pretty-printing is unhygienic
12
13 #![feature(decl_macro)]
14 #![allow(unused)]
15
16 mod ok {
17     macro mac_trait_item($method: ident) {
18         fn $method();
19     }
20
21     trait Tr {
22         mac_trait_item!(method);
23     }
24
25     macro mac_trait_impl() {
26         impl Tr for u8 { // OK
27             fn method() {} // OK
28         }
29     }
30
31     mac_trait_impl!();
32 }
33
34 mod error {
35     macro mac_trait_item() {
36         fn method();
37     }
38
39     trait Tr {
40         mac_trait_item!();
41     }
42
43     macro mac_trait_impl() {
44         impl Tr for u8 { //~ ERROR not all trait items implemented, missing: `method`
45             fn method() {} //~ ERROR method `method` is not a member of trait `Tr`
46         }
47     }
48
49     mac_trait_impl!();
50 }
51
52 fn main() {}