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

Make future-incompat-report output more user-friendly #9953

Merged
merged 13 commits into from
Oct 19, 2021

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Oct 1, 2021

When the user enables --future-incompat-report, we now display
a high-level summary of the problem, as well as several suggestions
for fixing the affected crates.

The command cargo report future-incompatibilities now takes
a --crate option, which can be used to display a report
(including the actual lint messages) for a single crate.
When this option is not used, we display the report for all
crates.

Sample output from the actix crate:

> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo build -Z future-incompat-report

    Finished dev [unoptimized + debuginfo] target(s) in 2.09s
warning: the following packages contain code that will be rejected by a future version of Rust: actix v0.11.1 (/home/aaron/repos/actix/actix), ahash v0.7.4, arc-swap v0.4.4, autocfg v1.0.0, crossbeam-utils v0.8.5, futures-macro v0.3.17, futures-util v0.3.17, lazy_static v1.4.0, libc v0.2.103, lock_api v0.4.5, log v0.4.8, mio v0.7.13, parking_lot_core v0.8.5, signal-hook-registry v1.2.0, smallvec v1.7.0, syn v1.0.77, tokio v1.12.0, tokio-util v0.6.8, unicode-xid v0.2.0, version_check v0.9.3
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`

> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo build -Z future-incompat-report --future-incompat-report -Z unstable-options

    Finished dev [unoptimized + debuginfo] target(s) in 2.12s
warning: the following packages contain code that will be rejected by a future version of Rust: actix v0.11.1 (/home/aaron/repos/actix/actix), ahash v0.7.4, arc-swap v0.4.4, autocfg v1.0.0, crossbeam-utils v0.8.5, futures-macro v0.3.17, futures-util v0.3.17, lazy_static v1.4.0, libc v0.2.103, lock_api v0.4.5, log v0.4.8, mio v0.7.13, parking_lot_core v0.8.5, signal-hook-registry v1.2.0, smallvec v1.7.0, syn v1.0.77, tokio v1.12.0, tokio-util v0.6.8, unicode-xid v0.2.0, version_check v0.9.3
note: 
To solve this problem, you can try the following approaches:


- Some affected dependencies have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

ahash v0.7.4 has the following newer versions available: 0.7.5
arc-swap v0.4.4 has the following newer versions available: 0.4.8, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0
autocfg v1.0.0 has the following newer versions available: 1.0.1
log v0.4.8 has the following newer versions available: 0.4.11, 0.4.13, 0.4.14
signal-hook-registry v1.2.0 has the following newer versions available: 1.2.1, 1.2.2, 1.3.0, 1.4.0
syn v1.0.77 has the following newer versions available: 1.0.78, 1.0.79, 1.0.80
unicode-xid v0.2.0 has the following newer versions available: 0.2.1, 0.2.2

- If the issue is not solved by updating the dependencies, a fix has to be
  implemented by those dependencies. You can help with that by notifying the
  maintainers of this problem (e.g. by creating a bug report) or by proposing a
  fix to the maintainers (e.g. by creating a pull request):
  
  - actix:0.11.1
    - Repository: https://github.com/actix/actix
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "actix:0.11.1"

  - ahash:0.7.4
    - Repository: https://github.com/tkaitchuck/ahash
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "ahash:0.7.4"

  - arc-swap:0.4.4
    - Repository: https://github.com/vorner/arc-swap
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "arc-swap:0.4.4"

  - autocfg:1.0.0
    - Repository: https://github.com/cuviper/autocfg
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "autocfg:1.0.0"

  - crossbeam-utils:0.8.5
    - Repository: https://github.com/crossbeam-rs/crossbeam
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "crossbeam-utils:0.8.5"

  - futures-macro:0.3.17
    - Repository: https://github.com/rust-lang/futures-rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "futures-macro:0.3.17"

  - futures-util:0.3.17
    - Repository: https://github.com/rust-lang/futures-rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "futures-util:0.3.17"

  - lazy_static:1.4.0
    - Repository: https://github.com/rust-lang-nursery/lazy-static.rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "lazy_static:1.4.0"

  - libc:0.2.103
    - Repository: https://github.com/rust-lang/libc
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "libc:0.2.103"

  - lock_api:0.4.5
    - Repository: https://github.com/Amanieu/parking_lot
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "lock_api:0.4.5"

  - log:0.4.8
    - Repository: https://github.com/rust-lang/log
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "log:0.4.8"

  - mio:0.7.13
    - Repository: https://github.com/tokio-rs/mio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "mio:0.7.13"

  - parking_lot_core:0.8.5
    - Repository: https://github.com/Amanieu/parking_lot
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "parking_lot_core:0.8.5"

  - signal-hook-registry:1.2.0
    - Repository: https://github.com/vorner/signal-hook
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "signal-hook-registry:1.2.0"

  - smallvec:1.7.0
    - Repository: https://github.com/servo/rust-smallvec
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "smallvec:1.7.0"

  - syn:1.0.77
    - Repository: https://github.com/dtolnay/syn
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "syn:1.0.77"

  - tokio:1.12.0
    - Repository: https://github.com/tokio-rs/tokio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "tokio:1.12.0"

  - tokio-util:0.6.8
    - Repository: https://github.com/tokio-rs/tokio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "tokio-util:0.6.8"

  - unicode-xid:0.2.0
    - Repository: https://github.com/unicode-rs/unicode-xid
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "unicode-xid:0.2.0"

  - version_check:0.9.3
    - Repository: https://github.com/SergioBenitez/version_check
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "version_check:0.9.3"

- If waiting for an upstream fix is not an option, you can use the `[patch]`
  section in `Cargo.toml` to use your own version of the dependency. For more
  information, see:
  https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
            
note: this report can be shown with `cargo report future-incompatibilities -Z future-incompat-report --id 3`

> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo report future-incompatibilities -Z future-incompat-report --color never | head -n 100

The following warnings were discovered during the build. These warnings are an
indication that the packages contain code that will become an error in a
future release of Rust. These warnings typically cover changes to close
soundness problems, unintended or undocumented behavior, or critical problems
that cannot be fixed in a backwards-compatible fashion, and are not expected
to be in wide use.

Each warning should contain a link for more information on what the warning
means and how to resolve it.


- Some affected dependencies have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

ahash v0.7.4 has the following newer versions available: 0.7.5
arc-swap v0.4.4 has the following newer versions available: 0.4.8, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0
autocfg v1.0.0 has the following newer versions available: 1.0.1
log v0.4.8 has the following newer versions available: 0.4.11, 0.4.13, 0.4.14
signal-hook-registry v1.2.0 has the following newer versions available: 1.2.1, 1.2.2, 1.3.0, 1.4.0
syn v1.0.77 has the following newer versions available: 1.0.78, 1.0.79, 1.0.80
unicode-xid v0.2.0 has the following newer versions available: 0.2.1, 0.2.2

The package `actix v0.11.1 (/home/aaron/repos/actix/actix)` currently triggers the following future incompatibility lints:
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:25:9
>    |
> 25 | impl<T> Condition<T>
>    |         ^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> actix/src/lib.rs:30:10
>    |
> 30 | #![allow(deprecated)]
>    |          ^^^^^^^^^^
> 
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:42:21
>    |
> 42 | impl<T> Default for Condition<T>
>    |                     ^^^^^^^^^
> 
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:47:9
>    |
> 47 |         Condition {
>    |         ^^^^^^^^^
> 
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>    --> actix/src/lib.rs:120:28
>     |
> 120 |     pub use crate::utils::{Condition, IntervalFunc, TimerFunc};
>     |                            ^^^^^^^^^
> 
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:512:49
>     |
> 512 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
> 
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:636:49
>     |
> 636 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
> 
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:697:49
>     |
> 697 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
> 
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:31:9
>    |
> 31 |         self.waiters.push(tx);
>    |         ^^^^^^^^^^^^
> 
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:36:23
>    |
> 36 |         for waiter in self.waiters {
>    |                       ^^^^^^^^^^^^
> 
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:48:13
>    |
> 48 |             waiters: Vec::new(),
>    |             ^^^^^^^^^^^^^^^^^^^
> 
> warning: unused variable: `ctx`
>   --> actix/src/actor.rs:78:27
>    |
> 78 |     fn started(&mut self, ctx: &mut Self::Context) {}
>    |                           ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`
>    |
> note: the lint level is defined here
>   --> actix/src/actor.rs:72:9
>    |
> 72 | #[allow(unused_variables)]
>    |         ^^^^^^^^^^^^^^^^

