]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/source/chains_with_comment.rs
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
[rust.git] / src / tools / rustfmt / tests / source / 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 */.kaas()?
35 // comment
36        .test();
37     let loooooooooooooooooooooooooooooooooooooooooong = does_this?.look?.good?.should_we_break?.after_the_first_question_mark?;
38     let zzzz = expr?   // comment after parent
39 // comment 0
40 .another??? // comment 1
41 .another????  // comment 2
42 .another? // comment 3
43 .another?;
44
45     let y = a.very .loooooooooooooooooooooooooooooooooooooong() /* comment */ .chain()
46         .inside()  /* comment */        .weeeeeeeeeeeeeee()? .test()  .0
47         .x;
48
49     parameterized(f,
50                   substs,
51                   def_id,
52                   Ns::Value,
53                   &[],
54                   |tcx| tcx.lookup_item_type(def_id).generics)?;
55     fooooooooooooooooooooooooooo()?.bar()?.baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz()?;
56
57     // #2559
58     App::new("cargo-cache")
59 .version(crate_version!())
60 .bin_name("cargo")
61 .about("Manage cargo cache")
62 .author("matthiaskrgr")
63 .subcommand(
64 SubCommand::with_name("cache")
65 .version(crate_version!())
66 .bin_name("cargo-cache")
67 .about("Manage cargo cache")
68 .author("matthiaskrgr")
69 .arg(&list_dirs)
70 .arg(&remove_dir)
71 .arg(&gc_repos)
72 .arg(&info)
73 .arg(&keep_duplicate_crates)    .arg(&dry_run)
74 .arg(&auto_clean)
75 .arg(&auto_clean_expensive),
76         ) // subcommand
77         .arg(&list_dirs);
78 }
79
80 // #2177
81 impl Foo {
82     fn dirty_rev_dep_graph(
83         &self,
84         dirties: &HashSet<UnitKey>,
85     ) -> HashMap<UnitKey, HashSet<UnitKey>> {
86         let dirties = self.transitive_dirty_units(dirties);
87         trace!("transitive_dirty_units: {:?}", dirties);
88
89         self.rev_dep_graph.iter()
90         // Remove nodes that are not dirty
91             .filter(|&(unit, _)| dirties.contains(&unit))
92         // Retain only dirty dependencies of the ones that are dirty
93             .map(|(k, deps)| (k.clone(), deps.iter().cloned().filter(|d| dirties.contains(&d)).collect()))
94     }
95 }
96
97 // #2907
98 fn foo() {
99     let x = foo
100         .bar??  ? // comment
101         .baz;
102     let x = foo
103         .bar?  ??
104     // comment
105         .baz;
106     let x = foo
107         .bar? ? ? // comment
108     // comment
109         .baz;
110     let x = foo
111         .bar? ?? // comment
112     // comment
113         ? ??
114     // comment
115         ?  ??
116     // comment
117         ???  
118     // comment
119         ? ? ?
120         .baz;
121 }