Skip to content

Fix tests most unused pattern variable warnings #3286

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 6 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
148 changes: 74 additions & 74 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,83 +1859,83 @@ mod unsafe {
/// Converts a byte to a string.
unsafe fn from_byte(u: u8) -> ~str { unsafe::from_bytes([u]) }

/**
* Takes a bytewise (not UTF-8) slice from a string.
*
* Returns the substring from [`begin`..`end`).
*
* # Failure
*
* If begin is greater than end.
* If end is greater than the length of the string.
*/
unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str {
do as_buf(s) |sbuf, n| {
assert (begin <= end);
assert (end <= n);

let mut v = ~[];
vec::reserve(v, end - begin + 1u);
unsafe {
do vec::as_buf(v) |vbuf, _vlen| {
let src = ptr::offset(sbuf, begin);
ptr::memcpy(vbuf, src, end - begin);
}
vec::unsafe::set_len(v, end - begin);
vec::push(v, 0u8);
::unsafe::transmute(v)
}
}
}

/**
* Takes a bytewise (not UTF-8) view from a string.
*
* Returns the substring from [`begin`..`end`).
*
* # Failure
*
* If begin is greater than end.
* If end is greater than the length of the string.
*/
#[inline]
unsafe fn view_bytes(s: &str, begin: uint, end: uint) -> &str {
do as_buf(s) |sbuf, n| {
/**
* Takes a bytewise (not UTF-8) slice from a string.
*
* Returns the substring from [`begin`..`end`).
*
* # Failure
*
* If begin is greater than end.
* If end is greater than the length of the string.
*/
unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str {
do as_buf(s) |sbuf, n| {
assert (begin <= end);
assert (end <= n);

let tuple = (ptr::offset(sbuf, begin), end - begin + 1);
::unsafe::reinterpret_cast(tuple)
}
}

/// Appends a byte to a string. (Not UTF-8 safe).
unsafe fn push_byte(&s: ~str, b: u8) {
rustrt::rust_str_push(s, b);
}

/// Appends a vector of bytes to a string. (Not UTF-8 safe).
unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) {
for vec::each(bytes) |byte| { rustrt::rust_str_push(s, byte); }
}

/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
unsafe fn pop_byte(&s: ~str) -> u8 {
let len = len(s);
assert (len > 0u);
let b = s[len - 1u];
unsafe { set_len(s, len - 1u) };
return b;
}

/// Removes the first byte from a string and returns it. (Not UTF-8 safe).
unsafe fn shift_byte(&s: ~str) -> u8 {
let len = len(s);
assert (len > 0u);
let b = s[0];
s = unsafe { unsafe::slice_bytes(s, 1u, len) };
return b;
}
let mut v = ~[];
vec::reserve(v, end - begin + 1u);
unsafe {
do vec::as_buf(v) |vbuf, _vlen| {
let src = ptr::offset(sbuf, begin);
ptr::memcpy(vbuf, src, end - begin);
}
vec::unsafe::set_len(v, end - begin);
vec::push(v, 0u8);
::unsafe::transmute(v)
}
}
}

/**
* Takes a bytewise (not UTF-8) view from a string.
*
* Returns the substring from [`begin`..`end`).
*
* # Failure
*
* If begin is greater than end.
* If end is greater than the length of the string.
*/
#[inline]
unsafe fn view_bytes(s: &str, begin: uint, end: uint) -> &str {
do as_buf(s) |sbuf, n| {
assert (begin <= end);
assert (end <= n);

let tuple = (ptr::offset(sbuf, begin), end - begin + 1);
::unsafe::reinterpret_cast(tuple)
}
}

/// Appends a byte to a string. (Not UTF-8 safe).
unsafe fn push_byte(&s: ~str, b: u8) {
rustrt::rust_str_push(s, b);
}

/// Appends a vector of bytes to a string. (Not UTF-8 safe).
unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) {
for vec::each(bytes) |byte| { rustrt::rust_str_push(s, byte); }
}

/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
unsafe fn pop_byte(&s: ~str) -> u8 {
let len = len(s);
assert (len > 0u);
let b = s[len - 1u];
unsafe { set_len(s, len - 1u) };
return b;
}

/// Removes the first byte from a string and returns it. (Not UTF-8 safe).
unsafe fn shift_byte(&s: ~str) -> u8 {
let len = len(s);
assert (len > 0u);
let b = s[0];
s = unsafe { unsafe::slice_bytes(s, 1u, len) };
return b;
}