@rust-highfive
Copy link

r? @Eh2406

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 1, 2021
@Aaron1011
Copy link
Member Author

cc @LukasKalbertodt @alexcrichton

@alexcrichton
Copy link
Member

Seems pretty reasonable to me, thanks for this! One question I would have, although this is probably unrelated to this PR specifically, is what's going on here:

> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:25:9
>    |
> 25 | impl<T> Condition<T>
>    |         ^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> actix/src/lib.rs:30:10
>    |
> 30 | #![allow(deprecated)]
>    |          ^^^^^^^^^^
> 

In your last code-block the cargo report future-incompatibilities command seems to print warnings about deprecated items rather than future-incompat items, and I was curious why that was the case? I figured that lints were tagged as future-incompat and we'd only present those lints rather than all the lints from the crate. The specific error above is also bit odd in that it's warning about deprecation and points to a snippet which explicitly allows deprecation.

@Aaron1011
Copy link
Member Author

@alexcrichton: I'm using the special -Z future-incompat-test option, which makes all lints be reported as future-incompat lints.

@alexcrichton
Copy link
Member

Ah I see, makes sense! In that case I'd be happy to r+ this, but I'd like to confirm with @ehuss first.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Thanks!

This seems to remove the suggestions on how to update from cargo report future-incompat. Can those be retained? I suspect the normal behavior is that someone runs cargo build, and gets the message to run with the flag or cargo report future-incompat, and if they run the second command, they will never see the suggestions.

