-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rust compiler panic in librustc/traits/codegen #70243
Comments
A little bit more information, if I take this code: #[harness::test]
async fn select_equals() -> Result<(), Box<dyn Error>> {
let client = connect().await?;
assert_eq!(
test::select()
.where_eq(test::bar(), 32)
.with(test::bar())
.execute(&client)
.await?
.collect()
.await?,
vec![32]
);
Ok(())
} …and remove https://gist.github.com/calebmer/752055b54d3573435048a41c6fd609e8 Although I think that might only be because the code is unreachable without the test macro. |
Expanding the error message:
…and zooming in on:
…the type |
This code is probably relevant. It’s doing some admittedly weird things: /// A stream of PostgreSQL rows that were selected with some properly
/// typed `Selection`.
///
/// Doesn’t actually implement `Stream` because we need to make sure the
/// lifetimes are correct.
pub struct RowStream<S> {
selection: S,
stream: postgresql::RowStream,
}
impl<S> RowStream<S> {
/// Maps the typed borrowed row data into whatever format you want to use.
/// We don’t implement `Stream` since it’s important that we get the
/// lifetimes right.
#[inline]
pub fn map<X, F, T>(self, mut mapper: F) -> impl Stream<Item = Result<T, Error>>
where
X: Table,
S: for<'a> Selection<'a, X>,
F: for<'a> FnMut(<S as Selection<'a, X>>::Data) -> T,
{
let RowStream { selection, stream } = self;
stream.map(move |row| {
let row = row.map_err(log::convert_error!("failed to execute sql query"))?;
let row = Arc::new(row);
let data = selection.dangerously_select_from_row(&row);
let data = mapper(data);
Ok::<_, Error>(data)
})
}
/// Map all the items and then collect them into a `Vec`. Same as
/// `stream.map().try_collect::<Vec<_>>()`.
#[inline]
pub async fn map_collect<X, F, T>(self, mut mapper: F) -> Result<Vec<T>, Error>
where
X: Table,
S: for<'a> Selection<'a, X>,
F: for<'a> FnMut(<S as Selection<'a, X>>::Data) -> T,
{
self.map(mapper).try_collect().await
}
/// Collects all the rows into a `Vec` as long as the data does not
/// contain references.
#[inline]
pub async fn collect<'a, X, T>(self) -> Result<Vec<T>, Error>
where
X: Table,
S: for<'b> Selection<'b, X, Data = T>,
T: 'static,
{
self.map_collect(|row| row).await
}
} |
Probably a duplicate of #62529. |
I’m able to get this code working by changing pub fn map<X, F, T, U>(self, mut mapper: F) -> impl Stream<Item = Result<U, Error>>
where
X: Table,
S: for<'a> Selection<'a, X, Data = T>,
F: FnMut(T) -> U,
{
let RowStream { selection, stream } = self;
stream.map(move |row| {
let row = row.map_err(log::convert_error!("failed to execute sql query"))?;
let row = Arc::new(row);
let data = selection.dangerously_select_from_row(&row);
let data = mapper(data);
Ok::<_, Error>(data)
})
} |
The Rust compiler panicked with the following message. I’m not planning on taking the time to create a minimal repro, so you can immediately close if you’d like. Don’t know how useful just sharing a panic. message is.
The text was updated successfully, but these errors were encountered: