]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/chains_with_comment.rs
:arrow_up: rust-analyzer
[rust.git] / src / tools / rustfmt / tests / target / chains_with_comment.rs
1 // Chains with comment.
2
3 fn main() {
4     let x = y // comment
5         .z;
6
7     foo // foo
8         // comment after parent
9         .x
10         .y
11         // comment 1
12         .bar() // comment after bar()
13         // comment 2
14         .foobar
15         // comment after
16         // comment 3
17         .baz(x, y, z);
18
19     self.rev_dep_graph
20         .iter()
21         // Remove nodes that are not dirty
22         .filter(|&(unit, _)| dirties.contains(&unit))
23         // Retain only dirty dependencies of the ones that are dirty
24         .map(|(k, deps)| {
25             (
26                 k.clone(),
27                 deps.iter()
28                     .cloned()
29                     .filter(|d| dirties.contains(&d))
30                     .collect(),
31             )
32         });
33
34     let y = expr /* comment */
35         .kaas()?
36         // comment
37         .test();
38     let loooooooooooooooooooooooooooooooooooooooooong = does_this?
39         .look?
40         .good?
41         .should_we_break?
42         .after_the_first_question_mark?;
43     let zzzz = expr? // comment after parent
44         // comment 0
45         .another??? // comment 1
46         .another???? // comment 2
47         .another? // comment 3
48         .another?;
49
50     let y = a
51         .very
52         .loooooooooooooooooooooooooooooooooooooong() /* comment */
53         .chain()
54         .inside() /* comment */
55         .weeeeeeeeeeeeeee()?
56         .test()
57         .0
58         .x;
59
60     parameterized(f, substs, def_id, Ns::Value, &[], |tcx| {
61         tcx.lookup_item_type(def_id).generics
62     })?;
63     fooooooooooooooooooooooooooo()?
64         .bar()?
65         .baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
66
67     // #2559
68     App::new("cargo-cache")
69         .version(crate_version!())
70         .bin_name("cargo")
71         .about("Manage cargo cache")
72         .author("matthiaskrgr")
73         .subcommand(
74             SubCommand::with_name("cache")
75                 .version(crate_version!())
76                 .bin_name("cargo-cache")
77                 .about("Manage cargo cache")
78                 .author("matthiaskrgr")
79                 .arg(&list_dirs)
80                 .arg(&remove_dir)
81                 .arg(&gc_repos)
82                 .arg(&info)
83                 .arg(&keep_duplicate_crates)
84                 .arg(&dry_run)
85                 .arg(&auto_clean)
86                 .arg(&auto_clean_expensive),
87         ) // subcommand
88         .arg(&list_dirs);
89 }
90
91 // #2177
92 impl Foo {
93     fn dirty_rev_dep_graph(
94         &self,
95         dirties: &HashSet<UnitKey>,
96     ) -> HashMap<UnitKey, HashSet<UnitKey>> {
97         let dirties = self.transitive_dirty_units(dirties);
98         trace!("transitive_dirty_units: {:?}", dirties);
99
100         self.rev_dep_graph
101             .iter()
102             // Remove nodes that are not dirty
103             .filter(|&(unit, _)| dirties.contains(&unit))
104             // Retain only dirty dependencies of the ones that are dirty
105             .map(|(k, deps)| {
106                 (
107                     k.clone(),
108                     deps.iter()
109                         .cloned()
110                         .filter(|d| dirties.contains(&d))
111                         .collect(),
112                 )
113             })
114     }
115 }
116
117 // #2907
118 fn foo() {
119     let x = foo
120         .bar??? // comment
121         .baz;
122     let x = foo
123         .bar???
124         // comment
125         .baz;
126     let x = foo
127         .bar??? // comment
128         // comment
129         .baz;
130     let x = foo
131         .bar??????????????? // comment
132         // comment
133         // comment
134         // comment
135         // comment
136         .baz;
137 }