/// Sets the length of the string and adds the null terminator
unsafe fn set_len(&v: ~str, new_len: uint) {
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/ast_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
map_struct_def(struct_def, node_item(i, item_path), i.ident, i.id, cx,
v);
}
item_trait(tps, traits, methods) => {
item_trait(_, traits, methods) => {
// Map trait refs to their parent classes. This is
// so we can find the self_ty
for traits.each |p| {
Expand Down Expand Up @@ -318,16 +318,16 @@ fn node_id_to_str(map: map, id: node_id, itr: ident_interner) -> ~str {
fmt!("foreign item %s with abi %? (id=%?)",
path_ident_to_str(*path, item.ident, itr), abi, id)
}
Some(node_method(m, impl_did, path)) => {
Some(node_method(m, _, path)) => {
fmt!("method %s in %s (id=%?)",
*itr.get(m.ident), path_to_str(*path, itr), id)
}
Some(node_trait_method(tm, impl_did, path)) => {
Some(node_trait_method(tm, _, path)) => {
let m = ast_util::trait_method_to_ty_method(*tm);
fmt!("method %s in %s (id=%?)",
*itr.get(m.ident), path_to_str(*path, itr), id)
}
Some(node_variant(variant, def_id, path)) => {
Some(node_variant(variant, _, path)) => {
fmt!("variant %s in %s (id=%?)",
*itr.get(variant.node.name), path_to_str(*path, itr), id)
}
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 @@ -197,7 +197,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>,
cx: ext_ctxt, &&it: @ast::item,
fld: ast_fold) -> Option<@ast::item> {
match it.node {
item_mac({node: mac_invoc_tt(pth, tts), span}) => {
item_mac({node: mac_invoc_tt(pth, tts), _}) => {
let extname = cx.parse_sess().interner.get(pth.idents[0]);
match exts.find(*extname) {
None => {
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/simplext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) {
Some(p_id) => {
fn select(cx: ext_ctxt, m: matchable) -> match_result {
return match m {
match_expr(e) => Some(leaf(specialize_match(m))),
match_expr(*) => Some(leaf(specialize_match(m))),
_ => cx.bug(~"broken traversal in p_t_s_r")
}
}
Expand Down Expand Up @@ -646,7 +646,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
match elts[0u].node {
expr_mac(mac) => {
match mac.node {
mac_invoc(pth, invoc_arg, body) => {
mac_invoc(pth, invoc_arg, _) => {
match path_to_ident(pth) {
Some(id) => {
let id_str = cx.str_of(id);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/print/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl printer {
if !self.scan_stack_empty {
let x = self.scan_top();
match copy self.token[x] {
BEGIN(b) => {
BEGIN(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graydon this was one line that I was unsure about. It seemed like it could be a bug...? But prob not

if k > 0 {
self.size[self.scan_pop()] = self.size[x] +
self.right_total;
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {

fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
match ni.node {
foreign_item_fn(fd, purity, tps) => {
foreign_item_fn(fd, _, tps) => {
v.visit_ty_params(tps, e, v);
visit_fn_decl(fd, e, v);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn visit_view_item(e: env, i: @ast::view_item) {

fn visit_item(e: env, i: @ast::item) {
match i.node {
ast::item_foreign_mod(m) => {
ast::item_foreign_mod(_) => {
match attr::foreign_abi(i.attrs) {
either::Right(abi) => {
if abi != ast::foreign_abi_cdecl &&
Expand Down
8 changes: 4 additions & 4 deletions src/rustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
ebml_w.end_tag();
}
item_fn(decl, purity, tps, _) => {
item_fn(_, purity, tps, _) => {
add_to_index();
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(item.id));
Expand Down Expand Up @@ -630,7 +630,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
needs to know*/
for struct_def.fields.each |f| {
match f.node.kind {
named_field(ident, mutability, vis) => {
named_field(ident, _, vis) => {
ebml_w.start_tag(tag_item_field);
encode_visibility(ebml_w, vis);
encode_name(ecx, ebml_w, ident);
Expand Down Expand Up @@ -790,7 +790,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer,

ebml_w.start_tag(tag_items_data_item);
match nitem.node {
foreign_item_fn(fn_decl, purity, tps) => {
foreign_item_fn(_, purity, tps) => {
encode_def_id(ebml_w, local_def(nitem.id));
encode_family(ebml_w, purity_fn_family(purity));
encode_type_param_bounds(ebml_w, ecx, tps);
Expand All @@ -803,7 +803,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
}
encode_path(ecx, ebml_w, path, ast_map::path_name(nitem.ident));
}
foreign_item_const(t) => {
foreign_item_const(*) => {
encode_def_id(ebml_w, local_def(nitem.id));
encode_family(ebml_w, 'c');
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id));
Expand Down
4 changes: 2 additions & 2 deletions src/rustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ fn mk_filesearch(maybe_sysroot: Option<Path>,
self.target_triple));
match get_cargo_lib_path_nearest() {
result::ok(p) => vec::push(paths, p),
result::err(p) => ()
result::err(_) => ()
}
match get_cargo_lib_path() {
result::ok(p) => vec::push(paths, p),
result::err(p) => ()
result::err(_) => ()
}
paths
}
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/middle/borrowck/gather_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl gather_loan_ctxt {
arm_id: ast::node_id, alt_id: ast::node_id) {
do self.bccx.cat_pattern(discr_cmt, root_pat) |cmt, pat| {
match pat.node {
ast::pat_ident(bm, id, o_pat) if !self.pat_is_variant(pat) => {
ast::pat_ident(bm, _, _) if !self.pat_is_variant(pat) => {
match bm {
ast::bind_by_value | ast::bind_by_move => {
// copying does not borrow anything, so no check
Expand Down
6 changes: 3 additions & 3 deletions src/rustc/middle/borrowck/loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ impl loan_ctxt {
// then the memory is freed.
self.loan_unstable_deref(cmt, cmt_base, req_mutbl)
}
cat_deref(cmt1, _, unsafe_ptr) |
cat_deref(cmt1, _, gc_ptr) |
cat_deref(cmt1, _, region_ptr(_)) => {
cat_deref(_, _, unsafe_ptr) |
cat_deref(_, _, gc_ptr) |
cat_deref(_, _, region_ptr(_)) => {
// Aliased data is simply not lendable.
self.bccx.tcx.sess.span_bug(
cmt.span,
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/middle/borrowck/preserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl preserve_condition {
fn combine(pc: preserve_condition) -> preserve_condition {
match self {
pc_ok => {pc}
pc_if_pure(e) => {self}
pc_if_pure(_) => {self}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/rustc/middle/check_alt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
// Grab the class data that we care about.
let class_fields, class_id;
match ty::get(left_ty).struct {
ty::ty_class(cid, substs) => {
ty::ty_class(cid, _) => {
class_id = cid;
class_fields = ty::lookup_class_fields(tcx, class_id);
}
Expand Down Expand Up @@ -414,7 +414,7 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) {

fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
match tcx.def_map.find(pat.id) {
Some(def_variant(enum_id, var_id)) => {
Some(def_variant(enum_id, _)) => {
if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map,

fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) {
match e.node {
expr_path(path) => {
expr_path(*) => {
match env.def_map.find(e.id) {
Some(def_const(def_id)) => {
match env.ast_map.get(def_id.node) {
Expand Down
4 changes: 2 additions & 2 deletions src/rustc/middle/freevars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk)

let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
match expr.node {
ast::expr_fn(proto, decl, _, _) => {
ast::expr_fn(proto, _, _, _) => {
if proto != ast::proto_bare {
visit::visit_expr(expr, depth + 1, v);
}
}
ast::expr_fn_block(*) => {
visit::visit_expr(expr, depth + 1, v);
}
ast::expr_path(path) => {
ast::expr_path(*) => {
let mut i = 0;
match def_map.find(expr.id) {
None => fail ~"path not found",
Expand Down
4 changes: 2 additions & 2 deletions src/rustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
either::Right(ast::foreign_abi_rust_intrinsic) => {
for nmod.items.each |ni| {
match ni.node {
ast::foreign_item_fn(decl, _, tps) => {
ast::foreign_item_fn(decl, _, _) => {
check_foreign_fn(cx, it.id, decl);
}
ast::foreign_item_const(*) => {} // XXX: Not implemented.
Expand All @@ -434,7 +434,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
match s.node {
ast::stmt_semi(@{id: id,
callee_id: _,
node: ast::expr_path(@path),
node: ast::expr_path(_),
span: _}, _) => {
cx.sess.span_lint(
path_statement, id, it.id,
Expand Down
Loading