Skip to content

Remove some @Pat #10657

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
wants to merge 3 commits into from
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
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'self> Visitor<()> for CheckLoanCtxt<'self> {
fn visit_block(&mut self, b:&ast::Block, _:()) {
check_loans_in_block(self, b);
}
fn visit_pat(&mut self, p:@ast::Pat, _:()) {
fn visit_pat(&mut self, p:&ast::Pat, _:()) {
check_loans_in_pat(self, p);
}
fn visit_fn(&mut self, fk:&visit::fn_kind, fd:&ast::fn_decl,
Expand Down Expand Up @@ -847,7 +847,7 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>,
}

fn check_loans_in_pat<'a>(this: &mut CheckLoanCtxt<'a>,
pat: @ast::Pat)
pat: &ast::Pat)
{
this.check_for_conflicting_loans(pat.id);
this.check_move_out_from_id(pat.id, pat.span);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'self> visit::Visitor<()> for GatherLoanCtxt<'self> {
fn visit_stmt(&mut self, s:@Stmt, _:()) {
add_stmt_to_map(self, s);
}
fn visit_pat(&mut self, p:@Pat, _:()) {
fn visit_pat(&mut self, p:&Pat, _:()) {
add_pat_to_id_range(self, p);
}
fn visit_local(&mut self, l:@Local, _:()) {
Expand Down Expand Up @@ -119,7 +119,7 @@ pub fn gather_loans(bccx: &BorrowckCtxt,
}

fn add_pat_to_id_range(this: &mut GatherLoanCtxt,
p: @ast::Pat) {
p: &ast::Pat) {
// NB: This visitor function just adds the pat ids into the id
// range. We gather loans that occur in patterns using the
// `gather_pat()` method below. Eventually these two should be
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Visitor<bool> for CheckCrateVisitor {
fn visit_item(&mut self, i:@item, env:bool) {
check_item(self, self.sess, self.ast_map, self.def_map, i, env);
}
fn visit_pat(&mut self, p:@Pat, env:bool) {
fn visit_pat(&mut self, p:&Pat, env:bool) {
check_pat(self, p, env);
}
fn visit_expr(&mut self, ex:@Expr, env:bool) {
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn check_item(v: &mut CheckCrateVisitor,
}
}

pub fn check_pat(v: &mut CheckCrateVisitor, p: @Pat, _is_const: bool) {
pub fn check_pat(v: &mut CheckCrateVisitor, p: &Pat, _is_const: bool) {
fn is_str(e: @Expr) -> bool {
match e.node {
ExprVstore(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ fn check_unsafe_block(cx: &Context, e: &ast::Expr) {
}
}

fn check_unused_mut_pat(cx: &Context, p: @ast::Pat) {
fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
match p.node {
ast::PatIdent(ast::BindByValue(ast::MutMutable),
ref path, _) if pat_util::pat_is_binding(cx.tcx.def_map, p)=> {
Expand Down Expand Up @@ -1119,7 +1119,7 @@ impl<'self> Visitor<()> for Context<'self> {
}
}

fn visit_pat(&mut self, p: @ast::Pat, _: ()) {
fn visit_pat(&mut self, p: &ast::Pat, _: ()) {
check_pat_non_uppercase_statics(self, p);
check_unused_mut_pat(self, p);

Expand Down
23 changes: 0 additions & 23 deletions src/librustc/middle/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ impl VisitContext {
}

ExprMatch(discr, ref arms) => {
// We must do this first so that `arms_have_by_move_bindings`
// below knows which bindings are moves.
for arm in arms.iter() {
self.consume_arm(arm);
}
Expand Down Expand Up @@ -657,27 +655,6 @@ impl VisitContext {
self.consume_expr(arg_expr)
}

pub fn arms_have_by_move_bindings(&mut self,
moves_map: MovesMap,
arms: &[Arm])
-> Option<@Pat> {
let mut ret = None;
for arm in arms.iter() {
for &pat in arm.pats.iter() {
let cont = do ast_util::walk_pat(pat) |p| {
if moves_map.contains(&p.id) {
ret = Some(p);
false
} else {
true
}
};
if !cont { return ret }
}
}
ret
}

pub fn compute_captures(&mut self, fn_expr_id: NodeId) -> @[CaptureVar] {
debug!("compute_capture_vars(fn_expr_id={:?})", fn_expr_id);
let _indenter = indenter();
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub type PatIdMap = HashMap<Ident, NodeId>;

// This is used because same-named variables in alternative patterns need to
// use the NodeId of their namesake in the first pattern.
pub fn pat_id_map(dm: resolve::DefMap, pat: @Pat) -> PatIdMap {
pub fn pat_id_map(dm: resolve::DefMap, pat: &Pat) -> PatIdMap {
let mut map = HashMap::new();
do pat_bindings(dm, pat) |_bm, p_id, _s, n| {
map.insert(path_to_ident(n), p_id);
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn pat_is_const(dm: resolve::DefMap, pat: &Pat) -> bool {
}
}

pub fn pat_is_binding(dm: resolve::DefMap, pat: @Pat) -> bool {
pub fn pat_is_binding(dm: resolve::DefMap, pat: &Pat) -> bool {
match pat.node {
PatIdent(*) => {
!pat_is_variant_or_struct(dm, pat) &&
Expand All @@ -62,7 +62,7 @@ pub fn pat_is_binding(dm: resolve::DefMap, pat: @Pat) -> bool {
}
}

pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @Pat) -> bool {
pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: &Pat) -> bool {
match pat.node {
PatIdent(*) => pat_is_binding(dm, pat),
PatWild | PatWildMulti => true,
Expand All @@ -73,7 +73,7 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @Pat) -> bool {
/// Call `it` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub fn pat_bindings(dm: resolve::DefMap,
pat: @Pat,
pat: &Pat,
it: |BindingMode, NodeId, Span, &Path|) {
do walk_pat(pat) |p| {
match p.node {
Expand All @@ -86,15 +86,15 @@ pub fn pat_bindings(dm: resolve::DefMap,
};
}

pub fn pat_binding_ids(dm: resolve::DefMap, pat: @Pat) -> ~[NodeId] {
pub fn pat_binding_ids(dm: resolve::DefMap, pat: &Pat) -> ~[NodeId] {
let mut found = ~[];
pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) );
return found;
}

/// Checks if the pattern contains any patterns that bind something to
/// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(*)`.
pub fn pat_contains_bindings(dm: resolve::DefMap, pat: @Pat) -> bool {
pub fn pat_contains_bindings(dm: resolve::DefMap, pat: &Pat) -> bool {
let mut contains_bindings = false;
do walk_pat(pat) |p| {
if pat_is_binding(dm, p) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ impl<'self> Visitor<()> for PrivacyVisitor<'self> {
}
}

fn visit_pat(&mut self, pattern: @ast::Pat, _: ()) {
fn visit_pat(&mut self, pattern: &ast::Pat, _: ()) {
match pattern.node {
ast::PatStruct(_, ref fields, _) => {
match ty::get(ty::pat_ty(self.tcx, pattern)).sty {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn resolve_arm(visitor: &mut RegionResolutionVisitor,
}

fn resolve_pat(visitor: &mut RegionResolutionVisitor,
pat: @ast::Pat,
pat: &ast::Pat,
cx: Context) {
assert_eq!(cx.var_parent, cx.parent);
parent_to_expr(visitor, cx, pat.id, pat.span);
Expand Down Expand Up @@ -480,7 +480,7 @@ impl Visitor<Context> for RegionResolutionVisitor {
fn visit_arm(&mut self, a:&Arm, cx:Context) {
resolve_arm(self, a, cx);
}
fn visit_pat(&mut self, p:@Pat, cx:Context) {
fn visit_pat(&mut self, p:&Pat, cx:Context) {
resolve_pat(self, p, cx);
}
fn visit_stmt(&mut self, s:@Stmt, cx:Context) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Visitor<()> for GatherLocalsVisitor {

}
// Add pattern bindings.
fn visit_pat(&mut self, p:@ast::Pat, _:()) {
fn visit_pat(&mut self, p:&ast::Pat, _:()) {
match p.node {
ast::PatIdent(_, ref path, _)
if pat_util::pat_is_binding(self.fcx.ccx.tcx.def_map, p) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn visit_block(b: &ast::Block, wbcx: &mut WbCtxt) {
visit::walk_block(wbcx, b, ());
}

fn visit_pat(p: @ast::Pat, wbcx: &mut WbCtxt) {
fn visit_pat(p: &ast::Pat, wbcx: &mut WbCtxt) {
if !wbcx.success {
return;
}
Expand Down Expand Up @@ -323,7 +323,7 @@ impl Visitor<()> for WbCtxt {
fn visit_stmt(&mut self, s:@ast::Stmt, _:()) { visit_stmt(s, self); }
fn visit_expr(&mut self, ex:@ast::Expr, _:()) { visit_expr(ex, self); }
fn visit_block(&mut self, b:&ast::Block, _:()) { visit_block(b, self); }
fn visit_pat(&mut self, p:@ast::Pat, _:()) { visit_pat(p, self); }
fn visit_pat(&mut self, p:&ast::Pat, _:()) { visit_pat(p, self); }
fn visit_local(&mut self, l:@ast::Local, _:()) { visit_local(l, self); }
}

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ast_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Ctx {
visit::walk_block(self, b, ());
}

fn map_pat(&mut self, pat: @Pat) {
fn map_pat(&mut self, pat: &Pat) {
match pat.node {
PatIdent(_, ref path, _) => {
// Note: this is at least *potentially* a pattern...
Expand Down Expand Up @@ -345,7 +345,7 @@ impl Visitor<()> for Ctx {
self.path.pop();
}

fn visit_pat(&mut self, pat: @Pat, _: ()) {
fn visit_pat(&mut self, pat: &Pat, _: ()) {
self.map_pat(pat);
visit::walk_pat(self, pat, ())
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ impl<'self, O: IdVisitingOperation> Visitor<()> for IdVisitor<'self, O> {
visit::walk_stmt(self, statement, env)
}

fn visit_pat(&mut self, pattern: @Pat, env: ()) {
fn visit_pat(&mut self, pattern: &Pat, env: ()) {
self.operation.visit_id(pattern.id);
visit::walk_pat(self, pattern, env)
}
Expand Down Expand Up @@ -636,7 +636,7 @@ pub fn is_item_impl(item: @ast::item) -> bool {
}
}

pub fn walk_pat(pat: @Pat, it: |@Pat| -> bool) -> bool {
pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
if !it(pat) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ struct NewNameFinderContext {
}

impl Visitor<()> for NewNameFinderContext {
fn visit_pat(&mut self, pattern: @ast::Pat, _: ()) {
fn visit_pat(&mut self, pattern: &ast::Pat, _: ()) {
match *pattern {
// we found a pat_ident!
ast::Pat {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub trait Visitor<E:Clone> {
fn visit_block(&mut self, b:&Block, e:E) { walk_block(self, b, e) }
fn visit_stmt(&mut self, s:@Stmt, e:E) { walk_stmt(self, s, e) }
fn visit_arm(&mut self, a:&Arm, e:E) { walk_arm(self, a, e) }
fn visit_pat(&mut self, p:@Pat, e:E) { walk_pat(self, p, e) }
fn visit_pat(&mut self, p:&Pat, e:E) { walk_pat(self, p, e) }
fn visit_decl(&mut self, d:@Decl, e:E) { walk_decl(self, d, e) }
fn visit_expr(&mut self, ex:@Expr, e:E) { walk_expr(self, ex, e) }
fn visit_expr_post(&mut self, _ex:@Expr, _e:E) { }
Expand Down