Skip to content

Commit 54b7d21

Browse files
committed
Auto merge of #69950 - Centril:rollup-xh0hmvx, r=Centril
Rollup of 10 pull requests Successful merges: - #68899 (Add Display and Error impls for proc_macro::LexError) - #69011 (Document unsafe blocks in core::fmt) - #69674 (Rename DefKind::Method and TraitItemKind::Method ) - #69705 (Toolstate: remove redundant beta-week check.) - #69722 (Tweak output for invalid negative impl AST errors) - #69747 (Rename rustc guide) - #69792 (Implement Error for TryReserveError) - #69830 (miri: ICE on invalid terminators) - #69921 (rustdoc: remove unused import) - #69945 (update outdated comment) Failed merges: r? @ghost
2 parents 23de827 + 9463cf3 commit 54b7d21

File tree

140 files changed

+543
-431
lines changed

Some content is hidden

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

140 files changed

+543
-431
lines changed

.github/ISSUE_TEMPLATE/tracking_issue.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ for larger features an implementation could be broken up into multiple PRs.
3636

3737
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
3838
instructions?)
39-
- [ ] Adjust documentation ([see instructions on rustc-guide][doc-guide])
40-
- [ ] Stabilization PR ([see instructions on rustc-guide][stabilization-guide])
39+
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
40+
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
4141

42-
[stabilization-guide]: https://rust-lang.github.io/rustc-guide/stabilization_guide.html#stabilization-pr
43-
[doc-guide]: https://rust-lang.github.io/rustc-guide/stabilization_guide.html#documentation-prs
42+
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
43+
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
4444

4545
### Unresolved Questions
4646
<!--

