Skip to content

Commit

Permalink
Auto merge of #69643 - Dylan-DPC:rollup-gmt6lm8, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 2, 2020
2 parents 18c275b + 50cfd43 commit 0d94daa
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# email addresses.
#

Aaron Power <[email protected]> Erin Power <[email protected]>
Aaron Todd <[email protected]>
Abhishek Chanda <[email protected]> Abhishek Chanda <[email protected]>
Adolfo Ochagavía <[email protected]>
Expand Down Expand Up @@ -84,6 +83,8 @@ Eric Holk <[email protected]> <[email protected]>
Eric Holmes <[email protected]>
Eric Reed <[email protected]> <[email protected]>
Erick Tryzelaar <[email protected]> <[email protected]>
Erin Power <[email protected]> <[email protected]>
Erin Power <[email protected]> <[email protected]>
Esteban Küber <[email protected]> <[email protected]>
Esteban Küber <[email protected]> <[email protected]>
Esteban Küber <[email protected]> <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/toolstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ fn change_toolstate(
if new_state != state {
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
if new_state < state {
if !["rustc-guide", "miri", "embedded-book"].contains(&tool.as_str()) {
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
regressed = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
8 changes: 2 additions & 6 deletions src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1894,9 +1894,7 @@ where
let to_skip = self.n;
self.n = 0;
// nth(n) skips n+1
if self.iter.nth(to_skip - 1).is_none() {
return None;
}
self.iter.nth(to_skip - 1)?;
}
self.iter.nth(n)
}
Expand All @@ -1916,9 +1914,7 @@ where
fn last(mut self) -> Option<I::Item> {
if self.n > 0 {
// nth(n) skips n+1
if self.iter.nth(self.n - 1).is_none() {
return None;
}
self.iter.nth(self.n - 1)?;
}
self.iter.last()
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ impl<'hir> Map<'hir> {
Node::Variant(_) => DefKind::Variant,
Node::Ctor(variant_data) => {
// FIXME(eddyb) is this even possible, if we have a `Node::Ctor`?
if variant_data.ctor_hir_id().is_none() {
return None;
}
variant_data.ctor_hir_id()?;

let ctor_of = match self.find(self.get_parent_node(hir_id)) {
Some(Node::Item(..)) => def::CtorOf::Struct,
Some(Node::Variant(..)) => def::CtorOf::Variant,
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ impl<'tcx> Instance<'tcx> {
}

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

match self.def {
InstanceDef::Item(def_id) => tcx
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ E0714: include_str!("./error_codes/E0714.md"),
E0715: include_str!("./error_codes/E0715.md"),
E0716: include_str!("./error_codes/E0716.md"),
E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"),
E0725: include_str!("./error_codes/E0725.md"),
Expand Down Expand Up @@ -605,7 +606,6 @@ E0748: include_str!("./error_codes/E0748.md"),
E0710, // an unknown tool name found in scoped lint
E0711, // a feature has been declared with conflicting stability attributes
E0717, // rustc_promotable without stability attribute
E0719, // duplicate values for associated type binding
// E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
Expand Down
42 changes: 22 additions & 20 deletions src/librustc_error_codes/error_codes/E0378.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
The `DispatchFromDyn` trait was implemented on something which is not a pointer
or a newtype wrapper around a pointer.

Erroneous code example:

```compile-fail,E0378
#![feature(dispatch_from_dyn)]
use std::ops::DispatchFromDyn;
struct WrapperExtraField<T> {
ptr: T,
extra_stuff: i32,
}
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
where
T: DispatchFromDyn<U>,
{}
```

The `DispatchFromDyn` trait currently can only be implemented for
builtin pointer types and structs that are newtype wrappers around them
— that is, the struct must have only one field (except for`PhantomData`),
and that field must itself implement `DispatchFromDyn`.

Examples:

```
#![feature(dispatch_from_dyn, unsize)]
use std::{
Expand All @@ -20,6 +38,8 @@ where
{}
```

Another example:

```
#![feature(dispatch_from_dyn)]
use std::{
Expand All @@ -37,21 +57,3 @@ where
T: DispatchFromDyn<U>,
{}
```

Example of illegal `DispatchFromDyn` implementation
(illegal because of extra field)

```compile-fail,E0378
#![feature(dispatch_from_dyn)]
use std::ops::DispatchFromDyn;
struct WrapperExtraField<T> {
ptr: T,
extra_stuff: i32,
}
impl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>
where
T: DispatchFromDyn<U>,
{}
```
35 changes: 35 additions & 0 deletions src/librustc_error_codes/error_codes/E0719.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
The value for an associated type has already been specified.

Erroneous code example:

```compile_fail,E0719
#![feature(associated_type_bounds)]
trait FooTrait {}
trait BarTrait {}
// error: associated type `Item` in trait `Iterator` is specified twice
struct Foo<T: Iterator<Item: FooTrait, Item: BarTrait>> { f: T }
```

`Item` in trait `Iterator` cannot be specified multiple times for struct `Foo`.
To fix this, create a new trait that is a combination of the desired traits and
specify the associated type with the new trait.

Corrected example:

```
#![feature(associated_type_bounds)]
trait FooTrait {}
trait BarTrait {}
trait FooBarTrait: FooTrait + BarTrait {}
struct Foo<T: Iterator<Item: FooBarTrait>> { f: T }
```

For more information about associated types, see [the book][bk-at]. For more
information on associated type bounds, see [RFC 2289][rfc-2289].

[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types
[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html
4 changes: 1 addition & 3 deletions src/librustc_incremental/persist/work_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
files: &[(WorkProductFileKind, PathBuf)],
) -> Option<(WorkProductId, WorkProduct)> {
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
if sess.opts.incremental.is_none() {
return None;
}
sess.opts.incremental.as_ref()?;

let saved_files = files
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_resolve/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
// this may resolve to either a value or a type, but for documentation
// purposes it's good enough to just favor one over the other.
self.r.per_ns(|this, ns| {
if let Some(binding) = source_bindings[ns].get().ok() {
if let Ok(binding) = source_bindings[ns].get() {
this.import_res_map.entry(directive.id).or_default()[ns] = Some(binding.res());
}
});
Expand Down Expand Up @@ -1293,7 +1293,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let mut redundant_span = PerNS { value_ns: None, type_ns: None, macro_ns: None };

self.r.per_ns(|this, ns| {
if let Some(binding) = source_bindings[ns].get().ok() {
if let Ok(binding) = source_bindings[ns].get() {
if binding.res() == Res::Err {
return;
}
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_traits/chalk_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ impl context::AggregateOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> {

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

if simplified_answers.peek_answer().is_none() {
return None;
}
simplified_answers.peek_answer()?;

let SimplifiedAnswer { subst: constrained_subst, ambiguous } =
simplified_answers.next_answer().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ impl ToSocketAddrs for str {
type Iter = vec::IntoIter<SocketAddr>;
fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
// try to parse as a regular SocketAddr first
if let Some(addr) = self.parse().ok() {
if let Ok(addr) = self.parse() {
return Ok(vec![addr].into_iter());
}

Expand Down
1 change: 1 addition & 0 deletions src/test/ui/associated-type-bounds/duplicate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,4 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>;

error: aborting due to 96 previous errors

For more information about this error, try `rustc --explain E0719`.
1 change: 1 addition & 0 deletions src/test/ui/error-codes/E0719.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> {

error: aborting due to 2 previous errors

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

0 comments on commit 0d94daa

Please sign in to comment.