Skip to content

Remove (more) dependencies on TypeContents #20159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
};
let mut visitor = ExprUseVisitor::new(&mut checker,
checker.cx.tcx,
cx.param_env.clone());
&cx.param_env);
visitor.walk_expr(guard);
}

Expand Down
14 changes: 10 additions & 4 deletions src/librustc/middle/check_rvalues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn check_crate(tcx: &ty::ctxt,
}

struct RvalueContext<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>
tcx: &'a ty::ctxt<'tcx>,
}

impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
Expand All @@ -40,21 +40,27 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
fn_id: ast::NodeId) {
{
let param_env = ParameterEnvironment::for_item(self.tcx, fn_id);
let mut euv = euv::ExprUseVisitor::new(self, self.tcx, param_env);
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: &param_env };
let mut euv = euv::ExprUseVisitor::new(&mut delegate, self.tcx, &param_env);
euv.walk_fn(fd, b);
}
visit::walk_fn(self, fk, fd, b, s)
}
}

impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContext<'a, 'tcx> {
struct RvalueContextDelegate<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
param_env: &'a ty::ParameterEnvironment<'tcx>,
}

impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
fn consume(&mut self,
_: ast::NodeId,
span: Span,
cmt: mc::cmt<'tcx>,
_: euv::ConsumeMode) {
debug!("consume; cmt: {}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
if !ty::type_is_sized(self.tcx, cmt.ty) {
if !ty::type_is_sized(self.tcx, cmt.ty, self.param_env) {
span_err!(self.tcx.sess, span, E0161,
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
ty_to_string(self.tcx, cmt.ty));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn check_crate(tcx: &ty::ctxt) {
};
{
let param_env = ty::empty_parameter_environment();
let visitor = euv::ExprUseVisitor::new(&mut checker, tcx, param_env);
let visitor = euv::ExprUseVisitor::new(&mut checker, tcx, &param_env);
visit::walk_crate(&mut GlobalVisitor(visitor), tcx.map.krate());
}
visit::walk_crate(&mut CheckStaticVisitor {
Expand Down
15 changes: 7 additions & 8 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ impl OverloadedCallType {
// supplies types from the tree. After type checking is complete, you
// can just use the tcx as the typer.

pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> {
pub struct ExprUseVisitor<'d,'t,'tcx:'t,TYPER:'t> {
typer: &'t TYPER,
mc: mc::MemCategorizationContext<'t,TYPER>,
delegate: &'d mut (Delegate<'tcx>+'d),
param_env: ParameterEnvironment<'tcx>,
param_env: &'t ParameterEnvironment<'tcx>,
}

/// Whether the elements of an overloaded operation are passed by value or by reference
Expand All @@ -311,7 +311,7 @@ enum PassArgs {
impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
pub fn new(delegate: &'d mut Delegate<'tcx>,
typer: &'t TYPER,
param_env: ParameterEnvironment<'tcx>)
param_env: &'t ParameterEnvironment<'tcx>)
-> ExprUseVisitor<'d,'t,'tcx,TYPER> {
ExprUseVisitor {
typer: typer,
Expand Down Expand Up @@ -355,7 +355,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
cmt: mc::cmt<'tcx>) {
let mode = copy_or_move(self.tcx(),
cmt.ty,
&self.param_env,
self.param_env,
DirectRefMove);
self.delegate.consume(consume_id, consume_span, cmt, mode);
}
Expand Down Expand Up @@ -991,7 +991,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
ast::PatIdent(ast::BindByValue(_), _, _) => {
match copy_or_move(tcx,
cmt_pat.ty,
&self.param_env,
self.param_env,
PatBindingMove) {
Copy => mode.lub(CopyingMatch),
Move(_) => mode.lub(MovingMatch),
Expand Down Expand Up @@ -1021,8 +1021,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
let typer = self.typer;
let def_map = &self.typer.tcx().def_map;
let delegate = &mut self.delegate;
let param_env = &mut self.param_env;

let param_env = self.param_env;
mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
if pat_util::pat_is_binding(def_map, pat) {
let tcx = typer.tcx();
Expand Down Expand Up @@ -1242,7 +1241,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
closure_expr.span,
freevar.def);
let mode = copy_or_move(self.tcx(), cmt_var.ty,
&self.param_env, CaptureMove);
self.param_env, CaptureMove);
self.delegate.consume(closure_expr.id, freevar.span, cmt_var, mode);
}
}
Expand Down
Loading