]> git.lizzy.rs Git - rust.git/blob - tests/ui/linkedlist.rs
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / linkedlist.rs
1 #![feature(associated_type_defaults)]
2 #![warn(clippy::linkedlist)]
3 #![allow(unused, dead_code, clippy::needless_pass_by_value)]
4
5 extern crate alloc;
6 use alloc::collections::linked_list::LinkedList;
7
8 const C: LinkedList<i32> = LinkedList::new();
9 static S: LinkedList<i32> = LinkedList::new();
10
11 trait Foo {
12     type Baz = LinkedList<u8>;
13     fn foo(_: LinkedList<u8>);
14     const BAR: Option<LinkedList<u8>>;
15 }
16
17 // Ok, we don’t want to warn for implementations; see issue #605.
18 impl Foo for LinkedList<u8> {
19     fn foo(_: LinkedList<u8>) {}
20     const BAR: Option<LinkedList<u8>> = None;
21 }
22
23 pub struct Bar {
24     priv_linked_list_field: LinkedList<u8>,
25     pub pub_linked_list_field: LinkedList<u8>,
26 }
27 impl Bar {
28     fn foo(_: LinkedList<u8>) {}
29 }
30
31 // All of these test should be trigger the lint because they are not
32 // part of the public api
33 fn test(my_favorite_linked_list: LinkedList<u8>) {}
34 fn test_ret() -> Option<LinkedList<u8>> {
35     None
36 }
37 fn test_local_not_linted() {
38     let _: LinkedList<u8>;
39 }
40
41 // All of these test should be allowed because they are part of the
42 // public api and `avoid_breaking_exported_api` is `false` by default.
43 pub fn pub_test(the_most_awesome_linked_list: LinkedList<u8>) {}
44 pub fn pub_test_ret() -> Option<LinkedList<u8>> {
45     None
46 }
47
48 fn main() {}