CONTRIBUTING.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ hop on the [Rust Discord server][rust-discord] or [Rust Zulip server][rust-zulip
1919

2020
As a reminder, all contributors are expected to follow our [Code of Conduct][coc].
2121

22-
The [rustc-guide] is your friend! It describes how the compiler works and how
22+
The [rustc-dev-guide] is your friend! It describes how the compiler works and how
2323
to contribute to it in more detail than this document.
2424

2525
If this is your first time contributing, the [walkthrough] chapter of the guide
@@ -29,8 +29,8 @@ can give you a good example of how a typical contribution would go.
2929
[rust-discord]: http://discord.gg/rust-lang
3030
[rust-zulip]: https://rust-lang.zulipchat.com
3131
[coc]: https://www.rust-lang.org/conduct.html
32-
[rustc-guide]: https://rust-lang.github.io/rustc-guide/
33-
[walkthrough]: https://rust-lang.github.io/rustc-guide/walkthrough.html
32+
[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
33+
[walkthrough]: https://rustc-dev-guide.rust-lang.org/walkthrough.html
3434

3535
## Feature Requests
3636
[feature-requests]: #feature-requests
@@ -103,12 +103,12 @@ $ RUST_BACKTRACE=1 rustc ...
103103
## The Build System
104104

105105
For info on how to configure and build the compiler, please see [this
106-
chapter][rustcguidebuild] of the rustc-guide. This chapter contains info for
106+
chapter][rustcguidebuild] of the rustc-dev-guide. This chapter contains info for
107107
contributions to the compiler and the standard library. It also lists some
108108
really useful commands to the build system (`./x.py`), which could save you a
109109
lot of time.
110110

111-
[rustcguidebuild]: https://rust-lang.github.io/rustc-guide/building/how-to-build-and-run.html
111+
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
112112

113113
## Pull Requests
114114
[pull-requests]: #pull-requests
@@ -336,9 +336,9 @@ to check small fixes. For example, `rustdoc src/doc/reference.md` will render
336336
reference to `doc/reference.html`. The CSS might be messed up, but you can
337337
verify that the HTML is right.
338338

339-
Additionally, contributions to the [rustc-guide] are always welcome. Contributions
339+
Additionally, contributions to the [rustc-dev-guide] are always welcome. Contributions
340340
can be made directly at [the
341-
rust-lang/rustc-guide](https://github.com/rust-lang/rustc-guide) repo. The issue
341+
rust-lang/rustc-dev-guide](https://github.com/rust-lang/rustc-dev-guide) repo. The issue
342342
tracker in that repo is also a great way to find things that need doing. There
343343
are issues for beginners and advanced compiler devs alike!
344344

@@ -434,7 +434,7 @@ For people new to Rust, and just starting to contribute, or even for
434434
more seasoned developers, some useful places to look for information
435435
are:
436436

437-
* The [rustc guide] contains information about how various parts of the compiler work and how to contribute to the compiler
437+
* The [rustc dev guide] contains information about how various parts of the compiler work and how to contribute to the compiler
438438
* [Rust Forge][rustforge] contains additional documentation, including write-ups of how to achieve common tasks
439439
* The [Rust Internals forum][rif], a place to ask questions and
440440
discuss Rust's internals
@@ -448,13 +448,13 @@ are:
448448
* **Google!** ([search only in Rust Documentation][gsearchdocs] to find types, traits, etc. quickly)
449449
* Don't be afraid to ask! The Rust community is friendly and helpful.
450450

451-
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
451+
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
452452
[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
453453
[gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here
454454
[rif]: http://internals.rust-lang.org
455455
[rr]: https://doc.rust-lang.org/book/README.html
456456
[rustforge]: https://forge.rust-lang.org/
457457
[tlgba]: http://tomlee.co/2014/04/a-more-detailed-tour-of-the-rust-compiler/
458458
[ro]: http://www.rustaceans.org/
459-
[rctd]: https://rust-lang.github.io/rustc-guide/tests/intro.html
459+
[rctd]: https://rustc-dev-guide.rust-lang.org/tests/intro.html
460460
[cheatsheet]: https://buildbot2.rust-lang.org/homu/

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Read ["Installation"] from [The Book].
1515
## Installing from Source
1616

1717
_Note: If you wish to contribute to the compiler, you should read [this
18-
chapter][rustcguidebuild] of the rustc-guide instead of this section._
18+
chapter][rustcguidebuild] of the rustc-dev-guide instead of this section._
1919

2020
The Rust build system has a Python script called `x.py` to bootstrap building
2121
the compiler. More information about it may be found by running `./x.py --help`
22-
or reading the [rustc guide][rustcguidebuild].
22+
or reading the [rustc dev guide][rustcguidebuild].
2323

24-
[rustcguidebuild]: https://rust-lang.github.io/rustc-guide/building/how-to-build-and-run.html
24+
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
2525

2626
### Building on *nix
2727
1. Make sure you have installed the dependencies:
@@ -249,13 +249,13 @@ Most real-time collaboration happens in a variety of channels on the
249249
community, documentation, and all major contribution areas in the Rust ecosystem.
250250
A good place to ask for help would be the #help channel.
251251
252-
The [rustc guide] might be a good place to start if you want to find out how
252+
The [rustc dev guide] might be a good place to start if you want to find out how
253253
various parts of the compiler work.
254254
255255
Also, you may find the [rustdocs for the compiler itself][rustdocs] useful.
256256
257257
[rust-discord]: https://discord.gg/rust-lang
258-
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
258+
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html
259259
[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/
260260
261261
## License

src/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ This directory contains the source code of the rust project, including:
33
- `libstd`
44
- Various submodules for tools, like rustdoc, rls, etc.
55

6-
For more information on how various parts of the compiler work, see the [rustc guide].
6+
For more information on how various parts of the compiler work, see the [rustc dev guide].
77

8-
[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html
8+
[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/about-this-guide.html

src/bootstrap/toolstate.rs

+22-33
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,21 @@ impl Step for ToolStateCheck {
215215
tool, old_state, state
216216
);
217217
} else {
218+
// This warning only appears in the logs, which most
219+
// people won't read. It's mostly here for testing and
220+
// debugging.
218221
eprintln!(
219222
"warning: Tool `{}` is not test-pass (is `{}`), \
220223
this should be fixed before beta is branched.",
221224
tool, state
222225
);
223226
}
224227
}
228+
// `publish_toolstate.py` is responsible for updating
229+
// `latest.json` and creating comments/issues warning people
230+
// if there is a regression. That all happens in a separate CI
231+
// job on the master branch once the PR has passed all tests
232+
// on the `auto` branch.
225233
}
226234
}
227235

@@ -230,7 +238,7 @@ impl Step for ToolStateCheck {
230238
}
231239

232240
if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
233-
commit_toolstate_change(&toolstates, in_beta_week);
241+
commit_toolstate_change(&toolstates);
234242
}
235243
}
236244

@@ -325,11 +333,11 @@ fn prepare_toolstate_config(token: &str) {
325333
Err(_) => false,
326334
};
327335
if !success {
328-
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
336+
panic!("git config key={} value={} failed (status: {:?})", key, value, status);
329337
}
330338
}
331339

