rust/compiler/rustc_resolve/src
Matthias Krüger 3dfda2c72f
Rollup merge of #109985 - blyxyas:is_test_crate, r=compiler-errors
Add little `is_test_crate` function

Ok, this is quite a story.
I'm mainly a Clippy contributor, so I was fixing [this Clippy issue](https://github.com/rust-lang/rust-clippy/pull/10584) about a lint having to ignore test modules but that wasn't ignoring test files (integration test, `test/` dirs and such).

As test **files** don't tend to have an inner `#[cfg(test)]` module inside them, I tried everything, looking for filenames, looking for item's parents in the HIR Map, doing black magic...

I even asked [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20Checking.20if.20file.20is.20integration.20test), and jyn answered something about `--cfg test`. Aha! That's something that I might be looking for, so I started looking at `rustc_driver_impl` flag parsing and configuration and all that.

Then, I stumbled on [this function right here](2e486be8d2/compiler/rustc_driver_impl/src/lib.rs (L174-L181)), and noticed the argument `config: Config`. That's a hint.

So [Config](https://doc.rust-lang.org/beta/nightly-rustc/rustc_interface/interface/struct.Config.html) has the field `opts: Options`, and [`Options`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_session/options/struct.Options.html) has the field `test`.

This journey has been ~7 or 8 hours in 3 days, it's a very hard thing to find, so this PR adds a mini-function to check if the current crate is a testing one. So that no one has to travel through the same as me, and can just search for `is_test_crate` in the documentation.
2023-04-09 23:40:04 +02:00
..
diagnostics Implement the unused_macro_rules lint 2022-05-05 19:13:00 +02:00
late suggest adding const param 2023-04-07 09:11:53 +02:00
build_reduced_graph.rs resolve: Preserve reexport chains in ModChildren 2023-04-08 13:29:15 +03:00
check_unused.rs Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
def_collector.rs Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
diagnostics.rs Make span a bit better 2023-04-06 16:52:17 +00:00
effective_visibilities.rs resolve: Restore some effective visibility optimizations 2023-03-31 17:07:59 +04:00
errors.rs Deny useing tool paths 2023-04-04 14:10:13 +01:00
ident.rs Rollup merge of #109909 - clubby789:import-tool-mod, r=petrochenkov 2023-04-06 07:18:29 +09:00
imports.rs resolve: Preserve reexport chains in ModChildren 2023-04-08 13:29:15 +03:00
late.rs Auto merge of #110041 - fmease:diag-sugg-adding-const-param, r=compiler-errors 2023-04-09 10:54:04 +00:00
lib.rs Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
macros.rs rustc_interface: Add a new query pre_configure 2023-03-23 14:22:48 +04:00
rustdoc.rs Update doc(primitive) in rustc_resolve 2023-03-31 00:04:24 +02:00