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

#92007 appears to break inference for previously compiling code #93821

Closed
hawkw opened this issue Feb 9, 2022 · 1 comment · Fixed by #93893
Closed

#92007 appears to break inference for previously compiling code #93821

hawkw opened this issue Feb 9, 2022 · 1 comment · Fixed by #93893
Assignees
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hawkw
Copy link
Contributor

hawkw commented Feb 9, 2022

PR #92007 e7cc3bd appears to break type inference in code that compiled on previous nightlies. This was found via a build failure in tracing's CI after updating to nightly-2022-02-08: https://github.com/tokio-rs/tracing/runs/5129006951?check_suite_focus=true#step:4:530

Code

This test (https://github.com/tokio-rs/tracing/blob/0d4acb25b6162fc64c84dbaca9cac7145d394a2a/tracing-subscriber/tests/utils.rs#L6-L20), which builds a tracing subscriber and sets it as the default using an extension trait, now fails to compile:

#[test]
fn init_ext_works() {
    let (subscriber, finished) = collector::mock()
        .event(
            event::mock()
                .at_level(tracing::Level::INFO)
                .with_target("init_works"),
        )
        .done()
        .run_with_handle();

    let _guard = subscriber.set_default();
    tracing::info!(target: "init_works", "it worked!");
    finished.assert_finished();
}

The definition of the extension trait looks like this (comments and non-relevant code elided):

pub trait SubscriberInitExt
where
    Self: Into<Dispatch>,
{
    fn set_default(self) -> dispatch::DefaultGuard {
        dispatch::set_default(&self.into())
    }
}

The complete code can be found here: https://github.com/tokio-rs/tracing/blob/0d4acb25b6162fc64c84dbaca9cac7145d394a2a/tracing-subscriber/src/util.rs#L10-L93. But, I'm pretty sure that basically only the trait bounds are relevant.

I expected to see this happen: the code compiles.

Instead, this happened: compilation fails with this error

error[E0283]: type annotations needed
  --> tracing-subscriber/tests/utils.rs:17:29
   |
17 |     let _guard = subscriber.set_default();
   |                             ^^^^^^^^^^^ cannot infer type for struct `Dispatch`
   |
   = note: multiple `impl`s satisfying `Dispatch: ~const From<impl Collect>` found in the following crates: `core`, `tracing_core`:
           - impl<C> From<C> for Dispatch
             where C: 'static, C: Collect, C: Send, C: Sync;
           - impl<T> From<T> for T;
   = note: required because of the requirements on the impl of `Into<Dispatch>` for `impl Collect`
note: required by a bound in `tracing_subscriber::util::SubscriberInitExt::set_default`
  --> /home/runner/work/tracing/tracing/tracing-subscriber/src/util.rs:25:11
   |
25 |     Self: Into<Dispatch>,
   |           ^^^^^^^^^^^^^^ required by this bound in `tracing_subscriber::util::SubscriberInitExt::set_default`

For more information about this error, try `rustc --explain E0283`.

Version it worked on

It most recently worked on: nightly-2022-02-07 (734368a)

Version with regression

The regression was introduced in: nightly-2022-02-07 (0c292c9)

I ran cargo-bisect-rustc with cargo test --all on a checkout of tokio-rs/tracing@0d4acb2. The regressed commit appears to be e7cc3bd (PR #92007).

Complete `cargo-bisect-rustc` output:
:; cargo bisect-rustc --start 734368a20 --end 0c292c966 -- test --all
bisecting ci builds
starting at 734368a20, ending at 0c292c966
opening existing repository at "rust.git"
refreshing repository
fetching (via local git) commits from 734368a20 to 0c292c9667f1b202a9150d58bdd2e89e3e803996
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 6 bors merge commits in the specified range
  commit[0] 2022-02-07UTC: Auto merge of #87869 - thomcc:skinny-io-error, r=yaahc
  commit[1] 2022-02-07UTC: Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis
  commit[2] 2022-02-08UTC: Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisa
  commit[3] 2022-02-08UTC: Auto merge of #93762 - matthiaskrgr:rollup-vdjpfmz, r=matthiaskrgr
  commit[4] 2022-02-08UTC: Auto merge of #93626 - wesleywiser:fix_hashmap_natvis, r=michaelwoerister
  commit[5] 2022-02-08UTC: Auto merge of #93572 - scottmcm:generic-iter-process, r=yaahc
validated commits found, specifying toolchains

installing 734368a200904ef9c21db86c595dc04263c87be0
cargo for x86_64-unknown-linux-gnu: 6.31 MB / 6.31 MB [============================================================================================================] 100.00 % 11.54 MB/s testing...
RESULT: 734368a200904ef9c21db86c595dc04263c87be0, ===> No
uninstalling 734368a200904ef9c21db86c595dc04263c87be0

installing 0c292c9667f1b202a9150d58bdd2e89e3e803996
cargo for x86_64-unknown-linux-gnu: 6.32 MB / 6.32 MB [============================================================================================================] 100.00 % 10.41 MB/s testing...
RESULT: 0c292c9667f1b202a9150d58bdd2e89e3e803996, ===> Yes
uninstalling 0c292c9667f1b202a9150d58bdd2e89e3e803996

installing 2a8dbdb1e2d9f44e7971d9a70b41d4d86db0112f
cargo for x86_64-unknown-linux-gnu: 6.30 MB / 6.30 MB [=============================================================================================================] 100.00 % 8.64 MB/s testing...
RESULT: 2a8dbdb1e2d9f44e7971d9a70b41d4d86db0112f, ===> Yes
uninstalling 2a8dbdb1e2d9f44e7971d9a70b41d4d86db0112f

installing e7cc3bddbe0d0e374d05e7003e662bba1742dbae
cargo for x86_64-unknown-linux-gnu: 6.31 MB / 6.31 MB [============================================================================================================] 100.00 % 10.84 MB/s testing...
RESULT: e7cc3bddbe0d0e374d05e7003e662bba1742dbae, ===> Yes
uninstalling e7cc3bddbe0d0e374d05e7003e662bba1742dbae

searched toolchains 734368a200904ef9c21db86c595dc04263c87be0 through 0c292c9667f1b202a9150d58bdd2e89e3e803996


********************************************************************************
Regression in e7cc3bddbe0d0e374d05e7003e662bba1742dbae
********************************************************************************

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

@hawkw hawkw added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Feb 9, 2022
@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Feb 9, 2022
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 9, 2022
@apiraino
Copy link
Contributor

apiraino commented Feb 9, 2022

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-critical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
4 participants