Skip to content

Commit

Permalink
Make all proc-macro back-compat lints deny-by-default
Browse files Browse the repository at this point in the history
The affected crates have had plenty of time to update.
By keeping these as lints rather than making them hard errors,
we ensure that downstream crates will still be able to compile,
even if they transitive depend on broken versions of the affected
crates.

This should hopefully discourage anyone from writing any
new code which relies on the backwards-compatibility behavior.
  • Loading branch information
Aaron1011 committed Aug 15, 2021
1 parent 8007b50 commit cbfd873
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 79 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ declare_lint! {
/// [issue #50504]: https://github.com/rust-lang/rust/issues/50504
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
Warn,
Deny,
"detects proc macro derives using inaccessible names from parent modules",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
Expand Down Expand Up @@ -3239,7 +3239,7 @@ declare_lint! {
/// [issue #83125]: https://github.com/rust-lang/rust/issues/83125
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub PROC_MACRO_BACK_COMPAT,
Warn,
Deny,
"detects usage of old versions of certain proc-macro crates",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/proc-macro/generate-mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `OuterAttr` in this scope
struct S;

#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope
//~| WARN cannot find type `OuterDerive` in this scope
#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `OuterDerive` in this scope
//~| WARN this was previously accepted
//~| WARN this was previously accepted
struct Z;

fn inner_block() {
#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope
//~| WARN cannot find type `OuterDerive` in this scope
#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope
//~| ERROR cannot find type `OuterDerive` in this scope
//~| WARN this was previously accepted
//~| WARN this was previously accepted
struct InnerZ;
Expand Down
20 changes: 10 additions & 10 deletions src/test/ui/proc-macro/generate-mod.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,47 +38,47 @@ LL | #[generate_mod::check_attr]
OuterAttr
= note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: cannot find type `FromOutside` in this scope
error: cannot find type `FromOutside` in this scope
--> $DIR/generate-mod.rs:16:10
|
LL | #[derive(generate_mod::CheckDerive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
= note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
= note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: cannot find type `OuterDerive` in this scope
error: cannot find type `OuterDerive` in this scope
--> $DIR/generate-mod.rs:16:10
|
LL | #[derive(generate_mod::CheckDerive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: cannot find type `FromOutside` in this scope
error: cannot find type `FromOutside` in this scope
--> $DIR/generate-mod.rs:23:14
|
LL | #[derive(generate_mod::CheckDerive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: cannot find type `OuterDerive` in this scope
error: cannot find type `OuterDerive` in this scope
--> $DIR/generate-mod.rs:23:14
|
LL | #[derive(generate_mod::CheckDerive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
= note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 4 previous errors; 4 warnings emitted
error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0412`.
11 changes: 5 additions & 6 deletions src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// check-pass
// aux-build:pin-project-internal-0.4.0.rs
// compile-flags: -Z span-debug

Expand All @@ -24,7 +23,7 @@ mod no_version {
}

struct Foo;
impl_macros!(Foo); //~ WARN using an old version
impl_macros!(Foo); //~ ERROR using an old version
//~| WARN this was previously
arrays!(Foo);
other!(Foo);
Expand All @@ -41,9 +40,9 @@ mod with_version {
}

struct Foo;
impl_macros!(Foo); //~ WARN using an old version
impl_macros!(Foo); //~ ERROR using an old version
//~| WARN this was previously
arrays!(Foo); //~ WARN using an old version
arrays!(Foo); //~ ERROR using an old version
//~| WARN this was previously
other!(Foo);
}
Expand All @@ -52,15 +51,15 @@ mod actix_web_test {
include!("actix-web/src/extract.rs");

struct Foo;
tuple_from_req!(Foo); //~ WARN using an old version
tuple_from_req!(Foo); //~ ERROR using an old version
//~| WARN this was previously
}

mod actix_web_version_test {
include!("actix-web-2.0.0/src/extract.rs");

struct Foo;
tuple_from_req!(Foo); //~ WARN using an old version
tuple_from_req!(Foo); //~ ERROR using an old version
//~| WARN this was previously
}

Expand Down
66 changes: 33 additions & 33 deletions src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr
Original file line number Diff line number Diff line change
@@ -1,169 +1,169 @@
warning: using an old version of `time-macros-impl`
error: using an old version of `time-macros-impl`
--> $DIR/time-macros-impl/src/lib.rs:5:32
|
LL | #[my_macro] struct One($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:27:5
::: $DIR/group-compat-hack.rs:26:5
|
LL | impl_macros!(Foo);
| ------------------ in this macro invocation
|
= note: `#[warn(proc_macro_back_compat)]` on by default
= note: `#[deny(proc_macro_back_compat)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using an old version of `time-macros-impl`
error: using an old version of `time-macros-impl`
--> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32
|
LL | #[my_macro] struct One($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:44:5
::: $DIR/group-compat-hack.rs:43:5
|
LL | impl_macros!(Foo);
| ------------------ in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using an old version of `js-sys`
error: using an old version of `js-sys`
--> $DIR/js-sys-0.3.17/src/lib.rs:5:32
|
LL | #[my_macro] struct Two($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:46:5
::: $DIR/group-compat-hack.rs:45:5
|
LL | arrays!(Foo);
| ------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above
= note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using an old version of `actix-web`
error: using an old version of `actix-web`
--> $DIR/actix-web/src/extract.rs:5:34
|
LL | #[my_macro] struct Three($T);
| ^^
|
::: $DIR/group-compat-hack.rs:55:5
::: $DIR/group-compat-hack.rs:54:5
|
LL | tuple_from_req!(Foo);
| --------------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
= note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: using an old version of `actix-web`
error: using an old version of `actix-web`
--> $DIR/actix-web-2.0.0/src/extract.rs:5:34
|
LL | #[my_macro] struct Three($T);
| ^^
|
::: $DIR/group-compat-hack.rs:63:5
::: $DIR/group-compat-hack.rs:62:5
|
LL | tuple_from_req!(Foo);
| --------------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
= note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 5 warnings emitted
error: aborting due to 5 previous errors

Future incompatibility report: Future breakage diagnostic:
warning: using an old version of `time-macros-impl`
error: using an old version of `time-macros-impl`
--> $DIR/time-macros-impl/src/lib.rs:5:32
|
LL | #[my_macro] struct One($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:27:5
::: $DIR/group-compat-hack.rs:26:5
|
LL | impl_macros!(Foo);
| ------------------ in this macro invocation
|
= note: `#[warn(proc_macro_back_compat)]` on by default
= note: `#[deny(proc_macro_back_compat)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
warning: using an old version of `time-macros-impl`
error: using an old version of `time-macros-impl`
--> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32
|
LL | #[my_macro] struct One($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:44:5
::: $DIR/group-compat-hack.rs:43:5
|
LL | impl_macros!(Foo);
| ------------------ in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
warning: using an old version of `js-sys`
error: using an old version of `js-sys`
--> $DIR/js-sys-0.3.17/src/lib.rs:5:32
|
LL | #[my_macro] struct Two($name);
| ^^^^^
|
::: $DIR/group-compat-hack.rs:46:5
::: $DIR/group-compat-hack.rs:45:5
|
LL | arrays!(Foo);
| ------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above
= note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
warning: using an old version of `actix-web`
error: using an old version of `actix-web`
--> $DIR/actix-web/src/extract.rs:5:34
|
LL | #[my_macro] struct Three($T);
| ^^
|
::: $DIR/group-compat-hack.rs:55:5
::: $DIR/group-compat-hack.rs:54:5
|
LL | tuple_from_req!(Foo);
| --------------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
= note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)

Future breakage diagnostic:
warning: using an old version of `actix-web`
error: using an old version of `actix-web`
--> $DIR/actix-web-2.0.0/src/extract.rs:5:34
|
LL | #[my_macro] struct Three($T);
| ^^
|
::: $DIR/group-compat-hack.rs:63:5
::: $DIR/group-compat-hack.rs:62:5
|
LL | tuple_from_req!(Foo);
| --------------------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
= note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
= note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)

Loading

0 comments on commit cbfd873

Please sign in to comment.