未验证 提交 ea873f57 编写于 作者: D David Wood

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.
上级 fc84f5f8
......@@ -471,6 +471,7 @@ fn hash_stable<W: StableHasherResult>(&self,
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 @@ fn description(&self) -> &'static str {
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 @@ fn best_blame_constraint(
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 @@ fn check_terminator(
value_ty,
ty,
term_location.to_locations(),
ConstraintCategory::Return,
ConstraintCategory::Yield,
) {
span_mirbug!(
self,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册