Skip to content

Commit a4119ba

Browse files
Rollup merge of #107291 - oli-obk:rustdoc_breaking_change, r=estebank
[breaking change] Remove a rustdoc back compat warning This warning was introduced in #62855 for users who use `rustdoc` directly on proc macro crates (instead of using `cargo doc`) without passing `--crate-type proc-macro` (which `cargo doc` passed automatically).
2 parents b90a385 + 60b0da1 commit a4119ba

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

compiler/rustc_interface/locales/en-US.ftl

-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ interface_mixed_bin_crate =
1111
interface_mixed_proc_macro_crate =
1212
cannot mix `proc-macro` crate type with others
1313
14-
interface_proc_macro_doc_without_arg =
15-
Trying to document proc macro crate without passing '--crate-type proc-macro to rustdoc
16-
.warn = The generated documentation may be incorrect
17-
1814
interface_error_writing_dependencies =
1915
error writing dependencies to `{$path}`: {$error}
2016

compiler/rustc_interface/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ pub struct MixedBinCrate;
3131
#[diag(interface_mixed_proc_macro_crate)]
3232
pub struct MixedProcMacroCrate;
3333

34-
#[derive(Diagnostic)]
35-
#[diag(interface_proc_macro_doc_without_arg)]
36-
pub struct ProcMacroDocWithoutArg;
37-
3834
#[derive(Diagnostic)]
3935
#[diag(interface_error_writing_dependencies)]
4036
pub struct ErrorWritingDependencies<'a> {

compiler/rustc_interface/src/passes.rs

+12-22
Original file line numberDiff line numberDiff line change
@@ -287,28 +287,18 @@ fn configure_and_expand(mut krate: ast::Crate, resolver: &mut Resolver<'_, '_>)
287287
sess.emit_warning(errors::ProcMacroCratePanicAbort);
288288
}
289289

290-
// For backwards compatibility, we don't try to run proc macro injection
291-
// if rustdoc is run on a proc macro crate without '--crate-type proc-macro' being
292-
// specified. This should only affect users who manually invoke 'rustdoc', as
293-
// 'cargo doc' will automatically pass the proper '--crate-type' flags.
294-
// However, we do emit a warning, to let such users know that they should
295-
// start passing '--crate-type proc-macro'
296-
if has_proc_macro_decls && sess.opts.actually_rustdoc && !is_proc_macro_crate {
297-
sess.emit_warning(errors::ProcMacroDocWithoutArg);
298-
} else {
299-
krate = sess.time("maybe_create_a_macro_crate", || {
300-
let is_test_crate = sess.opts.test;
301-
rustc_builtin_macros::proc_macro_harness::inject(
302-
sess,
303-
resolver,
304-
krate,
305-
is_proc_macro_crate,
306-
has_proc_macro_decls,
307-
is_test_crate,
308-
sess.diagnostic(),
309-
)
310-
});
311-
}
290+
krate = sess.time("maybe_create_a_macro_crate", || {
291+
let is_test_crate = sess.opts.test;
292+
rustc_builtin_macros::proc_macro_harness::inject(
293+
sess,
294+
resolver,
295+
krate,
296+
is_proc_macro_crate,
297+
has_proc_macro_decls,
298+
is_test_crate,
299+
sess.diagnostic(),
300+
)
301+
});
312302

313303
// Done with macro expansion!
314304

tests/rustdoc-ui/proc_macro_bug.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// regression test for failing to pass `--crate-type proc-macro` to rustdoc
2+
// when documenting a proc macro crate https://github.com/rust-lang/rust/pull/107291
3+
4+
extern crate proc_macro;
5+
6+
use proc_macro::TokenStream;
7+
8+
#[proc_macro_derive(DeriveA)]
9+
//~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
10+
pub fn a_derive(input: TokenStream) -> TokenStream {
11+
input
12+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
2+
--> $DIR/proc_macro_bug.rs:8:1
3+
|
4+
LL | #[proc_macro_derive(DeriveA)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)