]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/traits/mod.rs
Auto merge of #69442 - jakevossen5:master, r=Mark-Simulacrum
[rust.git] / src / librustc / traits / mod.rs
index de2ec53e51e788a93d0734309c5b006d6cbb8d55..1a4ea66a5f1d979cb8ab0493b076fa0c2a841f5f 100644 (file)
 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<N> {
         }
     }
 
+    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<M, F>(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, _)