From 174ae5f95a7c3ec849a7bcb8cf80da7c776d5e6c Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Fri, 27 Sep 2024 11:53:11 -0700 Subject: [PATCH 1/8] add test --- crates/flux-driver/src/collector/mod.rs | 2 +- tests/tests/pos/surface/issue-808.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/tests/pos/surface/issue-808.rs diff --git a/crates/flux-driver/src/collector/mod.rs b/crates/flux-driver/src/collector/mod.rs index 74681ccf96..dd1e14f738 100644 --- a/crates/flux-driver/src/collector/mod.rs +++ b/crates/flux-driver/src/collector/mod.rs @@ -22,7 +22,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir::{ self as hir, def::DefKind, - def_id::{DefId, LocalDefId, CRATE_DEF_ID}, + def_id::{LocalDefId, CRATE_DEF_ID}, EnumDef, ImplItemKind, Item, ItemKind, OwnerId, VariantData, CRATE_OWNER_ID, }; use rustc_middle::ty::TyCtxt; diff --git a/tests/tests/pos/surface/issue-808.rs b/tests/tests/pos/surface/issue-808.rs new file mode 100644 index 0000000000..0b2ecbc88b --- /dev/null +++ b/tests/tests/pos/surface/issue-808.rs @@ -0,0 +1,24 @@ +trait Trait1 { + type Assoc1; +} + +impl Trait1 for i32 { + type Assoc1 = i32; +} + +trait Trait2 { + type Assoc2; +} + +struct S { + f: T, +} + +impl Trait2 for S +where + T2: Trait1, +{ + type Assoc2 = T1; +} + +fn test(x: as Trait2>::Assoc2) {} From 3f5f421400d2c7a1ba8ef15088e7aad3bea14aa0 Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Mon, 30 Sep 2024 17:15:10 -0700 Subject: [PATCH 2/8] temp checkin --- crates/flux-middle/src/rty/projections.rs | 70 ++++++++++++++++++++++- tests/tests/pos/surface/issue-808.rs | 4 +- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index cc97bc4b97..9e90312150 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -3,6 +3,7 @@ use std::iter; use flux_arc_interner::List; use flux_common::{bug, tracked_span_bug}; use flux_rustc_bridge::{lowering::Lower, ToRustc}; +use rustc_hash::FxHashSet; use rustc_hir::def_id::DefId; use rustc_infer::{infer::InferCtxt, traits::Obligation}; use rustc_middle::{ @@ -145,9 +146,9 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { // and the id of a rust impl block // impl Iterator for IntoIter - // 1. Match the self type of the rust impl block and the flux self type of the obligation + // 1. MATCH the self type of the rust impl block and the flux self type of the obligation // to infer a substitution - // IntoIter<{v. i32[v] | v > 0}, Global> against IntoIter + // IntoIter<{v. i32[v] | v > 0}, Global> MATCH IntoIter // => {T -> {v. i32[v] | v > 0}, A -> Global} let impl_trait_ref = self @@ -159,12 +160,34 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { let generics = self.tcx().generics_of(impl_def_id); let mut subst = TVarSubst::new(generics); + // println!("TRACE: confirm_candidate (0) oblig={obligation:?}, cand={candidate:?}, preds={preds:?}"); for (a, b) in iter::zip(&impl_trait_ref.args, &obligation.args) { + // println!("TRACE: confirm_candidate (1) subst: a={a:?}, b={b:?}"); subst.generic_args(a, b); } + // println!("TRACE: confirm_candidate (2) oblig={obligation:?}, cand={candidate:?} subst={subst:?}"); + + // 2. Gather the ProjectionPredicates and solve them see issue-808.rs + let mut projection_preds: FxHashSet<_> = self + .genv + .predicates_of(impl_def_id)? + .instantiate_identity() + .predicates + .iter() + .filter_map(|pred| { + if let ClauseKind::Projection(pred) = pred.kind_skipping_binder() { + Some(pred.clone()) + } else { + None + } + }) + .collect(); + + self.solve_projection_predicates(&mut subst, &mut projection_preds)?; + let args = subst.finish(self.tcx(), generics); - // 2. Get the associated type in the impl block and apply the substitution to it + // 3. Get the associated type in the impl block and apply the substitution to it let assoc_type_id = self .tcx() .associated_items(impl_def_id) @@ -183,6 +206,47 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { } } + // find a projection predicate that can be solved because the lhs is defined in subst e.g. + // T2 : Trait1 + // can be solved if `subst` defines `T2` + fn find_projection_predicate_candidate( + &self, + subst: &TVarSubst, + projection_preds: &mut FxHashSet, + ) -> Option { + let res = projection_preds + .iter() + .find(|pp| todo!("issue-808-1")) + .map(|p| p.clone()); + + if let Some(ref pp) = res { + projection_preds.remove(&pp); + } + res + } + + // Given (1) a projection predicate like `T2 : Trait1` and (2) a solution for `T2` e.g. `i32`, we want to + // 1. (Recursively) compute the projection `::Assoc + // 2. Unify the result of (1) with `T1` in subst. + fn solve_projection_predicate( + &self, + subst: &mut TVarSubst, + projection_pred: ProjectionPredicate, + ) -> QueryResult { + todo!("ISSUE-808-2") + } + + fn solve_projection_predicates( + &self, + subst: &mut TVarSubst, + projection_preds: &mut FxHashSet, + ) -> QueryResult { + while let Some(p) = self.find_projection_predicate_candidate(subst, projection_preds) { + self.solve_projection_predicate(subst, p)?; + } + Ok(()) + } + fn assemble_candidates_from_param_env( &self, obligation: &AliasTy, diff --git a/tests/tests/pos/surface/issue-808.rs b/tests/tests/pos/surface/issue-808.rs index 0b2ecbc88b..748c061349 100644 --- a/tests/tests/pos/surface/issue-808.rs +++ b/tests/tests/pos/surface/issue-808.rs @@ -3,7 +3,7 @@ trait Trait1 { } impl Trait1 for i32 { - type Assoc1 = i32; + type Assoc1 = bool; } trait Trait2 { @@ -11,7 +11,7 @@ trait Trait2 { } struct S { - f: T, + fld: T, } impl Trait2 for S From 50570df91a76885dd1d411a0cf87f1f351e3a14b Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 10:27:41 -0700 Subject: [PATCH 3/8] fix #808 hopefully --- crates/flux-middle/src/rty/projections.rs | 122 +++++++++++----------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index 9e90312150..4113479f40 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -137,7 +137,47 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { Ok((true, ty)) } - fn confirm_candidate(&self, candidate: Candidate, obligation: &AliasTy) -> QueryResult { + // See issue-808.rs for an example of what this function is for. + fn resolve_projection_predicates( + &mut self, + subst: &mut TVarSubst, + impl_def_id: DefId, + ) -> QueryResult { + // 1. make a partial substitution with the "known" generic arguments e.g. + // Given [T1 ->?, T2 -> i32] make a substitution [T1 -> T1, T2 -> i32] + let known_args = subst.as_generic_args(&self.genv, self.genv.generics_of(impl_def_id)?)?; + + // 2. instantiate the generic_predicates of `impl_def_id` with the known_args + // e.g. given a predicate `T2 : Trait1` and known_args [T1 -> T1, T2 -> i32] + // we get `i32 : Trait1` + let projection_preds: FxHashSet<_> = self + .genv + .predicates_of(impl_def_id)? + .map(|generic_predicates| generic_predicates.predicates) + .instantiate(self.tcx(), &known_args, &[]) + .iter() + .filter_map(|pred| { + if let ClauseKind::Projection(pred) = pred.kind_skipping_binder() { + Some(pred.clone()) + } else { + None + } + }) + .collect(); + + // 3. recursively solve each of the projection predicates and unify result with the predicate's term + // e.g. given `i32 : Trait1` we + // - `normalize_projection_ty` on `::Assoc` to get `bool` + // - unify `T1` with `bool` + for p in projection_preds.iter() { + let obligation = &p.projection_ty; + let (_, ty) = self.normalize_projection_ty(obligation)?; + subst.tys(&p.term, &ty); + } + Ok(()) + } + + fn confirm_candidate(&mut self, candidate: Candidate, obligation: &AliasTy) -> QueryResult { match candidate { Candidate::ParamEnv(pred) | Candidate::TraitDef(pred) => Ok(pred.term), Candidate::UserDefinedImpl(impl_def_id) => { @@ -160,30 +200,12 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { let generics = self.tcx().generics_of(impl_def_id); let mut subst = TVarSubst::new(generics); - // println!("TRACE: confirm_candidate (0) oblig={obligation:?}, cand={candidate:?}, preds={preds:?}"); for (a, b) in iter::zip(&impl_trait_ref.args, &obligation.args) { - // println!("TRACE: confirm_candidate (1) subst: a={a:?}, b={b:?}"); subst.generic_args(a, b); } - // println!("TRACE: confirm_candidate (2) oblig={obligation:?}, cand={candidate:?} subst={subst:?}"); // 2. Gather the ProjectionPredicates and solve them see issue-808.rs - let mut projection_preds: FxHashSet<_> = self - .genv - .predicates_of(impl_def_id)? - .instantiate_identity() - .predicates - .iter() - .filter_map(|pred| { - if let ClauseKind::Projection(pred) = pred.kind_skipping_binder() { - Some(pred.clone()) - } else { - None - } - }) - .collect(); - - self.solve_projection_predicates(&mut subst, &mut projection_preds)?; + self.resolve_projection_predicates(&mut subst, impl_def_id)?; let args = subst.finish(self.tcx(), generics); @@ -206,47 +228,6 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { } } - // find a projection predicate that can be solved because the lhs is defined in subst e.g. - // T2 : Trait1 - // can be solved if `subst` defines `T2` - fn find_projection_predicate_candidate( - &self, - subst: &TVarSubst, - projection_preds: &mut FxHashSet, - ) -> Option { - let res = projection_preds - .iter() - .find(|pp| todo!("issue-808-1")) - .map(|p| p.clone()); - - if let Some(ref pp) = res { - projection_preds.remove(&pp); - } - res - } - - // Given (1) a projection predicate like `T2 : Trait1` and (2) a solution for `T2` e.g. `i32`, we want to - // 1. (Recursively) compute the projection `::Assoc - // 2. Unify the result of (1) with `T1` in subst. - fn solve_projection_predicate( - &self, - subst: &mut TVarSubst, - projection_pred: ProjectionPredicate, - ) -> QueryResult { - todo!("ISSUE-808-2") - } - - fn solve_projection_predicates( - &self, - subst: &mut TVarSubst, - projection_preds: &mut FxHashSet, - ) -> QueryResult { - while let Some(p) = self.find_projection_predicate_candidate(subst, projection_preds) { - self.solve_projection_predicate(subst, p)?; - } - Ok(()) - } - fn assemble_candidates_from_param_env( &self, obligation: &AliasTy, @@ -385,6 +366,25 @@ impl TVarSubst { Self { args: vec![None; generics.count()] } } + fn as_generic_args( + &self, + genv: &GlobalEnv, + generics: crate::rty::Generics, + ) -> QueryResult> { + self.args + .iter() + .enumerate() + .map(|(idx, arg)| { + if let Some(arg) = arg { + Ok(arg.clone()) + } else { + let param = generics.param_at(idx, *genv)?; + Ok(GenericArg::from_param_def(¶m)) + } + }) + .collect() + } + fn finish<'tcx>( self, tcx: TyCtxt<'tcx>, From c4f5b839195b09b77cadb75287f15003666d113d Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 10:32:08 -0700 Subject: [PATCH 4/8] fix #829 hopefully --- crates/flux-middle/src/rty/projections.rs | 2 +- tests/tests/pos/surface/{issue-808.rs => issue-829.rs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/tests/pos/surface/{issue-808.rs => issue-829.rs} (100%) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index 4113479f40..940af81bb9 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -137,7 +137,7 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { Ok((true, ty)) } - // See issue-808.rs for an example of what this function is for. + // See issue-829.rs for an example of what this function is for. fn resolve_projection_predicates( &mut self, subst: &mut TVarSubst, diff --git a/tests/tests/pos/surface/issue-808.rs b/tests/tests/pos/surface/issue-829.rs similarity index 100% rename from tests/tests/pos/surface/issue-808.rs rename to tests/tests/pos/surface/issue-829.rs From 69e69468a6b2dafa012e0c208d929b21d97d7867 Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 10:35:08 -0700 Subject: [PATCH 5/8] fix #829 hopefully --- crates/flux-middle/src/rty/projections.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index 940af81bb9..839beaf03a 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -169,7 +169,7 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { // e.g. given `i32 : Trait1` we // - `normalize_projection_ty` on `::Assoc` to get `bool` // - unify `T1` with `bool` - for p in projection_preds.iter() { + for p in projection_preds { let obligation = &p.projection_ty; let (_, ty) = self.normalize_projection_ty(obligation)?; subst.tys(&p.term, &ty); From ccb930b158b522ab0b2452ff8a937343bb527c73 Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 13:43:21 -0700 Subject: [PATCH 6/8] sigh --- crates/flux-middle/src/rty/projections.rs | 119 ++++++++++++++-------- crates/flux-middle/src/rty/subst.rs | 10 +- tests/tests/pos/surface/issue-829b.rs | 25 +++++ 3 files changed, 109 insertions(+), 45 deletions(-) create mode 100644 tests/tests/pos/surface/issue-829b.rs diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index 839beaf03a..ec73675894 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -3,7 +3,6 @@ use std::iter; use flux_arc_interner::List; use flux_common::{bug, tracked_span_bug}; use flux_rustc_bridge::{lowering::Lower, ToRustc}; -use rustc_hash::FxHashSet; use rustc_hir::def_id::DefId; use rustc_infer::{infer::InferCtxt, traits::Obligation}; use rustc_middle::{ @@ -14,8 +13,9 @@ use rustc_trait_selection::traits::SelectionContext; use super::{ fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}, - AliasKind, AliasReft, AliasTy, BaseTy, Binder, Clause, ClauseKind, Const, Expr, ExprKind, - GenericArg, ProjectionPredicate, RefineArgs, Region, SubsetTy, Ty, TyKind, + subst::{GenericsSubstDelegate, GenericsSubstFolder}, + AliasKind, AliasReft, AliasTy, BaseTy, Binder, Clause, ClauseKind, Const, EarlyBinder, Expr, + ExprKind, GenericArg, ProjectionPredicate, RefineArgs, Region, SubsetTy, Ty, TyKind, }; use crate::{ global_env::GlobalEnv, @@ -137,42 +137,60 @@ impl<'genv, 'tcx, 'cx> Normalizer<'genv, 'tcx, 'cx> { Ok((true, ty)) } - // See issue-829.rs for an example of what this function is for. + fn find_resolved_predicates( + &self, + subst: &mut TVarSubst, + preds: Vec>, + ) -> (Vec, Vec>) { + let mut resolved = vec![]; + let mut unresolved = vec![]; + for pred in preds { + let term = pred.clone().skip_binder().term; + let alias_ty = pred.clone().map(|p| p.projection_ty); + match subst.instantiate_partial(alias_ty) { + Some(projection_ty) => { + let pred = ProjectionPredicate { projection_ty, term }; + resolved.push(pred); + } + None => unresolved.push(pred.clone()), + } + } + (resolved, unresolved) + } + + // See issue-829*.rs for an example of what this function is for. fn resolve_projection_predicates( &mut self, subst: &mut TVarSubst, impl_def_id: DefId, ) -> QueryResult { - // 1. make a partial substitution with the "known" generic arguments e.g. - // Given [T1 ->?, T2 -> i32] make a substitution [T1 -> T1, T2 -> i32] - let known_args = subst.as_generic_args(&self.genv, self.genv.generics_of(impl_def_id)?)?; - - // 2. instantiate the generic_predicates of `impl_def_id` with the known_args - // e.g. given a predicate `T2 : Trait1` and known_args [T1 -> T1, T2 -> i32] - // we get `i32 : Trait1` - let projection_preds: FxHashSet<_> = self + let mut projection_preds: Vec<_> = self .genv .predicates_of(impl_def_id)? - .map(|generic_predicates| generic_predicates.predicates) - .instantiate(self.tcx(), &known_args, &[]) + .skip_binder() + .predicates .iter() .filter_map(|pred| { if let ClauseKind::Projection(pred) = pred.kind_skipping_binder() { - Some(pred.clone()) + Some(EarlyBinder(pred.clone())) } else { None } }) .collect(); - // 3. recursively solve each of the projection predicates and unify result with the predicate's term - // e.g. given `i32 : Trait1` we - // - `normalize_projection_ty` on `::Assoc` to get `bool` - // - unify `T1` with `bool` - for p in projection_preds { - let obligation = &p.projection_ty; - let (_, ty) = self.normalize_projection_ty(obligation)?; - subst.tys(&p.term, &ty); + while !projection_preds.is_empty() { + let (resolved, unresolved) = self.find_resolved_predicates(subst, projection_preds); + + if resolved.is_empty() { + break; // failed: there is some unresolved projection pred! + } + for p in resolved { + let obligation = &p.projection_ty; + let (_, ty) = self.normalize_projection_ty(obligation)?; + subst.tys(&p.term, &ty); + } + projection_preds = unresolved; } Ok(()) } @@ -361,28 +379,49 @@ struct TVarSubst { args: Vec>, } +impl GenericsSubstDelegate for &TVarSubst { + type Error = (); + + fn ty_for_param(&mut self, param_ty: rustc_middle::ty::ParamTy) -> Result { + match self.args.get(param_ty.index as usize) { + Some(Some(GenericArg::Ty(ty))) => Ok(ty.clone()), + Some(None) => Err(()), + arg => tracked_span_bug!("expected type for generic parameter, found `{arg:?}`"), + } + } + + fn sort_for_param( + &mut self, + _param_ty: rustc_middle::ty::ParamTy, + ) -> Result { + todo!() + } + + fn ctor_for_param(&mut self, _param_ty: rustc_middle::ty::ParamTy) -> super::SubsetTyCtor { + todo!() + } + + fn region_for_param(&mut self, _ebr: rustc_middle::ty::EarlyParamRegion) -> Region { + todo!() + } + + fn expr_for_param_const(&self, _param_const: rustc_middle::ty::ParamConst) -> Expr { + todo!() + } + + fn const_for_param(&mut self, _param: &Const) -> Const { + todo!() + } +} + impl TVarSubst { fn new(generics: &rustc_middle::ty::Generics) -> Self { Self { args: vec![None; generics.count()] } } - fn as_generic_args( - &self, - genv: &GlobalEnv, - generics: crate::rty::Generics, - ) -> QueryResult> { - self.args - .iter() - .enumerate() - .map(|(idx, arg)| { - if let Some(arg) = arg { - Ok(arg.clone()) - } else { - let param = generics.param_at(idx, *genv)?; - Ok(GenericArg::from_param_def(¶m)) - } - }) - .collect() + fn instantiate_partial(&mut self, pred: EarlyBinder) -> Option { + let mut folder = GenericsSubstFolder::new(&*self, &[]); + pred.skip_binder().try_fold_with(&mut folder).ok() } fn finish<'tcx>( diff --git a/crates/flux-middle/src/rty/subst.rs b/crates/flux-middle/src/rty/subst.rs index 9eeacfc6c1..791b616212 100644 --- a/crates/flux-middle/src/rty/subst.rs +++ b/crates/flux-middle/src/rty/subst.rs @@ -334,7 +334,7 @@ pub trait GenericsSubstDelegate { type Error = !; fn sort_for_param(&mut self, param_ty: ParamTy) -> Result; - fn ty_for_param(&mut self, param_ty: ParamTy) -> Ty; + fn ty_for_param(&mut self, param_ty: ParamTy) -> Result; fn ctor_for_param(&mut self, param_ty: ParamTy) -> SubsetTyCtor; fn region_for_param(&mut self, ebr: EarlyParamRegion) -> Region; fn expr_for_param_const(&self, param_const: ParamConst) -> Expr; @@ -358,9 +358,9 @@ impl<'a, 'tcx> GenericsSubstDelegate for GenericArgsDelegate<'a, 'tcx> { } } - fn ty_for_param(&mut self, param_ty: ParamTy) -> Ty { + fn ty_for_param(&mut self, param_ty: ParamTy) -> Result { match self.0.get(param_ty.index as usize) { - Some(GenericArg::Ty(ty)) => ty.clone(), + Some(GenericArg::Ty(ty)) => Ok(ty.clone()), Some(arg) => tracked_span_bug!("expected type for generic parameter, found `{arg:?}`"), None => tracked_span_bug!("type parameter out of range {param_ty:?}"), } @@ -433,7 +433,7 @@ where (self.sort_for_param)(param_ty) } - fn ty_for_param(&mut self, param_ty: ParamTy) -> Ty { + fn ty_for_param(&mut self, param_ty: ParamTy) -> Result { bug!("unexpected type param {param_ty:?}"); } @@ -497,7 +497,7 @@ impl FallibleTypeFolder for GenericsSubstFolder<'_, D> fn try_fold_ty(&mut self, ty: &Ty) -> Result { match ty.kind() { - TyKind::Param(param_ty) => Ok(self.delegate.ty_for_param(*param_ty)), + TyKind::Param(param_ty) => self.delegate.ty_for_param(*param_ty), TyKind::Indexed(BaseTy::Param(param_ty), idx) => { let idx = idx.try_fold_with(self)?; Ok(self diff --git a/tests/tests/pos/surface/issue-829b.rs b/tests/tests/pos/surface/issue-829b.rs new file mode 100644 index 0000000000..5022771528 --- /dev/null +++ b/tests/tests/pos/surface/issue-829b.rs @@ -0,0 +1,25 @@ +trait Trait1 { + type Assoc1; +} + +impl Trait1 for i32 { + type Assoc1 = i32; +} + +trait Trait2 { + type Assoc2; +} + +struct S { + fld: T, +} + +impl Trait2 for S +where + T2: Trait1, + T1: Trait1, +{ + type Assoc2 = T1; +} + +fn test(x: as Trait2>::Assoc2) {} From 4ac0704be6b083556aade596f0a34f642c1321d8 Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 14:27:05 -0700 Subject: [PATCH 7/8] Update crates/flux-middle/src/rty/projections.rs Co-authored-by: Nico Lehmann --- crates/flux-middle/src/rty/projections.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index ec73675894..e03d8596d3 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -394,7 +394,7 @@ impl GenericsSubstDelegate for &TVarSubst { &mut self, _param_ty: rustc_middle::ty::ParamTy, ) -> Result { - todo!() + tracked_span_bug!() } fn ctor_for_param(&mut self, _param_ty: rustc_middle::ty::ParamTy) -> super::SubsetTyCtor { From b23a70d400f6548bc044b3dd2d061e1a95f1bbce Mon Sep 17 00:00:00 2001 From: Ranjit Jhala Date: Tue, 1 Oct 2024 14:28:07 -0700 Subject: [PATCH 8/8] change todo to tracked-span-bug --- crates/flux-middle/src/rty/projections.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/flux-middle/src/rty/projections.rs b/crates/flux-middle/src/rty/projections.rs index ec73675894..a8b111a9e2 100644 --- a/crates/flux-middle/src/rty/projections.rs +++ b/crates/flux-middle/src/rty/projections.rs @@ -394,23 +394,23 @@ impl GenericsSubstDelegate for &TVarSubst { &mut self, _param_ty: rustc_middle::ty::ParamTy, ) -> Result { - todo!() + tracked_span_bug!() } fn ctor_for_param(&mut self, _param_ty: rustc_middle::ty::ParamTy) -> super::SubsetTyCtor { - todo!() + tracked_span_bug!() } fn region_for_param(&mut self, _ebr: rustc_middle::ty::EarlyParamRegion) -> Region { - todo!() + tracked_span_bug!() } fn expr_for_param_const(&self, _param_const: rustc_middle::ty::ParamConst) -> Expr { - todo!() + tracked_span_bug!() } fn const_for_param(&mut self, _param: &Const) -> Const { - todo!() + tracked_span_bug!() } }