From 34c3e2462c7eadd7f3ec475469697dd19360c3d3 Mon Sep 17 00:00:00 2001 From: Ngo Iok Ui Date: Sat, 20 Mar 2021 19:43:22 +0800 Subject: [PATCH 1/3] Generate docs for core and alloc locally --- rust/Makefile | 21 +++++++++++++++------ rust/compiler_builtins.rs | 1 + rust/kernel/lib.rs | 1 + rust/module.rs | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index eb8f12ce1644ea..5c58ad536833e1 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -6,6 +6,10 @@ extra-$(CONFIG_RUST) += bindings_generated.rs libmodule.so extra-$(CONFIG_RUST) += exports_core_generated.h exports_alloc_generated.h extra-$(CONFIG_RUST) += exports_kernel_generated.h +# `$(rustc_flags)` is passed in case the user added `--sysroot`. +rustc_sysroot = $(shell $(RUSTC) $(rustc_flags) --print sysroot) +rustc_src = $(rustc_sysroot)/lib/rustlib/src/rust + RUSTDOC = rustdoc quiet_cmd_rustdoc = RUSTDOC $< @@ -14,9 +18,13 @@ quiet_cmd_rustdoc = RUSTDOC $< $(RUSTDOC) $(filter-out --emit=%, $(rustc_flags)) \ $(rustdoc_target_flags) -L $(objtree)/rust/ \ --output $(objtree)/rust/doc --crate-name $(subst rustdoc-,,$@) \ - -Fmissing-docs @$(objtree)/include/generated/rustc_cfg $< + @$(objtree)/include/generated/rustc_cfg $< -rustdoc: rustdoc-module rustdoc-compiler_builtins rustdoc-kernel +rustdoc: rustdoc-core rustdoc-module rustdoc-compiler_builtins rustdoc-alloc rustdoc-kernel + +rustdoc-core: private skip_clippy = 1 +rustdoc-core: $(rustc_src)/library/core/src/lib.rs FORCE + $(call if_changed,rustdoc) rustdoc-module: private rustdoc_target_flags = --crate-type proc-macro \ --extern proc_macro @@ -26,6 +34,11 @@ rustdoc-module: $(srctree)/rust/module.rs FORCE rustdoc-compiler_builtins: $(srctree)/rust/compiler_builtins.rs FORCE $(call if_changed,rustdoc) +rustdoc-alloc: private skip_clippy = 1 +rustdoc-alloc: $(rustc_src)/library/alloc/src/lib.rs \ + $(objtree)/rust/compiler_builtins.o FORCE + $(call if_changed,rustdoc) + rustdoc-kernel: private rustdoc_target_flags = --extern alloc \ --extern module=$(objtree)/rust/libmodule.so rustdoc-kernel: $(srctree)/rust/kernel/lib.rs rustdoc-module \ @@ -115,10 +128,6 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L sed -i '/^\#/d' $(depfile) \ $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) -# `$(rustc_flags)` is passed in case the user added `--sysroot`. -rustc_sysroot = $(shell $(RUSTC) $(rustc_flags) --print sysroot) -rustc_src = $(rustc_sysroot)/lib/rustlib/src/rust - .SECONDEXPANSION: $(objtree)/rust/core.o: private skip_clippy = 1 $(objtree)/rust/core.o: $$(rustc_src)/library/core/src/lib.rs FORCE diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs index c8f765b1fd81e8..1ec1a6ce504754 100644 --- a/rust/compiler_builtins.rs +++ b/rust/compiler_builtins.rs @@ -29,6 +29,7 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] +#![deny(missing_docs)] macro_rules! define_panicking_intrinsics( ($reason: tt, { $($ident: ident, )* }) => { diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index 49cd6bbe20dae8..c20be5099d5404 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -17,6 +17,7 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] +#![deny(missing_docs)] // Ensure conditional compilation based on the kernel configuration works; // otherwise we may silently break things like initcall handling. diff --git a/rust/module.rs b/rust/module.rs index 7ff3c3880f23aa..2155296519dd42 100644 --- a/rust/module.rs +++ b/rust/module.rs @@ -8,6 +8,7 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] +#![deny(missing_docs)] use proc_macro::{token_stream, Delimiter, Group, TokenStream, TokenTree}; From 6b6b9e9d19398422d03f75e62469eff54be9b39e Mon Sep 17 00:00:00 2001 From: Ngo Iok Ui Date: Sat, 20 Mar 2021 22:32:37 +0800 Subject: [PATCH 2/3] Keep the forbid flag in Makefile --- rust/Makefile | 7 +++---- rust/compiler_builtins.rs | 2 +- rust/kernel/lib.rs | 1 - rust/module.rs | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rust/Makefile b/rust/Makefile index 5c58ad536833e1..b78c15136db2dd 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -22,25 +22,24 @@ quiet_cmd_rustdoc = RUSTDOC $< rustdoc: rustdoc-core rustdoc-module rustdoc-compiler_builtins rustdoc-alloc rustdoc-kernel -rustdoc-core: private skip_clippy = 1 rustdoc-core: $(rustc_src)/library/core/src/lib.rs FORCE $(call if_changed,rustdoc) rustdoc-module: private rustdoc_target_flags = --crate-type proc-macro \ - --extern proc_macro + --extern proc_macro -Fmissing-docs rustdoc-module: $(srctree)/rust/module.rs FORCE $(call if_changed,rustdoc) +rustdoc-compiler_builtins: private rustdoc_target_flags = -Fmissing-docs rustdoc-compiler_builtins: $(srctree)/rust/compiler_builtins.rs FORCE $(call if_changed,rustdoc) -rustdoc-alloc: private skip_clippy = 1 rustdoc-alloc: $(rustc_src)/library/alloc/src/lib.rs \ $(objtree)/rust/compiler_builtins.o FORCE $(call if_changed,rustdoc) rustdoc-kernel: private rustdoc_target_flags = --extern alloc \ - --extern module=$(objtree)/rust/libmodule.so + --extern module=$(objtree)/rust/libmodule.so -Fmissing-docs rustdoc-kernel: $(srctree)/rust/kernel/lib.rs rustdoc-module \ $(objtree)/rust/libmodule.so $(objtree)/rust/bindings_generated.rs FORCE $(call if_changed,rustdoc) diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs index 1ec1a6ce504754..546e7fb4f59c85 100644 --- a/rust/compiler_builtins.rs +++ b/rust/compiler_builtins.rs @@ -29,7 +29,7 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] -#![deny(missing_docs)] +#![forbid(missing_docs)] macro_rules! define_panicking_intrinsics( ($reason: tt, { $($ident: ident, )* }) => { diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index c20be5099d5404..49cd6bbe20dae8 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -17,7 +17,6 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] -#![deny(missing_docs)] // Ensure conditional compilation based on the kernel configuration works; // otherwise we may silently break things like initcall handling. diff --git a/rust/module.rs b/rust/module.rs index 2155296519dd42..96e45f2f0cd962 100644 --- a/rust/module.rs +++ b/rust/module.rs @@ -8,7 +8,7 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] -#![deny(missing_docs)] +#![forbid(missing_docs)] use proc_macro::{token_stream, Delimiter, Group, TokenStream, TokenTree}; From daa380f32b970eeec060888ec2d622b2e2f8ea7a Mon Sep 17 00:00:00 2001 From: Ngo Iok Ui Date: Sat, 20 Mar 2021 22:34:37 +0800 Subject: [PATCH 3/3] Remove missing doc lint on each crate --- rust/compiler_builtins.rs | 1 - rust/module.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs index 546e7fb4f59c85..c8f765b1fd81e8 100644 --- a/rust/compiler_builtins.rs +++ b/rust/compiler_builtins.rs @@ -29,7 +29,6 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] -#![forbid(missing_docs)] macro_rules! define_panicking_intrinsics( ($reason: tt, { $($ident: ident, )* }) => { diff --git a/rust/module.rs b/rust/module.rs index 96e45f2f0cd962..7ff3c3880f23aa 100644 --- a/rust/module.rs +++ b/rust/module.rs @@ -8,7 +8,6 @@ #![deny(clippy::correctness)] #![deny(clippy::perf)] #![deny(clippy::style)] -#![forbid(missing_docs)] use proc_macro::{token_stream, Delimiter, Group, TokenStream, TokenTree};