|
| 1 | +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +// aux-build:no_method_suggested_traits.rs |
| 12 | +extern crate no_method_suggested_traits; |
| 13 | + |
| 14 | +struct Foo; |
| 15 | +enum Bar { X } |
| 16 | + |
| 17 | +mod foo { |
| 18 | + pub trait Bar { |
| 19 | + fn method(&self) {} |
| 20 | + |
| 21 | + fn method2(&self) {} |
| 22 | + } |
| 23 | + |
| 24 | + impl Bar for u32 {} |
| 25 | + |
| 26 | + impl Bar for char {} |
| 27 | +} |
| 28 | + |
| 29 | +fn main() { |
| 30 | + // test the values themselves, and autoderef. |
| 31 | + |
| 32 | + |
| 33 | + 1u32.method(); |
| 34 | + //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them |
| 35 | + //~| ERROR no method named |
| 36 | + //~| HELP `use foo::Bar;` |
| 37 | + //~| HELP `use no_method_suggested_traits::foo::PubPub;` |
| 38 | + std::rc::Rc::new(&mut Box::new(&1u32)).method(); |
| 39 | + //~^ HELP following traits are implemented but not in scope, perhaps add a `use` for one of them |
| 40 | + //~| ERROR no method named |
| 41 | + //~| HELP `use foo::Bar;` |
| 42 | + //~| HELP `use no_method_suggested_traits::foo::PubPub;` |
| 43 | + |
| 44 | + 'a'.method(); |
| 45 | + //~^ ERROR no method named |
| 46 | + //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it: |
| 47 | + //~| HELP `use foo::Bar;` |
| 48 | + std::rc::Rc::new(&mut Box::new(&'a')).method(); |
| 49 | + //~^ ERROR no method named |
| 50 | + //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it: |
| 51 | + //~| HELP `use foo::Bar;` |
| 52 | + |
| 53 | + 1i32.method(); |
| 54 | + //~^ ERROR no method named |
| 55 | + //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it: |
| 56 | + //~| HELP `use no_method_suggested_traits::foo::PubPub;` |
| 57 | + std::rc::Rc::new(&mut Box::new(&1i32)).method(); |
| 58 | + //~^ ERROR no method named |
| 59 | + //~| HELP the following trait is implemented but not in scope, perhaps add a `use` for it: |
| 60 | + //~| HELP `use no_method_suggested_traits::foo::PubPub;` |
| 61 | + |
| 62 | + Foo.method(); |
| 63 | + //~^ ERROR no method named |
| 64 | + //~| HELP following traits define an item `method`, perhaps you need to implement one of them |
| 65 | + //~| HELP `foo::Bar` |
| 66 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 67 | + //~| HELP `no_method_suggested_traits::Reexported` |
| 68 | + //~| HELP `no_method_suggested_traits::bar::PubPriv` |
| 69 | + //~| HELP `no_method_suggested_traits::qux::PrivPub` |
| 70 | + //~| HELP `no_method_suggested_traits::quz::PrivPriv` |
| 71 | + std::rc::Rc::new(&mut Box::new(&Foo)).method(); |
| 72 | + //~^ ERROR no method named |
| 73 | + //~| HELP following traits define an item `method`, perhaps you need to implement one of them |
| 74 | + //~| HELP `foo::Bar` |
| 75 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 76 | + //~| HELP `no_method_suggested_traits::Reexported` |
| 77 | + //~| HELP `no_method_suggested_traits::bar::PubPriv` |
| 78 | + //~| HELP `no_method_suggested_traits::qux::PrivPub` |
| 79 | + //~| HELP `no_method_suggested_traits::quz::PrivPriv` |
| 80 | + |
| 81 | + 1u64.method2(); |
| 82 | + //~^ ERROR no method named |
| 83 | + //~| HELP the following trait defines an item `method2`, perhaps you need to implement it |
| 84 | + //~| HELP `foo::Bar` |
| 85 | + std::rc::Rc::new(&mut Box::new(&1u64)).method2(); |
| 86 | + //~^ ERROR no method named |
| 87 | + //~| HELP the following trait defines an item `method2`, perhaps you need to implement it |
| 88 | + //~| HELP `foo::Bar` |
| 89 | + |
| 90 | + no_method_suggested_traits::Foo.method2(); |
| 91 | + //~^ ERROR no method named |
| 92 | + //~| HELP following trait defines an item `method2`, perhaps you need to implement it |
| 93 | + //~| HELP `foo::Bar` |
| 94 | + std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2(); |
| 95 | + //~^ ERROR no method named |
| 96 | + //~| HELP following trait defines an item `method2`, perhaps you need to implement it |
| 97 | + //~| HELP `foo::Bar` |
| 98 | + no_method_suggested_traits::Bar::X.method2(); |
| 99 | + //~^ ERROR no method named |
| 100 | + //~| HELP following trait defines an item `method2`, perhaps you need to implement it |
| 101 | + //~| HELP `foo::Bar` |
| 102 | + std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2(); |
| 103 | + //~^ ERROR no method named |
| 104 | + //~| HELP following trait defines an item `method2`, perhaps you need to implement it |
| 105 | + //~| HELP `foo::Bar` |
| 106 | + |
| 107 | + Foo.method3(); |
| 108 | + //~^ ERROR no method named |
| 109 | + //~| HELP following trait defines an item `method3`, perhaps you need to implement it |
| 110 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 111 | + std::rc::Rc::new(&mut Box::new(&Foo)).method3(); |
| 112 | + //~^ ERROR no method named |
| 113 | + //~| HELP following trait defines an item `method3`, perhaps you need to implement it |
| 114 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 115 | + Bar::X.method3(); |
| 116 | + //~^ ERROR no method named |
| 117 | + //~| HELP following trait defines an item `method3`, perhaps you need to implement it |
| 118 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 119 | + std::rc::Rc::new(&mut Box::new(&Bar::X)).method3(); |
| 120 | + //~^ ERROR no method named |
| 121 | + //~| HELP following trait defines an item `method3`, perhaps you need to implement it |
| 122 | + //~| HELP `no_method_suggested_traits::foo::PubPub` |
| 123 | + |
| 124 | + // should have no help: |
| 125 | + 1_usize.method3(); //~ ERROR no method named |
| 126 | + std::rc::Rc::new(&mut Box::new(&1_usize)).method3(); //~ ERROR no method named |
| 127 | + no_method_suggested_traits::Foo.method3(); //~ ERROR no method named |
| 128 | + std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3(); |
| 129 | + //~^ ERROR no method named |
| 130 | + no_method_suggested_traits::Bar::X.method3(); //~ ERROR no method named |
| 131 | + std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3(); |
| 132 | + //~^ ERROR no method named |
| 133 | +} |
0 commit comments