Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
81e4027
Update RELEASES.md for 1.42.0
XAMPPRocky Feb 9, 2020
26fdcbb
Update RELEASES.md
XAMPPRocky Feb 9, 2020
7ab01b2
Update RELEASES.md
XAMPPRocky Feb 10, 2020
32daa2a
Update RELEASES.md
XAMPPRocky Feb 10, 2020
b030280
Blacklist powerpc-unknown-linux-gnu as having non-ignored GNU C ZSTs.
anyska Feb 18, 2020
9fa8d87
Add more context to E0599 errors
estebank Feb 18, 2020
24bfa16
Reduce vebosity of E0599
estebank Feb 18, 2020
70255ef
On single local candidate, use span label
estebank Feb 18, 2020
2e8399d
Deduplicate information in E0599
estebank Feb 18, 2020
1b4c5b5
Track all predicates in errors, not just trait obligations
estebank Feb 19, 2020
9a7345b
Show information of chain of bound obligations
estebank Feb 19, 2020
615542a
Point at closure definitions
estebank Feb 19, 2020
9245415
Mention the full path of the implementing trait
estebank Feb 19, 2020
cfbb746
Tweak wording
estebank Feb 19, 2020
7818a1d
Suggest constraining type parameters
estebank Feb 19, 2020
3a58953
Account for arbitrary self types in E0599
estebank Feb 19, 2020
529b891
Review comments: split requirement text to multiple lines for readabi…
estebank Feb 21, 2020
5da3939
miri/machine: add canonical_alloc_id hook to replace find_foreign_static
RalfJung Feb 23, 2020
e7a344f
Update RELEASES.md
XAMPPRocky Feb 23, 2020
01d9329
canonicalize alloc ID before calling tag_static_base_pointer
RalfJung Feb 23, 2020
9b62d60
fmt
RalfJung Feb 23, 2020
162d727
Also blacklist powerpc-unknown-linux-musl.
anyska Feb 24, 2020
a66599f
keep predicate order and tweak output
estebank Feb 25, 2020
c02de78
Reduce verbosity when suggesting restricting type params
estebank Feb 25, 2020
0173490
Reword message
estebank Feb 25, 2020
c02e56a
Do not suggest implementing traits if present in predicates
estebank Feb 25, 2020
526280a
Merge branch 'master' into relnotes-1.42.0
XAMPPRocky Feb 26, 2020
e6c8596
Revert "Backport only: avoid ICE on bad placeholder type"
estebank Feb 27, 2020
a7b727d
Account for bounds when denying `_` in type parameters
estebank Feb 13, 2020
c6cfcf9
Account for associated items when denying `_`
estebank Feb 17, 2020
4e0bea3
Stabilize `boxed_slice_try_from`
JohnTitor Feb 28, 2020
85b585d
late resolve, visit_fn: bail early if there's no body.
Centril Feb 28, 2020
35d64ee
Rollup merge of #68989 - XAMPPRocky:relnotes-1.42.0, r=Mark-Simulacrum
Dylan-DPC Feb 28, 2020
0c3a8cd
Rollup merge of #69148 - estebank:cold-as-ice, r=oli-obk
Dylan-DPC Feb 28, 2020
88f66f1
Rollup merge of #69255 - estebank:e0599-details, r=varkor
Dylan-DPC Feb 28, 2020
e5da563
Rollup merge of #69263 - anyska:blacklist-powerpc-zst, r=nagisa
Dylan-DPC Feb 28, 2020
04f5aae
Rollup merge of #69408 - RalfJung:canonical-alloc-id, r=oli-obk
Dylan-DPC Feb 28, 2020
bad53f3
Rollup merge of #69538 - JohnTitor:boxed-slice-try-from, r=Centril
Dylan-DPC Feb 28, 2020
a1b918a
Rollup merge of #69539 - Centril:fix-69401, r=petrochenkov
Dylan-DPC Feb 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
On single local candidate, use span label
  • Loading branch information
