Skip to content

Commit 5f7c9da

Browse files
committed
Auto merge of #51287 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 5 pull requests Successful merges: - #51135 (Tweak output on E0599 for assoc fn used as method) - #51152 (Replace `if` with `if and only if` in the definition dox of `Sync`) - #51262 (Add missing whitespace in num example) - #51272 (Remove feature flag from fs::read_to_string example) - #51286 (Pull 1.26.2 release notes into master) Failed merges:
2 parents bfa41f2 + c8f9b7c commit 5f7c9da

File tree

8 files changed

+69
-29
lines changed

8 files changed

+69
-29
lines changed

Diff for: RELEASES.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.26.2 (2018-06-05)
2+
==========================
3+
4+
Compatibility Notes
5+
-------------------
6+
7+
- [The borrow checker was fixed to avoid unsoundness when using match ergonomics][51117]
8+
9+
[51117]: https://github.com/rust-lang/rust/issues/51117
10+
111
Version 1.26.1 (2018-05-29)
212
==========================
313

Diff for: src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub trait Copy : Clone {
294294
/// This trait is automatically implemented when the compiler determines
295295
/// it's appropriate.
296296
///
297-
/// The precise definition is: a type `T` is `Sync` if `&T` is
297+
/// The precise definition is: a type `T` is `Sync` if and only if `&T` is
298298
/// [`Send`][send]. In other words, if there is no possibility of
299299
/// [undefined behavior][ub] (including data races) when passing
300300
/// `&T` references between threads.

Diff for: src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ Basic usage:
23132313
```
23142314
", $Feature, "assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(1), ",
23152315
"Some(", stringify!($SelfT), "::max_value() - 1));
2316-
assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3),None);", $EndFeature, "
2316+
assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, "
23172317
```"),
23182318
#[stable(feature = "rust1", since = "1.0.0")]
23192319
#[inline]

Diff for: src/librustc_typeck/check/method/suggest.rs

+47-15
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
119119
}
120120
};
121121

