Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[breaking change] Remove a rustdoc back compat warning #107291

Merged
merged 2 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions compiler/rustc_interface/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ interface_mixed_bin_crate =
interface_mixed_proc_macro_crate =
cannot mix `proc-macro` crate type with others

interface_proc_macro_doc_without_arg =
Trying to document proc macro crate without passing '--crate-type proc-macro to rustdoc
.warn = The generated documentation may be incorrect

interface_error_writing_dependencies =
error writing dependencies to `{$path}`: {$error}

Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_interface/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ pub struct MixedBinCrate;
#[diag(interface_mixed_proc_macro_crate)]
pub struct MixedProcMacroCrate;

#[derive(Diagnostic)]
#[diag(interface_proc_macro_doc_without_arg)]
pub struct ProcMacroDocWithoutArg;

#[derive(Diagnostic)]
#[diag(interface_error_writing_dependencies)]
pub struct ErrorWritingDependencies<'a> {
Expand Down
34 changes: 12 additions & 22 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,18 @@ fn configure_and_expand(mut krate: ast::Crate, resolver: &mut Resolver<'_, '_>)
sess.emit_warning(errors::ProcMacroCratePanicAbort);
}

// For backwards compatibility, we don't try to run proc macro injection
// if rustdoc is run on a proc macro crate without '--crate-type proc-macro' being
// specified. This should only affect users who manually invoke 'rustdoc', as
// 'cargo doc' will automatically pass the proper '--crate-type' flags.
// However, we do emit a warning, to let such users know that they should
// start passing '--crate-type proc-macro'
if has_proc_macro_decls && sess.opts.actually_rustdoc && !is_proc_macro_crate {
sess.emit_warning(errors::ProcMacroDocWithoutArg);
} else {
krate = sess.time("maybe_create_a_macro_crate", || {
let is_test_crate = sess.opts.test;
rustc_builtin_macros::proc_macro_harness::inject(
sess,
resolver,
krate,
is_proc_macro_crate,
has_proc_macro_decls,
is_test_crate,
sess.diagnostic(),
)
});
}
krate = sess.time("maybe_create_a_macro_crate", || {
let is_test_crate = sess.opts.test;
rustc_builtin_macros::proc_macro_harness::inject(
sess,
resolver,
krate,
is_proc_macro_crate,
has_proc_macro_decls,
is_test_crate,
sess.diagnostic(),
)
});

// Done with macro expansion!

Expand Down
12 changes: 12 additions & 0 deletions tests/rustdoc-ui/proc_macro_bug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// regression test for failing to pass `--crate-type proc-macro` to rustdoc
// when documenting a proc macro crate https://github.com/rust-lang/rust/pull/107291

extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro_derive(DeriveA)]
//~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
pub fn a_derive(input: TokenStream) -> TokenStream {
input
}
8 changes: 8 additions & 0 deletions tests/rustdoc-ui/proc_macro_bug.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
--> $DIR/proc_macro_bug.rs:8:1
|
LL | #[proc_macro_derive(DeriveA)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error