X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Ftraits%2Fmod.rs;h=1a4ea66a5f1d979cb8ab0493b076fa0c2a841f5f;hb=e86c9e6ef8be7ddec0360f20aae7d86c69c59a83;hp=de2ec53e51e788a93d0734309c5b006d6cbb8d55;hpb=d91657877a44ecc9450b6d996bef577a1d1ec647;p=rust.git diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index de2ec53e51e..1a4ea66a5f1 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -13,11 +13,11 @@ use crate::ty::subst::SubstsRef; use crate::ty::{self, AdtKind, List, Ty, TyCtxt}; +use rustc_ast::ast; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; -use syntax::ast; use std::borrow::Cow; use std::fmt::Debug; @@ -581,6 +581,20 @@ pub fn nested_obligations(self) -> Vec { } } + pub fn borrow_nested_obligations(&self) -> &[N] { + match &self { + VtableImpl(i) => &i.nested[..], + VtableParam(n) => &n[..], + VtableBuiltin(i) => &i.nested[..], + VtableAutoImpl(d) => &d.nested[..], + VtableClosure(c) => &c.nested[..], + VtableGenerator(c) => &c.nested[..], + VtableObject(d) => &d.nested[..], + VtableFnPointer(d) => &d.nested[..], + VtableTraitAlias(d) => &d.nested[..], + } + } + pub fn map(self, f: F) -> Vtable<'tcx, M> where F: FnMut(N) -> M, @@ -820,8 +834,7 @@ pub fn solution(&self) -> Option<(String, Option<(String, Span)>)> { MethodViolationCode::UndispatchableReceiver, span, ) => ( - format!("consider changing method `{}`'s `self` parameter to be `&self`", name) - .into(), + format!("consider changing method `{}`'s `self` parameter to be `&self`", name), Some(("&Self".to_string(), span)), ), ObjectSafetyViolation::AssocConst(name, _)