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 Oct 18, 2021
1 parent 5dab47d commit 02e4d0b
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 88 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Expand Up @@ -1957,7 +1957,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 @@ -3253,7 +3253,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
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
38 changes: 19 additions & 19 deletions src/test/ui/proc-macro/generate-mod.stderr
Expand Up @@ -38,94 +38,94 @@ 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`.
Future incompatibility report: Future breakage diagnostic:
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)

Future breakage diagnostic:
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)

Future breakage diagnostic:
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)

Future breakage diagnostic:
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)

Future breakage diagnostic:
warning: cannot find type `FromOutside` in this scope
Expand Down
11 changes: 5 additions & 6 deletions src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs
@@ -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

0 comments on commit 02e4d0b

Please sign in to comment.