Skip to content

Commit 18a1891

Browse files
committed
Auto merge of #67048 - RalfJung:rollup-drjnmt0, r=RalfJung
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
2 parents d825e35 + 1ae771b commit 18a1891

File tree

86 files changed

+598
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+598
-229
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1823,9 +1823,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
18231823

18241824
[[package]]
18251825
name = "libc"
1826-
version = "0.2.64"
1826+
version = "0.2.66"
18271827
source = "registry+https://github.com/rust-lang/crates.io-index"
1828-
checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
1828+
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
18291829
dependencies = [
18301830
"rustc-std-workspace-core",
18311831
]

src/ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fi
2323
ci_dir=`cd $(dirname $0) && pwd`
2424
source "$ci_dir/shared.sh"
2525

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

src/libcore/fmt/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ pub trait Display {
662662
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
663663
/// let val = self.0;
664664
///
665-
/// write!(f, "{:o}", val) // delegate to i32's implementation
665+
/// fmt::Octal::fmt(&val, f) // delegate to i32's implementation
666666
/// }
667667
/// }
668668
///
@@ -712,7 +712,7 @@ pub trait Octal {
712712
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
713713
/// let val = self.0;
714714
///
715-
/// write!(f, "{:b}", val) // delegate to i32's implementation
715+
/// fmt::Binary::fmt(&val, f) // delegate to i32's implementation
716716
/// }
717717
/// }
718718
///
@@ -771,7 +771,7 @@ pub trait Binary {
771771
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
772772
/// let val = self.0;
773773
///
774-
/// write!(f, "{:x}", val) // delegate to i32's implementation
774+
/// fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
775775
/// }
776776
/// }
777777
///
@@ -824,7 +824,7 @@ pub trait LowerHex {
824824
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
825825
/// let val = self.0;
826826
///
827-
/// write!(f, "{:X}", val) // delegate to i32's implementation
827+
/// fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
828828
/// }
829829
/// }
830830
///
@@ -869,7 +869,8 @@ pub trait UpperHex {
869869
/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
870870
/// // use `as` to convert to a `*const T`, which implements Pointer, which we can use
871871
///
872-
/// write!(f, "{:p}", self as *const Length)
872+
/// let ptr = self as *const Self;
873+
/// fmt::Pointer::fmt(&ptr, f)
873874
/// }
874875
/// }
875876
///

src/libcore/iter/traits/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@
9191
/// ```
9292
#[stable(feature = "rust1", since = "1.0.0")]
9393
#[rustc_on_unimplemented(
94-
message="a collection of type `{Self}` cannot be built from an iterator \
94+
message="a value of type `{Self}` cannot be built from an iterator \
9595
over elements of type `{A}`",
96-
label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
96+
label="value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
9797
)]
9898
pub trait FromIterator<A>: Sized {
9999
/// Creates a value from an iterator.

src/libcore/sync/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//!
2828
//! Atomic variables are safe to share between threads (they implement [`Sync`])
2929
//! but they do not themselves provide the mechanism for sharing and follow the
30-
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
30+
//! [threading model](../../../std/thread/index.html#the-threading-model) of Rust.
3131
//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an
3232
//! atomically-reference-counted shared pointer).
3333
//!

src/libpanic_unwind/gcc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1
129129
#[cfg(target_arch = "hexagon")]
130130
const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1
131131

132+
#[cfg(target_arch = "riscv64")]
133+
const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
134+
132135
// The following code is based on GCC's C and C++ personality routines. For reference, see:
133136
// https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc
134137
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c

src/librustc/infer/error_reporting/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1809,12 +1809,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
18091809
sub_region,
18101810
"...",
18111811
);
1812-
err.note(&format!(
1813-
"...so that the {}:\nexpected {}\n found {}",
1814-
sup_trace.cause.as_requirement_str(),
1815-
sup_expected.content(),
1816-
sup_found.content()
1812+
err.span_note(sup_trace.cause.span, &format!(
1813+
"...so that the {}",
1814+
sup_trace.cause.as_requirement_str()
18171815
));
1816+
1817+
err.note_expected_found(
1818+
&"",
1819+
sup_expected,
1820+
&"",
1821+
sup_found
1822+
);
18181823
err.emit();
18191824
return;
18201825
}

src/librustc/infer/error_reporting/note.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1313
match *origin {
1414
infer::Subtype(ref trace) => {
1515
if let Some((expected, found)) = self.values_str(&trace.values) {
16-
let expected = expected.content();
17-
let found = found.content();
18-
err.note(&format!("...so that the {}:\nexpected {}\n found {}",
19-
trace.cause.as_requirement_str(),
20-
expected,
21-
found));
16+
err.span_note(
17+
trace.cause.span,
18+
&format!(
19+
"...so that the {}",
20+
trace.cause.as_requirement_str()
21+
)
22+
);
23+
24+
err.note_expected_found(
25+
&"",
26+
expected,
27+
&"",
28+
found
29+
);
2230
} else {
2331
// FIXME: this really should be handled at some earlier stage. Our
2432
// handling of region checking when type errors are present is

src/librustc/ty/print/pretty.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,9 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
12821282
if !self.empty_path {
12831283
write!(self, "::")?;
12841284
}
1285+
if ast::Ident::from_str(&name).is_raw_guess() {
1286+
write!(self, "r#")?;
1287+
}
12851288
write!(self, "{}", name)?;
12861289

12871290
// FIXME(eddyb) this will print e.g. `{{closure}}#3`, but it

src/librustc_data_structures/obligation_forest/mod.rs

+60-29
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@ type ObligationTreeIdGenerator =
130130
pub struct ObligationForest<O: ForestObligation> {
131131
/// The list of obligations. In between calls to
132132
/// `process_obligations`, this list only contains nodes in the
133-
/// `Pending` or `Success` state (with a non-zero number of
133+
/// `Pending` or `Waiting` state (with a non-zero number of
134134
/// incomplete children). During processing, some of those nodes
135135
/// may be changed to the error state, or we may find that they
136-
/// are completed (That is, `num_incomplete_children` drops to 0).
137-
/// At the end of processing, those nodes will be removed by a
138-
/// call to `compress`.
136+
/// are completed. At the end of processing, those nodes will be
137+
/// removed by a call to `compress`.
139138
///
140139
/// `usize` indices are used here and throughout this module, rather than
141140
/// `rustc_index::newtype_index!` indices, because this code is hot enough that the
@@ -211,28 +210,56 @@ impl<O> Node<O> {
211210
/// represents the current state of processing for the obligation (of
212211
/// type `O`) associated with this node.
213212
///
214-
/// Outside of ObligationForest methods, nodes should be either Pending
215-
/// or Waiting.
213+
/// The non-`Error` state transitions are as follows.
214+
/// ```
215+
/// (Pre-creation)
216+
/// |
217+
/// | register_obligation_at() (called by process_obligations() and
218+
/// v from outside the crate)
219+
/// Pending
220+
/// |
221+
/// | process_obligations()
222+
/// v
223+
/// Success
224+
/// | ^
225+
/// | | update_waiting_and_success_states()
226+
/// | v
227+
/// | Waiting
228+
/// |
229+
/// | process_cycles()
230+
/// v
231+
/// Done
232+
/// |
233+
/// | compress()
234+
/// v
235+
/// (Removed)
236+
/// ```
237+
/// The `Error` state can be introduced in several places, via `error_at()`.
238+
///
239+
/// Outside of `ObligationForest` methods, nodes should be either `Pending` or
240+
/// `Waiting`.
216241
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
217242
enum NodeState {
218-
/// Obligations for which selection had not yet returned a
219-
/// non-ambiguous result.
243+
/// This obligation has not yet been selected successfully. Cannot have
244+
/// subobligations.
220245
Pending,
221246

222-
/// This obligation was selected successfully, but may or
223-
/// may not have subobligations.
247+
/// This obligation was selected successfully, but the state of any
248+
/// subobligations are current unknown. It will be converted to `Waiting`
249+
/// or `Done` once the states of the subobligations become known.
224250
Success,
225251

226-
/// This obligation was selected successfully, but it has
227-
/// a pending subobligation.
252+
/// This obligation was selected successfully, but it has one or more
253+
/// pending subobligations.
228254
Waiting,
229255

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

234-
/// This obligation was resolved to an error. Error nodes are
235-
/// removed from the vector by the compression step.
261+
/// This obligation was resolved to an error. It will be removed by the
262+
/// next compression step.
236263
Error,
237264
}
238265

@@ -464,7 +491,7 @@ impl<O: ForestObligation> ObligationForest<O> {
464491
};
465492
}
466493

467-
self.mark_as_waiting();
494+
self.update_waiting_and_success_states();
468495
self.process_cycles(processor);
469496
let completed = self.compress(do_completed);
470497

@@ -477,10 +504,9 @@ impl<O: ForestObligation> ObligationForest<O> {
477504
}
478505
}
479506

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

563589
// This always-inlined function is for the hot call site.
564590
#[inline(always)]
565-
fn inlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
591+
fn inlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
566592
for &index in node.dependents.iter() {
567593
let node = &self.nodes[index];
568594
match node.state.get() {
569595
NodeState::Waiting | NodeState::Error => {}
570596
NodeState::Success => {
571597
node.state.set(NodeState::Waiting);
572598
// This call site is cold.
573-
self.uninlined_mark_neighbors_as_waiting_from(node);
599+
self.uninlined_mark_dependents_as_waiting(node);
574600
}
575601
NodeState::Pending | NodeState::Done => {
576602
// This call site is cold.
577-
self.uninlined_mark_neighbors_as_waiting_from(node);
603+
self.uninlined_mark_dependents_as_waiting(node);
578604
}
579605
}
580606
}
581607
}
582608

583609
// This never-inlined function is for the cold call site.
584610
#[inline(never)]
585-
fn uninlined_mark_neighbors_as_waiting_from(&self, node: &Node<O>) {
586-
self.inlined_mark_neighbors_as_waiting_from(node)
611+
fn uninlined_mark_dependents_as_waiting(&self, node: &Node<O>) {
612+
self.inlined_mark_dependents_as_waiting(node)
587613
}
588614

589-
/// Marks all nodes that depend on a pending node as `NodeState::Waiting`.
590-
fn mark_as_waiting(&self) {
615+
/// Updates the states of all `Waiting` and `Success` nodes. Upon
616+
/// completion, all such nodes that depend on a pending node will be marked
617+
/// as `Waiting`, and all others will be marked as `Success`.
618+
fn update_waiting_and_success_states(&self) {
619+
// Optimistically mark all `Waiting` nodes as `Success`.
591620
for node in &self.nodes {
592621
if node.state.get() == NodeState::Waiting {
593622
node.state.set(NodeState::Success);
594623
}
595624
}
596625

626+
// Convert all `Success` nodes that still depend on a pending node to
627+
// `Waiting`. This may undo some of the changes done in the loop above.
597628
for node in &self.nodes {
598629
if node.state.get() == NodeState::Pending {
599630
// This call site is hot.
600-
self.inlined_mark_neighbors_as_waiting_from(node);
631+
self.inlined_mark_dependents_as_waiting(node);
601632
}
602633
}
603634
}

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ E0622: include_str!("./error_codes/E0622.md"),
347347
E0623: include_str!("./error_codes/E0623.md"),
348348
E0624: include_str!("./error_codes/E0624.md"),
349349
E0626: include_str!("./error_codes/E0626.md"),
350+
E0631: include_str!("./error_codes/E0631.md"),
350351
E0633: include_str!("./error_codes/E0633.md"),
351352
E0635: include_str!("./error_codes/E0635.md"),
352353
E0636: include_str!("./error_codes/E0636.md"),
@@ -580,7 +581,6 @@ E0745: include_str!("./error_codes/E0745.md"),
580581
// rustc_const_unstable attribute must be paired with stable/unstable
581582
// attribute
582583
E0630,
583-
E0631, // type mismatch in closure arguments
584584
E0632, // cannot provide explicit generic arguments when `impl Trait` is
585585
// used in argument position
586586
E0634, // type has conflicting packed representaton hints

src/librustc_error_codes/error_codes/E0092.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
You tried to declare an undefined atomic operation function.
1+
An undefined atomic operation function was declared.
2+
23
Erroneous code example:
34

45
```compile_fail,E0092
@@ -11,8 +12,8 @@ extern "rust-intrinsic" {
1112
```
1213

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

1718
```
1819
#![feature(intrinsics)]

src/librustc_error_codes/error_codes/E0093.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
You declared an unknown intrinsic function. Erroneous code example:
1+
An unknown intrinsic function was declared.
2+
3+
Erroneous code example:
24

35
```compile_fail,E0093
46
#![feature(intrinsics)]
@@ -15,8 +17,8 @@ fn main() {
1517
```
1618

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

2123
```
2224
#![feature(intrinsics)]

src/librustc_error_codes/error_codes/E0094.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
You gave an invalid number of type parameters to an intrinsic function.
1+
An invalid number of type parameters was given to an intrinsic function.
2+
23
Erroneous code example:
34

45
```compile_fail,E0094

src/librustc_error_codes/error_codes/E0106.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This error indicates that a lifetime is missing from a type. If it is an error
22
inside a function signature, the problem may be with failing to adhere to the
33
lifetime elision rules (see below).
44

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

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

2929
The lifetime elision rules require that any function signature with an elided
30-
output lifetime must either have
30+
output lifetime must either have:
3131

3232
- exactly one input lifetime
3333
- or, multiple input lifetimes, but the function must also be a method with a

0 commit comments

Comments
 (0)