mirror of https://github.com/rust-lang/rust.git
Tweak use of trimmed paths
This commit is contained in:
parent
ab8dc9a0ad
commit
153ed09fb3
|
@ -259,7 +259,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mode = no_match_data.mode;
|
||||
let tcx = self.tcx;
|
||||
let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty);
|
||||
let ty_str = with_forced_trimmed_paths!(self.ty_to_string(rcvr_ty));
|
||||
let (ty_str, ty_file) = tcx.short_ty_string(rcvr_ty);
|
||||
let short_ty_str = with_forced_trimmed_paths!(rcvr_ty.to_string());
|
||||
let is_method = mode == Mode::MethodCall;
|
||||
let unsatisfied_predicates = &no_match_data.unsatisfied_predicates;
|
||||
let similar_candidate = no_match_data.similar_candidate;
|
||||
|
@ -276,11 +277,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
if self.suggest_wrapping_range_with_parens(tcx, rcvr_ty, source, span, item_name, &ty_str)
|
||||
|| self.suggest_constraining_numerical_ty(
|
||||
tcx, rcvr_ty, source, span, item_kind, item_name, &ty_str,
|
||||
)
|
||||
{
|
||||
// We could pass the file for long types into these two, but it isn't strictly necessary
|
||||
// given how targetted they are.
|
||||
if self.suggest_wrapping_range_with_parens(
|
||||
tcx,
|
||||
rcvr_ty,
|
||||
source,
|
||||
span,
|
||||
item_name,
|
||||
&short_ty_str,
|
||||
) || self.suggest_constraining_numerical_ty(
|
||||
tcx,
|
||||
rcvr_ty,
|
||||
source,
|
||||
span,
|
||||
item_kind,
|
||||
item_name,
|
||||
&short_ty_str,
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
span = item_name.span;
|
||||
|
@ -319,6 +333,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
rcvr_ty.prefix_string(self.tcx),
|
||||
ty_str_reported,
|
||||
);
|
||||
let ty_str = if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
|
||||
short_ty_str
|
||||
} else {
|
||||
ty_str
|
||||
};
|
||||
if let Some(file) = ty_file {
|
||||
err.note(&format!("the full type name has been written to '{}'", file.display(),));
|
||||
}
|
||||
if rcvr_ty.references_error() {
|
||||
err.downgrade_to_delayed_bug();
|
||||
}
|
||||
|
@ -826,7 +848,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let primary_message = primary_message.unwrap_or_else(|| {
|
||||
format!(
|
||||
"the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, \
|
||||
but its trait bounds were not satisfied"
|
||||
but its trait bounds were not satisfied"
|
||||
)
|
||||
});
|
||||
err.set_primary_message(&primary_message);
|
||||
|
|
|
@ -10,7 +10,7 @@ note: required by a bound in `Foo::Out`
|
|||
LL | type Out: Default + ToString + ?Sized = dyn ToString;
|
||||
| ^^^^^^^ required by this bound in `Foo::Out`
|
||||
|
||||
error[E0599]: no function or associated item named `default` found for trait object `dyn ToString` in the current scope
|
||||
error[E0599]: no function or associated item named `default` found for trait object `(dyn ToString + 'static)` in the current scope
|
||||
--> $DIR/issue-43924.rs:14:39
|
||||
|
|
||||
LL | assert_eq!(<() as Foo<u32>>::Out::default().to_string(), "false");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no method named `closure` found for reference `&Obj<[closure@issue-33784.rs:25:43]>` in the current scope
|
||||
error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
|
||||
--> $DIR/issue-33784.rs:27:7
|
||||
|
|
||||
LL | p.closure();
|
||||
|
@ -9,7 +9,7 @@ help: to call the function stored in `closure`, surround the field access with p
|
|||
LL | (p.closure)();
|
||||
| + +
|
||||
|
||||
error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@issue-33784.rs:25:43]>` in the current scope
|
||||
error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:45]>` in the current scope
|
||||
--> $DIR/issue-33784.rs:29:7
|
||||
|
|
||||
LL | q.fn_ptr();
|
||||
|
|
|
@ -100,7 +100,7 @@ help: a unit struct with a similar name exists
|
|||
LL | let xe1 = XEmpty2();
|
||||
| ~~~~~~~
|
||||
|
||||
error[E0599]: no variant or associated item named `Empty3` found for enum `XE` in the current scope
|
||||
error[E0599]: no variant or associated item named `Empty3` found for enum `empty_struct::XE` in the current scope
|
||||
--> $DIR/empty-struct-braces-expr.rs:25:19
|
||||
|
|
||||
LL | let xe3 = XE::Empty3;
|
||||
|
@ -109,7 +109,7 @@ LL | let xe3 = XE::Empty3;
|
|||
| variant or associated item not found in `XE`
|
||||
| help: there is a variant with a similar name: `XEmpty3`
|
||||
|
||||
error[E0599]: no variant or associated item named `Empty3` found for enum `XE` in the current scope
|
||||
error[E0599]: no variant or associated item named `Empty3` found for enum `empty_struct::XE` in the current scope
|
||||
--> $DIR/empty-struct-braces-expr.rs:26:19
|
||||
|
|
||||
LL | let xe3 = XE::Empty3();
|
||||
|
|
|
@ -4,7 +4,7 @@ error[E0425]: cannot find value `oops` in this scope
|
|||
LL | let arc = std::sync::Arc::new(oops);
|
||||
| ^^^^ not found in this scope
|
||||
|
||||
error[E0599]: no method named `bar` found for struct `Arc<[closure@fn-help-with-err.rs:18:36]>` in the current scope
|
||||
error[E0599]: no method named `bar` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:18:36: 18:38]>` in the current scope
|
||||
--> $DIR/fn-help-with-err.rs:19:10
|
||||
|
|
||||
LL | arc2.bar();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
|
||||
|
||||
// rust-lang/rust#30786: the use of `for<'b> &'b mut A: Stream<Item=T`
|
||||
// should act as assertion that item does not borrow from its stream;
|
||||
// but an earlier buggy rustc allowed `.map(|x: &_| x)` which does
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@issue-30786.rs:117:27]>`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-30786.rs:118:22
|
||||
error[E0599]: the method `filterx` exists for struct `Map<Repeat, [closure@issue-30786.rs:119:27]>`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-30786.rs:120:22
|
||||
|
|
||||
LL | pub struct Map<S, F> {
|
||||
| --------------------
|
||||
|
@ -8,19 +8,19 @@ LL | pub struct Map<S, F> {
|
|||
| doesn't satisfy `_: StreamExt`
|
||||
...
|
||||
LL | let filter = map.filterx(|x: &_| true);
|
||||
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@issue-30786.rs:117:27]>` due to unsatisfied trait bounds
|
||||
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@issue-30786.rs:119:27]>` due to unsatisfied trait bounds
|
||||
|
|
||||
note: the following trait bounds were not satisfied:
|
||||
`&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
|
||||
`&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
|
||||
`&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:117:27: 117:34]>: Stream`
|
||||
--> $DIR/issue-30786.rs:96:50
|
||||
`&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:119:27: 119:34]>: Stream`
|
||||
`&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:119:27: 119:34]>: Stream`
|
||||
`&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:119:27: 119:34]>: Stream`
|
||||
--> $DIR/issue-30786.rs:98:50
|
||||
|
|
||||
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
|
||||
| --------- - ^^^^^^ unsatisfied trait bound introduced here
|
||||
|
||||
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, [closure@issue-30786.rs:129:30]>`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-30786.rs:130:24
|
||||
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, [closure@issue-30786.rs:131:30]>`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-30786.rs:132:24
|
||||
|
|
||||
LL | pub struct Filter<S, F> {
|
||||
| -----------------------
|
||||
|
@ -31,11 +31,12 @@ LL | pub struct Filter<S, F> {
|
|||
LL | let count = filter.countx();
|
||||
| ^^^^^^ method cannot be called due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/issue-30786/issue-30786.long-type-hash.txt'
|
||||
note: the following trait bounds were not satisfied:
|
||||
`&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
|
||||
`&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
|
||||
`&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream`
|
||||
--> $DIR/issue-30786.rs:96:50
|
||||
`&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream`
|
||||
`&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream`
|
||||
`&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream`
|
||||
--> $DIR/issue-30786.rs:98:50
|
||||
|
|
||||
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
|
||||
| --------- - ^^^^^^ unsatisfied trait bound introduced here
|
||||
|
|
|
@ -145,7 +145,7 @@ note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
|
|||
LL | pub trait Bar {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0599]: no method named `method2` found for struct `Foo` in the current scope
|
||||
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 | no_method_suggested_traits::Foo.method2();
|
||||
|
@ -158,7 +158,7 @@ note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
|
|||
LL | pub trait Bar {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&Foo>>` in the current scope
|
||||
error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method_suggested_traits::Foo>>` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:52:71
|
||||
|
|
||||
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method2();
|
||||
|
@ -171,7 +171,7 @@ note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
|
|||
LL | pub trait Bar {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0599]: no method named `method2` found for enum `Bar` in the current scope
|
||||
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 | no_method_suggested_traits::Bar::X.method2();
|
||||
|
@ -184,7 +184,7 @@ note: `foo::Bar` defines an item `method2`, perhaps you need to implement it
|
|||
LL | pub trait Bar {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&Bar>>` in the current scope
|
||||
error[E0599]: no method named `method2` found for struct `Rc<&mut Box<&no_method_suggested_traits::Bar>>` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:56:74
|
||||
|
|
||||
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method2();
|
||||
|
@ -255,25 +255,25 @@ error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&usize>>`
|
|||
LL | std::rc::Rc::new(&mut Box::new(&1_usize)).method3();
|
||||
| ^^^^^^^ method not found in `Rc<&mut Box<&usize>>`
|
||||
|
||||
error[E0599]: no method named `method3` found for struct `Foo` in the current scope
|
||||
error[E0599]: no method named `method3` found for struct `no_method_suggested_traits::Foo` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:71:37
|
||||
|
|
||||
LL | no_method_suggested_traits::Foo.method3();
|
||||
| ^^^^^^^ method not found in `Foo`
|
||||
|
||||
error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&Foo>>` in the current scope
|
||||
error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&no_method_suggested_traits::Foo>>` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:72:71
|
||||
|
|
||||
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Foo)).method3();
|
||||
| ^^^^^^^ method not found in `Rc<&mut Box<&Foo>>`
|
||||
|
||||
error[E0599]: no method named `method3` found for enum `Bar` in the current scope
|
||||
error[E0599]: no method named `method3` found for enum `no_method_suggested_traits::Bar` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:74:40
|
||||
|
|
||||
LL | no_method_suggested_traits::Bar::X.method3();
|
||||
| ^^^^^^^ method not found in `Bar`
|
||||
|
||||
error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&Bar>>` in the current scope
|
||||
error[E0599]: no method named `method3` found for struct `Rc<&mut Box<&no_method_suggested_traits::Bar>>` in the current scope
|
||||
--> $DIR/no-method-suggested-traits.rs:75:74
|
||||
|
|
||||
LL | std::rc::Rc::new(&mut Box::new(&no_method_suggested_traits::Bar::X)).method3();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no method named `homura` found for reference `&str` in the current scope
|
||||
error[E0599]: no method named `homura` found for reference `&'static str` in the current scope
|
||||
--> $DIR/issue-19521.rs:2:8
|
||||
|
|
||||
LL | "".homura()();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no function or associated item named `new_undirected` found for struct `Graph<i32, i32>` in the current scope
|
||||
error[E0599]: no function or associated item named `new_undirected` found for struct `issue_30123_aux::Graph<i32, i32>` in the current scope
|
||||
--> $DIR/issue-30123.rs:7:33
|
||||
|
|
||||
LL | let ug = Graph::<i32, i32>::new_undirected();
|
||||
|
|
|
@ -13,7 +13,7 @@ note: `X` defines an item `make_g`, perhaps you need to implement it
|
|||
LL | trait X {
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0599]: no function or associated item named `make_f` found for fn pointer `fn(&())` in the current scope
|
||||
error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'a> fn(&'a ())` in the current scope
|
||||
--> $DIR/issue-57642-higher-ranked-subtype.rs:35:25
|
||||
|
|
||||
LL | let x = <fn (&())>::make_f();
|
||||
|
|
|
@ -16,7 +16,7 @@ LL | fn owned(self: Box<Self>);
|
|||
LL | x.owned();
|
||||
| ^^^^^ method not found in `&mut dyn Foo`
|
||||
|
||||
error[E0599]: no method named `managed` found for struct `Box<dyn Foo>` in the current scope
|
||||
error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static)>` in the current scope
|
||||
--> $DIR/object-pointer-types.rs:23:7
|
||||
|
|
||||
LL | x.managed();
|
||||
|
|
|
@ -4,7 +4,7 @@ error[E0599]: no method named `as_str` found for reference `&str` in the current
|
|||
LL | s.as_str();
|
||||
| -^^^^^^-- help: remove this method call
|
||||
|
||||
error[E0599]: no method named `as_str` found for reference `&str` in the current scope
|
||||
error[E0599]: no method named `as_str` found for reference `&'a str` in the current scope
|
||||
--> $DIR/remove-as_str.rs:7:7
|
||||
|
|
||||
LL | s.as_str();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pub fn main() {
|
||||
let _ = "foo".iter(); //~ ERROR no method named `iter` found for reference `&str` in the current scope
|
||||
let _ = "foo".foo(); //~ ERROR no method named `foo` found for reference `&str` in the current scope
|
||||
let _ = "foo".iter(); //~ ERROR no method named `iter` found for reference `&'static str` in the current scope
|
||||
let _ = "foo".foo(); //~ ERROR no method named `foo` found for reference `&'static str` in the current scope
|
||||
let _ = String::from("bar").iter(); //~ ERROR no method named `iter` found for struct `String` in the current scope
|
||||
let _ = (&String::from("bar")).iter(); //~ ERROR no method named `iter` found for reference `&String` in the current scope
|
||||
let _ = 0.iter(); //~ ERROR no method named `iter` found for type `{integer}` in the current scope
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no method named `iter` found for reference `&str` in the current scope
|
||||
error[E0599]: no method named `iter` found for reference `&'static str` in the current scope
|
||||
--> $DIR/suggest-using-chars.rs:2:19
|
||||
|
|
||||
LL | let _ = "foo".iter();
|
||||
|
@ -9,7 +9,7 @@ help: because of the in-memory representation of `&str`, to obtain an `Iterator`
|
|||
LL | let _ = "foo".chars();
|
||||
| ~~~~~
|
||||
|
||||
error[E0599]: no method named `foo` found for reference `&str` in the current scope
|
||||
error[E0599]: no method named `foo` found for reference `&'static str` in the current scope
|
||||
--> $DIR/suggest-using-chars.rs:3:19
|
||||
|
|
||||
LL | let _ = "foo".foo();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0599]: no method named `call` found for closure `[closure@unboxed-closures-static-call-wrong-trait.rs:6:26]` in the current scope
|
||||
error[E0599]: no method named `call` found for closure `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:6:26: 6:29]` in the current scope
|
||||
--> $DIR/unboxed-closures-static-call-wrong-trait.rs:7:10
|
||||
|
|
||||
LL | mut_.call((0, ));
|
||||
|
|
Loading…
Reference in New Issue