estebank committed Feb 21, 2020
commit 70255ef7d7ca78e037941f99f5a34ce5cc474df8
33 changes: 23 additions & 10 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let message = |action| {
format!(
"the following {traits_define} an item `{name}`, perhaps you need to {action} \
{one_of_them}:",
{one_of_them}:",
traits_define =
if candidates.len() == 1 { "trait defines" } else { "traits define" },
action = action,
Expand Down Expand Up @@ -944,19 +944,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

if !suggested {
let mut msg = message(if let Some(param) = param_type {
let action = if let Some(param) = param_type {
format!("restrict type parameter `{}` with", param)
} else {
"implement".to_string()
});
for (i, trait_info) in candidates.iter().enumerate() {
msg.push_str(&format!(
"\ncandidate #{}: `{}`",
i + 1,
self.tcx.def_path_str(trait_info.def_id),
));
};
let mut use_note = true;
if let [trait_info] = &candidates[..] {
if let Some(span) = self.tcx.hir().span_if_local(trait_info.def_id) {
err.span_label(
self.tcx.sess.source_map().def_span(span),
&format!("this trait defines an item `{}`", item_name),
);
use_note = false
}
}
if use_note {
let mut msg = message(action);
for (i, trait_info) in candidates.iter().enumerate() {
msg.push_str(&format!(
"\ncandidate #{}: `{}`",
i + 1,
self.tcx.def_path_str(trait_info.def_id),
));
}
err.note(&msg[..]);
}
err.note(&msg[..]);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/associated-const/associated-const-no-item.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
error[E0599]: no associated item named `ID` found for type `i32` in the current scope
--> $DIR/associated-const-no-item.rs:5:23
|
LL | trait Foo {
| --------- this trait defines an item `ID`
...
LL | const X: i32 = <i32>::ID;
| ^^ associated item not found in `i32`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `ID`, perhaps you need to implement it:
candidate #1: `Foo`

error: aborting due to previous error

Expand Down
20 changes: 12 additions & 8 deletions src/test/ui/auto-ref-slice-plus-ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,44 @@ error[E0599]: no method named `test_mut` found for struct `std::vec::Vec<{intege
|
LL | a.test_mut();
| ^^^^^^^^ help: there is a method with a similar name: `get_mut`
...
LL | trait MyIter {
| ------------ this trait defines an item `test_mut`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
candidate #1: `MyIter`

error[E0599]: no method named `test` found for struct `std::vec::Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
|
LL | a.test();
| ^^^^ method not found in `std::vec::Vec<{integer}>`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
candidate #1: `MyIter`

error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
|
LL | ([1]).test();
| ^^^^ method not found in `[{integer}; 1]`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
candidate #1: `MyIter`

error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
|
LL | (&[1]).test();
| ^^^^ method not found in `&[{integer}; 1]`
...
LL | trait MyIter {
| ------------ this trait defines an item `test`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `test`, perhaps you need to implement it:
candidate #1: `MyIter`

error: aborting due to 4 previous errors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
error[E0599]: no method named `foo` found for struct `Bar` in the current scope
--> $DIR/issue-21659-show-relevant-trait-impls-3.rs:20:8
|
LL | trait Foo<A> {
| ------------ this trait defines an item `foo`
...
LL | struct Bar;
| ----------- method `foo` not found for this
...
LL | f1.foo(1usize);
| ^^^ method not found in `Bar`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `Foo`

error: aborting due to previous error

Expand Down
30 changes: 18 additions & 12 deletions src/test/ui/impl-trait/no-method-suggested-traits.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -122,62 +122,68 @@ LL | std::rc::Rc::new(&mut Box::new(&Foo)).method();
error[E0599]: no method named `method2` found for type `u64` in the current scope
--> $DIR/no-method-suggested-traits.rs:45:10
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | 1u64.method2();
| ^^^^^^^ method not found in `u64`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&u64>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:47:44
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&1u64)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u64>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method2` found for struct `no_method_suggested_traits::Foo` in the current scope
--> $DIR/no-method-suggested-traits.rs:50:37
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | no_method_suggested_traits::Foo.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:52:71
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Foo>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method2` found for enum `no_method_suggested_traits::Bar` in the current scope
--> $DIR/no-method-suggested-traits.rs:54:40
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | no_method_suggested_traits::Bar::X.method2();
| ^^^^^^^ method not found in `no_method_suggested_traits::Bar`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method2` found for struct `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>` in the current scope
--> $DIR/no-method-suggested-traits.rs:56:74
|
LL | pub trait Bar {
| ------------- this trait defines an item `method2`
...
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
| ^^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&no_method_suggested_traits::Bar>>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `method2`, perhaps you need to implement it:
candidate #1: `foo::Bar`

error[E0599]: no method named `method3` found for struct `Foo` in the current scope
--> $DIR/no-method-suggested-traits.rs:59:9
Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/issues/issue-5153.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
error[E0599]: no method named `foo` found for reference `&dyn Foo` in the current scope
--> $DIR/issue-5153.rs:10:27
|
LL | trait Foo {
| --------- this trait defines an item `foo`
...
LL | (&5isize as &dyn Foo).foo();
| ^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `Foo`

error: aborting due to previous error

Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/issues/issue-57362-1.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
error[E0599]: no method named `f` found for fn pointer `fn(&u8)` in the current scope
--> $DIR/issue-57362-1.rs:20:7
|
LL | trait Trait {
| ----------- this trait defines an item `f`
...
LL | a.f();
| ^ method not found in `fn(&u8)`
|
= note: `a` is a function, perhaps you wish to call it
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `f`, perhaps you need to implement it:
candidate #1: `Trait`

error: aborting due to previous error

Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/issues/issue-57362-2.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope
--> $DIR/issue-57362-2.rs:22:25
|
LL | trait X {
| ------- this trait defines an item `make_g`
...
LL | let x = <fn (&())>::make_g();
| ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `make_g`, perhaps you need to implement it:
candidate #1: `X`

error: aborting due to previous error

Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/never_type/issue-2149.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ LL | for elt in self { r = r + f(*elt); }
error[E0599]: no method named `bind` found for array `[&str; 1]` in the current scope
--> $DIR/issue-2149.rs:13:12
|
LL | trait VecMonad<A> {
| ----------------- this trait defines an item `bind`
...
LL | ["hi"].bind(|x| [x] );
| ^^^^ method not found in `[&str; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `bind`, perhaps you need to implement it:
candidate #1: `VecMonad`

error: aborting due to 2 previous errors

Expand Down
10 changes: 6 additions & 4 deletions src/test/ui/object-pointer-types.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:11:7
|
LL | trait Foo {
| --------- this trait defines an item `owned`
...
LL | x.owned();
| ^^^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `owned`, perhaps you need to implement it:
candidate #1: `Foo`

error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:17:7
|
LL | trait Foo {
| --------- this trait defines an item `owned`
...
LL | x.owned();
| ^^^^^ method not found in `&mut dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `owned`, perhaps you need to implement it:
candidate #1: `Foo`

error[E0599]: no method named `managed` found for struct `std::boxed::Box<(dyn Foo + 'static)>` in the current scope
--> $DIR/object-pointer-types.rs:23:7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
--> $DIR/point-at-arbitrary-self-type-trait-method.rs:9:7
|
LL | trait B { fn foo(self: Box<Self>); }
| --- the method is available for `std::boxed::Box<A>` here
| ------- --- the method is available for `std::boxed::Box<A>` here
| |
| this trait defines an item `foo`
LL | struct A;
| --------- method `foo` not found for this
...
LL | A.foo()
| ^^^ method not found in `A`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo`, perhaps you need to implement it:
candidate #1: `B`

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
error[E0599]: no method named `foo_one` found for struct `MyStruct` in the current scope
--> $DIR/specialization-trait-not-implemented.rs:22:29
|
LL | trait Foo {
| --------- this trait defines an item `foo_one`
...
LL | struct MyStruct;
| ----------------
| |
Expand All @@ -13,8 +16,6 @@ LL | println!("{}", MyStruct.foo_one());
= note: the method `foo_one` exists but the following trait bounds were not satisfied:
`MyStruct: Foo`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `foo_one`, perhaps you need to implement it:
candidate #1: `Foo`

error: aborting due to previous error

Expand Down
Loading