Skip to content

Commit 0d94daa

Browse files
committed
Auto merge of #69643 - Dylan-DPC:rollup-gmt6lm8, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #69620 (doc(librustc_error_codes): add long error explanation for E0719) - #69621 (use question mark operator in a few places.) - #69626 (Toolstate: don't duplicate nightly tool list.) - #69633 (Update my mailmap entry) - #69634 (clean up E0378 explanation) - #69637 (Don't convert Results to Options just for matching.) - #69641 (Update books) Failed merges: r? @ghost
2 parents 18c275b + 50cfd43 commit 0d94daa

File tree

18 files changed

+77
-48
lines changed

18 files changed

+77
-48
lines changed

.mailmap

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# email addresses.
66
#
77

8-
Aaron Power <[email protected]> Erin Power <[email protected]>
98
Aaron Todd <[email protected]>
109
Abhishek Chanda <[email protected]> Abhishek Chanda <[email protected]>
1110
Adolfo Ochagavía <[email protected]>
@@ -84,6 +83,8 @@ Eric Holk <[email protected]> <[email protected]>
8483
Eric Holmes <[email protected]>
8584
8685
86+
87+
8788
8889
8990

src/bootstrap/toolstate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fn change_toolstate(
443443
if new_state != state {
444444
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
445445
if new_state < state {
446-
if !["rustc-guide", "miri", "embedded-book"].contains(&tool.as_str()) {
446+
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
447447
regressed = true;
448448
}
449449
}

src/libcore/iter/adapters/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1894,9 +1894,7 @@ where
18941894
let to_skip = self.n;
18951895
self.n = 0;
18961896
// nth(n) skips n+1
1897-
if self.iter.nth(to_skip - 1).is_none() {
1898-
return None;
1899-
}
1897+
self.iter.nth(to_skip - 1)?;
19001898
}
19011899
self.iter.nth(n)
19021900
}
@@ -1916,9 +1914,7 @@ where
19161914
fn last(mut self) -> Option<I::Item> {
19171915
if self.n > 0 {
19181916
// nth(n) skips n+1
1919-
if self.iter.nth(self.n - 1).is_none() {
1920-
return None;
1921-
}
1917+
self.iter.nth(self.n - 1)?;
19221918
}
19231919
self.iter.last()
19241920
}

