Skip to content

Commit 4533be9

Browse files
committed
Auto merge of rust-lang#87569 - JohnTitor:rollup-7ydfetw, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#81050 (Stabilize core::task::ready!) - rust-lang#81363 (Remove P: Unpin bound on impl Future for Pin) - rust-lang#86839 (Add doc aliases to fs.rs) - rust-lang#87435 (fix example code for E0617) - rust-lang#87451 (Add support for tuple struct field documentation) - rust-lang#87491 (Integrate context into the memorial to Anna) - rust-lang#87521 (Add long explanation for E0498) - rust-lang#87527 (Don't run MIR unsafeck at all when using `-Zthir-unsafeck`) - rust-lang#87550 (Add `CI_ONLY_WHEN_CHANNEL` and run `x86_64-gnu-stable` only on nightly) - rust-lang#87565 (Use backticks when referring to `core::future::Ready` in panic message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b708886 + 6c4888a commit 4533be9

File tree

24 files changed

+202
-69
lines changed

24 files changed

+202
-69
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ jobs:
263263
env:
264264
IMAGE: x86_64-gnu
265265
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
266+
CI_ONLY_WHEN_CHANNEL: nightly
266267
os: ubuntu-latest-xl
267268
- name: x86_64-gnu-aux
268269
os: ubuntu-latest-xl

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ E0493: include_str!("./error_codes/E0493.md"),
248248
E0495: include_str!("./error_codes/E0495.md"),
249249
E0496: include_str!("./error_codes/E0496.md"),
250250
E0497: include_str!("./error_codes/E0497.md"),
251+
E0498: include_str!("./error_codes/E0498.md"),
251252
E0499: include_str!("./error_codes/E0499.md"),
252253
E0500: include_str!("./error_codes/E0500.md"),
253254
E0501: include_str!("./error_codes/E0501.md"),
@@ -604,7 +605,6 @@ E0783: include_str!("./error_codes/E0783.md"),
604605
// E0488, // lifetime of variable does not enclose its declaration
605606
// E0489, // type/lifetime parameter not in scope here
606607
E0490, // a value of type `..` is borrowed for too long
607-
E0498, // malformed plugin attribute
608608
E0514, // metadata version mismatch
609609
E0519, // local crate and dependency have same (crate-name, disambiguator)
610610
// two dependencies have same (crate-name, disambiguator) but different SVH
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The `plugin` attribute was malformed.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0498
6+
#![feature(plugin)]
7+
#![plugin(foo(args))] // error: invalid argument
8+
#![plugin(bar="test")] // error: invalid argument
9+
```
10+
11+
The `#[plugin]` attribute should take a single argument: the name of the plugin.
12+
13+
For example, for the plugin `foo`:
14+
15+
```ignore (requires external plugin crate)
16+
#![feature(plugin)]
17+
#![plugin(foo)] // ok!
18+
```
19+
20+
See the [`plugin` feature] section of the Unstable book for more details.
21+
22+
[`plugin` feature]: https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html

compiler/rustc_error_codes/src/error_codes/E0617.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ Attempted to pass an invalid type of variable into a variadic function.
33
Erroneous code example:
44

55
```compile_fail,E0617
6+
# use std::os::raw::{c_char, c_int};
67
extern "C" {
7-
fn printf(c: *const i8, ...);
8+
fn printf(format: *const c_char, ...) -> c_int;
89
}
910
1011
unsafe {
11-
printf(::std::ptr::null(), 0f32);
12+
printf("%f\n\0".as_ptr() as _, 0f32);
1213
// error: cannot pass an `f32` to variadic function, cast to `c_double`
1314
}
1415
```
@@ -21,10 +22,12 @@ to import from `std::os::raw`).
2122
In this case, `c_double` has the same size as `f64` so we can use it directly:
2223

2324
```no_run
25+
# use std::os::raw::{c_char, c_int};
2426
# extern "C" {
25-
# fn printf(c: *const i8, ...);
27+
# fn printf(format: *const c_char, ...) -> c_int;
2628
# }
29+
2730
unsafe {
28-
printf(::std::ptr::null(), 0f64); // ok!
31+
printf("%f\n\0".as_ptr() as _, 0f64); // ok!
2932
}
3033
```

compiler/rustc_mir/src/transform/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,12 @@ fn mir_const<'tcx>(
259259
}
260260

261261
// Unsafety check uses the raw mir, so make sure it is run.
262-
if let Some(param_did) = def.const_param_did {
263-
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
264-
} else {
265-
tcx.ensure().unsafety_check_result(def.did);
262+
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
263+
if let Some(param_did) = def.const_param_did {
264+
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
265+
} else {
266+
tcx.ensure().unsafety_check_result(def.did);
267+
}
266268
}
267269

