-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Introduce AliasKind::Inherent
for inherent associated types
#109410
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,9 @@ fn insert_required_predicates_to_be_wf<'tcx>( | |
); | ||
} | ||
|
||
// FIXME(inherent_associated_types): Handle this case properly. | ||
ty::Alias(ty::Inherent, _) => {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to think harder about this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not blocking I guess. |
||
|
||
_ => {} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,8 @@ impl<'tcx> InferCtxt<'tcx> { | |
bug!() | ||
} | ||
|
||
(_, ty::Alias(AliasKind::Projection, _)) | (ty::Alias(AliasKind::Projection, _), _) | ||
(_, ty::Alias(AliasKind::Projection | AliasKind::Inherent, _)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, technically, though I'm not sure if the new solver is adjusted to handle projection goals with IATs, so it'll ICE with |
||
| (ty::Alias(AliasKind::Projection | AliasKind::Inherent, _), _) | ||
if self.tcx.trait_solver_next() => | ||
{ | ||
relation.register_type_relate_obligation(a, b); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ use rustc_middle::lint::in_external_macro; | |
use rustc_middle::ty::layout::{LayoutError, LayoutOf}; | ||
use rustc_middle::ty::print::with_no_trimmed_paths; | ||
use rustc_middle::ty::subst::GenericArgKind; | ||
use rustc_middle::ty::TypeVisitableExt; | ||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, VariantDef}; | ||
use rustc_session::lint::{BuiltinLintDiagnostics, FutureIncompatibilityReason}; | ||
use rustc_span::edition::Edition; | ||
|
@@ -1461,6 +1462,10 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds { | |
// Bounds are respected for `type X = impl Trait` | ||
return; | ||
} | ||
if cx.tcx.type_of(item.owner_id).skip_binder().has_inherent_projections() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm... why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this deep check for inherent projections? Well, bounds on type aliases are respected as matter of fact if the RHS contains an IAT since we look at the In "IAT, take 3" that we briefly talked about, with a hypothetical Note that the |
||
// Bounds are respected for `type X = … Type::Inherent …` | ||
return; | ||
} | ||
// There must not be a where clause | ||
if type_alias_generics.predicates.is_empty() { | ||
return; | ||
|
@@ -1580,7 +1585,6 @@ declare_lint_pass!( | |
|
||
impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { | ||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { | ||
use rustc_middle::ty::visit::TypeVisitableExt; | ||
use rustc_middle::ty::Clause; | ||
use rustc_middle::ty::PredicateKind::*; | ||
|
||
|
@@ -2917,6 +2921,7 @@ impl ClashingExternDeclarations { | |
| (Generator(..), Generator(..)) | ||
| (GeneratorWitness(..), GeneratorWitness(..)) | ||
| (Alias(ty::Projection, ..), Alias(ty::Projection, ..)) | ||
| (Alias(ty::Inherent, ..), Alias(ty::Inherent, ..)) | ||
| (Alias(ty::Opaque, ..), Alias(ty::Opaque, ..)) => false, | ||
|
||
// These definitely should have been caught above. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you would like me to, I can address this in this by PR by changing the API. It has several users though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine for now.