Debian Codegraph @

examples/custom_files.rs

raw symbols SCIP
1 //! An example that shows how to implement a simple custom file database.
2 //! The database uses 32-bit file-ids, which could be useful for optimizing
3 //! memory usage.
4 //!
5 //! To run this example, execute the following command from the top level of
6 //! this repository:
7 //!
8 //! ```sh
9 //! cargo run --example custom_files
10 //! ```
11
12 use codespan_reportingrust-analyzer cargo codespan-reporting 0.12.0 crate/::diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/::{Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#, Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#};
13 use codespan_reportingrust-analyzer cargo codespan-reporting 0.12.0 crate/::termrust-analyzer cargo codespan-reporting 0.12.0 term/;
14 use codespan_reportingrust-analyzer cargo codespan-reporting 0.12.0 crate/::termrust-analyzer cargo codespan-reporting 0.12.0 term/::termcolorrust-analyzer cargo termcolor 1.4.1 crate/::{ColorChoicerust-analyzer cargo termcolor 1.4.1 ColorChoice#, StandardStreamrust-analyzer cargo termcolor 1.4.1 StandardStream#};
15 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#;
16
17 fn mainrust-analyzer cargo codespan-reporting 0.12.0 main().() -> anyhowrust-analyzer cargo anyhow 1.0.0 crate/::Resultrust-analyzer cargo anyhow 1.0.0 Result#<()> {
18 let mut files = filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#::newrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]new().();
19
20 let file_id0 = files.addrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]add().("0.greeting", "hello world!").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
21 let file_id1 = files.addrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]add().("1.greeting", "bye world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
22
23 let messages = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
24 Messagerust-analyzer cargo codespan-reporting 0.12.0 Message#::UnwantedGreetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings# {
25 greetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings#greetings.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(file_id0, 0..5), (file_id1, 0..3)],
26 },
27 Messagerust-analyzer cargo codespan-reporting 0.12.0 Message#::OverTheTopExclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations# {
28 exclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations#exclamations.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(file_id0, 11..12)],
29 },
30 ];
31
32 let writer = StandardStreamrust-analyzer cargo termcolor 1.4.1 StandardStream#::stderrrust-analyzer cargo termcolor 1.4.1 impl#[StandardStream]stderr().(ColorChoicerust-analyzer cargo termcolor 1.4.1 ColorChoice#::Alwaysrust-analyzer cargo termcolor 1.4.1 ColorChoice#Always#);
33 let config = termrust-analyzer cargo codespan-reporting 0.12.0 term/::Configrust-analyzer cargo codespan-reporting 0.12.0 term/config/Config#::defaultrust-analyzer cargo codespan-reporting 0.12.0 term/config/impl#[Config][Default]default().();
34 for message in &messages {
35 let writer = &mut writer.lockrust-analyzer cargo termcolor 1.4.1 impl#[StandardStream]lock().();
36 termrust-analyzer cargo codespan-reporting 0.12.0 term/::emitrust-analyzer cargo codespan-reporting 0.12.0 term/emit().(writer, &config, &files, &message.to_diagnosticrust-analyzer cargo codespan-reporting 0.12.0 impl#[Message]to_diagnostic().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
37 }
38
39 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
40 }
41
42 /// A module containing the file implementation
43 mod filesrust-analyzer cargo codespan-reporting 0.12.0 files/ {
44 use codespan_reportingrust-analyzer cargo codespan-reporting 0.12.0 crate/::filesrust-analyzer cargo codespan-reporting 0.12.0 files/;
45 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#;
46
47 /// A file that is backed by an `Arc<String>`.
48 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
49 struct Filerust-analyzer cargo codespan-reporting 0.12.0 files/File# {
50 /// The name of the file.
51 namerust-analyzer cargo codespan-reporting 0.12.0 files/File#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
52 /// The source code of the file.
53 sourcerust-analyzer cargo codespan-reporting 0.12.0 files/File#source.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
54 /// The starting byte indices in the source code.
55 line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize>,
56 }
57
58 impl Filerust-analyzer cargo codespan-reporting 0.12.0 files/File# {
59 fn line_startrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[File]line_start().(&self, line_index: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
60 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#;
61
62 match line_index.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][Ord]cmp().(&self.line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()) {
63 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self
64 .line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts.
65 .getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(line_index)
66 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("failed despite previous check")),
67 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.sourcerust-analyzer cargo codespan-reporting 0.12.0 files/File#source..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()),
68 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#::LineTooLargerust-analyzer cargo codespan-reporting 0.12.0 files/Error#LineTooLarge# {
69 givenrust-analyzer cargo codespan-reporting 0.12.0 files/Error#LineTooLarge#given.: line_index,
70 maxrust-analyzer cargo codespan-reporting 0.12.0 files/Error#LineTooLarge#max.: self.line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1,
71 }),
72 }
73 }
74 }
75
76 /// An opaque file identifier.
77 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
78 pub struct FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#(u32);
79
80 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
81 pub struct Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files# {
82 filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#files.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Filerust-analyzer cargo codespan-reporting 0.12.0 files/File#>,
83 }
84
85 impl Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files# {
86 /// Create a new files database.
87 pub fn newrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]new().() -> Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files# {
88 Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files# { filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#files.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() }
89 }
90
91 /// Add a file to the database, returning the handle that can be used to
92 /// refer to it again.
93 pub fn addrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]add().(
94 &mut self,
95 name: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
96 source: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
97 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#> {
98 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
99
100 let file_id = FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#(u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u32][`TryFrom<usize>`]try_from().(self.filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#files..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().);
101 let name = name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
102 let source = source.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
103 let line_starts = filesrust-analyzer cargo codespan-reporting 0.12.0 files/::line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/line_starts().(&source).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
104
105 self.filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#files..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Filerust-analyzer cargo codespan-reporting 0.12.0 files/File# {
106 namerust-analyzer cargo codespan-reporting 0.12.0 files/File#name.,
107 line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts.,
108 sourcerust-analyzer cargo codespan-reporting 0.12.0 files/File#source.,
109 });
110
111 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(file_id)
112 }
113
114 /// Get the file corresponding to the given id.
115 fn getrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]get().(&self, file_id: FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&Filerust-analyzer cargo codespan-reporting 0.12.0 files/File#, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
116 self.filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#files.
117 .getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(file_id.0rust-analyzer cargo codespan-reporting 0.12.0 files/FileId#0. as usize)
118 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#::FileMissingrust-analyzer cargo codespan-reporting 0.12.0 files/Error#FileMissing#)
119 }
120 }
121
122 impl<'files> filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files#<'files> for Filesrust-analyzer cargo codespan-reporting 0.12.0 files/Files# {
123 type FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]FileId# = FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#;
124 type Namerust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]Name# = &'files str;
125 type Sourcerust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]Source# = &'files str;
126
127 fn namerust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]name().(&self, file_id: FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
128 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.getrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]get().(file_id)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..namerust-analyzer cargo codespan-reporting 0.12.0 files/File#name..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().())
129 }
130
131 fn sourcerust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]source().(&self, file_id: FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&str, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
132 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&self.getrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]get().(file_id)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..sourcerust-analyzer cargo codespan-reporting 0.12.0 files/File#source.)
133 }
134
135 fn line_indexrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]line_index().(&self, file_id: FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#, byte_index: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
136 self.getrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]get().(file_id)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
137 .line_startsrust-analyzer cargo codespan-reporting 0.12.0 files/File#line_starts.
138 .binary_searchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]binary_search().(&byte_index)
139 .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]or_else().(|next_line| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(next_line rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1))
140 }
141
142 fn line_rangerust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files][`Files<'files>`]line_range().(
143 &self,
144 file_id: FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#,
145 line_index: usize,
146 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>, filesrust-analyzer cargo codespan-reporting 0.12.0 files/::Errorrust-analyzer cargo codespan-reporting 0.12.0 files/Error#> {
147 let file = self.getrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[Files]get().(file_id)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
148 let line_start = file.line_startrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[File]line_start().(line_index)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
149 let next_line_start = file.line_startrust-analyzer cargo codespan-reporting 0.12.0 files/impl#[File]line_start().(line_index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
150
151 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(line_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#next_line_start)
152 }
153 }
154 }
155
156 /// A Diagnostic message.
157 enum Messagerust-analyzer cargo codespan-reporting 0.12.0 Message# {
158 UnwantedGreetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings# {
159 greetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings#greetings.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(filesrust-analyzer cargo codespan-reporting 0.12.0 files/::FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>)>,
160 },
161 OverTheTopExclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations# {
162 exclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations#exclamations.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(filesrust-analyzer cargo codespan-reporting 0.12.0 files/::FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#, Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>)>,
163 },
164 }
165
166 impl Messagerust-analyzer cargo codespan-reporting 0.12.0 Message# {
167 fn to_diagnosticrust-analyzer cargo codespan-reporting 0.12.0 impl#[Message]to_diagnostic().(&self) -> Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#<filesrust-analyzer cargo codespan-reporting 0.12.0 files/::FileIdrust-analyzer cargo codespan-reporting 0.12.0 files/FileId#> {
168 match self {
169 Messagerust-analyzer cargo codespan-reporting 0.12.0 Message#::UnwantedGreetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings# { greetingsrust-analyzer cargo codespan-reporting 0.12.0 Message#UnwantedGreetings#greetings. } => Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]error().()
170 .with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_message().("greetings are not allowed")
171 .with_labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_labels().(
172 greetings
173 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
174 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(file_id, range)| {
175 Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#::primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]primary().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().file_id, range.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`][Clone]clone().()).with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]with_message().("a greeting")
176 })
177 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
178 )
179 .with_notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_notes().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
180 "found greetings!".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
181 "pleas no greetings :(".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
182 ]),
183 Messagerust-analyzer cargo codespan-reporting 0.12.0 Message#::OverTheTopExclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations# { exclamationsrust-analyzer cargo codespan-reporting 0.12.0 Message#OverTheTopExclamations#exclamations. } => Diagnosticrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Diagnostic#::errorrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]error().()
184 .with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_message().("over-the-top exclamations")
185 .with_labelsrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_labels().(
186 exclamations
187 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
188 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(file_id, range)| {
189 Labelrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/Label#::primaryrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]primary().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().file_id, range.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`][Clone]clone().()).with_messagerust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Label<FileId>`]with_message().("an exclamation")
190 })
191 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
192 )
193 .with_notesrust-analyzer cargo codespan-reporting 0.12.0 diagnostic/impl#[`Diagnostic<FileId>`]with_notes().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["ridiculous!".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()]),
194 }
195 }
196 }