Skip to content

Commit

Permalink
Auto merge of #67048 - RalfJung:rollup-drjnmt0, r=RalfJung
Browse files Browse the repository at this point in the history
Rollup of 13 pull requests

Successful merges:

 - #66405 (Tweak `ObligationForest` `NodeState`s)
 - #66730 (remove dependency from libhermit)
 - #66764 (Tweak wording of `collect()` on bad target type)
 - #66899 (Standard library support for riscv64gc-unknown-linux-gnu)
 - #66900 (Clean up error codes)
 - #66974 ([CI] fix the `! isCI` check in src/ci/run.sh)
 - #66979 (Add long error for E0631 and update ui tests.)
 - #67005 (capitalize Rust)
 - #67010 (Accurately portray raw identifiers in error messages)
 - #67011 (Include a span in more `expected...found` notes)
 - #67017 (cleanup long error explanations)
 - #67021 (Fix docs for formatting delegations)
 - #67041 (add ExitStatusExt into prelude)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 5, 2019
2 parents d825e35 + 1ae771b commit 18a1891
Show file tree
Hide file tree
Showing 86 changed files with 598 additions and 229 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1823,9 +1823,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"

[[package]]
name = "libc"
version = "0.2.64"
version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
2 changes: 1 addition & 1 deletion src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi
ci_dir=`cd $(dirname $0) && pwd`
source "$ci_dir/shared.sh"

if [ ! isCI ] || isCiBranch auto || isCiBranch beta; then
if ! isCI || isCiBranch auto || isCiBranch beta; then
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests"
fi

