mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 10:55:14 +00:00
Introduce constraint category for yields.
This commit adds a new `ConstraintCategory` for yield points - this allows for differentiation between a normal return and a yield in the diagnostics.
This commit is contained in:
parent
fc84f5f837
commit
ea873f57c9
@ -471,6 +471,7 @@ impl_stable_hash_for!(struct mir::ClosureOutlivesRequirement<'tcx> {
|
||||
|
||||
impl_stable_hash_for!(enum mir::ConstraintCategory {
|
||||
Return,
|
||||
Yield,
|
||||
UseAsConst,
|
||||
UseAsStatic,
|
||||
TypeAnnotation,
|
||||
|
@ -2905,6 +2905,7 @@ pub struct ClosureOutlivesRequirement<'tcx> {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
|
||||
pub enum ConstraintCategory {
|
||||
Return,
|
||||
Yield,
|
||||
UseAsConst,
|
||||
UseAsStatic,
|
||||
TypeAnnotation,
|
||||
|
@ -38,6 +38,7 @@ impl ConstraintDescription for ConstraintCategory {
|
||||
match self {
|
||||
ConstraintCategory::Assignment => "assignment ",
|
||||
ConstraintCategory::Return => "returning this value ",
|
||||
ConstraintCategory::Yield => "yielding this value ",
|
||||
ConstraintCategory::UseAsConst => "using this value as a constant ",
|
||||
ConstraintCategory::UseAsStatic => "using this value as a static ",
|
||||
ConstraintCategory::Cast => "cast ",
|
||||
@ -133,11 +134,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
let constraint_sup_scc = self.constraint_sccs.scc(constraint.sup);
|
||||
|
||||
match categorized_path[i].0 {
|
||||
ConstraintCategory::OpaqueType
|
||||
| ConstraintCategory::Boring
|
||||
| ConstraintCategory::BoringNoLocation
|
||||
| ConstraintCategory::Internal => false,
|
||||
ConstraintCategory::TypeAnnotation | ConstraintCategory::Return => true,
|
||||
ConstraintCategory::OpaqueType | ConstraintCategory::Boring |
|
||||
ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal => false,
|
||||
ConstraintCategory::TypeAnnotation | ConstraintCategory::Return |
|
||||
ConstraintCategory::Yield => true,
|
||||
_ => constraint_sup_scc != target_scc,
|
||||
}
|
||||
});
|
||||
|
@ -1467,7 +1467,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
value_ty,
|
||||
ty,
|
||||
term_location.to_locations(),
|
||||
ConstraintCategory::Return,
|
||||
ConstraintCategory::Yield,
|
||||
) {
|
||||
span_mirbug!(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user