268270
let mut body = tcx.mir_built(def).steal();

library/core/src/future/future.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ impl<F: ?Sized + Future + Unpin> Future for &mut F {
111111
#[stable(feature = "futures_api", since = "1.36.0")]
112112
impl<P> Future for Pin<P>
113113
where
114-
P: Unpin + ops::DerefMut<Target: Future>,
114+
P: ops::DerefMut<Target: Future>,
115115
{
116116
type Output = <<P as ops::Deref>::Target as Future>::Output;
117117

118118
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
119-
Pin::get_mut(self).as_mut().poll(cx)
119+
<P::Target as Future>::poll(self.as_deref_mut(), cx)
120120
}
121121
}

library/core/src/future/ready.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<T> Future for Ready<T> {
2020

2121
#[inline]
2222
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
23-
Poll::Ready(self.0.take().expect("Ready polled after completion"))
23+
Poll::Ready(self.0.take().expect("`Ready` polled after completion"))
2424
}
2525
}
2626

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#![feature(exhaustive_patterns)]
129129
#![feature(no_core)]
130130
#![feature(auto_traits)]
131+
#![feature(pin_deref_mut)]
131132
#![feature(prelude_import)]
132133
#![feature(ptr_metadata)]
133134
#![feature(repr_simd, platform_intrinsics)]

library/core/src/pin.rs

+38
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,44 @@ impl<T: ?Sized> Pin<&'static T> {
802802
}
803803
}
804804

805+
impl<'a, P: DerefMut> Pin<&'a mut Pin<P>> {
806+
/// Gets a pinned mutable reference from this nested pinned pointer.
807+
///
808+
/// This is a generic method to go from `Pin<&mut Pin<Pointer<T>>>` to `Pin<&mut T>`. It is
809+
/// safe because the existence of a `Pin<Pointer<T>>` ensures that the pointee, `T`, cannot
810+
/// move in the future, and this method does not enable the pointee to move. "Malicious"
811+
/// implementations of `P::DerefMut` are likewise ruled out by the contract of
812+
/// `Pin::new_unchecked`.
813+
#[unstable(feature = "pin_deref_mut", issue = "86918")]
814+
#[inline(always)]
815+
pub fn as_deref_mut(self) -> Pin<&'a mut P::Target> {
816+
// SAFETY: What we're asserting here is that going from
817+
//
818+
// Pin<&mut Pin<P>>
819+
//
820+
// to
821+
//
822+
// Pin<&mut P::Target>
823+
//
824+
// is safe.
825+
//
826+
// We need to ensure that two things hold for that to be the case:
827+
//
828+
// 1) Once we give out a `Pin<&mut P::Target>`, an `&mut P::Target` will not be given out.
829+
// 2) By giving out a `Pin<&mut P::Target>`, we do not risk of violating `Pin<&mut Pin<P>>`
830+
//
831+
// The existence of `Pin<P>` is sufficient to guarantee #1: since we already have a
832+
// `Pin<P>`, it must already uphold the pinning guarantees, which must mean that
833+
// `Pin<&mut P::Target>` does as well, since `Pin::as_mut` is safe. We do not have to rely
834+
// on the fact that P is _also_ pinned.
835+
//
836+
// For #2, we need to ensure that code given a `Pin<&mut P::Target>` cannot cause the
837+
// `Pin<P>` to move? That is not possible, since `Pin<&mut P::Target>` no longer retains
838+
// any access to the `P` itself, much less the `Pin<P>`.
839+
unsafe { self.get_unchecked_mut() }.as_mut()
840+
}
841+
}
842+
805843
impl<T: ?Sized> Pin<&'static mut T> {
806844
/// Get a pinned mutable reference from a static mutable reference.
807845
///

library/core/src/task/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ mod wake;
1111
pub use self::wake::{Context, RawWaker, RawWakerVTable, Waker};
1212

1313
mod ready;
14-
#[unstable(feature = "ready_macro", issue = "70922")]
14+
#[stable(feature = "ready_macro", since = "1.56.0")]
1515
pub use ready::ready;