src/librustc/hir/map/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,8 @@ impl<'hir> Map<'hir> {
338338
Node::Variant(_) => DefKind::Variant,
339339
Node::Ctor(variant_data) => {
340340
// FIXME(eddyb) is this even possible, if we have a `Node::Ctor`?
341-
if variant_data.ctor_hir_id().is_none() {
342-
return None;
343-
}
341+
variant_data.ctor_hir_id()?;
342+
344343
let ctor_of = match self.find(self.get_parent_node(hir_id)) {
345344
Some(Node::Item(..)) => def::CtorOf::Struct,
346345
Some(Node::Variant(..)) => def::CtorOf::Variant,

src/librustc/ty/instance.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ impl<'tcx> Instance<'tcx> {
115115
}
116116

117117
// If this a non-generic instance, it cannot be a shared monomorphization.
118-
if self.substs.non_erasable_generics().next().is_none() {
119-
return None;
120-
}
118+
self.substs.non_erasable_generics().next()?;
121119

122120
match self.def {
123121
InstanceDef::Item(def_id) => tcx

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ E0714: include_str!("./error_codes/E0714.md"),
395395
E0715: include_str!("./error_codes/E0715.md"),
396396
E0716: include_str!("./error_codes/E0716.md"),
397397
E0718: include_str!("./error_codes/E0718.md"),
398+
E0719: include_str!("./error_codes/E0719.md"),
398399
E0720: include_str!("./error_codes/E0720.md"),
399400
E0723: include_str!("./error_codes/E0723.md"),
400401
E0725: include_str!("./error_codes/E0725.md"),
@@ -605,7 +606,6 @@ E0748: include_str!("./error_codes/E0748.md"),
605606
E0710, // an unknown tool name found in scoped lint
606607
E0711, // a feature has been declared with conflicting stability attributes
607608
E0717, // rustc_promotable without stability attribute
608-
E0719, // duplicate values for associated type binding
609609
// E0721, // `await` keyword
610610
E0722, // Malformed `#[optimize]` attribute
611611
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions

src/librustc_error_codes/error_codes/E0378.md

+22-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
The `DispatchFromDyn` trait was implemented on something which is not a pointer
2+
or a newtype wrapper around a pointer.
3+
4+
Erroneous code example:
5+
6+
```compile-fail,E0378
7+
#![feature(dispatch_from_dyn)]
8+
use std::ops::DispatchFromDyn;
9+
10+
struct WrapperExtraField<T> {
11+
ptr: T,
12+
extra_stuff: i32,
13+
}
14+
15+
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
16+
where
17+
T: DispatchFromDyn<U>,
18+
{}
19+
```
20+
121
The `DispatchFromDyn` trait currently can only be implemented for
222
builtin pointer types and structs that are newtype wrappers around them
323
— that is, the struct must have only one field (except for`PhantomData`),
424
and that field must itself implement `DispatchFromDyn`.
525

6-
Examples:
7-
826
```
927
#![feature(dispatch_from_dyn, unsize)]
1028
use std::{
@@ -20,6 +38,8 @@ where
2038
{}
2139
```
2240

41+
Another example:
42+
2343
```
2444
#![feature(dispatch_from_dyn)]
2545
use std::{
@@ -37,21 +57,3 @@ where
3757
T: DispatchFromDyn<U>,
3858
{}
3959
```
40-
41-
Example of illegal `DispatchFromDyn` implementation
42-
(illegal because of extra field)
43-
44-
```compile-fail,E0378
45-
#![feature(dispatch_from_dyn)]
46-
use std::ops::DispatchFromDyn;
47-
48-
struct WrapperExtraField<T> {
49-
ptr: T,
50-
extra_stuff: i32,
51-
}
52-
53-
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
54-
where
55-
T: DispatchFromDyn<U>,
56-
{}
57-
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
The value for an associated type has already been specified.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0719
6+
#![feature(associated_type_bounds)]
7+
8+
trait FooTrait {}
9+
trait BarTrait {}
10+
11+
// error: associated type `Item` in trait `Iterator` is specified twice
12+
struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T }
13+
```
14+
15+
`Item` in trait `Iterator` cannot be specified multiple times for struct `Foo`.
16+
To fix this, create a new trait that is a combination of the desired traits and
17+
specify the associated type with the new trait.
18+
19+
Corrected example:
20+
21+
```
22+
#![feature(associated_type_bounds)]
23+
24+
trait FooTrait {}
25+
trait BarTrait {}
26+
trait FooBarTrait: FooTrait + BarTrait {}
27+
28+
struct Foo<T: Iterator<Item: FooBarTrait>> { f: T }
29+
```
30+
31+
For more information about associated types, see [the book][bk-at]. For more
32+
information on associated type bounds, see [RFC 2289][rfc-2289].
33+
34+
[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types
35+
[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html

src/librustc_incremental/persist/work_product.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
1313
files: &[(WorkProductFileKind, PathBuf)],
1414
) -> Option<(WorkProductId, WorkProduct)> {
1515
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
16-
if sess.opts.incremental.is_none() {
17-
return None;
18-
}
16+
sess.opts.incremental.as_ref()?;
1917

2018
let saved_files = files
2119
.iter()

src/librustc_resolve/imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
12521252
// this may resolve to either a value or a type, but for documentation
12531253
// purposes it's good enough to just favor one over the other.
12541254
self.r.per_ns(|this, ns| {
1255-
if let Some(binding) = source_bindings[ns].get().ok() {
1255+
if let Ok(binding) = source_bindings[ns].get() {
12561256
this.import_res_map.entry(directive.id).or_default()[ns] = Some(binding.res());
12571257
}
12581258
});
@@ -1293,7 +1293,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
12931293
let mut redundant_span = PerNS { value_ns: None, type_ns: None, macro_ns: None };
12941294

12951295
self.r.per_ns(|this, ns| {
1296-
if let Some(binding) = source_bindings[ns].get().ok() {
1296+
if let Ok(binding) = source_bindings[ns].get() {
12971297
if binding.res() == Res::Err {
12981298
return;
12991299
}

src/librustc_traits/chalk_context/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ impl context::AggregateOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> {
112112

113113
debug!("make_solution(root_goal = {:?})", root_goal);
114114

115-
if simplified_answers.peek_answer().is_none() {
116-
return None;
117-
}
115+
simplified_answers.peek_answer()?;
118116

119117
let SimplifiedAnswer { subst: constrained_subst, ambiguous } =
120118
simplified_answers.next_answer().unwrap();

src/libstd/net/addr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ impl ToSocketAddrs for str {
901901
type Iter = vec::IntoIter<SocketAddr>;
902902
fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
903903
// try to parse as a regular SocketAddr first
904-
if let Some(addr) = self.parse().ok() {
904+
if let Ok(addr) = self.parse() {
905905
return Ok(vec![addr].into_iter());
906906
}
907907

src/test/ui/associated-type-bounds/duplicate.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,4 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;
728728

729729
error: aborting due to 96 previous errors
730730

731+
For more information about this error, try `rustc --explain E0719`.

src/test/ui/error-codes/E0719.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> {
1616

1717
error: aborting due to 2 previous errors
1818

19+
For more information about this error, try `rustc --explain E0719`.

0 commit comments

Comments
 (0)