From 050ad0d67e3353a1395f23b2a21db0583948ebf2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 6 Dec 2015 22:25:53 +0530 Subject: [PATCH] Correct span for unused type parameter error in type alias (fixes #30236) --- src/librustc_typeck/check/mod.rs | 7 +++---- src/test/compile-fail/issue-30236.rs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/test/compile-fail/issue-30236.rs diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index ed8bb6a962509..622b2e4238fbb 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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 { @@ -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, ty: Ty<'tcx>) { debug!("check_bounds_are_used(n_tps={}, ty={:?})", @@ -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); } diff --git a/src/test/compile-fail/issue-30236.rs b/src/test/compile-fail/issue-30236.rs new file mode 100644 index 0000000000000..45a5cd093379f --- /dev/null +++ b/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 or the MIT license +// , 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() { + +} +