src/bin/cargo/commands/report.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
.collect::<Vec<_>>()
.join("\n")
};
let to_display = if config.shell().err_supports_color() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed a small bug while reading this: #9960 (no need to fix it now, just making a note)

src/cargo/core/compiler/job_queue.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/job_queue.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/job_queue.rs Outdated Show resolved Hide resolved
@Aaron1011 Aaron1011 force-pushed the nicer-incompat-report branch from 0424195 to 6818336 Compare October 8, 2021 20:42
@Aaron1011
Copy link
Member Author

@ehuss: I've implemented your suggestions

This seems to remove the suggestions on how to update from cargo report future-incompat. Can those be retained?

I think that would be unnecessarily verbose - the full report is already pretty long.

@ehuss
Copy link
Contributor

ehuss commented Oct 12, 2021

I think it is good to be concerned about the size and amount of detail in the report. However, I think the size increase is quite modest, and I think the information about newer versions is perhaps one of the most important parts of the message.

Looking at a sample report of a typical hit on proc_macro_back_compat, the report is 66 lines long (mostly just the warning text). Adding the version information only adds 4 lines, which I think is a pretty small increase. Those lines look like this:

The following packages appear to have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

rental v0.5.5 has the following newer versions available: 0.5.6

It seems like providing guidance on how the user can potentially fix the issue is a very important part of the message.

@ehuss ehuss assigned ehuss and unassigned Eh2406 Oct 12, 2021
When the user enables `--future-incompat-report`, we now display
a high-level summary of the problem, as well as several suggestions
for fixing the affected crates.

The command `cargo report future-incompatibilities` now takes
a `--crate` option, which can be used to display a report
(including the actual lint messages) for a single crate.
When this option is not used, we display the report for all
crates.
@Aaron1011 Aaron1011 force-pushed the nicer-incompat-report branch from ef59695 to 6f18507 Compare October 12, 2021 22:02
@Aaron1011
Copy link
Member Author

Aaron1011 commented Oct 12, 2021

@ehuss - I've adjusted the code to same the computed update message along with the report, and to display it when the report is shown.

src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/job_queue.rs Outdated Show resolved Hide resolved
@Aaron1011
Copy link
Member Author

@ehuss I've applied your feedback.

src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/job_queue.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/future_incompat.rs Outdated Show resolved Hide resolved
tests/testsuite/future_incompat_report.rs Outdated Show resolved Hide resolved
@Aaron1011
Copy link
Member Author

@ehuss - I've applied your suggestions. The on-disk report now contains the same suggestions shown in the build output.

@ehuss
Copy link
Contributor

ehuss commented Oct 19, 2021

Thanks! I appreciate you sticking with my finicky reviews.

@bors r+

@bors
Copy link
Contributor

bors commented Oct 19, 2021

📌 Commit 7ffba67 has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 19, 2021
@bors
Copy link
Contributor

bors commented Oct 19, 2021

⌛ Testing commit 7ffba67 with merge 7fbbf4e...

@bors
Copy link
Contributor

bors commented Oct 19, 2021

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 7fbbf4e to master...

@bors bors merged commit 7fbbf4e into rust-lang:master Oct 19, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 19, 2021
Update cargo

6 commits in c7957a74bdcf3b11e7154c1a9401735f23ebd484..7fbbf4e8f23e3c24b8afff541dcb17e53eb5ff88
2021-10-11 20:17:07 +0000 to 2021-10-19 02:16:48 +0000
- Make future-incompat-report output more user-friendly (rust-lang/cargo#9953)
- Fix fetching git repos after a force push. (rust-lang/cargo#9979)
- Add rustc-link-args to doctest build (rust-lang/cargo#9916)
- Add the start of a basic benchmarking suite. (rust-lang/cargo#9955)
- Use forms for issue templates. (rust-lang/cargo#9970)
- Add rust_metadata to SerializedPackage (rust-lang/cargo#9967)
@ehuss ehuss added this to the 1.58.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants