Skip to content

Commit

Permalink
Correct span for unused type parameter error in type alias (fixes #30236
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Manishearth committed Dec 6, 2015
1 parent bf79ffa commit 050ad0d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -704,9 +704,9 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
hir::ItemStruct(..) => {
check_struct(ccx, it.id, it.span);
}
hir::ItemTy(ref t, ref generics) => {
hir::ItemTy(_, ref generics) => {
let pty_ty = ccx.tcx.node_id_to_type(it.id);
check_bounds_are_used(ccx, t.span, &generics.ty_params, pty_ty);
check_bounds_are_used(ccx, &generics.ty_params, pty_ty);
}
hir::ItemForeignMod(ref m) => {
if m.abi == abi::RustIntrinsic {
Expand Down Expand Up @@ -4904,7 +4904,6 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool {
}

pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
span: Span,
tps: &OwnedSlice<hir::TyParam>,
ty: Ty<'tcx>) {
debug!("check_bounds_are_used(n_tps={}, ty={:?})",
Expand All @@ -4923,7 +4922,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,

for (i, b) in tps_used.iter().enumerate() {
if !*b {
span_err!(ccx.tcx.sess, span, E0091,
span_err!(ccx.tcx.sess, tps[i].span, E0091,
"type parameter `{}` is unused",
tps[i].name);
}
Expand Down
18 changes: 18 additions & 0 deletions src/test/compile-fail/issue-30236.rs
@@ -0,0 +1,18 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

type Foo<
Unused //~ ERROR type parameter `Unused` is unused
> = u8;

fn main() {

}

0 comments on commit 050ad0d

Please sign in to comment.