332-
// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
340+
// If changing anything here, then please check that `src/ci/publish_toolstate.sh` is up to date
333341
// as well.
334342
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
335343
git_config("user.name", "Rust Toolstate Update");
@@ -373,14 +381,14 @@ fn read_old_toolstate() -> Vec<RepoState> {
373381
///
374382
/// * See <https://help.github.com/articles/about-commit-email-addresses/>
375383
/// if a private email by GitHub is wanted.
376-
fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool) {
377-
let old_toolstate = read_old_toolstate();
378-
384+
fn commit_toolstate_change(current_toolstate: &ToolstateData) {
379385
let message = format!("({} CI update)", OS.expect("linux/windows only"));
380386
let mut success = false;
381387
for _ in 1..=5 {
382-
// Update the toolstate results (the new commit-to-toolstate mapping) in the toolstate repo.
383-
change_toolstate(&current_toolstate, &old_toolstate, in_beta_week);
388+
// Upload the test results (the new commit-to-toolstate mapping) to the toolstate repo.
389+
// This does *not* change the "current toolstate"; that only happens post-landing
390+
// via `src/ci/docker/publish_toolstate.sh`.
391+
publish_test_results(&current_toolstate);
384392

385393
// `git commit` failing means nothing to commit.
386394
let status = t!(Command::new("git")
@@ -429,31 +437,12 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
429437
}
430438
}
431439

432-
fn change_toolstate(
433-
current_toolstate: &ToolstateData,
434-
old_toolstate: &[RepoState],
435-
in_beta_week: bool,
436-
) {
437-
let mut regressed = false;
438-
for repo_state in old_toolstate {
439-
let tool = &repo_state.tool;
440-
let state = repo_state.state();
441-
let new_state = current_toolstate[tool.as_str()];
442-
443-
if new_state != state {
444-
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
445-
if new_state < state {
446-
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
447-
regressed = true;
448-
}
449-
}
450-
}
451-
}
452-
453-
if regressed && in_beta_week {
454-
std::process::exit(1);
455-
}
456-
440+
/// Updates the "history" files with the latest results.
441+
///
442+
/// These results will later be promoted to `latest.json` by the
443+
/// `publish_toolstate.py` script if the PR passes all tests and is merged to
444+
/// master.
445+
fn publish_test_results(current_toolstate: &ToolstateData) {
457446
let commit = t!(std::process::Command::new("git").arg("rev-parse").arg("HEAD").output());
458447
let commit = t!(String::from_utf8(commit.stdout));
459448

src/ci/publish_toolstate.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ GIT_COMMIT_MSG="$(git log --format=%s -n1 HEAD)"
2323
cd rust-toolstate
2424
FAILURE=1
2525
for RETRY_COUNT in 1 2 3 4 5; do
26-
# The purpose is to publish the new "current" toolstate in the toolstate repo.
26+
# The purpose of this is to publish the new "current" toolstate in the toolstate repo.
27+
# This happens post-landing, on master.
28+
# (Publishing the per-commit test results happens pre-landing in src/bootstrap/toolstate.rs).
2729
"$(ciCheckoutPath)/src/tools/publish_toolstate.py" "$GIT_COMMIT" \
2830
"$GIT_COMMIT_MSG" \
2931
"$MESSAGE_FILE" \

src/doc/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Rust. It's also sometimes called "the 'nomicon."
120120

121121
## The `rustc` Contribution Guide
122122

123-
[The `rustc` Guide](https://rust-lang.github.io/rustc-guide/) documents how
123+
[The `rustc` Guide](https://rustc-dev-guide.rust-lang.org/) documents how
124124
the compiler works and how to contribute to it. This is useful if you want to build
125125
or modify the Rust compiler from source (e.g. to target something non-standard).
126126

src/doc/rustc/src/contributing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Contributing to rustc
22

33
We'd love to have your help improving `rustc`! To that end, we've written [a
4-
whole book][rustc_guide] on its
4+
whole book][rustc_dev_guide] on its
55
internals, how it works, and how to get started working on it. To learn
66
more, you'll want to check that out.
77

88
If you would like to contribute to _this_ book, you can find its source in the
99
rustc source at [src/doc/rustc][rustc_book].
1010

11-
[rustc_guide]: https://rust-lang.github.io/rustc-guide/
11+
[rustc_dev_guide]: https://rustc-dev-guide.rust-lang.org/
1212
[rustc_book]: https://github.com/rust-lang/rust/tree/master/src/doc/rustc

src/liballoc/collections/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub use linked_list::LinkedList;
4242
pub use vec_deque::VecDeque;
4343

4444
use crate::alloc::{Layout, LayoutErr};
45+
use core::fmt::Display;
4546

4647
/// The error type for `try_reserve` methods.
4748
#[derive(Clone, PartialEq, Eq, Debug)]
@@ -77,6 +78,23 @@ impl From<LayoutErr> for TryReserveError {
7778
}
7879
}
7980

81+
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
82+
impl Display for TryReserveError {
83+
fn fmt(
84+
&self,
85+
fmt: &mut core::fmt::Formatter<'_>,
86+
) -> core::result::Result<(), core::fmt::Error> {
87+
fmt.write_str("memory allocation failed")?;
88+
let reason = match &self {
89+
TryReserveError::CapacityOverflow => {
90+
" because the computed capacity exceeded the collection's maximum"
91+
}
92+
TryReserveError::AllocError { .. } => " because the memory allocator returned a error",
93+
};
94+
fmt.write_str(reason)
95+
}
96+
}
97+
8098
/// An intermediate trait for specialization of `Extend`.
8199
#[doc(hidden)]
82100
trait SpecExtend<I: IntoIterator> {

src/libcore/fmt/float.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp};
22
use crate::mem::MaybeUninit;
33
use crate::num::flt2dec;
44

5-
// ignore-tidy-undocumented-unsafe
6-
75
// Don't inline this so callers don't use the stack space this function
86
// requires unless they have to.
97
#[inline(never)]
@@ -16,6 +14,7 @@ fn float_to_decimal_common_exact<T>(
1614
where
1715
T: flt2dec::DecodableFloat,
1816
{
17+
// SAFETY: Possible undefined behavior, see FIXME(#53491)
1918
unsafe {
2019
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
2120
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 4]>::uninit();
@@ -48,6 +47,7 @@ fn float_to_decimal_common_shortest<T>(
4847
where
4948
T: flt2dec::DecodableFloat,
5049
{
50+
// SAFETY: Possible undefined behavior, see FIXME(#53491)
5151
unsafe {
5252
// enough for f32 and f64
5353
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit();
@@ -103,6 +103,7 @@ fn float_to_exponential_common_exact<T>(
103103
where
104104
T: flt2dec::DecodableFloat,
105105
{
106+
// SAFETY: Possible undefined behavior, see FIXME(#53491)
106107
unsafe {
107108
let mut buf = MaybeUninit::<[u8; 1024]>::uninit(); // enough for f32 and f64
108109
let mut parts = MaybeUninit::<[flt2dec::Part<'_>; 6]>::uninit();
@@ -132,6 +133,7 @@ fn float_to_exponential_common_shortest<T>(
132133
where
133134
T: flt2dec::DecodableFloat,
134135
{
136+
// SAFETY: Possible undefined behavior, see FIXME(#53491)
135137
unsafe {
136138
// enough for f32 and f64
137139
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninit();

src/libcore/fmt/mod.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Utilities for formatting and printing strings.
22
3-
// ignore-tidy-undocumented-unsafe
4-
53
#![stable(feature = "rust1", since = "1.0.0")]
64

75
use crate::cell::{Cell, Ref, RefCell, RefMut, UnsafeCell};
@@ -281,6 +279,14 @@ impl<'a> ArgumentV1<'a> {
281279
#[doc(hidden)]
282280
#[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "none")]
283281
pub fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter<'_>) -> Result) -> ArgumentV1<'b> {
282+
// SAFETY: `mem::transmute(x)` is safe because
283+
// 1. `&'b T` keeps the lifetime it originated with `'b`
284+
// (so as to not have an unbounded lifetime)
285+
// 2. `&'b T` and `&'b Void` have the same memory layout
286+
// (when `T` is `Sized`, as it is here)
287+
// `mem::transmute(f)` is safe since `fn(&T, &mut Formatter<'_>) -> Result`
288+
// and `fn(&Void, &mut Formatter<'_>) -> Result` have the same ABI
289+
// (as long as `T` is `Sized`)
284290
unsafe { ArgumentV1 { formatter: mem::transmute(f), value: mem::transmute(x) } }
285291
}
286292

@@ -1399,6 +1405,14 @@ impl<'a> Formatter<'a> {
13991405

14001406
fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted<'_>) -> Result {
14011407
fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result {
1408+
// SAFETY: This is used for `flt2dec::Part::Num` and `flt2dec::Part::Copy`.
1409+
// It's safe to use for `flt2dec::Part::Num` since every char `c` is between
1410+
// `b'0'` and `b'9'`, which means `s` is valid UTF-8.
1411+
// It's also probably safe in practice to use for `flt2dec::Part::Copy(buf)`
1412+
// since `buf` should be plain ASCII, but it's possible for someone to pass
1413+
// in a bad value for `buf` into `flt2dec::to_shortest_str` since it is a
1414+
// public function.
1415+
// FIXME: Determine whether this could result in UB.
14021416
buf.write_str(unsafe { str::from_utf8_unchecked(s) })
14031417
}
14041418

0 commit comments

Comments
 (0)