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

-Znext-solver with TinyVec and Rand #119262

Closed
wyatt-herkamp opened this issue Dec 23, 2023 · 4 comments
Closed

-Znext-solver with TinyVec and Rand #119262

wyatt-herkamp opened this issue Dec 23, 2023 · 4 comments
Assignees
Labels
C-bug Category: This is a bug. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative

Comments

@wyatt-herkamp
Copy link
Contributor

I was trying the new trait resolver system and I am getting compiler issues with two libraries

https://github.com/rust-random/rand
https://github.com/Lokathor/tinyvec

Tinyvec

error[E0311]: the associated type `<arrayvec::ArrayVec<A> as core::ops::Index<I>>::Output` may not live long enough
    |
help: consider adding an explicit lifetime bound
   --> src\arrayvec.rs:175:11
    |
175 |   fn index<'a>(&'a self, index: I) -> &'a Self::Output where <arrayvec::ArrayVec<A> as core::ops::Index<I>>::Output: 'a {
    |           ++++  ++                     ++              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0311]: the associated type `<arrayvec::ArrayVec<A> as core::ops::Index<I>>::Output` may not live long enough
    |
help: consider adding an explicit lifetime bound
   --> src\arrayvec.rs:183:15
    |
183 |   fn index_mut<'a>(&'a mut self, index: I) -> &'a mut Self::Output where <arrayvec::ArrayVec<A> as core::ops::Index<I>>::Output: 'a {
    |               ++++  ++                         ++                  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0311]: the associated type `<SliceVec<'s, T> as core::ops::Index<I>>::Output` may not live long enough
   |
help: consider adding an explicit lifetime bound
  --> src\slicevec.rs:53:11
   |
53 |   fn index<'a>(&'a self, index: I) -> &'a Self::Output where <SliceVec<'s, T> as core::ops::Index<I>>::Output: 'a {
   |           ++++  ++                     ++              ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0311]: the associated type `<SliceVec<'s, T> as core::ops::Index<I>>::Output` may not live long enough
   |
help: consider adding an explicit lifetime bound
  --> src\slicevec.rs:64:15
   |
64 |   fn index_mut<'a>(&'a mut self, index: I) -> &'a mut Self::Output where <SliceVec<'s, T> as core::ops::Index<I>>::Output: 'a {
   |               ++++  ++                         ++                  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Rand

error[E0311]: the associated type `<ReseedingCore<R, Rsdr> as BlockRngCore>::Results` may not live long enough
    |
help: consider adding an explicit lifetime bound
   --> src\rngs\adapter\reseeding.rs:172:16
    |
172 |     fn generate<'a>(&mut self, results: &'a mut Self::Results) where <ReseedingCore<R, Rsdr> as BlockRngCore>::Results: 'a {
    |                ++++                      ++                    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0311]: the associated type `<ReseedingCore<R, Rsdr> as BlockRngCore>::Results` may not live long enough
    |
help: consider adding an explicit lifetime bound
   --> src\rngs\adapter\reseeding.rs:240:27
    |
240 ~     fn reseed_and_generate<'a>(
241 ~         &mut self, results: &'a mut <Self as BlockRngCore>::Results, global_fork_counter: usize,
242 ~     ) where <ReseedingCore<R, Rsdr> as BlockRngCore>::Results: 'a {
    |

Instead, this happened: explanation

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (d6d7a9386 2023-12-22)
binary: rustc
commit-hash: d6d7a93866f2ffcfb51828b8859bdad760b54ce0
commit-date: 2023-12-22
host: x86_64-pc-windows-msvc
release: 1.77.0-nightly
LLVM version: 17.0.6

The two libraries are depends of my project. I tried compiling them by themselves. Still getting the error.

I am not sure if this is the correct way to report this bug.

#107374

@wyatt-herkamp wyatt-herkamp added the C-bug Category: This is a bug. label Dec 23, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 23, 2023
@wyatt-herkamp wyatt-herkamp changed the title -Znext-solver and TinyVec -Znext-solver and TinyVec and Rand Dec 23, 2023
@wyatt-herkamp wyatt-herkamp changed the title -Znext-solver and TinyVec and Rand -Znext-solver with TinyVec and Rand Dec 23, 2023
@SNCPlay42
Copy link
Contributor

SNCPlay42 commented Dec 23, 2023

Reduced from tinyvec (note this requires -Znext-solver=globally, not just -Znext-solver=coherence):

use core::ops::Index;

pub struct SliceVec<T> {
    data: T,
}

impl<T, I> Index<I> for SliceVec<T> {
    type Output = ();
    fn index(&self, index: I) -> &Self::Output {
        unimplemented!()
    }
}

The rand version looks basically the same - the associated type mentioned is an argument, not the return type.

@Nilstrieb Nilstrieb added T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 24, 2023
@compiler-errors
Copy link
Member

This is fixed by #119101

@compiler-errors compiler-errors self-assigned this Dec 25, 2023
@compiler-errors
Copy link
Member

Correction: This will be fixed by #120513, since we need to fix it for NLL too.

@wyatt-herkamp
Copy link
Contributor Author

The code compiles now with the -Znext-solver flag!
Thank y'all.

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. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

No branches or pull requests

5 participants