blob: e1477d7f8463d8d6d6304f091e3b760adecd8193 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
//@no-rustfix: fixes are only done to traits, not the impls
//@aux-build:../../ui/auxiliary/proc_macros.rs
//@revisions: private all
//@[private] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/ref_option/private
//@[all] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/ref_option/all
#![warn(clippy::ref_option)]
pub trait PubTrait {
fn pub_trait_opt(&self, a: &Option<Vec<u8>>);
//~[all]^ ref_option
fn pub_trait_ret(&self) -> &Option<Vec<u8>>;
//~[all]^ ref_option
}
trait PrivateTrait {
fn trait_opt(&self, a: &Option<String>);
//~^ ref_option
fn trait_ret(&self) -> &Option<String>;
//~^ ref_option
}
pub struct PubStruct;
impl PubTrait for PubStruct {
fn pub_trait_opt(&self, a: &Option<Vec<u8>>) {}
fn pub_trait_ret(&self) -> &Option<Vec<u8>> {
panic!()
}
}
struct PrivateStruct;
impl PrivateTrait for PrivateStruct {
fn trait_opt(&self, a: &Option<String>) {}
fn trait_ret(&self) -> &Option<String> {
panic!()
}
}
pub mod external {
proc_macros::external!(
pub trait PubTrait {
fn pub_trait_opt(&self, a: &Option<Vec<u8>>);
fn pub_trait_ret(&self) -> &Option<Vec<u8>>;
}
trait PrivateTrait {
fn trait_opt(&self, a: &Option<String>);
fn trait_ret(&self) -> &Option<String>;
}
);
}
pub mod proc_macros {
proc_macros::with_span!(
span
pub trait PubTrait {
fn pub_trait_opt(&self, a: &Option<Vec<u8>>);
fn pub_trait_ret(&self) -> &Option<Vec<u8>>;
}
trait PrivateTrait {
fn trait_opt(&self, a: &Option<String>);
fn trait_ret(&self) -> &Option<String>;
}
);
}
fn main() {}
|