-
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
ICE: borrowck best_blame_constraint
unwrap on a None
value, OpaqueTypeKey { def_id...
#133252
Comments
/cc @estebank since this seems to be diagnostics-related (?) |
Backtrace looks like #114640. ICE'd while borrow-checking around https://github.com/Turbo87/crates.io/blob/cf1ac7c853bc4cea21a8fd3fdb7e17260d1a242c/src/controllers/user/me.rs#L68. rust/compiler/rustc_borrowck/src/region_infer/mod.rs Lines 1958 to 1967 in f6e511e
It looks a bit like #114640 and #123157, but #123157 is feature-gated-dependent. @Turbo87 does it repro if you |
Option::unwrap()
on a None
valuebest_blame_constraint
unwrap on a None
value, OpaqueTypeKey { def_id...
yep, reproduces every time I run, also when running |
Thanks for the info. That is certainly curious. |
Partial reduction: use diesel::associations::{BelongsTo, HasTable};
use diesel::deserialize::{self, FromStaticSqlRow};
use diesel::pg::Pg;
use diesel::query_builder::{AsQuery, AstPass, Query, QueryFragment};
use diesel::query_dsl::CompatibleType;
use diesel::{
BelongingToDsl, ExpressionMethods, Identifiable, QueryDsl, QueryResult, Queryable, Selectable,
SelectableHelper,
};
use std::future::Future;
impl<T: Send> ResolveThis for T {}
trait ResolveThis {
fn resolve(&self) {}
}
diesel::table! {
crates (id) {
id -> Int4,
}
}
diesel::table! {
follows (user_id, crate_id) {
user_id -> Int4,
crate_id -> Int4,
}
}
diesel::table! {
users (id) {
id -> Int4,
}
}
diesel::table! {
versions (id) {
id -> Int4,
crate_id -> Int4,
published_by -> Nullable<Int4>,
}
}
diesel::joinable!(versions -> crates (crate_id));
diesel::joinable!(versions -> users (published_by));
diesel::allow_tables_to_appear_in_same_query!(crates, follows, users, versions,);
struct PaginatedQuery<T>(T);
impl<T> PaginatedQuery<T> {
async fn async_load<'a, U>(&self)
where
Self: LoadQuery<'a, WithCount<U>>,
{
self.internal_load().await;
}
}
impl<T: Query> Query for PaginatedQuery<T> {
type SqlType = (T::SqlType,);
}
impl<T> QueryFragment<Pg> for PaginatedQuery<T> {
fn walk_ast<'b>(&'b self, _out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
loop {}
}
}
trait AppError: 'static {}
fn ice() -> impl Future<Output = Option<Box<dyn AppError>>> {
async {
let user = User { id: 0 };
let followed_crates = Follow::belonging_to(&user).select(follows::crate_id);
let query = PaginatedQuery(
versions::table
.inner_join(crates::table)
.left_outer_join(users::table)
.filter(crates::id.eq_any(followed_crates))
.select(<Option<User>>::as_select()),
);
query.async_load().resolve();
None
}
}
struct WithCount<T> {
record: T,
}
impl<T, __ST0> Queryable<__ST0, Pg> for WithCount<T>
where
(T,): FromStaticSqlRow<__ST0, Pg>,
{
type Row = (T,);
fn build(row: Self::Row) -> deserialize::Result<Self> {
loop {}
}
}
struct Follow {
user_id: i32,
}
impl HasTable for Follow {
type Table = follows::table;
fn table() -> Self::Table {
loop {}
}
}
impl<__FK> BelongsTo<User> for Follow
where
__FK: std::hash::Hash + std::cmp::Eq,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
{
type ForeignKey = __FK;
type ForeignKeyColumn = follows::user_id;
fn foreign_key(&self) -> Option<&Self::ForeignKey> {
loop {}
}
fn foreign_key_column() -> Self::ForeignKeyColumn {
loop {}
}
}
struct User {
id: i32,
}
impl<__ST0> Queryable<__ST0, Pg> for User
where
(i32,): FromStaticSqlRow<__ST0, Pg>,
{
type Row = (i32,);
fn build(row: Self::Row) -> deserialize::Result<Self> {
loop {}
}
}
impl HasTable for User {
type Table = users::table;
fn table() -> Self::Table {
users::table
}
}
impl<'ident> Identifiable for &'ident User {
type Id = &'ident i32;
fn id(self) -> Self::Id {
loop {}
}
}
impl Selectable<Pg> for User {
type SelectExpression = (users::id,);
fn construct_selection() -> Self::SelectExpression {
loop {}
}
}
trait LoadQuery<'query, U> {
type LoadFuture: Future;
fn internal_load(&self) -> Self::LoadFuture {
loop {}
}
}
impl<'query, T, U> LoadQuery<'query, U> for T
where
T: AsQuery + 'query,
T::SqlType: CompatibleType<U, Pg>,
{
type LoadFuture = MapOk;
}
struct MapOk;
impl Future for MapOk {
type Output = ();
fn poll(
self: std::pin::Pin<&mut Self>,
_: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
todo!()
}
}
|
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: