X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Fbuild%2Fexpr%2Fas_place.rs;h=5429ce2a2e3dfe34214aff6804bc03d802722729;hb=ed871cb368f6b72dde644b0c21e0f9e62dba1810;hp=cb3c88876a3a803b7d5a327c3bccd37db88f34ab;hpb=91d5d56c00d8e2926ccf856f14a4e52ef480d039;p=rust.git diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index cb3c88876a3..5429ce2a2e3 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -1,13 +1,3 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - //! See docs in build/expr/mod.rs use build::expr::category::Category; @@ -16,7 +6,7 @@ use hair::*; use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::*; -use rustc::ty::Variance; +use rustc::ty::{CanonicalUserTypeAnnotation, Variance}; use rustc_data_structures::indexed_vec::Idx; @@ -143,6 +133,9 @@ fn expr_as_place( ExprKind::PlaceTypeAscription { source, user_ty } => { let place = unpack!(block = this.as_place(block, source)); if let Some(user_ty) = user_ty { + let annotation_index = this.canonical_user_type_annotations.push( + CanonicalUserTypeAnnotation { span: source_info.span, user_ty } + ); this.cfg.push( block, Statement { @@ -150,7 +143,7 @@ fn expr_as_place( kind: StatementKind::AscribeUserType( place.clone(), Variance::Invariant, - box UserTypeProjection { base: user_ty, projs: vec![], }, + box UserTypeProjection { base: annotation_index, projs: vec![], }, ), }, ); @@ -163,6 +156,9 @@ fn expr_as_place( block = this.as_temp(block, source.temp_lifetime, source, mutability) ); if let Some(user_ty) = user_ty { + let annotation_index = this.canonical_user_type_annotations.push( + CanonicalUserTypeAnnotation { span: source_info.span, user_ty } + ); this.cfg.push( block, Statement { @@ -170,7 +166,7 @@ fn expr_as_place( kind: StatementKind::AscribeUserType( Place::Local(temp.clone()), Variance::Invariant, - box UserTypeProjection { base: user_ty, projs: vec![], }, + box UserTypeProjection { base: annotation_index, projs: vec![], }, ), }, );