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

Deprecate no_debug and custom_derive #37128

Merged
merged 5 commits into from
Oct 27, 2016
Merged

Deprecate no_debug and custom_derive #37128

merged 5 commits into from
Oct 27, 2016

Conversation

nrc
Copy link
Member

@nrc nrc commented Oct 12, 2016

@nrc nrc added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 12, 2016
@nrc
Copy link
Member Author

nrc commented Oct 12, 2016

cc #29721 and #29644

@bors
Copy link
Contributor

bors commented Oct 13, 2016

☔ The latest upstream changes (presumably #37118) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; left a few suggestions for improvement.

..) = g {
cx.span_lint(DEPRECATED,
attr.span,
&format!("use of deprecated attribute: {}", name));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: probably we want:

"use of deprecated attribute: `{}`"
                   //         ^  ^ note ticks

right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, let's link the deprecation to a tracking issue

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the format for deprecated items. That probably should have back ticks too (added), but we don't have the tracking issue number anywhere so we can't link to it very easily.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well for deprecated items we give a reason, right? I imagined adding the issue number (or maybe just a string) to the Deprecated variant of Stability, in any case.

let name = &*attr.name();
for &(n, _, ref g) in feature_gate::KNOWN_ATTRIBUTES {
if n == name {
if let &feature_gate::AttributeGate::Gated(feature_gate::Stability::Deprecated,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this seems mega-inefficient...but probably it doesn't matter as there aren't that many attributes, and that table ain't that long, I guess?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At minimum we could filter out the list of deprecations once rather than per attribute =)

// fn() is not Debug
impl ::std::fmt::Debug for AttributeGate {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match *self {
Gated(ref name, ref expl, _) => write!(fmt, "Gated({}, {})", name, expl),
Gated(_, ref name, ref expl, _) => write!(fmt, "Gated({}, {})", name, expl),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why exclude Stability from the Debug printout?

@nrc
Copy link
Member Author

nrc commented Oct 18, 2016

@nikomatsakis changes made

@nrc
Copy link
Member Author

nrc commented Oct 18, 2016

More changes for review

@bors
Copy link
Contributor

bors commented Oct 19, 2016

☔ The latest upstream changes (presumably #37269) made this pull request unmergeable. Please resolve the merge conflicts.

@nrc
Copy link
Member Author

nrc commented Oct 19, 2016

rebased

@nikomatsakis
Copy link
Contributor

tidy errors:

/build/src/libsyntax/feature_gate.rs:672: line longer than 100 chars

@nikomatsakis
Copy link
Contributor

r=me once tidy is fixed; thanks

@nrc
Copy link
Member Author

nrc commented Oct 19, 2016

@bors: r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 19, 2016

📌 Commit f6e0b3a has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 20, 2016

⌛ Testing commit f6e0b3a with merge 5694dd1...

@bors
Copy link
Contributor

bors commented Oct 20, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton alexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 24, 2016
@nikomatsakis
Copy link
Contributor

@nrc

---- [compile-fail] compile-fail\feature-gate-no-debug-2.rs stdout ----

error: C:/bot/slave/auto-win-gnu-32-opt-rustbuild/build/src/test/compile-fail/feature-gate-no-debug-2.rs:14: unexpected "error": '14:1: 14:12: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute is an experimental feature. See https://github.com/rust-lang/rust/issues/29721'

error: C:/bot/slave/auto-win-gnu-32-opt-rustbuild/build/src/test/compile-fail/feature-gate-no-debug-2.rs:14: expected error not found: use of deprecated attribute: no_debug

error: 1 unexpected errors found, 1 expected errors not found
status: exit code: 101
command: PATH="C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2\bin;C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2-tools\i686-pc-windows-gnu\release\deps;C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2-rustc\i686-pc-windows-gnu\release\deps;C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2-test\i686-pc-windows-gnu\release\deps;C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2-std\i686-pc-windows-gnu\release\deps;C:\mingw-w64\i686-4.9.1-win32-dwarf-rt_v3-rev1\mingw32\bin;C:\Python27;C:\msys64\mingw32\bin;C:\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\msys64\usr\bin;C:\python27;C:\python27\scripts;C:\program files (x86)\inno setup 5;C:\program files (x86)\CMake\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files\CMake\bin" C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\stage2\bin\rustc.exe C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\src/test\compile-fail\feature-gate-no-debug-2.rs -L C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\test\compile-fail --target=i686-pc-windows-gnu --error-format json -L C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\test\compile-fail\feature-gate-no-debug-2.stage2-i686-pc-windows-gnu.compile-fail.libaux -C prefer-dynamic -o C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\test\compile-fail\feature-gate-no-debug-2.stage2-i686-pc-windows-gnu.exe -Crpath -O -Lnative=C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\obj\build\i686-pc-windows-gnu\rust-test-helpers
unexpected errors (from JSON output): [
    Error {
        line_num: 14,
        kind: Some(
            Error
        ),
        msg: "14:1: 14:12: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute is an experimental feature. See https://github.com/rust-lang/rust/issues/29721"
    }
]

not found errors (from test file): [
    Error {
        line_num: 14,
        kind: Some(
            Error
        ),
        msg: "use of deprecated attribute: no_debug"
    }
]

thread '[compile-fail] compile-fail\feature-gate-no-debug-2.rs' panicked at 'explicit panic', C:\bot\slave\auto-win-gnu-32-opt-rustbuild\build\src\tools\compiletest\src\runtest.rs:1097
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    [compile-fail] compile-fail\feature-gate-no-debug-2.rs

@nrc
Copy link
Member Author

nrc commented Oct 25, 2016

@bors: r=@nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 25, 2016

📌 Commit 38f993f has been approved by @nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 25, 2016

⌛ Testing commit 38f993f with merge 98cb0c3...

bors added a commit that referenced this pull request Oct 25, 2016
Deprecate no_debug and custom_derive

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Oct 25, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member

alexcrichton commented Oct 25, 2016

Ok that failure corresponds to a failure to free on Windows. That's terrifying!

@bors: retry

@bors
Copy link
Contributor

bors commented Oct 25, 2016

⌛ Testing commit 38f993f with merge 3c4de7f...

@bors
Copy link
Contributor

bors commented Oct 25, 2016

💔 Test failed - auto-mac-64-opt

@alexcrichton
Copy link
Member

@bors: retry

@nikomatsakis
Copy link
Contributor

I'm inclined not to backport at this point. Not because it's harmful per se but just because we can just push deprecation back one cycle, so why not? What do you think @nrc?

@nrc
Copy link
Member Author

nrc commented Oct 25, 2016

@nikomatsakis yeah, it is getting kind of late into the cycle for a backport.

@nikomatsakis nikomatsakis removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 25, 2016
@nikomatsakis
Copy link
Contributor

Removed beta-nominated tag: decided against backport.

@bors
Copy link
Contributor

bors commented Oct 26, 2016

⌛ Testing commit 38f993f with merge 918bc3a...

@bors
Copy link
Contributor

bors commented Oct 26, 2016

💔 Test failed - auto-linux-64-opt

@alexcrichton
Copy link
Member

Hm that's two segfaults at the same location on two different platforms, maybe a legitimate segfault?

@nrc
Copy link
Member Author

nrc commented Oct 26, 2016

Dammit, Rust is not meant to segfault

@nrc
Copy link
Member Author

nrc commented Oct 27, 2016

@bors: r=@alexcrichton

@bors
Copy link
Contributor

bors commented Oct 27, 2016

📌 Commit 8c4a39c has been approved by @alexcrichton

@bors
Copy link
Contributor

bors commented Oct 27, 2016

⌛ Testing commit 8c4a39c with merge 46d39f3...

bors added a commit that referenced this pull request Oct 27, 2016
Deprecate no_debug and custom_derive

r? @nikomatsakis
@bors bors merged commit 8c4a39c into rust-lang:master Oct 27, 2016
@nrc
Copy link
Member Author

nrc commented Oct 27, 2016

FTR r was nikomatsakis, not alexcrichton

@SergioBenitez
Copy link
Contributor

I'd like to request that this deprecation be reverted, and I plan on submitting a PR to do so. This deprecation penalizes developers that write multiple types of syntax extensions instead of only custom derives, and it seems unnecessary while macros 2.0 are still some time away.

At present, it is possible to have a single codegen crate that implements custom attributes, custom derives, and procedural macros. All of these syntax extensions can be imported into a project with:

#![feature(plugin, custom_derive)]
#![plugin(codegen_crate)]

With this deprecation, however, this is no longer possible.

The alternative, of course, is to use macros 1.1. But custom derives via macros 1.1 must be implemented in a separate crate of type proc-macro. As a result, a second crate must be created. This means that a project using custom derives and custom attributes or procedural macros must implement syntax extensions in two different crates, and users using that project must depend on both crates and import the syntax extensions in two different ways:

#![feature(plugin)]
#![plugin(codegen_crate)]

#[macro_use] extern crate derive_crate;

I believe this will lead to user confusion: syntax extensions are now coming from two different crates, and they must be imported via completely different mechanisms. While before a single declaration brought in all syntax extensions, now two different declarations are used to bring in syntax extensions.

This is also significantly more unergonomic for the developer. This is because it is no longer feasible to easily share code between custom derives and other syntax extensions. The work-arounds are to have one create depend on the other, pushing logic to one "master" crate, or to create a third crate that contains the shared logic. Clearly, neither are as ergonomic as the existing implementation.

All of this issues will likely be ameliorated by the unification macros 2.0 promises to bring. But macros 2.0 won't land in a nightly release any time soon, and they won't be stabilized until quite some time after that. So why deprecate this unnecessarily early? It penalizes developers that write multiple types of syntax extensions. We should keep this around until macros 2.0 are within reach of stabilization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants