Skip to content

Commit 48aeaba

Browse files
committed
Auto merge of #22801 - huonw:crateify-lint, r=kmcallister
This pulls out the implementations of most built-in lints into a separate crate, to reduce edit-compile-test iteration times with librustc_lint and increase parallelism. This should enable lints to be refactored, added and deleted much more easily as it slashes the edit-compile cycle to get a minimal working compiler to test with (`make rustc-stage1`) from librustc -> librustc_typeck -> ... -> librustc_driver -> libcore -> ... -> libstd to librustc_lint -> librustc_driver -> libcore -> ... libstd which is significantly faster, mainly due to avoiding the librustc build itself. The intention would be to move as much as possible of the infrastructure into the crate too, but the plumbing is deeply intertwined with librustc itself at the moment. Also, there are lints for which diagnostics are registered directly in the compiler code, not in their own crate traversal, and their definitions have to remain in librustc. This is a [breaking-change] for direct users of the compiler APIs: callers of `rustc::session::build_session` or `rustc::session::build_session_` need to manually call `rustc_lint::register_builtins` on their return value. This should make #22206 easier.
2 parents 1c93934 + 3909253 commit 48aeaba

File tree

15 files changed

+2267
-2167
lines changed

15 files changed

+2267
-2167
lines changed

mk/crates.mk

+8-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TARGET_CRATES := libc std flate arena term \
5454
log graphviz core rbml alloc \
5555
unicode rustc_bitflags
5656
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
57-
rustc_trans rustc_back rustc_llvm rustc_privacy
57+
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint
5858
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
5959
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
6060
TOOLS := compiletest rustdoc rustc rustbook
@@ -70,20 +70,21 @@ DEPS_graphviz := std
7070
DEPS_syntax := std term serialize log fmt_macros arena libc
7171
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
7272
rustc_typeck rustc_resolve log syntax serialize rustc_llvm \
73-
rustc_trans rustc_privacy
73+
rustc_trans rustc_privacy rustc_lint
7474

7575
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
7676
log syntax serialize rustc_llvm
7777
DEPS_rustc_typeck := rustc syntax
7878
DEPS_rustc_borrowck := rustc log graphviz syntax
7979
DEPS_rustc_resolve := rustc log syntax
8080
DEPS_rustc_privacy := rustc log syntax
81+
DEPS_rustc_lint := rustc log syntax
8182
DEPS_rustc := syntax flate arena serialize getopts rbml \
8283
log graphviz rustc_llvm rustc_back
8384
DEPS_rustc_llvm := native:rustllvm libc std
8485
DEPS_rustc_back := std syntax rustc_llvm flate log libc
8586
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
86-
test
87+
test rustc_lint
8788
DEPS_rustc_bitflags := core
8889
DEPS_flate := std native:miniz
8990
DEPS_arena := std
@@ -128,11 +129,13 @@ DOC_CRATES := $(filter-out rustc, \
128129
$(filter-out rustc_resolve, \
129130
$(filter-out rustc_driver, \
130131
$(filter-out rustc_privacy, \
132+
$(filter-out rustc_lint, \
131133
$(filter-out log, \
132134
$(filter-out getopts, \
133-
$(filter-out syntax, $(CRATES)))))))))))
135+
$(filter-out syntax, $(CRATES))))))))))))
134136
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
135-
rustc_typeck rustc_driver syntax rustc_privacy
137+
rustc_typeck rustc_driver syntax rustc_privacy \
138+
rustc_lint
136139

137140
# This macro creates some simple definitions for each crate being built, just
138141
# some munging of all of the parameters above.

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(eval $(call RUST_CRATE,coretest))
2121

2222
TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) coretest
2323
TEST_DOC_CRATES = $(DOC_CRATES)
24-
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans,\
24+
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans rustc_lint,\
2525
$(HOST_CRATES))
2626
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
2727

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#![feature(unsafe_destructor)]
4040
#![feature(staged_api)]
4141
#![feature(std_misc)]
42-
#![feature(unicode)]
4342
#![feature(os)]
4443
#![cfg_attr(test, feature(test))]
4544

0 commit comments

Comments
 (0)