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

Regression in nightly-2022-05-01 relating to trait objects #96664

Closed
Edgeworth opened this issue May 3, 2022 · 3 comments · Fixed by #96715
Closed

Regression in nightly-2022-05-01 relating to trait objects #96664

Edgeworth opened this issue May 3, 2022 · 3 comments · Fixed by #96715
Labels
C-bug Category: This is a bug. P-high High 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

@Edgeworth
Copy link

Code

When updating from nightly nightly-2022-04-30-x86_64-unknown-linux-gnu to nightly nightly-2022-05-01-x86_64-unknown-linux-gnu, some code that previously compiled stopped compiling. Here's the basic idea of it:

pub trait State = Clone + Send + Sync + PartialOrd + PartialEq + fmt::Display;
pub trait RandState<S: State> = FnMut() -> S + Send;

pub struct Evolver<E: Evaluator> {
    rand_state: Box<dyn RandState<E::State>>
}

I expected to see this happen: compiles

Instead, this happened:

error[E0225]: only auto traits can be used as additional traits in a trait object
   --> src/gen/evaluated.rs:172:26
    |
172 |         genfn: &mut (dyn RandState<S> + '_),
    |                          ^^^^^^^^^^^^
    |                          |
    |                          trait alias used in trait object type (additional use)
    |                          trait alias used in trait object type (first use)
    |
   ::: src/evolve/evolver.rs:14:24
    |
14  | pub trait RandState<S: State> = FnMut() -> S + Send;
    |                        -----    ------------ first non-auto trait
    |                        |
    |                        referenced here (additional use)
    |
   ::: src/eval.rs:8:19
    |
8   | pub trait State = Clone + Send + Sync + PartialOrd + PartialEq + fmt::Display;
    |                   ----- additional non-auto trait
    |
    = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: FnMut<()> + Clone + PartialOrd + PartialEq + std::fmt::Display {}`

This code previously compiled, and the code already does what the advice of the error message suggests, so it seems like a regression to me.

If needed, you can get the full repro by looking at https://github.com/Edgeworth/memega

Version it worked on

nightly-2022-04-30-x86_64-unknown-linux-gnu

Version with regression

nightly-2022-05-01-x86_64-unknown-linux-gnu

@Edgeworth Edgeworth added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels May 3, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 3, 2022
@Edgeworth
Copy link
Author

Edgeworth commented May 3, 2022

According to bisect, looks like this change in behaviour happened when d201c81
(#93803) was merged.

@inquisitivecrystal
Copy link
Contributor

According to bisect, looks like this change in behaviour happened when d201c81
(#93803) was merged.

CC @cjgillot

@inquisitivecrystal inquisitivecrystal added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels May 3, 2022
@apiraino
Copy link
Contributor

apiraino commented May 4, 2022

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

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 4, 2022
@estebank estebank added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 10, 2022
@bors bors closed this as completed in 362010d May 10, 2022
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-high High 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
Development

Successfully merging a pull request may close this issue.

5 participants