|
1 | 1 | use crate::infer::at::At;
|
2 | 2 | use crate::infer::canonical::OriginalQueryValues;
|
3 | 3 | use crate::infer::InferOk;
|
4 |
| -use crate::ty::subst::GenericArg; |
5 |
| -use crate::ty::{self, Ty, TyCtxt}; |
6 |
| -use rustc_span::source_map::Span; |
7 |
| -use std::iter::FromIterator; |
| 4 | + |
| 5 | +use rustc::ty::subst::GenericArg; |
| 6 | +use rustc::ty::{self, Ty, TyCtxt}; |
| 7 | + |
| 8 | +pub use rustc::traits::query::{DropckOutlivesResult, DtorckConstraint}; |
8 | 9 |
|
9 | 10 | impl<'cx, 'tcx> At<'cx, 'tcx> {
|
10 | 11 | /// Given a type `ty` of some value being dropped, computes a set
|
@@ -65,76 +66,6 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
|
65 | 66 | }
|
66 | 67 | }
|
67 | 68 |
|
68 |
| -#[derive(Clone, Debug, Default, HashStable, TypeFoldable, Lift)] |
69 |
| -pub struct DropckOutlivesResult<'tcx> { |
70 |
| - pub kinds: Vec<GenericArg<'tcx>>, |
71 |
| - pub overflows: Vec<Ty<'tcx>>, |
72 |
| -} |
73 |
| - |
74 |
| -impl<'tcx> DropckOutlivesResult<'tcx> { |
75 |
| - pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) { |
76 |
| - if let Some(overflow_ty) = self.overflows.iter().next() { |
77 |
| - rustc_errors::struct_span_err!( |
78 |
| - tcx.sess, |
79 |
| - span, |
80 |
| - E0320, |
81 |
| - "overflow while adding drop-check rules for {}", |
82 |
| - ty, |
83 |
| - ) |
84 |
| - .note(&format!("overflowed on {}", overflow_ty)) |
85 |
| - .emit(); |
86 |
| - } |
87 |
| - } |
88 |
| - |
89 |
| - pub fn into_kinds_reporting_overflows( |
90 |
| - self, |
91 |
| - tcx: TyCtxt<'tcx>, |
92 |
| - span: Span, |
93 |
| - ty: Ty<'tcx>, |
94 |
| - ) -> Vec<GenericArg<'tcx>> { |
95 |
| - self.report_overflows(tcx, span, ty); |
96 |
| - let DropckOutlivesResult { kinds, overflows: _ } = self; |
97 |
| - kinds |
98 |
| - } |
99 |
| -} |
100 |
| - |
101 |
| -/// A set of constraints that need to be satisfied in order for |
102 |
| -/// a type to be valid for destruction. |
103 |
| -#[derive(Clone, Debug, HashStable)] |
104 |
| -pub struct DtorckConstraint<'tcx> { |
105 |
| - /// Types that are required to be alive in order for this |
106 |
| - /// type to be valid for destruction. |
107 |
| - pub outlives: Vec<ty::subst::GenericArg<'tcx>>, |
108 |
| - |
109 |
| - /// Types that could not be resolved: projections and params. |
110 |
| - pub dtorck_types: Vec<Ty<'tcx>>, |
111 |
| - |
112 |
| - /// If, during the computation of the dtorck constraint, we |
113 |
| - /// overflow, that gets recorded here. The caller is expected to |
114 |
| - /// report an error. |
115 |
| - pub overflows: Vec<Ty<'tcx>>, |
116 |
| -} |
117 |
| - |
118 |
| -impl<'tcx> DtorckConstraint<'tcx> { |
119 |
| - pub fn empty() -> DtorckConstraint<'tcx> { |
120 |
| - DtorckConstraint { outlives: vec![], dtorck_types: vec![], overflows: vec![] } |
121 |
| - } |
122 |
| -} |
123 |
| - |
124 |
| -impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> { |
125 |
| - fn from_iter<I: IntoIterator<Item = DtorckConstraint<'tcx>>>(iter: I) -> Self { |
126 |
| - let mut result = Self::empty(); |
127 |
| - |
128 |
| - for DtorckConstraint { outlives, dtorck_types, overflows } in iter { |
129 |
| - result.outlives.extend(outlives); |
130 |
| - result.dtorck_types.extend(dtorck_types); |
131 |
| - result.overflows.extend(overflows); |
132 |
| - } |
133 |
| - |
134 |
| - result |
135 |
| - } |
136 |
| -} |
137 |
| - |
138 | 69 | /// This returns true if the type `ty` is "trivial" for
|
139 | 70 | /// dropck-outlives -- that is, if it doesn't require any types to
|
140 | 71 | /// outlive. This is similar but not *quite* the same as the
|
|
0 commit comments