Don't warn when imported traits are indeed used
This commit is contained in:
parent
6a4483ec7a
commit
b368cb2341
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user