about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-02-05 12:29:45 -0500
committerAlex Crichton <alex@alexcrichton.com>2013-02-05 12:41:19 -0500
commitb368cb234126d1ada88ad5214102c68898eeffc7 (patch)
tree8d9f678bbfe0822d1e93848cfe1477421d27f5f1 /src
parent6a4483ec7a92bedab69b363aeeb6931b1bb5951f (diff)
downloadrust-b368cb234126d1ada88ad5214102c68898eeffc7.tar.gz
rust-b368cb234126d1ada88ad5214102c68898eeffc7.zip
Don't warn when imported traits are indeed used
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/resolve.rs11
-rw-r--r--src/test/compile-fail/unused-imports-warn.rs6
2 files changed, 14 insertions, 3 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 4213201db61..e332a71b57c 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -5061,9 +5061,13 @@ pub impl Resolver {
                             Some(def) => {
                                 match def {
                                     def_ty(trait_def_id) => {
-                                        self.
+                                        let added = self.
                                         add_trait_info_if_containing_method(
                                         found_traits, trait_def_id, name);
+                                        if added {
+                                            import_resolution.state.used =
+                                                true;
+                                        }
                                     }
                                     _ => {
                                         // Continue.
@@ -5096,7 +5100,7 @@ pub impl Resolver {
 
     fn add_trait_info_if_containing_method(found_traits: @DVec<def_id>,
                                            trait_def_id: def_id,
-                                           name: ident) {
+                                           name: ident) -> bool {
 
         debug!("(adding trait info if containing method) trying trait %d:%d \
                 for method '%s'",
@@ -5112,9 +5116,10 @@ pub impl Resolver {
                        trait_def_id.node,
                        self.session.str_of(name));
                 (*found_traits).push(trait_def_id);
+                true
             }
             Some(_) | None => {
-                // Continue.
+                false
             }
         }
     }
diff --git a/src/test/compile-fail/unused-imports-warn.rs b/src/test/compile-fail/unused-imports-warn.rs
index 52a9e1b38ff..6dcdb413f88 100644
--- a/src/test/compile-fail/unused-imports-warn.rs
+++ b/src/test/compile-fail/unused-imports-warn.rs
@@ -20,6 +20,11 @@ use core::util::*;              // shouldn't get errors for not using
 // Should only get one error instead of two errors here
 use core::option::{Some, None}; //~ ERROR unused import
 
+use core::io::ReaderUtil;       //~ ERROR unused import
+// Be sure that if we just bring some methods into scope that they're also
+// counted as being used.
+use core::io::WriterUtil;
+
 mod foo {
     pub struct Point{x: int, y: int}
     pub struct Square{p: Point, h: uint, w: uint}
@@ -37,4 +42,5 @@ fn main() {
     cal(foo::Point{x:3, y:9});
     let a = 3;
     ignore(a);
+    io::stdout().write_str(~"a");
 }