rust/compiler/rustc_interface/src
bors 98c8619502 Auto merge of #89214 - smoelius:register_tool, r=petrochenkov
Pass real crate-level attributes to `pre_expansion_lint`

The PR concerns the unstable feature `register_tool` (#66079).

The feature's implementation requires the attributes of the crate being compiled, so that when attributes like `allow(foo::bar)` are encountered, it can be verified that `register_tool(foo)` appears in the crate root.

However, the crate's attributes are not readily available during early lint passes. Specifically, on this line, `krate.attrs` appears to be the attributes of the current source file, not the attributes of the whole crate: bf642323d6/compiler/rustc_lint/src/context.rs (L815)

Consequently, "unknown tool" errors were being produced when `allow(foo::bar)` appeared in a submodule, even though `register_tool(foo)` appeared in the crate root.

EDITED: The proposed fix is to obtain the real crate-level attributes in `configure_and_expand` and pass them to `pre_expansion_lint`. (See `@petrochenkov's` [comment](https://github.com/rust-lang/rust/pull/89214#issuecomment-926927072) below.)

The original "prosed fix" text follows.

---

The proposed fix is to add an `error_on_unknown_tool` flag to `LintLevelsBuilder`. The flag controls whether "unknown tool" errors are emitted. The flag is set during late passes, but not earlier.

More specifically, this PR contains two commits:

* The first adds a `known-tool-in-submodule` UI test that does not currently pass.
* The second adds the `error_on_unknown_tool` flag. The new test passes with the addition of this flag.

This change has the added benefit of eliminating some errors that were duplicated in existing tests.

To the reviewer: please check that I implemented the UI test correctly.
2021-09-27 18:21:14 +00:00
..
callbacks.rs Add sanity check. 2021-09-10 20:18:26 +02:00
interface.rs Move OnDiskCache to rustc_query_impl. 2021-07-18 11:14:07 +02:00
lib.rs Simplify scoped_thread 2021-09-23 12:56:59 -04:00
passes.rs Auto merge of #89214 - smoelius:register_tool, r=petrochenkov 2021-09-27 18:21:14 +00:00
proc_macro_decls.rs Use () for proc_macro_decls_static. 2021-05-12 13:58:43 +02:00
queries.rs Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
tests.rs Rollup merge of #87320 - danakj:debug-compilation-dir, r=michaelwoerister 2021-09-15 14:56:56 -07:00
util.rs Check for macros in built-in attributes that don't support them. 2021-09-25 09:03:15 -07:00