]> git.proxmox.com Git - rustc.git/blob - tests/rustdoc-ui/unescaped_backticks.rs
New upstream version 1.76.0+dfsg1
[rustc.git] / tests / rustdoc-ui / unescaped_backticks.rs
1 #![deny(rustdoc::unescaped_backticks)]
2 #![allow(rustdoc::broken_intra_doc_links)]
3 #![allow(rustdoc::invalid_html_tags)]
4 #![allow(rustdoc::redundant_explicit_links)]
5
6 ///
7 pub fn empty() {}
8
9 #[doc = ""]
10 pub fn empty2() {}
11
12 /// `
13 //~^ ERROR unescaped backtick
14 pub fn single() {}
15
16 /// \`
17 pub fn escaped() {}
18
19 /// \\`
20 //~^ ERROR unescaped backtick
21 pub fn not_escaped() {}
22
23 /// \\\`
24 pub fn not_not_escaped() {}
25
26 /// [`link1]
27 //~^ ERROR unescaped backtick
28 pub fn link1() {}
29
30 /// [link2`]
31 //~^ ERROR unescaped backtick
32 pub fn link2() {}
33
34 /// [`link_long](link_long)
35 //~^ ERROR unescaped backtick
36 pub fn link_long() {}
37
38 /// [`broken-link]
39 //~^ ERROR unescaped backtick
40 pub fn broken_link() {}
41
42 /// <xx:`>
43 pub fn url() {}
44
45 /// <x:`>
46 //~^ ERROR unescaped backtick
47 pub fn not_url() {}
48
49 /// <h1>`</h1>
50 pub fn html_tag() {}
51
52 /// &#96;
53 pub fn html_escape() {}
54
55 /// 🦀`🦀
56 //~^ ERROR unescaped backtick
57 pub fn unicode() {}
58
59 /// `foo(
60 //~^ ERROR unescaped backtick
61 ///
62 /// paragraph
63 pub fn paragraph() {}
64
65 /// `foo `bar`
66 //~^ ERROR unescaped backtick
67 ///
68 /// paragraph
69 pub fn paragraph2() {}
70
71 /// `foo(
72 //~^ ERROR unescaped backtick
73 /// not paragraph
74 pub fn not_paragraph() {}
75
76 /// Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`.
77 //~^ ERROR unescaped backtick
78 ///
79 /// You could use this function to add 42 to a number `n` (add(n, 42)`),
80 /// or even to add a number `n` to 42 (`add(42, b)`)!
81 //~^ ERROR unescaped backtick
82 pub fn add1(a: i32, b: i32) -> i32 { a + b }
83
84 /// Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`.
85 //~^ ERROR unescaped backtick
86 ///
87 /// You could use this function to add 42 to a number `n` (`add(n, 42)),
88 /// or even to add a number `n` to 42 (`add(42, n)`)!
89 //~^ ERROR unescaped backtick
90 pub fn add2(a: i32, b: i32) -> i32 { a + b }
91
92 /// Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`.
93 //~^ ERROR unescaped backtick
94 ///
95 /// You could use this function to add 42 to a number `n` (`add(n, 42)`),
96 /// or even to add a number `n` to 42 (add(42, n)`)!
97 //~^ ERROR unescaped backtick
98 pub fn add3(a: i32, b: i32) -> i32 { a + b }
99
100 /// Addition is commutative, which means that `add(a, b)` is the same as `add(b, a).
101 //~^ ERROR unescaped backtick
102 ///
103 /// You could use this function to add 42 to a number `n` (`add(n, 42)),
104 /// or even to add a number `n` to 42 (`add(42, n)`)!
105 //~^ ERROR unescaped backtick
106 pub fn add4(a: i32, b: i32) -> i32 { a + b }
107
108 #[doc = "`"]
109 //~^ ERROR unescaped backtick
110 pub fn attr() {}
111
112 #[doc = concat!("\\", "`")]
113 pub fn attr_escaped() {}
114
115 #[doc = concat!("\\\\", "`")]
116 //~^ ERROR unescaped backtick
117 pub fn attr_not_escaped() {}
118
119 #[doc = "Addition is commutative, which means that add(a, b)` is the same as `add(b, a)`."]
120 //~^ ERROR unescaped backtick
121 pub fn attr_add1(a: i32, b: i32) -> i32 { a + b }
122
123 #[doc = "Addition is commutative, which means that `add(a, b) is the same as `add(b, a)`."]
124 //~^ ERROR unescaped backtick
125 pub fn attr_add2(a: i32, b: i32) -> i32 { a + b }
126
127 #[doc = "Addition is commutative, which means that `add(a, b)` is the same as add(b, a)`."]
128 //~^ ERROR unescaped backtick
129 pub fn attr_add3(a: i32, b: i32) -> i32 { a + b }
130
131 #[doc = "Addition is commutative, which means that `add(a, b)` is the same as `add(b, a)."]
132 //~^ ERROR unescaped backtick
133 pub fn attr_add4(a: i32, b: i32) -> i32 { a + b }
134
135 /// ``double backticks``
136 /// `foo
137 //~^ ERROR unescaped backtick
138 pub fn double_backticks() {}
139
140 /// # `(heading
141 //~^ ERROR unescaped backtick
142 /// ## heading2)`
143 //~^ ERROR unescaped backtick
144 ///
145 /// multi `(
146 //~^ ERROR unescaped backtick
147 /// line
148 /// ) heading
149 /// =
150 ///
151 /// para)`(graph
152 //~^ ERROR unescaped backtick
153 ///
154 /// para)`(graph2
155 //~^ ERROR unescaped backtick
156 ///
157 /// 1. foo)`
158 //~^ ERROR unescaped backtick
159 /// 2. `(bar
160 //~^ ERROR unescaped backtick
161 /// * baz)`
162 //~^ ERROR unescaped backtick
163 /// * `(quux
164 //~^ ERROR unescaped backtick
165 ///
166 /// `#![this_is_actually_an_image(and(not), an = "attribute")]
167 //~^ ERROR unescaped backtick
168 ///
169 /// #![this_is_actually_an_image(and(not), an = "attribute")]`
170 //~^ ERROR unescaped backtick
171 ///
172 /// [this_is_actually_an_image(and(not), an = "attribute")]: `.png
173 ///
174 /// | `table( | )head` |
175 //~^ ERROR unescaped backtick
176 //~| ERROR unescaped backtick
177 /// |---------|--------|
178 /// | table`( | )`body |
179 //~^ ERROR unescaped backtick
180 //~| ERROR unescaped backtick
181 pub fn complicated_markdown() {}
182
183 /// The `custom_mir` attribute tells the compiler to treat the function as being custom MIR. This
184 /// attribute only works on functions - there is no way to insert custom MIR into the middle of
185 /// another function. The `dialect` and `phase` parameters indicate which [version of MIR][dialect
186 /// docs] you are inserting here. Generally you'll want to use `#![custom_mir(dialect = "built")]`
187 /// if you want your MIR to be modified by the full MIR pipeline, or `#![custom_mir(dialect =
188 //~^ ERROR unescaped backtick
189 /// "runtime", phase = "optimized")] if you don't.
190 pub mod mir {}
191
192 pub mod rustc {
193 /// Constructs a `TyKind::Error` type and registers a `span_delayed_bug` with the given `msg to
194 //~^ ERROR unescaped backtick
195 /// ensure it gets used.
196 pub fn ty_error_with_message() {}
197
198 pub struct WhereClause {
199 /// `true` if we ate a `where` token: this can happen
200 /// if we parsed no predicates (e.g. `struct Foo where {}
201 /// This allows us to accurately pretty-print
202 /// in `nt_to_tokenstream`
203 //~^ ERROR unescaped backtick
204 pub has_where_token: bool,
205 }
206
207 /// A symbol is an interned or gensymed string. The use of `newtype_index!` means
208 /// that `Option<Symbol>` only takes up 4 bytes, because `newtype_index! reserves
209 //~^ ERROR unescaped backtick
210 /// the last 256 values for tagging purposes.
211 pub struct Symbol();
212
213 /// It is equivalent to `OpenOptions::new()` but allows you to write more
214 /// readable code. Instead of `OpenOptions::new().read(true).open("foo.txt")`
215 /// you can write `File::with_options().read(true).open("foo.txt"). This
216 /// also avoids the need to import `OpenOptions`.
217 //~^ ERROR unescaped backtick
218 pub fn with_options() {}
219
220 /// Subtracts `set from `row`. `set` can be either `BitSet` or
221 /// `HybridBitSet`. Has no effect if `row` does not exist.
222 //~^ ERROR unescaped backtick
223 ///
224 /// Returns true if the row was changed.
225 pub fn subtract_row() {}
226
227 pub mod assert_module_sources {
228 //! The reason that we use `cfg=...` and not `#[cfg_attr]` is so that
229 //! the HIR doesn't change as a result of the annotations, which might
230 //! perturb the reuse results.
231 //!
232 //! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")]
233 //~^ ERROR unescaped backtick
234 //! allows for doing a more fine-grained check to see if pre- or post-lto data
235 //! was re-used.
236
237 /// `cfg=...
238 //~^ ERROR unescaped backtick
239 pub fn foo() {}
240
241 /// `cfg=... and not `#[cfg_attr]`
242 //~^ ERROR unescaped backtick
243 pub fn bar() {}
244 }
245
246 /// Conceptually, this is like a `Vec<Vec<RWU>>`. But the number of
247 /// RWU`s can get very large, so it uses a more compact representation.
248 //~^ ERROR unescaped backtick
249 pub struct RWUTable {}
250
251 /// Like [Self::canonicalize_query], but preserves distinct universes. For
252 /// example, canonicalizing `&'?0: Trait<'?1>`, where `'?0` is in `U1` and
253 /// `'?1` is in `U3` would be canonicalized to have ?0` in `U1` and `'?1`
254 /// in `U2`.
255 //~^ ERROR unescaped backtick
256 ///
257 /// This is used for Chalk integration.
258 pub fn canonicalize_query_preserving_universes() {}
259
260 /// Note that we used to return `Error` here, but that was quite
261 /// dubious -- the premise was that an error would *eventually* be
262 /// reported, when the obligation was processed. But in general once
263 /// you see an `Error` you are supposed to be able to assume that an
264 /// error *has been* reported, so that you can take whatever heuristic
265 /// paths you want to take. To make things worse, it was possible for
266 /// cycles to arise, where you basically had a setup like `<MyType<$0>
267 /// as Trait>::Foo == $0`. Here, normalizing `<MyType<$0> as
268 /// Trait>::Foo> to `[type error]` would lead to an obligation of
269 /// `<MyType<[type error]> as Trait>::Foo`. We are supposed to report
270 /// an error for this obligation, but we legitimately should not,
271 /// because it contains `[type error]`. Yuck! (See issue #29857 for
272 //~^ ERROR unescaped backtick
273 /// one case where this arose.)
274 pub fn normalize_to_error() {}
275
276 /// you don't want to cache that `B: AutoTrait` or `A: AutoTrait`
277 /// is `EvaluatedToOk`; this is because they were only considered
278 /// ok on the premise that if `A: AutoTrait` held, but we indeed
279 /// encountered a problem (later on) with `A: AutoTrait. So we
280 /// currently set a flag on the stack node for `B: AutoTrait` (as
281 /// well as the second instance of `A: AutoTrait`) to suppress
282 //~^ ERROR unescaped backtick
283 /// caching.
284 pub struct TraitObligationStack;
285
286 /// Extend `scc` so that it can outlive some placeholder region
287 /// from a universe it can't name; at present, the only way for
288 /// this to be true is if `scc` outlives `'static`. This is
289 /// actually stricter than necessary: ideally, we'd support bounds
290 /// like `for<'a: 'b`>` that might then allow us to approximate
291 /// `'a` with `'b` and not `'static`. But it will have to do for
292 //~^ ERROR unescaped backtick
293 /// now.
294 pub fn add_incompatible_universe(){}
295 }
296
297 /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
298 /// which returns an `Option<Dispatch>`. If all [`Dispatch`] clones that point
299 /// at the `Subscriber` have been dropped, [`WeakDispatch::upgrade`] will return
300 /// `None`. Otherwise, it will return `Some(Dispatch)`.
301 //~^ ERROR unescaped backtick
302 ///
303 /// Returns some reference to this `[`Subscriber`] value if it is of type `T`,
304 /// or `None` if it isn't.
305 //~^ ERROR unescaped backtick
306 ///
307 /// Called before the filtered [`Layer]'s [`on_event`], to determine if
308 /// `on_event` should be called.
309 //~^ ERROR unescaped backtick
310 ///
311 /// Therefore, if the `Filter will change the value returned by this
312 /// method, it is responsible for ensuring that
313 /// [`rebuild_interest_cache`][rebuild] is called after the value of the max
314 //~^ ERROR unescaped backtick
315 /// level changes.
316 pub mod tracing {}
317
318 macro_rules! id {
319 ($($tt:tt)*) => { $($tt)* }
320 }
321
322 id! {
323 /// The Subscriber` may be accessed by calling [`WeakDispatch::upgrade`],
324 //~^ ERROR unescaped backtick
325 //~| ERROR unescaped backtick
326 //~| ERROR unescaped backtick
327 //~| ERROR unescaped backtick
328 /// which returns an `Option<Dispatch>`. If all [`Dispatch`] clones that point
329 /// at the `Subscriber` have been dropped, [`WeakDispatch::upgrade`] will return
330 /// `None`. Otherwise, it will return `Some(Dispatch)`.
331 ///
332 /// Returns some reference to this `[`Subscriber`] value if it is of type `T`,
333 /// or `None` if it isn't.
334 ///
335 /// Called before the filtered [`Layer]'s [`on_event`], to determine if
336 /// `on_event` should be called.
337 ///
338 /// Therefore, if the `Filter will change the value returned by this
339 /// method, it is responsible for ensuring that
340 /// [`rebuild_interest_cache`][rebuild] is called after the value of the max
341 /// level changes.
342 pub mod tracing_macro {}
343 }
344
345 /// Regression test for <https://github.com/rust-lang/rust/issues/111117>
346 pub mod trillium_server_common {
347 /// One-indexed, because the first CloneCounter is included. If you don't
348 /// want the original to count, construct a [``CloneCounterObserver`]
349 /// instead and use [`CloneCounterObserver::counter`] to increment.
350 //~^ ERROR unescaped backtick
351 pub struct CloneCounter;
352
353 /// This is used by the above.
354 pub struct CloneCounterObserver;
355 }