Debian Codegraph @

.cargo/vendor/syn/tests/repo/mod.rs

raw
1 #![allow(clippy::manual_assert)]
2
3 mod progress;
4
5 use self::progress::Progress;
6 use anyhow::Result;
7 use flate2::read::GzDecoder;
8 use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
9 use rayon::ThreadPoolBuilder;
10 use std::collections::BTreeSet;
11 use std::env;
12 use std::ffi::OsStr;
13 use std::fs;
14 use std::path::{Path, PathBuf};
15 use tar::Archive;
16 use walkdir::{DirEntry, WalkDir};
17
18 // nightly-2025-08-14
19 const REVISION: &str = "3672a55b7cfd0a12e7097197b6242872473ffaa7";
20
21 #[rustfmt::skip]
22 static EXCLUDE_FILES: &[&str] = &[
23 // TODO: const traits: `pub const trait Trait {}`
24 // https://github.com/dtolnay/syn/issues/1887
25 "src/tools/clippy/tests/ui/assign_ops.rs",
26 "src/tools/clippy/tests/ui/missing_const_for_fn/const_trait.rs",
27 "src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs",
28 "src/tools/rust-analyzer/crates/test-utils/src/minicore.rs",
29
30 // TODO: unsafe binders: `unsafe<'a> &'a T`
31 // https://github.com/dtolnay/syn/issues/1791
32 "src/tools/rustfmt/tests/source/unsafe-binders.rs",
33 "src/tools/rustfmt/tests/target/unsafe-binders.rs",
34 "tests/mir-opt/gvn_on_unsafe_binder.rs",
35 "tests/rustdoc/auxiliary/unsafe-binder-dep.rs",
36 "tests/rustdoc/unsafe-binder.rs",
37 "tests/ui/unsafe-binders/cat-projection.rs",
38
39 // TODO: unsafe fields: `struct S { unsafe field: T }`
40 // https://github.com/dtolnay/syn/issues/1792
41 "src/tools/clippy/tests/ui/derive.rs",
42 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/record_field_list.rs",
43 "src/tools/rustfmt/tests/source/unsafe-field.rs",
44 "src/tools/rustfmt/tests/target/unsafe-field.rs",
45 "tests/ui/unsafe-fields/auxiliary/unsafe-fields-crate-dep.rs",
46
47 // TODO: guard patterns: `match expr { (A if f()) | (B if g()) => {} }`
48 // https://github.com/dtolnay/syn/issues/1793
49 "src/tools/rustfmt/tests/target/guard_patterns.rs",
50 "tests/ui/pattern/rfc-3637-guard-patterns/only-gather-locals-once.rs",
51
52 // TODO: struct field default: `struct S { field: i32 = 1 }`
53 // https://github.com/dtolnay/syn/issues/1774
54 "compiler/rustc_errors/src/markdown/parse.rs",
55 "compiler/rustc_session/src/config.rs",
56 "src/tools/clippy/tests/ui/exhaustive_items.rs",
57 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/record_field_default_values.rs",
58 "src/tools/rustfmt/tests/source/default-field-values.rs",
59 "src/tools/rustfmt/tests/target/default-field-values.rs",
60 "tests/ui/structs/default-field-values/auxiliary/struct_field_default.rs",
61 "tests/ui/structs/default-field-values/const-trait-default-field-value.rs",
62 "tests/ui/structs/default-field-values/field-references-param.rs",
63 "tests/ui/structs/default-field-values/support.rs",
64 "tests/ui/structs/default-field-values/use-normalized-ty-for-default-struct-value.rs",
65
66 // TODO: return type notation: `where T: Trait<method(): Send>` and `where T::method(..): Send`
67 // https://github.com/dtolnay/syn/issues/1434
68 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/return_type_syntax_in_path.rs",
69 "src/tools/rustfmt/tests/target/return-type-notation.rs",
70 "tests/rustdoc-json/return-type-notation.rs",
71 "tests/rustdoc/return-type-notation.rs",
72 "tests/ui/associated-type-bounds/all-generics-lookup.rs",
73 "tests/ui/associated-type-bounds/implied-from-self-where-clause.rs",
74 "tests/ui/associated-type-bounds/return-type-notation/basic.rs",
75 "tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.rs",
76 "tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.rs",
77 "tests/ui/associated-type-bounds/return-type-notation/path-constrained-in-method.rs",
78 "tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs",
79 "tests/ui/associated-type-bounds/return-type-notation/path-works.rs",
80 "tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs",
81 "tests/ui/async-await/return-type-notation/issue-110963-late.rs",
82 "tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs",
83 "tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs",
84 "tests/ui/async-await/return-type-notation/super-method-bound.rs",
85 "tests/ui/async-await/return-type-notation/supertrait-bound.rs",
86 "tests/ui/borrowck/alias-liveness/rtn-static.rs",
87 "tests/ui/feature-gates/feature-gate-return_type_notation.rs",
88
89 // TODO: lazy type alias syntax with where-clause in trailing position
90 // https://github.com/dtolnay/syn/issues/1525
91 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_item_where_clause.rs",
92 "src/tools/rustfmt/tests/source/type-alias-where-clauses-with-comments.rs",
93 "src/tools/rustfmt/tests/source/type-alias-where-clauses.rs",
94 "src/tools/rustfmt/tests/target/type-alias-where-clauses-with-comments.rs",
95 "src/tools/rustfmt/tests/target/type-alias-where-clauses.rs",
96 "tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs",
97
98 // TODO: gen blocks and functions
99 // https://github.com/dtolnay/syn/issues/1526
100 "compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs",
101 "compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs",
102 "compiler/rustc_metadata/src/rmeta/decoder.rs",
103 "compiler/rustc_middle/src/ty/closure.rs",
104 "compiler/rustc_middle/src/ty/context.rs",
105 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/gen_blocks.rs",
106 "tests/ui/async-await/async-drop/assign-incompatible-types.rs",
107 "tests/ui/coroutine/async-gen-deduce-yield.rs",
108 "tests/ui/coroutine/async-gen-yield-ty-is-unit.rs",
109 "tests/ui/coroutine/async_gen_fn_iter.rs",
110 "tests/ui/coroutine/gen_block_is_fused_iter.rs",
111 "tests/ui/coroutine/gen_block_is_iter.rs",
112 "tests/ui/coroutine/gen_block_iterate.rs",
113 "tests/ui/coroutine/gen_fn_iter.rs",
114 "tests/ui/coroutine/gen_fn_lifetime_capture.rs",
115 "tests/ui/coroutine/other-attribute-on-gen.rs",
116 "tests/ui/coroutine/return-types-diverge.rs",
117 "tests/ui/higher-ranked/builtin-closure-like-bounds.rs",
118 "tests/ui/sanitizer/cfi/coroutine.rs",
119
120 // TODO: postfix yield
121 // https://github.com/dtolnay/syn/issues/1890
122 "tests/pretty/postfix-yield.rs",
123 "tests/ui/coroutine/postfix-yield.rs",
124
125 // TODO: `!` as a pattern
126 // https://github.com/dtolnay/syn/issues/1546
127 "tests/mir-opt/building/match/never_patterns.rs",
128 "tests/pretty/never-pattern.rs",
129 "tests/ui/rfcs/rfc-0000-never_patterns/always-read-in-closure-capture.rs",
130 "tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs",
131 "tests/ui/rfcs/rfc-0000-never_patterns/use-bindings.rs",
132
133 // TODO: async trait bounds: `impl async Fn()`
134 // https://github.com/dtolnay/syn/issues/1628
135 "src/tools/miri/tests/pass/async-closure-captures.rs",
136 "src/tools/miri/tests/pass/async-closure-drop.rs",
137 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/async_trait_bound.rs",
138 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/for_binder_bound.rs",
139 "src/tools/rustfmt/tests/target/asyncness.rs",
140 "tests/coverage/async_closure.rs",
141 "tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs",
142 "tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs",
143 "tests/ui/async-await/async-closures/auxiliary/foreign.rs",
144 "tests/ui/async-await/async-closures/body-check-on-non-fnmut.rs",
145 "tests/ui/async-await/async-closures/box-deref-in-debuginfo.rs",
146 "tests/ui/async-await/async-closures/brand.rs",
147 "tests/ui/async-await/async-closures/captures.rs",
148 "tests/ui/async-await/async-closures/clone-closure.rs",
149 "tests/ui/async-await/async-closures/constrained-but-no-upvars-yet.rs",
150 "tests/ui/async-await/async-closures/debuginfo-by-move-body.rs",
151 "tests/ui/async-await/async-closures/drop.rs",
152 "tests/ui/async-await/async-closures/force-move-due-to-inferred-kind.rs",
153 "tests/ui/async-await/async-closures/foreign.rs",
154 "tests/ui/async-await/async-closures/inline-body.rs",
155 "tests/ui/async-await/async-closures/mangle.rs",
156 "tests/ui/async-await/async-closures/moro-example.rs",
157 "tests/ui/async-await/async-closures/move-is-async-fn.rs",
158 "tests/ui/async-await/async-closures/mut-ref-reborrow.rs",
159 "tests/ui/async-await/async-closures/no-borrow-from-env.rs",
160 "tests/ui/async-await/async-closures/non-copy-arg-does-not-force-inner-move.rs",
161 "tests/ui/async-await/async-closures/overlapping-projs.rs",
162 "tests/ui/async-await/async-closures/precise-captures.rs",
163 "tests/ui/async-await/async-closures/refd.rs",
164 "tests/ui/async-await/async-closures/signature-deduction.rs",
165 "tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs",
166 "tests/ui/async-await/async-fn/higher-ranked-async-fn.rs",
167 "tests/ui/async-await/async-fn/impl-trait.rs",
168 "tests/ui/async-await/async-fn/project.rs",
169 "tests/ui/async-await/async-fn/sugar.rs",
170
171 // TODO: mutable by-reference bindings (mut ref)
172 // https://github.com/dtolnay/syn/issues/1629
173 "src/tools/rustfmt/tests/source/mut_ref.rs",
174 "src/tools/rustfmt/tests/target/mut_ref.rs",
175 "tests/ui/mut/mut-ref.rs",
176
177 // TODO: postfix match
178 // https://github.com/dtolnay/syn/issues/1630
179 "src/tools/clippy/tests/ui/unnecessary_semicolon.rs",
180 "src/tools/rustfmt/tests/source/postfix-match/pf-match.rs",
181 "src/tools/rustfmt/tests/target/postfix-match/pf-match.rs",
182 "tests/pretty/postfix-match/simple-matches.rs",
183 "tests/ui/match/postfix-match/no-unused-parens.rs",
184 "tests/ui/match/postfix-match/pf-match-chain.rs",
185 "tests/ui/match/postfix-match/postfix-match.rs",
186
187 // TODO: delegation: `reuse Trait::bar { Box::new(self.0) }`
188 // https://github.com/dtolnay/syn/issues/1580
189 "tests/pretty/delegation.rs",
190 "tests/pretty/hir-delegation.rs",
191 "tests/ui/delegation/body-identity-glob.rs",
192 "tests/ui/delegation/body-identity-list.rs",
193 "tests/ui/delegation/explicit-paths-in-traits-pass.rs",
194 "tests/ui/delegation/explicit-paths-pass.rs",
195 "tests/ui/delegation/explicit-paths-signature-pass.rs",
196 "tests/ui/delegation/fn-header.rs",
197 "tests/ui/delegation/generics/free-fn-to-free-fn-pass.rs",
198 "tests/ui/delegation/generics/free-fn-to-trait-method-pass.rs",
199 "tests/ui/delegation/generics/impl-to-free-fn-pass.rs",
200 "tests/ui/delegation/generics/impl-trait-to-trait-method-pass.rs",
201 "tests/ui/delegation/generics/inherent-impl-to-trait-method-pass.rs",
202 "tests/ui/delegation/generics/trait-method-to-other-pass.rs",
203 "tests/ui/delegation/glob-glob.rs",
204 "tests/ui/delegation/glob-override.rs",
205 "tests/ui/delegation/glob.rs",
206 "tests/ui/delegation/impl-trait.rs",
207 "tests/ui/delegation/list.rs",
208 "tests/ui/delegation/macro-inside-glob.rs",
209 "tests/ui/delegation/macro-inside-list.rs",
210 "tests/ui/delegation/method-call-priority.rs",
211 "tests/ui/delegation/parse.rs",
212 "tests/ui/delegation/rename.rs",
213 "tests/ui/delegation/self-coercion.rs",
214
215 // TODO: for await
216 // https://github.com/dtolnay/syn/issues/1631
217 "tests/ui/async-await/for-await-2015.rs",
218 "tests/ui/async-await/for-await-passthrough.rs",
219 "tests/ui/async-await/for-await.rs",
220
221 // TODO: unparenthesized half-open range pattern inside slice pattern: `[1..]`
222 // https://github.com/dtolnay/syn/issues/1769
223 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/range_pat.rs",
224 "tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs",
225
226 // TODO: pinned type sugar: `&pin const Self`
227 // https://github.com/dtolnay/syn/issues/1770
228 "src/tools/rustfmt/tests/source/pin_sugar.rs",
229 "src/tools/rustfmt/tests/target/pin_sugar.rs",
230 "tests/pretty/pin-ergonomics-hir.rs",
231 "tests/pretty/pin-ergonomics.rs",
232 "tests/ui/pin-ergonomics/borrow.rs",
233 "tests/ui/pin-ergonomics/sugar-self.rs",
234 "tests/ui/pin-ergonomics/sugar.rs",
235
236 // TODO: attributes on where-predicates
237 // https://github.com/dtolnay/syn/issues/1705
238 "src/tools/rustfmt/tests/target/cfg_attribute_in_where.rs",
239
240 // TODO: super let
241 // https://github.com/dtolnay/syn/issues/1889
242 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/let_stmt.rs",
243
244 // TODO: "ergonomic clones": `f(obj.use)`, `thread::spawn(use || f(obj))`, `async use`
245 // https://github.com/dtolnay/syn/issues/1802
246 "tests/codegen-llvm/ergonomic-clones/closure.rs",
247 "tests/mir-opt/ergonomic-clones/closure.rs",
248 "tests/ui/ergonomic-clones/async/basic.rs",
249 "tests/ui/ergonomic-clones/closure/basic.rs",
250 "tests/ui/ergonomic-clones/closure/const-closure.rs",
251 "tests/ui/ergonomic-clones/closure/mutation.rs",
252 "tests/ui/ergonomic-clones/closure/nested.rs",
253 "tests/ui/ergonomic-clones/closure/once-move-out-on-heap.rs",
254 "tests/ui/ergonomic-clones/closure/with-binders.rs",
255 "tests/ui/ergonomic-clones/dotuse/basic.rs",
256 "tests/ui/ergonomic-clones/dotuse/block.rs",
257
258 // TODO: contracts
259 // https://github.com/dtolnay/syn/issues/1892
260 "tests/ui/contracts/internal_machinery/contract-ast-extensions-nest.rs",
261 "tests/ui/contracts/internal_machinery/contract-ast-extensions-tail.rs",
262 "tests/ui/contracts/internal_machinery/contracts-lowering-ensures-is-not-inherited-when-nesting.rs",
263 "tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs",
264
265 // TODO: frontmatter
266 // https://github.com/dtolnay/syn/issues/1893
267 "tests/ui/frontmatter/auxiliary/lib.rs",
268 "tests/ui/frontmatter/dot-in-infostring-non-leading.rs",
269 "tests/ui/frontmatter/escape.rs",
270 "tests/ui/frontmatter/frontmatter-inner-hyphens-1.rs",
271 "tests/ui/frontmatter/frontmatter-inner-hyphens-2.rs",
272 "tests/ui/frontmatter/frontmatter-non-lexible-tokens.rs",
273 "tests/ui/frontmatter/frontmatter-whitespace-3.rs",
274 "tests/ui/frontmatter/frontmatter-whitespace-4.rs",
275 "tests/ui/frontmatter/shebang.rs",
276 "tests/ui/unpretty/frontmatter.rs",
277
278 // TODO: `|| .. .method()`
279 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_range_method_call.rs",
280 "src/tools/rustfmt/tests/source/issue-4808.rs",
281
282 // Negative inherent impl: `impl !Box<JoinHandle> {}`
283 "src/tools/rustfmt/tests/source/negative-impl.rs",
284 "src/tools/rustfmt/tests/target/negative-impl.rs",
285
286 // Compile-fail expr parameter in const generic position: `f::<1 + 2>()`
287 "tests/ui/const-generics/early/closing-args-token.rs",
288 "tests/ui/const-generics/early/const-expression-parameter.rs",
289
290 // Compile-fail variadics in not the last position of a function parameter list
291 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/fn_def_param.rs",
292 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/param_list_vararg.rs",
293 "tests/ui/parser/variadic-ffi-syntactic-pass.rs",
294
295 // Need at least one trait in impl Trait, no such type as impl 'static
296 "tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs",
297
298 // Negative polarity trait bound: `where T: !Copy`
299 "src/tools/rustfmt/tests/target/negative-bounds.rs",
300 "tests/ui/traits/negative-bounds/supertrait.rs",
301
302 // Const impl that is not a trait impl: `impl ~const T {}`
303 "tests/ui/traits/const-traits/syntax.rs",
304
305 // Lifetimes and types out of order in angle bracketed path arguments
306 "tests/ui/parser/constraints-before-generic-args-syntactic-pass.rs",
307
308 // Deprecated anonymous parameter syntax in traits
309 "src/tools/rustfmt/tests/source/trait.rs",
310 "src/tools/rustfmt/tests/target/trait.rs",
311 "tests/pretty/hir-fn-params.rs",
312 "tests/rustdoc/anon-fn-params.rs",
313 "tests/rustdoc/auxiliary/ext-anon-fn-params.rs",
314 "tests/ui/fn/anonymous-parameters-trait-13105.rs",
315 "tests/ui/issues/issue-34074.rs",
316 "tests/ui/proc-macro/trait-fn-args-2015.rs",
317 "tests/ui/trait-bounds/anonymous-parameters-13775.rs",
318
319 // Deprecated where-clause location
320 "src/tools/rustfmt/tests/source/issue_4257.rs",
321 "src/tools/rustfmt/tests/source/issue_4911.rs",
322 "src/tools/rustfmt/tests/target/issue_4257.rs",
323 "src/tools/rustfmt/tests/target/issue_4911.rs",
324 "tests/pretty/gat-bounds.rs",
325 "tests/rustdoc/generic-associated-types/gats.rs",
326
327 // Deprecated trait object syntax with parenthesized generic arguments and no dyn keyword
328 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/path_fn_trait_args.rs",
329 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/typepathfn_with_coloncolon.rs",
330 "src/tools/rustfmt/tests/source/attrib.rs",
331 "src/tools/rustfmt/tests/source/closure.rs",
332 "src/tools/rustfmt/tests/source/existential_type.rs",
333 "src/tools/rustfmt/tests/source/fn-simple.rs",
334 "src/tools/rustfmt/tests/source/fn_args_layout-vertical.rs",
335 "src/tools/rustfmt/tests/source/issue-4689/one.rs",
336 "src/tools/rustfmt/tests/source/issue-4689/two.rs",
337 "src/tools/rustfmt/tests/source/paths.rs",
338 "src/tools/rustfmt/tests/source/structs.rs",
339 "src/tools/rustfmt/tests/target/attrib.rs",
340 "src/tools/rustfmt/tests/target/closure.rs",
341 "src/tools/rustfmt/tests/target/existential_type.rs",
342 "src/tools/rustfmt/tests/target/fn-simple.rs",
343 "src/tools/rustfmt/tests/target/fn.rs",
344 "src/tools/rustfmt/tests/target/fn_args_layout-vertical.rs",
345 "src/tools/rustfmt/tests/target/issue-4689/one.rs",
346 "src/tools/rustfmt/tests/target/issue-4689/two.rs",
347 "src/tools/rustfmt/tests/target/paths.rs",
348 "src/tools/rustfmt/tests/target/structs.rs",
349 "tests/codegen-units/item-collection/non-generic-closures.rs",
350 "tests/debuginfo/recursive-enum.rs",
351 "tests/pretty/closure-reform-pretty.rs",
352 "tests/run-make/reproducible-build-2/reproducible-build.rs",
353 "tests/run-make/reproducible-build/reproducible-build.rs",
354 "tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs",
355 "tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs",
356 "tests/ui/lifetimes/bare-trait-object-borrowck.rs",
357 "tests/ui/lifetimes/bare-trait-object.rs",
358 "tests/ui/parser/bounds-obj-parens.rs",
359
360 // Various extensions to Rust syntax made up by rust-analyzer
361 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/assoc_type_bound.rs",
362 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/const_param_default_path.rs",
363 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/field_expr.rs",
364 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/generic_arg_bounds.rs",
365 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/global_asm.rs",
366 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/question_for_type_trait_bound.rs",
367 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/ref_expr.rs",
368 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/use_tree_abs_star.rs",
369 "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0015_use_tree.rs",
370 "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0029_range_forms.rs",
371 "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0051_parameter_attrs.rs",
372 "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0055_dot_dot_dot.rs",
373 "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0068_item_modifiers.rs",
374 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0031_block_inner_attrs.rs",
375 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0038_endless_inclusive_range.rs",
376 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0045_ambiguous_trait_object.rs",
377 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0046_mutable_const_item.rs",
378 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0224_dangling_dyn.rs",
379 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0261_dangling_impl_undeclared_lifetime.rs",
380 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/dangling_impl.rs",
381 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/dangling_impl_reference.rs",
382 "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/impl_trait_lifetime_only.rs",
383
384 // Placeholder syntax for "throw expressions"
385 "compiler/rustc_errors/src/translation.rs",
386 "compiler/rustc_expand/src/module.rs",
387 "compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs",
388 "src/tools/clippy/tests/ui/needless_return.rs",
389 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/yeet_expr.rs",
390 "tests/pretty/yeet-expr.rs",
391 "tests/ui/try-trait/yeet-for-option.rs",
392 "tests/ui/try-trait/yeet-for-result.rs",
393
394 // Edition 2015 code using identifiers that are now keywords
395 // TODO: some of these we should probably parse
396 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/dyn_trait_type_weak.rs",
397 "src/tools/rustfmt/tests/source/configs/indent_style/block_call.rs",
398 "src/tools/rustfmt/tests/source/configs/use_try_shorthand/false.rs",
399 "src/tools/rustfmt/tests/source/configs/use_try_shorthand/true.rs",
400 "src/tools/rustfmt/tests/source/issue_1306.rs",
401 "src/tools/rustfmt/tests/source/try-conversion.rs",
402 "src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs",
403 "src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs",
404 "src/tools/rustfmt/tests/target/issue-1681.rs",
405 "src/tools/rustfmt/tests/target/issue_1306.rs",
406 "tests/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs",
407 "tests/ui/editions/edition-keywords-2015-2015.rs",
408 "tests/ui/editions/edition-keywords-2015-2018.rs",
409 "tests/ui/lint/keyword-idents/auxiliary/multi_file_submod.rs",
410 "tests/ui/lint/lint_pre_expansion_extern_module_aux.rs",
411 "tests/ui/macros/macro-comma-support-rpass.rs",
412 "tests/ui/macros/try-macro.rs",
413 "tests/ui/parser/extern-crate-async.rs",
414 "tests/ui/try-block/try-is-identifier-edition2015.rs",
415
416 // Excessive nesting
417 "tests/ui/issues/issue-74564-if-expr-stack-overflow.rs",
418
419 // Testing tools on invalid syntax
420 "src/tools/clippy/tests/ui/non_expressive_names_error_recovery.rs",
421 "src/tools/rustfmt/tests/coverage/target/comments.rs",
422 "src/tools/rustfmt/tests/parser/issue-4126/invalid.rs",
423 "src/tools/rustfmt/tests/parser/issue_4418.rs",
424 "src/tools/rustfmt/tests/parser/stashed-diag.rs",
425 "src/tools/rustfmt/tests/parser/stashed-diag2.rs",
426 "src/tools/rustfmt/tests/parser/unclosed-delims/issue_4466.rs",
427 "src/tools/rustfmt/tests/source/configs/disable_all_formatting/true.rs",
428 "src/tools/rustfmt/tests/source/configs/spaces_around_ranges/false.rs",
429 "src/tools/rustfmt/tests/source/configs/spaces_around_ranges/true.rs",
430 "src/tools/rustfmt/tests/source/type.rs",
431 "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs",
432 "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs",
433 "src/tools/rustfmt/tests/target/type.rs",
434 "src/tools/rustfmt/tests/target/unsafe_extern_blocks.rs",
435 "tests/run-make/translation/test.rs",
436 "tests/ui/generics/issue-94432-garbage-ice.rs",
437
438 // Generated file containing a top-level expression, used with `include!`
439 "compiler/rustc_codegen_gcc/src/intrinsic/archs.rs",
440
441 // Not actually test cases
442 "tests/ui/lint/expansion-time-include.rs",
443 "tests/ui/macros/auxiliary/macro-comma-support.rs",
444 "tests/ui/macros/auxiliary/macro-include-items-expr.rs",
445 "tests/ui/macros/include-single-expr-helper.rs",
446 "tests/ui/macros/include-single-expr-helper-1.rs",
447 "tests/ui/parser/issues/auxiliary/issue-21146-inc.rs",
448 ];
449
450 #[rustfmt::skip]
451 static EXCLUDE_DIRS: &[&str] = &[
452 // Inputs that intentionally do not parse
453 "src/tools/rust-analyzer/crates/parser/test_data/parser/err",
454 "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err",
455
456 // Inputs that lex but do not necessarily parse
457 "src/tools/rust-analyzer/crates/parser/test_data/lexer",
458
459 // Inputs that used to crash rust-analyzer, but aren't necessarily supposed to parse
460 "src/tools/rust-analyzer/crates/syntax/test_data/parser/fuzz-failures",
461 "src/tools/rust-analyzer/crates/syntax/test_data/reparse/fuzz-failures",
462
463 // Inputs that crash rustc, making no claim about whether they are valid Rust
464 "tests/crashes",
465 ];
466
467 // Directories in which a .stderr implies the corresponding .rs is not expected
468 // to work.
469 static UI_TEST_DIRS: &[&str] = &["tests/ui", "tests/rustdoc-ui"];
470
471 pub fn for_each_rust_file(for_each: impl Fn(&Path) + Sync + Send) {
472 let mut rs_files = BTreeSet::new();
473
474 let repo_dir = Path::new("tests/rust");
475 for entry in WalkDir::new(repo_dir)
476 .into_iter()
477 .filter_entry(base_dir_filter)
478 {
479 let entry = entry.unwrap();
480 if !entry.file_type().is_dir() {
481 rs_files.insert(entry.into_path());
482 }
483 }
484
485 for ui_test_dir in UI_TEST_DIRS {
486 for entry in WalkDir::new(repo_dir.join(ui_test_dir)) {
487 let mut path = entry.unwrap().into_path();
488 if path.extension() == Some(OsStr::new("stderr")) {
489 loop {
490 rs_files.remove(&path.with_extension("rs"));
491 path = path.with_extension("");
492 if path.extension().is_none() {
493 break;
494 }
495 }
496 }
497 }
498 }
499
500 rs_files.par_iter().map(PathBuf::as_path).for_each(for_each);
501 }
502
503 pub fn base_dir_filter(entry: &DirEntry) -> bool {
504 let path = entry.path();
505
506 let mut path_string = path.to_string_lossy();
507 if cfg!(windows) {
508 path_string = path_string.replace('\\', "/").into();
509 }
510 let path_string = if path_string == "tests/rust" {
511 return true;
512 } else if let Some(path) = path_string.strip_prefix("tests/rust/") {
513 path
514 } else {
515 panic!("unexpected path in Rust dist: {}", path_string);
516 };
517
518 if path.is_dir() {
519 return !EXCLUDE_DIRS.contains(&path_string);
520 }
521
522 if path.extension() != Some(OsStr::new("rs")) {
523 return false;
524 }
525
526 !EXCLUDE_FILES.contains(&path_string)
527 }
528
529 #[allow(dead_code)]
530 pub fn edition(path: &Path) -> &'static str {
531 if path.ends_with("dyn-2015-no-warnings-without-lints.rs") {
532 "2015"
533 } else {
534 "2021"
535 }
536 }
537
538 #[allow(dead_code)]
539 pub fn abort_after() -> usize {
540 match env::var("ABORT_AFTER_FAILURE") {
541 Ok(s) => s.parse().expect("failed to parse ABORT_AFTER_FAILURE"),
542 Err(_) => usize::MAX,
543 }
544 }
545
546 pub fn rayon_init() {
547 let stack_size = match env::var("RUST_MIN_STACK") {
548 Ok(s) => s.parse().expect("failed to parse RUST_MIN_STACK"),
549 Err(_) => 1024 * 1024 * if cfg!(debug_assertions) { 40 } else { 20 },
550 };
551 ThreadPoolBuilder::new()
552 .stack_size(stack_size)
553 .build_global()
554 .unwrap();
555 }
556
557 pub fn clone_rust() {
558 let needs_clone = match fs::read_to_string("tests/rust/COMMIT") {
559 Err(_) => true,
560 Ok(contents) => contents.trim() != REVISION,
561 };
562 if needs_clone {
563 download_and_unpack().unwrap();
564 }
565
566 let mut missing = String::new();
567 let test_src = Path::new("tests/rust");
568
569 let mut exclude_files_set = BTreeSet::new();
570 for exclude in EXCLUDE_FILES {
571 if !exclude_files_set.insert(exclude) {
572 panic!("duplicate path in EXCLUDE_FILES: {}", exclude);
573 }
574 for dir in EXCLUDE_DIRS {
575 if Path::new(exclude).starts_with(dir) {
576 panic!("excluded file {} is inside an excluded dir", exclude);
577 }
578 }
579 if !test_src.join(exclude).is_file() {
580 missing += "\ntests/rust/";
581 missing += exclude;
582 }
583 }
584
585 let mut exclude_dirs_set = BTreeSet::new();
586 for exclude in EXCLUDE_DIRS {
587 if !exclude_dirs_set.insert(exclude) {
588 panic!("duplicate path in EXCLUDE_DIRS: {}", exclude);
589 }
590 if !test_src.join(exclude).is_dir() {
591 missing += "\ntests/rust/";
592 missing += exclude;
593 missing += "/";
594 }
595 }
596
597 if !missing.is_empty() {
598 panic!("excluded test file does not exist:{}\n", missing);
599 }
600 }
601
602 fn download_and_unpack() -> Result<()> {
603 let url = format!("https://github.com/rust-lang/rust/archive/{REVISION}.tar.gz");
604 errorf!("downloading {url}\n");
605
606 let response = reqwest::blocking::get(url)?.error_for_status()?;
607 let progress = Progress::new(response);
608 let decoder = GzDecoder::new(progress);
609 let mut archive = Archive::new(decoder);
610 let prefix = format!("rust-{}", REVISION);
611
612 let tests_rust = Path::new("tests/rust");
613 if tests_rust.exists() {
614 fs::remove_dir_all(tests_rust)?;
615 }
616
617 for entry in archive.entries()? {
618 let mut entry = entry?;
619 let path = entry.path()?;
620 if path == Path::new("pax_global_header") {
621 continue;
622 }
623 let relative = path.strip_prefix(&prefix)?;
624 let out = tests_rust.join(relative);
625 entry.unpack(&out)?;
626 }
627
628 fs::write("tests/rust/COMMIT", REVISION)?;
629 Ok(())
630 }