library/core/src/task/ready.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
/// # Examples
99
///
1010
/// ```
11-
/// #![feature(ready_macro)]
12-
///
1311
/// use std::task::{ready, Context, Poll};
1412
/// use std::future::{self, Future};
1513
/// use std::pin::Pin;
@@ -29,8 +27,6 @@
2927
/// The `ready!` call expands to:
3028
///
3129
/// ```
32-
/// # #![feature(ready_macro)]
33-
/// #
3430
/// # use std::task::{Context, Poll};
3531
/// # use std::future::{self, Future};
3632
/// # use std::pin::Pin;
@@ -49,7 +45,7 @@
4945
/// # Poll::Ready(())
5046
/// # }
5147
/// ```
52-
#[unstable(feature = "ready_macro", issue = "70922")]
48+
#[stable(feature = "ready_macro", since = "1.56.0")]
5349
#[rustc_macro_transparency = "semitransparent"]
5450
pub macro ready($e:expr) {
5551
match $e {

library/std/src/fs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
19121912
/// Ok(())
19131913
/// }
19141914
/// ```
1915+
#[doc(alias = "mkdir")]
19151916
#[stable(feature = "rust1", since = "1.0.0")]
19161917
pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
19171918
DirBuilder::new().create(path.as_ref())
@@ -1991,6 +1992,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
19911992
/// Ok(())
19921993
/// }
19931994
/// ```
1995+
#[doc(alias = "rmdir")]
19941996
#[stable(feature = "rust1", since = "1.0.0")]
19951997
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
19961998
fs_imp::rmdir(path.as_ref())

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@
304304
#![feature(pin_static_ref)]
305305
#![feature(prelude_import)]
306306
#![feature(ptr_internals)]
307-
#![feature(ready_macro)]
308307
#![feature(rustc_attrs)]
309308
#![feature(rustc_private)]
310309
#![feature(shrink_to)]

src/ci/github-actions/ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ jobs:
416416
env:
417417
IMAGE: x86_64-gnu
418418
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
419+
# Only run this job on the nightly channel. Running this on beta
420+
# could cause failures when `dev: 1` in `stage0.txt`, and running
421+
# this on stable is useless.
422+
CI_ONLY_WHEN_CHANNEL: nightly
419423
<<: *job-linux-xl
420424

421425
- name: x86_64-gnu-aux

src/ci/scripts/should-skip-this.sh

+37-25
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,43 @@ IFS=$'\n\t'
88

99
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
1010

11-
if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
12-
echo "Executing the job since there is no skip rule in effect"
13-
exit 0
11+
if [[ -n "${CI_ONLY_WHEN_SUBMODULES_CHANGED-}" ]]; then
12+
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
13+
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
14+
15+
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
16+
17+
if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
18+
# Submodules pseudo-files inside git have the 160000 permissions, so when
19+
# those files are present in the diff a submodule was updated.
20+
echo "Submodules were updated"
21+
elif ! git diff --quiet "$BASE_COMMIT" -- src/tools/clippy src/tools/rustfmt; then
22+
# There is not an easy blanket search for subtrees. For now, manually list
23+
# the subtrees.
24+
echo "Clippy or rustfmt subtrees were updated"
25+
elif ! (git diff --quiet "$BASE_COMMIT" -- \
26+
src/test/rustdoc-gui \
27+
src/librustdoc \
28+
src/tools/rustdoc-gui); then
29+
# There was a change in either rustdoc or in its GUI tests.
30+
echo "Rustdoc was updated"
31+
else
32+
echo "Not executing this job since no submodules nor subtrees were updated"
33+
ciCommandSetEnv SKIP_JOB 1
34+
exit 0
35+
fi
1436
fi
1537

16-
git fetch "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_BASE_REF"
17-
BASE_COMMIT="$(git merge-base FETCH_HEAD HEAD)"
18-
19-
echo "Searching for toolstate changes between $BASE_COMMIT and $(git rev-parse HEAD)"
20-
21-
if git diff "$BASE_COMMIT" | grep --quiet "^index .* 160000"; then
22-
# Submodules pseudo-files inside git have the 160000 permissions, so when
23-
# those files are present in the diff a submodule was updated.
24-
echo "Executing the job since submodules are updated"
25-
elif ! git diff --quiet "$BASE_COMMIT" -- src/tools/clippy src/tools/rustfmt; then
26-
# There is not an easy blanket search for subtrees. For now, manually list
27-
# the subtrees.
28-
echo "Executing the job since clippy or rustfmt subtree was updated"
29-
elif ! (git diff --quiet "$BASE_COMMIT" -- \
30-
src/test/rustdoc-gui \
31-
src/librustdoc \
32-
src/tools/rustdoc-gui); then
33-
# There was a change in either rustdoc or in its GUI tests.
34-
echo "Executing the job since rustdoc was updated"
35-
else
36-
echo "Not executing this job since no submodules nor subtrees were updated"
37-
ciCommandSetEnv SKIP_JOB 1
38+
if [[ -n "${CI_ONLY_WHEN_CHANNEL-}" ]]; then
39+
if [[ "${CI_ONLY_WHEN_CHANNEL}" = "$(cat src/ci/channel)" ]]; then
40+
echo "The channel is the expected one"
41+
else
42+
echo "Not executing this job as the channel is not the expected one"
43+
ciCommandSetEnv SKIP_JOB 1
44+
exit 0
45+
fi
3846
fi
47+
48+
49+
echo "Executing the job since there is no skip rule preventing the execution"
50+
exit 0

src/librustdoc/clean/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1730,9 +1730,13 @@ impl Clean<Variant> for hir::VariantData<'_> {
17301730
fn clean(&self, cx: &mut DocContext<'_>) -> Variant {
17311731
match self {
17321732
hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)),
1733-
hir::VariantData::Tuple(..) => {
1734-
Variant::Tuple(self.fields().iter().map(|x| x.ty.clean(cx)).collect())
1735-
}
1733+
// Important note here: `Variant::Tuple` is used on tuple structs which are not in an
1734+
// enum (so where converting from `ty::VariantDef`). In case we are in an enum, the kind
1735+
// is provided by the `Variant` wrapper directly, and since we need the fields' name
1736+
// (even for a tuple struct variant!), it's simpler to just store it as a
1737+
// `Variant::Struct` instead of a `Variant::Tuple` (otherwise it would force us to make
1738+
// a lot of changes when rendering them to generate the name as well).
1739+
hir::VariantData::Tuple(..) => Variant::Struct(self.clean(cx)),
17361740
hir::VariantData::Unit(..) => Variant::CLike,
17371741
}
17381742
}

