Skip to content

Commit 6137ad4

Browse files
committed
move demand_eqtype_pat* to pat.rs
1 parent e952377 commit 6137ad4

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

src/librustc_typeck/check/demand.rs

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::check::FnCtxt;
22
use rustc::infer::InferOk;
3-
use rustc::traits::{self, ObligationCause, ObligationCauseCode};
3+
use rustc::traits::{self, ObligationCause};
44

55
use errors::{Applicability, DiagnosticBuilder};
66
use rustc::hir::{self, is_range_literal, print, Node};
@@ -79,32 +79,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7979
}
8080
}
8181

82-
pub fn demand_eqtype_pat_diag(
83-
&self,
84-
cause_span: Span,
85-
expected: Ty<'tcx>,
86-
actual: Ty<'tcx>,
87-
match_expr_span: Option<Span>,
88-
) -> Option<DiagnosticBuilder<'tcx>> {
89-
let cause = if let Some(span) = match_expr_span {
90-
self.cause(cause_span, ObligationCauseCode::Pattern { span, ty: expected })
91-
} else {
92-
self.misc(cause_span)
93-
};
94-
self.demand_eqtype_with_origin(&cause, expected, actual)
95-
}
96-
97-
pub fn demand_eqtype_pat(
98-
&self,
99-
cause_span: Span,
100-
expected: Ty<'tcx>,
101-
actual: Ty<'tcx>,
102-
match_expr_span: Option<Span>,
103-
) {
104-
self.demand_eqtype_pat_diag(cause_span, expected, actual, match_expr_span)
105-
.map(|mut err| err.emit());
106-
}
107-
10882
pub fn demand_coerce(
10983
&self,
11084
expr: &hir::Expr<'_>,

src/librustc_typeck/check/pat.rs

+29
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc::hir::pat_util::EnumerateAndAdjustIterator;
66
use rustc::hir::{self, HirId, Pat, PatKind};
77
use rustc::infer;
88
use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
9+
use rustc::traits::Pattern;
910
use rustc::ty::subst::GenericArg;
1011
use rustc::ty::{self, BindingMode, Ty, TypeFoldable};
1112
use syntax::ast;
@@ -29,6 +30,34 @@ pointers. If you encounter this error you should try to avoid dereferencing the
2930
You can read more about trait objects in the Trait Objects section of the Reference: \
3031
https://doc.rust-lang.org/reference/types.html#trait-objects";
3132

33+
impl<'tcx> FnCtxt<'_, 'tcx> {
34+
fn demand_eqtype_pat_diag(
35+
&self,
36+
cause_span: Span,
37+
expected: Ty<'tcx>,
38+
actual: Ty<'tcx>,
39+
match_expr_span: Option<Span>,
40+
) -> Option<DiagnosticBuilder<'tcx>> {
41+
let cause = if let Some(span) = match_expr_span {
42+
self.cause(cause_span, Pattern { span, ty: expected })
43+
} else {
44+
self.misc(cause_span)
45+
};
46+
self.demand_eqtype_with_origin(&cause, expected, actual)
47+
}
48+
49+
fn demand_eqtype_pat(
50+
&self,
51+
cause_span: Span,
52+
expected: Ty<'tcx>,
53+
actual: Ty<'tcx>,
54+
match_expr_span: Option<Span>,
55+
) {
56+
self.demand_eqtype_pat_diag(cause_span, expected, actual, match_expr_span)
57+
.map(|mut err| err.emit());
58+
}
59+
}
60+
3261
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3362
pub fn check_pat_top(
3463
&self,

0 commit comments

Comments
 (0)