use syntax::parse::token::InternedString;
use rustc_front::hir;
-use rustc_front::hir::{ItemImpl, ItemTrait};
+use rustc_front::hir::{ItemImpl, ItemTrait, PatKind};
use rustc_front::intravisit::Visitor;
pub use self::sty::{Binder, DebruijnIndex};
impl<'tcx> ToPolyTraitRef<'tcx> for PolyTraitPredicate<'tcx> {
fn to_poly_trait_ref(&self) -> PolyTraitRef<'tcx> {
- self.map_bound_ref(|trait_pred| trait_pred.trait_ref.clone())
+ self.map_bound_ref(|trait_pred| trait_pred.trait_ref)
}
}
// This is because here `self` has a `Binder` and so does our
// return value, so we are preserving the number of binding
// levels.
- ty::Binder(self.0.projection_ty.trait_ref.clone())
+ ty::Binder(self.0.projection_ty.trait_ref)
}
}
})
}
+ pub fn expr_ty_adjusted_opt(&self, expr: &hir::Expr) -> Option<Ty<'tcx>> {
+ self.expr_ty_opt(expr).map(|t| t.adjust(self,
+ expr.span,
+ expr.id,
+ self.tables.borrow().adjustments.get(&expr.id),
+ |method_call| {
+ self.tables.borrow().method_map.get(&method_call).map(|method| method.ty)
+ }))
+ }
+
pub fn expr_span(&self, id: NodeId) -> Span {
match self.map.find(id) {
Some(ast_map::NodeExpr(e)) => {
match self.map.find(id) {
Some(ast_map::NodeLocal(pat)) => {
match pat.node {
- hir::PatIdent(_, ref path1, _) => path1.node.name.as_str(),
+ PatKind::Ident(_, ref path1, _) => path1.node.name.as_str(),
_ => {
self.sess.bug(&format!("Variable id {} maps to {:?}, not local", id, pat));
},
hir::ExprCall(..) |
hir::ExprMethodCall(..) |
hir::ExprStruct(..) |
- hir::ExprRange(..) |
hir::ExprTup(..) |
hir::ExprIf(..) |
hir::ExprMatch(..) |
/// Given the did of an ADT, return a reference to its definition.
pub fn lookup_adt_def(&self, did: DefId) -> AdtDef<'tcx> {
// when reverse-variance goes away, a transmute::<AdtDefMaster,AdtDef>
- // woud be needed here.
+ // would be needed here.
self.lookup_adt_def_master(did)
}