src/librustdoc/html/render/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,9 @@ fn sidebar_struct(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, s: &clea
20072007
}
20082008

20092009
sidebar.push_str("</div>");
2010+
} else if let CtorKind::Fn = s.struct_type {
2011+
sidebar
2012+
.push_str("<h3 class=\"sidebar-title\"><a href=\"#fields\">Tuple Fields</a></h3>");
20102013
}
20112014
}
20122015

src/librustdoc/html/render/print_item.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10371037
write!(w, "<div class=\"sub-variant\" id=\"{id}\">", id = variant_id);
10381038
write!(
10391039
w,
1040-
"<h3>Fields of <b>{name}</b></h3><div>",
1041-
name = variant.name.as_ref().unwrap()
1040+
"<h3>{extra}Fields of <b>{name}</b></h3><div>",
1041+
extra = if s.struct_type == CtorKind::Fn { "Tuple " } else { "" },
1042+
name = variant.name.as_ref().unwrap(),
10421043
);
10431044
for field in &s.fields {
10441045
use crate::clean::StructFieldItem;
@@ -1176,21 +1177,21 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
11761177
_ => None,
11771178
})
11781179
.peekable();
1179-
if let CtorKind::Fictive = s.struct_type {
1180+
if let CtorKind::Fictive | CtorKind::Fn = s.struct_type {
11801181
if fields.peek().is_some() {
11811182
write!(
11821183
w,
11831184
"<h2 id=\"fields\" class=\"fields small-section-header\">\
1184-
Fields{}<a href=\"#fields\" class=\"anchor\"></a></h2>",
1185+
{}{}<a href=\"#fields\" class=\"anchor\"></a>\
1186+
</h2>",
1187+
if let CtorKind::Fictive = s.struct_type { "Fields" } else { "Tuple Fields" },
11851188
document_non_exhaustive_header(it)
11861189
);
11871190
document_non_exhaustive(w, it);
1188-
for (field, ty) in fields {
1189-
let id = cx.derive_id(format!(
1190-
"{}.{}",
1191-
ItemType::StructField,
1192-
field.name.as_ref().unwrap()
1193-
));
1191+
for (index, (field, ty)) in fields.enumerate() {
1192+
let field_name =
1193+
field.name.map_or_else(|| index.to_string(), |sym| (*sym.as_str()).to_string());
1194+
let id = cx.derive_id(format!("{}.{}", ItemType::StructField, field_name));
11941195
write!(
11951196
w,
11961197
"<span id=\"{id}\" class=\"{item_type} small-section-header\">\
@@ -1199,7 +1200,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
11991200
</span>",
12001201
item_type = ItemType::StructField,
12011202
id = id,
1202-
name = field.name.as_ref().unwrap(),
1203+
name = field_name,
12031204
ty = ty.print(cx)
12041205
);
12051206
document(w, cx, field, Some(it));
@@ -1507,7 +1508,10 @@ fn render_struct(
15071508
if let Some(g) = g {
15081509
write!(w, "{}", print_where_clause(g, cx, 0, false),)
15091510
}
1510-
w.write_str(";");
1511+
// We only want a ";" when we are displaying a tuple struct, not a variant tuple struct.
1512+
if structhead {
1513+
w.write_str(";");
1514+
}
15111515
}
15121516
CtorKind::Const => {
15131517
// Needed for PhantomData.

0 commit comments

Comments
 (0)