Expand Down
11 changes: 6 additions & 5 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ pub trait Display {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:o}", val) // delegate to i32's implementation
/// fmt::Octal::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -712,7 +712,7 @@ pub trait Octal {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:b}", val) // delegate to i32's implementation
/// fmt::Binary::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -771,7 +771,7 @@ pub trait Binary {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:x}", val) // delegate to i32's implementation
/// fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -824,7 +824,7 @@ pub trait LowerHex {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// let val = self.0;
///
/// write!(f, "{:X}", val) // delegate to i32's implementation
/// fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
/// }
/// }
///
Expand Down Expand Up @@ -869,7 +869,8 @@ pub trait UpperHex {
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// // use `as` to convert to a `*const T`, which implements Pointer, which we can use
///
/// write!(f, "{:p}", self as *const Length)
/// let ptr = self as *const Self;
/// fmt::Pointer::fmt(&ptr, f)
/// }
/// }
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(
message="a collection of type `{Self}` cannot be built from an iterator \
message="a value of type `{Self}` cannot be built from an iterator \
over elements of type `{A}`",
label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
label="value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
)]
pub trait FromIterator<A>: Sized {
/// Creates a value from an iterator.
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//!
//! Atomic variables are safe to share between threads (they implement [`Sync`])
//! but they do not themselves provide the mechanism for sharing and follow the
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
//! [threading model](../../../std/thread/index.html#the-threading-model) of Rust.
//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
//! atomically-reference-counted shared pointer).
//!
Expand Down
3 changes: 3 additions & 0 deletions src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1
#[cfg(target_arch = "hexagon")]
const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1

#[cfg(target_arch = "riscv64")]
const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11

// The following code is based on GCC's C and C++ personality routines. For reference, see:
// https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
Expand Down
15 changes: 10 additions & 5 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,12 +1809,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
sub_region,
"...",
);
err.note(&format!(
"...so that the {}:\nexpected {}\n found {}",
sup_trace.cause.as_requirement_str(),
sup_expected.content(),
sup_found.content()
err.span_note(sup_trace.cause.span, &format!(
"...so that the {}",
sup_trace.cause.as_requirement_str()
));

err.note_expected_found(
&"",
sup_expected,
&"",
sup_found
);
err.emit();
return;
}
Expand Down
20 changes: 14 additions & 6 deletions src/librustc/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
match *origin {
infer::Subtype(ref trace) => {
if let Some((expected, found)) = self.values_str(&trace.values) {
let expected = expected.content();
let found = found.content();
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
trace.cause.as_requirement_str(),
expected,
found));
err.span_note(
trace.cause.span,
&format!(
"...so that the {}",
trace.cause.as_requirement_str()
)
);

err.note_expected_found(
&"",
expected,
&"",
found
);
} else {
// FIXME: this really should be handled at some earlier stage. Our
// handling of region checking when type errors are present is
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,9 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
if !self.empty_path {
write!(self, "::")?;
}
if ast::Ident::from_str(&name).is_raw_guess() {
write!(self, "r#")?;
}
write!(self, "{}", name)?;

// FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it
Expand Down
89 changes: 60 additions & 29 deletions src/librustc_data_structures/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ type ObligationTreeIdGenerator =
pub struct ObligationForest<O: ForestObligation> {
/// The list of obligations. In between calls to
/// `process_obligations`, this list only contains nodes in the
/// `Pending` or `Success` state (with a non-zero number of
/// `Pending` or `Waiting` state (with a non-zero number of
/// incomplete children). During processing, some of those nodes
/// may be changed to the error state, or we may find that they
/// are completed (That is, `num_incomplete_children` drops to 0).
/// At the end of processing, those nodes will be removed by a
/// call to `compress`.
/// are completed. At the end of processing, those nodes will be
/// removed by a call to `compress`.
///
/// `usize` indices are used here and throughout this module, rather than
/// `rustc_index::newtype_index!` indices, because this code is hot enough that the
Expand Down Expand Up @@ -211,28 +210,56 @@ impl<O> Node<O> {
/// represents the current state of processing for the obligation (of
/// type `O`) associated with this node.
///
/// Outside of ObligationForest methods, nodes should be either Pending
/// or Waiting.
/// The non-`Error` state transitions are as follows.
/// ```
/// (Pre-creation)
/// |
/// | register_obligation_at() (called by process_obligations() and
/// v from outside the crate)
/// Pending
/// |
/// | process_obligations()
/// v
/// Success
/// | ^
/// | | update_waiting_and_success_states()
/// | v
/// | Waiting
/// |
/// | process_cycles()
/// v
/// Done
/// |
/// | compress()
/// v
/// (Removed)
/// ```
/// The `Error` state can be introduced in several places, via `error_at()`.
///
/// Outside of `ObligationForest` methods, nodes should be either `Pending` or
/// `Waiting`.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum NodeState {
/// Obligations for which selection had not yet returned a
/// non-ambiguous result.
/// This obligation has not yet been selected successfully. Cannot have
/// subobligations.
Pending,

/// This obligation was selected successfully, but may or
/// may not have subobligations.
/// This obligation was selected successfully, but the state of any
/// subobligations are current unknown. It will be converted to `Waiting`
/// or `Done` once the states of the subobligations become known.
Success,

/// This obligation was selected successfully, but it has
/// a pending subobligation.
/// This obligation was selected successfully, but it has one or more
/// pending subobligations.
Waiting,

/// This obligation, along with its subobligations, are complete,
/// and will be removed in the next collection.
/// This obligation was selected successfully, as were all of its
/// subobligations (of which there may be none). It will be removed by the
/// next compression step.
Done,

/// This obligation was resolved to an error. Error nodes are
/// removed from the vector by the compression step.
/// This obligation was resolved to an error. It will be removed by the
/// next compression step.
Error,
}

Expand Down Expand Up @@ -464,7 +491,7 @@ impl<O: ForestObligation> ObligationForest<O> {
};
}

self.mark_as_waiting();
self.update_waiting_and_success_states();
self.process_cycles(processor);
let completed = self.compress(do_completed);

Expand All @@ -477,10 +504,9 @@ impl<O: ForestObligation> ObligationForest<O> {
}
}

/// Mark all `NodeState::Success` nodes as `NodeState::Done` and
/// report all cycles between them. This should be called
/// after `mark_as_waiting` marks all nodes with pending
/// subobligations as NodeState::Waiting.
/// Mark all `Success` nodes as `Done` and report all cycles between them.
/// This should be called after `update_waiting_and_success_states` updates
/// the status of all `Waiting` and `Success` nodes.
fn process_cycles<P>(&self, processor: &mut P)
where P: ObligationProcessor<Obligation=O>
{
Expand Down Expand Up @@ -562,42 +588,47 @@ impl<O: ForestObligation> ObligationForest<O> {

// This always-inlined function is for the hot call site.
#[inline(always)]
fn inlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
fn inlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
for &index in node.dependents.iter() {
let node = &self.nodes[index];
match node.state.get() {
NodeState::Waiting | NodeState::Error => {}
NodeState::Success => {
node.state.set(NodeState::Waiting);
// This call site is cold.
self.uninlined_mark_neighbors_as_waiting_from(node);
self.uninlined_mark_dependents_as_waiting(node);
}
NodeState::Pending | NodeState::Done => {
// This call site is cold.
self.uninlined_mark_neighbors_as_waiting_from(node);
self.uninlined_mark_dependents_as_waiting(node);
}
}
}
}

// This never-inlined function is for the cold call site.
#[inline(never)]
fn uninlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
self.inlined_mark_neighbors_as_waiting_from(node)
fn uninlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
self.inlined_mark_dependents_as_waiting(node)
}

/// Marks all nodes that depend on a pending node as `NodeState::Waiting`.
fn mark_as_waiting(&self) {
/// Updates the states of all `Waiting` and `Success` nodes. Upon
/// completion, all such nodes that depend on a pending node will be marked
/// as `Waiting`, and all others will be marked as `Success`.
fn update_waiting_and_success_states(&self) {
// Optimistically mark all `Waiting` nodes as `Success`.
for node in &self.nodes {
if node.state.get() == NodeState::Waiting {
node.state.set(NodeState::Success);
}
}

// Convert all `Success` nodes that still depend on a pending node to
// `Waiting`. This may undo some of the changes done in the loop above.
for node in &self.nodes {
if node.state.get() == NodeState::Pending {
// This call site is hot.
self.inlined_mark_neighbors_as_waiting_from(node);
self.inlined_mark_dependents_as_waiting(node);
}
}
}
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 @@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0631: include_str!("./error_codes/E0631.md"),
E0633: include_str!("./error_codes/E0633.md"),
E0635: include_str!("./error_codes/E0635.md"),
E0636: include_str!("./error_codes/E0636.md"),
Expand Down Expand Up @@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"),
// rustc_const_unstable attribute must be paired with stable/unstable
// attribute
E0630,
E0631, // type mismatch in closure arguments
E0632, // cannot provide explicit generic arguments when `impl Trait` is
// used in argument position
E0634, // type has conflicting packed representaton hints
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_error_codes/error_codes/E0092.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You tried to declare an undefined atomic operation function.
An undefined atomic operation function was declared.

Erroneous code example:

```compile_fail,E0092
Expand All @@ -11,8 +12,8 @@ extern "rust-intrinsic" {
```

Please check you didn't make a mistake in the function's name. All intrinsic
functions are defined in librustc_codegen_llvm/intrinsic.rs and in
libcore/intrinsics.rs in the Rust source code. Example:
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
`libcore/intrinsics.rs` in the Rust source code. Example:

```
#![feature(intrinsics)]
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_error_codes/error_codes/E0093.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
You declared an unknown intrinsic function. Erroneous code example:
An unknown intrinsic function was declared.

Erroneous code example:

```compile_fail,E0093
#![feature(intrinsics)]
Expand All @@ -15,8 +17,8 @@ fn main() {
```

Please check you didn't make a mistake in the function's name. All intrinsic
functions are defined in librustc_codegen_llvm/intrinsic.rs and in
libcore/intrinsics.rs in the Rust source code. Example:
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
`libcore/intrinsics.rs` in the Rust source code. Example:

```
#![feature(intrinsics)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0094.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
You gave an invalid number of type parameters to an intrinsic function.
An invalid number of type parameters was given to an intrinsic function.

Erroneous code example:

```compile_fail,E0094
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0106.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This error indicates that a lifetime is missing from a type. If it is an error
inside a function signature, the problem may be with failing to adhere to the
lifetime elision rules (see below).

Here are some simple examples of where you'll run into this error:
Erroneous code examples:

```compile_fail,E0106
struct Foo1 { x: &bool }
Expand All @@ -27,7 +27,7 @@ function signatures which allows you to leave out lifetimes in certain cases.
For more background on lifetime elision see [the book][book-le].

The lifetime elision rules require that any function signature with an elided
output lifetime must either have
output lifetime must either have:

- exactly one input lifetime
- or, multiple input lifetimes, but the function must also be a method with a
Expand Down
Loading

0 comments on commit 18a1891

Please sign in to comment.