Fixed grammar in one diagnostic and blessed tests.

This commit is contained in:
Alexander Regueiro 2019-09-30 00:58:05 +01:00
parent 8a4af2f699
commit 13b61b50d9
16 changed files with 43 additions and 39 deletions

View File

@ -631,26 +631,30 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
fn suggest_valid_traits(&self,
err: &mut DiagnosticBuilder<'_>,
valid_out_of_scope_traits: Vec<DefId>) -> bool {
fn suggest_valid_traits(
&self,
err: &mut DiagnosticBuilder<'_>,
valid_out_of_scope_traits: Vec<DefId>,
) -> bool {
if !valid_out_of_scope_traits.is_empty() {
let mut candidates = valid_out_of_scope_traits;
candidates.sort();
candidates.dedup();
err.help("items from traits can only be used if the trait is in scope");
let msg = format!("the following {traits_are} implemented but not in scope, \
perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {
"trait is"
} else {
"traits are"
},
one_of_them = if candidates.len() == 1 {
"it"
} else {
"one of them"
});
let msg = format!(
"the following {traits_are} implemented but not in scope; \
perhaps add a `use` for {one_of_them}:",
traits_are = if candidates.len() == 1 {
"trait is"
} else {
"traits are"
},
one_of_them = if candidates.len() == 1 {
"it"
} else {
"one of them"
},
);
self.suggest_use_candidates(err, msg, candidates);
true

View File

@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use Lib::TheTrait;`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&Lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use Lib::TheTrait;`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use coherence_inherent_cc_lib::TheTrait;`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | s.the_fn();
| ^^^^^^ method not found in `&coherence_inherent_cc_lib::TheStruct`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use coherence_inherent_cc_lib::TheTrait;`
error: aborting due to previous error

View File

@ -25,7 +25,7 @@ LL | ().clone()
| ^^^^^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use std::clone::Clone;`
error: aborting due to 3 previous errors

View File

@ -8,7 +8,7 @@ LL | pub macro m() { ().f() }
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use foo::T;`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | 1u32.method();
| ^^^^^^ method not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
|
LL | use foo::Bar;
|
@ -23,7 +23,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1u32)).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&u32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope, perhaps add a `use` for one of them:
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
|
LL | use foo::Bar;
|
@ -41,7 +41,7 @@ LL | 'a'.method();
| ^^^^^^ method not found in `char`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use foo::Bar;
|
@ -61,7 +61,7 @@ LL | std::rc::Rc::new(&mut Box::new(&'a')).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&char>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use foo::Bar;
|
@ -73,7 +73,7 @@ LL | 1i32.method();
| ^^^^^^ method not found in `i32`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use no_method_suggested_traits::foo::PubPub;
|
@ -85,7 +85,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1i32)).method();
| ^^^^^^ method not found in `std::rc::Rc<&mut std::boxed::Box<&i32>>`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use no_method_suggested_traits::foo::PubPub;
|

View File

@ -5,7 +5,7 @@ LL | b.foo();
| ^^^ method not found in `&b::B`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use a::A;`
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | Command::new("echo").arg("hello").exec();
| ^^^^ method not found in `&mut std::process::Command`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use std::os::unix::process::CommandExt;
|

View File

@ -5,7 +5,7 @@ LL | ().a();
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A;
|

View File

@ -5,7 +5,7 @@ LL | x.foobar();
| ^^^^^^ method not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use crate::foo::foobar::Foobar;`
error[E0599]: no method named `bar` found for type `u32` in the current scope
@ -15,7 +15,7 @@ LL | x.bar();
| ^^^ method not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use crate::foo::Bar;
|
@ -33,7 +33,7 @@ LL | let y = u32::from_str("33");
| ^^^^^^^^ function or associated item not found in `u32`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use std::str::FromStr;
|

View File

@ -5,7 +5,7 @@ LL | ().f()
| ^ method not found in `()`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use foo::T;
|

View File

@ -28,7 +28,7 @@ LL | S.b();
| ^ method not found in `S`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use method::B;
|
@ -62,7 +62,7 @@ LL | S::b(&S);
| ^ function or associated item not found in `S`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use method::B;
|
@ -96,7 +96,7 @@ LL | S::B;
| ^ associated item not found in `S`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use assoc_const::B;
|

View File

@ -5,7 +5,7 @@ LL | foo.method();
| ^^^^^^
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL | use inner::Bar;
|

View File

@ -5,7 +5,7 @@ LL | x.deref();
| ^^^^^ method not found in `&()`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use std::ops::Deref;`
error: aborting due to previous error