122-
let note_str = format!("candidate #{} is defined in an impl{} \
123-
for the type `{}`",
124-
idx + 1,
125-
insertion,
126-
impl_ty);
122+
let note_str = if sources.len() > 1 {
123+
format!("candidate #{} is defined in an impl{} for the type `{}`",
124+
idx + 1,
125+
insertion,
126+
impl_ty)
127+
} else {
128+
format!("the candidate is defined in an impl{} for the type `{}`",
129+
insertion,
130+
impl_ty)
131+
};
127132
if let Some(note_span) = note_span {
128133
// We have a span pointing to the method. Show note with snippet.
129134
err.span_note(self.tcx.sess.codemap().def_span(note_span), &note_str);
@@ -137,11 +142,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
137142
.unwrap();
138143
let item_span = self.tcx.sess.codemap()
139144
.def_span(self.tcx.def_span(item.def_id));
140-
span_note!(err,
141-
item_span,
142-
"candidate #{} is defined in the trait `{}`",
143-
idx + 1,
144-
self.tcx.item_path_str(trait_did));
145+
if sources.len() > 1 {
146+
span_note!(err,
147+
item_span,
148+
"candidate #{} is defined in the trait `{}`",
149+
idx + 1,
150+
self.tcx.item_path_str(trait_did));
151+
} else {
152+
span_note!(err,
153+
item_span,
154+
"the candidate is defined in the trait `{}`",
155+
self.tcx.item_path_str(trait_did));
156+
}
145157
err.help(&format!("to disambiguate the method call, write `{}::{}({}{})` \
146158
instead",
147159
self.tcx.item_path_str(trait_did),
@@ -285,7 +297,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
285297
tcx.sess.diagnostic().struct_dummy()
286298
};
287299

288-
if let Some(def) = actual.ty_adt_def() {
300+
if let Some(def) = actual.ty_adt_def() {
289301
if let Some(full_sp) = tcx.hir.span_if_local(def.did) {
290302
let def_sp = tcx.sess.codemap().def_span(full_sp);
291303
err.span_label(def_sp, format!("{} `{}` not found {}",
@@ -368,7 +380,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
368380
if !static_sources.is_empty() {
369381
err.note("found the following associated functions; to be used as methods, \
370382
functions must have a `self` parameter");
371-
err.help(&format!("try with `{}::{}`", self.ty_to_string(actual), item_name));
383+
err.span_label(span, "this is an associated function, not a method");
384+
}
385+
if static_sources.len() == 1 {
386+
if let Some(expr) = rcvr_expr {
387+
err.span_suggestion(expr.span.to(span),
388+
"use associated function syntax instead",
389+
format!("{}::{}",
390+
self.ty_to_string(actual),
391+
item_name));
392+
} else {
393+
err.help(&format!("try with `{}::{}`",
394+
self.ty_to_string(actual), item_name));
395+
}
396+
397+
report_candidates(&mut err, static_sources);
398+
} else if static_sources.len() > 1 {
372399

373400
report_candidates(&mut err, static_sources);
374401
}
@@ -468,9 +495,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
468495
} else {
469496
let limit = if candidates.len() == 5 { 5 } else { 4 };
470497
for (i, trait_did) in candidates.iter().take(limit).enumerate() {
471-
msg.push_str(&format!("\ncandidate #{}: `use {};`",
472-
i + 1,
473-
self.tcx.item_path_str(*trait_did)));
498+
if candidates.len() > 1 {
499+
msg.push_str(&format!("\ncandidate #{}: `use {};`",
500+
i + 1,
501+
self.tcx.item_path_str(*trait_did)));
502+
} else {
503+
msg.push_str(&format!("\n`use {};`",
504+
self.tcx.item_path_str(*trait_did)));
505+
}
474506
}
475507
if candidates.len() > limit {
476508
msg.push_str(&format!("\nand {} others", candidates.len() - limit));

Diff for: src/libstd/fs.rs

-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
295295
/// # Examples
296296
///
297297
/// ```no_run
298-
/// #![feature(fs_read_write)]
299-
///
300298
/// use std::fs;
301299
/// use std::net::SocketAddr;
302300
///

Diff for: src/test/ui/hygiene/no_implicit_prelude.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LL | ().clone() //~ ERROR no method named `clone` found
2222
|
2323
= help: items from traits can only be used if the trait is in scope
2424
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
25-
candidate #1: `use std::clone::Clone;`
25+
`use std::clone::Clone;`
2626

2727
error: aborting due to 3 previous errors
2828

Diff for: src/test/ui/hygiene/trait_items.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | pub macro m() { ().f() } //~ ERROR no method named `f` found for type `
99
|
1010
= help: items from traits can only be used if the trait is in scope
1111
= note: the following trait is implemented but not in scope, perhaps add a `use` for it:
12-
candidate #1: `use foo::T;`
12+
`use foo::T;`
1313

1414
error: aborting due to previous error
1515

Diff for: src/test/ui/span/issue-7575.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope
22
--> $DIR/issue-7575.rs:74:18
33
|
44
LL | u.f8(42) + u.f9(342) + m.fff(42)
5-
| ^^
5+
| ^^ this is an associated function, not a method
66
|
77
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
8-
= help: try with `usize::f9`
98
note: candidate #1 is defined in the trait `CtxtFn`
109
--> $DIR/issue-7575.rs:16:5
1110
|
@@ -37,11 +36,13 @@ LL | struct Myisize(isize);
3736
| ---------------------- method `fff` not found for this
3837
...
3938
LL | u.f8(42) + u.f9(342) + m.fff(42)
40-
| ^^^
39+
| --^^^
40+
| | |
41+
| | this is an associated function, not a method
42+
| help: use associated function syntax instead: `Myisize::fff`
4143
|
4244
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
43-
= help: try with `Myisize::fff`
44-
note: candidate #1 is defined in an impl for the type `Myisize`
45+
note: the candidate is defined in an impl for the type `Myisize`
4546
--> $DIR/issue-7575.rs:51:5
4647
|
4748
LL | fn fff(i: isize) -> isize {
@@ -51,11 +52,10 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope
5152
--> $DIR/issue-7575.rs:82:7
5253
|
5354
LL | t.is_str()
54-
| ^^^^^^
55+
| ^^^^^^ this is an associated function, not a method
5556
|
5657
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
57-
= help: try with `T::is_str`
58-
note: candidate #1 is defined in the trait `ManyImplTrait`
58+
note: the candidate is defined in the trait `ManyImplTrait`
5959
--> $DIR/issue-7575.rs:57:5
6060
|
6161
LL | fn is_str() -> bool {

0 commit comments

Comments
 (0)