|
1 | | -// ignore-tidy-filelength |
2 | | - |
3 | 1 | pub use self::fold::{TypeFoldable, TypeVisitor}; |
4 | 2 | pub use self::AssocItemContainer::*; |
5 | 3 | pub use self::BorrowKind::*; |
@@ -192,58 +190,50 @@ pub struct AssocItem { |
192 | 190 | pub container: AssocItemContainer, |
193 | 191 |
|
194 | 192 | /// Whether this is a method with an explicit self |
195 | | - /// as its first argument, allowing method calls. |
196 | | - pub method_has_self_argument: bool, |
| 193 | + /// as its first parameter, allowing method calls. |
| 194 | + pub fn_has_self_parameter: bool, |
197 | 195 | } |
198 | 196 |
|
199 | 197 | #[derive(Copy, Clone, PartialEq, Debug, HashStable)] |
200 | 198 | pub enum AssocKind { |
201 | 199 | Const, |
202 | | - Method, |
| 200 | + Fn, |
203 | 201 | OpaqueTy, |
204 | 202 | Type, |
205 | 203 | } |
206 | 204 |
|
207 | 205 | impl AssocKind { |
208 | | - pub fn suggestion_descr(&self) -> &'static str { |
209 | | - match self { |
210 | | - ty::AssocKind::Method => "method call", |
211 | | - ty::AssocKind::Type | ty::AssocKind::OpaqueTy => "associated type", |
212 | | - ty::AssocKind::Const => "associated constant", |
213 | | - } |
214 | | - } |
215 | | - |
216 | 206 | pub fn namespace(&self) -> Namespace { |
217 | 207 | match *self { |
218 | 208 | ty::AssocKind::OpaqueTy | ty::AssocKind::Type => Namespace::TypeNS, |
219 | | - ty::AssocKind::Const | ty::AssocKind::Method => Namespace::ValueNS, |
| 209 | + ty::AssocKind::Const | ty::AssocKind::Fn => Namespace::ValueNS, |
220 | 210 | } |
221 | 211 | } |
222 | | -} |
223 | 212 |
|
224 | | -impl AssocItem { |
225 | | - pub fn def_kind(&self) -> DefKind { |
226 | | - match self.kind { |
| 213 | + pub fn as_def_kind(&self) -> DefKind { |
| 214 | + match self { |
227 | 215 | AssocKind::Const => DefKind::AssocConst, |
228 | | - AssocKind::Method => DefKind::AssocFn, |
| 216 | + AssocKind::Fn => DefKind::AssocFn, |
229 | 217 | AssocKind::Type => DefKind::AssocTy, |
230 | 218 | AssocKind::OpaqueTy => DefKind::AssocOpaqueTy, |
231 | 219 | } |
232 | 220 | } |
| 221 | +} |
233 | 222 |
|
| 223 | +impl AssocItem { |
234 | 224 | /// Tests whether the associated item admits a non-trivial implementation |
235 | 225 | /// for ! |
236 | 226 | pub fn relevant_for_never(&self) -> bool { |
237 | 227 | match self.kind { |
238 | 228 | AssocKind::OpaqueTy | AssocKind::Const | AssocKind::Type => true, |
239 | 229 | // FIXME(canndrew): Be more thorough here, check if any argument is uninhabited. |
240 | | - AssocKind::Method => !self.method_has_self_argument, |
| 230 | + AssocKind::Fn => !self.fn_has_self_parameter, |
241 | 231 | } |
242 | 232 | } |
243 | 233 |
|
244 | 234 | pub fn signature(&self, tcx: TyCtxt<'_>) -> String { |
245 | 235 | match self.kind { |
246 | | - ty::AssocKind::Method => { |
| 236 | + ty::AssocKind::Fn => { |
247 | 237 | // We skip the binder here because the binder would deanonymize all |
248 | 238 | // late-bound regions, and we don't want method signatures to show up |
249 | 239 | // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound |
@@ -2664,7 +2654,7 @@ impl<'tcx> TyCtxt<'tcx> { |
2664 | 2654 | pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> { |
2665 | 2655 | self.associated_items(id) |
2666 | 2656 | .in_definition_order() |
2667 | | - .filter(|item| item.kind == AssocKind::Method && item.defaultness.has_value()) |
| 2657 | + .filter(|item| item.kind == AssocKind::Fn && item.defaultness.has_value()) |
2668 | 2658 | } |
2669 | 2659 |
|
2670 | 2660 | pub fn trait_relevant_for_never(self, did: DefId) -> bool { |
|
0 commit comments