Skip to content

Commit 52b2286

Browse files
committed
Auto merge of #86348 - JohnTitor:rollup-o6a6k67, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #85283 (Avoid possible filename collision in coverage tests) - #86200 (Updates `Clone` docs for `Copy` comparison.) - #86209 (fix minor wording/typo issues in core::option docs) - #86242 (rustdoc- dont ICE on `ConstEvaluatable` predicates) - #86280 (Add a regression test for issue-76510) - #86293 (Allow to run only a few GUI tests) - #86327 (Don't mark "safe" intrinsics as unsafe) - #86345 (Remove some duplicate `char` assoc items on RELEASES.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d192c80 + 59ffa34 commit 52b2286

File tree

12 files changed

+160
-30
lines changed

12 files changed

+160
-30
lines changed

RELEASES.md

-14
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ Stabilised APIs
8181
- [`Vec::extend_from_within`]
8282
- [`array::from_mut`]
8383
- [`array::from_ref`]
84-
- [`char::MAX`]
85-
- [`char::REPLACEMENT_CHARACTER`]
86-
- [`char::UNICODE_VERSION`]
87-
- [`char::decode_utf16`]
88-
- [`char::from_digit`]
89-
- [`char::from_u32_unchecked`]
90-
- [`char::from_u32`]
9184
- [`cmp::max_by_key`]
9285
- [`cmp::max_by`]
9386
- [`cmp::min_by_key`]
@@ -152,13 +145,6 @@ related tools.
152145
[cargo/9298]: https://github.com/rust-lang/cargo/pull/9298
153146
[cargo/9282]: https://github.com/rust-lang/cargo/pull/9282
154147
[cargo/9392]: https://github.com/rust-lang/cargo/pull/9392
155-
[`char::MAX`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.MAX
156-
[`char::REPLACEMENT_CHARACTER`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.REPLACEMENT_CHARACTER
157-
[`char::UNICODE_VERSION`]: https://doc.rust-lang.org/std/primitive.char.html#associatedconstant.UNICODE_VERSION
158-
[`char::decode_utf16`]: https://doc.rust-lang.org/std/primitive.char.html#method.decode_utf16
159-
[`char::from_u32`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32
160-
[`char::from_u32_unchecked`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_u32_unchecked
161-
[`char::from_digit`]: https://doc.rust-lang.org/std/primitive.char.html#method.from_digit
162148
[`AtomicBool::fetch_update`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.fetch_update
163149
[`AtomicPtr::fetch_update`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicPtr.html#method.fetch_update
164150
[`BTreeMap::retain`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.retain

library/core/src/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/// A common trait for the ability to explicitly duplicate an object.
4040
///
41-
/// Differs from [`Copy`] in that [`Copy`] is implicit and extremely inexpensive, while
41+
/// Differs from [`Copy`] in that [`Copy`] is implicit and an inexpensive bit-wise copy, while
4242
/// `Clone` is always explicit and may or may not be expensive. In order to enforce
4343
/// these characteristics, Rust does not allow you to reimplement [`Copy`], but you
4444
/// may reimplement `Clone` and run arbitrary code.

library/core/src/option.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
//! the optional owned box, [`Option`]`<`[`Box<T>`]`>`.
5151
//!
5252
//! The following example uses [`Option`] to create an optional box of
53-
//! [`i32`]. Notice that in order to use the inner [`i32`] value first, the
54-
//! `check_optional` function needs to use pattern matching to
53+
//! [`i32`]. Notice that in order to use the inner [`i32`] value, the
54+
//! `check_optional` function first needs to use pattern matching to
5555
//! determine whether the box has a value (i.e., it is [`Some(...)`][`Some`]) or
5656
//! not ([`None`]).
5757
//!
@@ -1350,7 +1350,7 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
13501350
///
13511351
/// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original.
13521352
/// The [`map`] method takes the `self` argument by value, consuming the original,
1353-
/// so this technique uses `as_ref` to first take an `Option` to a reference
1353+
/// so this technique uses `from` to first take an `Option` to a reference
13541354
/// to the value inside the original.
13551355
///
13561356
/// [`map`]: Option::map

src/bootstrap/test.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ impl Step for RustdocGUI {
805805

806806
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
807807
let builder = run.builder;
808-
let run = run.path("src/test/rustdoc-gui");
808+
let run = run.suite_path("src/test/rustdoc-gui");
809809
run.default_condition(
810810
builder.config.nodejs.is_some()
811811
&& builder
@@ -870,6 +870,13 @@ impl Step for RustdocGUI {
870870
.arg(out_dir)
871871
.arg("--tests-folder")
872872
.arg(builder.build.src.join("src/test/rustdoc-gui"));
873+
for path in &builder.paths {
874+
if let Some(name) = path.file_name().and_then(|f| f.to_str()) {
875+
if name.ends_with(".goml") {
876+
command.arg("--file").arg(name);
877+
}
878+
}
879+
}
873880
builder.run(&mut command);
874881
}
875882
}

src/librustdoc/clean/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn};
2626
use rustc_span::hygiene::{AstPass, MacroKind};
2727
use rustc_span::symbol::{kw, sym, Ident, Symbol};
2828
use rustc_span::{self, ExpnKind};
29+
use rustc_target::spec::abi::Abi;
30+
use rustc_typeck::check::intrinsic::intrinsic_operation_unsafety;
2931
use rustc_typeck::hir_ty_to_ty;
3032

3133
use std::collections::hash_map::Entry;
@@ -350,12 +352,12 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
350352
ty::PredicateKind::RegionOutlives(pred) => pred.clean(cx),
351353
ty::PredicateKind::TypeOutlives(pred) => pred.clean(cx),
352354
ty::PredicateKind::Projection(pred) => Some(pred.clean(cx)),
355+
ty::PredicateKind::ConstEvaluatable(..) => None,
353356

354357
ty::PredicateKind::Subtype(..)
355358
| ty::PredicateKind::WellFormed(..)
356359
| ty::PredicateKind::ObjectSafe(..)
357360
| ty::PredicateKind::ClosureKind(..)
358-
| ty::PredicateKind::ConstEvaluatable(..)
359361
| ty::PredicateKind::ConstEquate(..)
360362
| ty::PredicateKind::TypeWellFormedFromEnv(..) => panic!("not user writable"),
361363
}
@@ -2132,7 +2134,11 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
21322134
decl,
21332135
generics,
21342136
header: hir::FnHeader {
2135-
unsafety: hir::Unsafety::Unsafe,
2137+
unsafety: if abi == Abi::RustIntrinsic {
2138+
intrinsic_operation_unsafety(item.ident.name)
2139+
} else {
2140+
hir::Unsafety::Unsafe
2141+
},
21362142
abi,
21372143
constness: hir::Constness::NotConst,
21382144
asyncness: hir::IsAsync::NotAsync,

src/test/run-make-fulldeps/coverage-reports/Makefile

+8-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ endif
8787
# Run it in order to generate some profiling data,
8888
# with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to
8989
# output the coverage stats for this run.
90-
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \
90+
LLVM_PROFILE_FILE="$(TMPDIR)"/[email protected] \
9191
$(call RUN,$@) || \
9292
( \
9393
status=$$?; \
@@ -97,16 +97,19 @@ endif
9797
) \
9898
)
9999

100-
# Run it through rustdoc as well to cover doctests
101-
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p.profraw \
100+
# Run it through rustdoc as well to cover doctests.
101+
# `%p` is the pid, and `%m` the binary signature. We suspect that the pid alone
102+
# might result in overwritten files and failed tests, as rustdoc spawns each
103+
# doctest as its own process, so make sure the filename is as unique as possible.
104+
LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p-%m.profraw \
102105
$(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/[email protected] \
103106
$$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/[email protected] ) \
104107
-L "$(TMPDIR)" -Zinstrument-coverage \
105108
-Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@
106109

107110
# Postprocess the profiling data so it can be used by the llvm-cov tool
108111
"$(LLVM_BIN_DIR)"/llvm-profdata merge --sparse \
109-
"$(TMPDIR)"/$@-*.profraw \
112+
"$(TMPDIR)"/$@*.profraw \
110113
-o "$(TMPDIR)"/[email protected]
111114

112115
# Generate a coverage report using `llvm-cov show`.
@@ -118,8 +121,7 @@ endif
118121
--instr-profile="$(TMPDIR)"/[email protected] \
119122
$(call BIN,"$(TMPDIR)"/$@) \
120123
$$( \
121-
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; \
122-
do \
124+
for file in $(TMPDIR)/rustdoc-$@/*/rust_out; do \
123125
[ -x "$$file" ] && printf "%s %s " -object $$file; \
124126
done \
125127
) \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![crate_name = "foo"]
2+
#![feature(const_evaluatable_checked, const_generics)]
3+
#![allow(incomplete_features)]
4+
// make sure that `ConstEvaluatable` predicates dont cause rustdoc to ICE #77647
5+
// @has foo/struct.Ice.html '//pre[@class="rust struct"]' \
6+
// 'pub struct Ice<const N: usize> where [(); N + 1]: ;'
7+
pub struct Ice<const N: usize> where [(); N + 1]:;

src/test/rustdoc/safe-intrinsic.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![feature(intrinsics)]
2+
#![feature(no_core)]
3+
4+
#![no_core]
5+
#![crate_name = "foo"]
6+
7+
extern "rust-intrinsic" {
8+
// @has 'foo/fn.abort.html'
9+
// @has - '//pre[@class="rust fn"]' 'pub extern "rust-intrinsic" fn abort() -> !'
10+
pub fn abort() -> !;
11+
// @has 'foo/fn.unreachable.html'
12+
// @has - '//pre[@class="rust fn"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !'
13+
pub fn unreachable() -> !;
14+
}
15+
16+
extern "C" {
17+
// @has 'foo/fn.needs_drop.html'
18+
// @has - '//pre[@class="rust fn"]' 'pub unsafe extern "C" fn needs_drop() -> !'
19+
pub fn needs_drop() -> !;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0764]: mutable references are not allowed in the final value of constants
2+
--> $DIR/issue-76510.rs:5:29
3+
|
4+
LL | const S: &'static mut str = &mut " hello ";
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0658]: mutation through a reference is not allowed in constants
8+
--> $DIR/issue-76510.rs:5:29
9+
|
10+
LL | const S: &'static mut str = &mut " hello ";
11+
| ^^^^^^^^^^^^^^
12+
|
13+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
14+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
15+
16+
error[E0596]: cannot borrow data in a `&` reference as mutable
17+
--> $DIR/issue-76510.rs:5:29
18+
|
19+
LL | const S: &'static mut str = &mut " hello ";
20+
| ^^^^^^^^^^^^^^ cannot borrow as mutable
21+
22+
error[E0080]: it is undefined behavior to use this value
23+
--> $DIR/issue-76510.rs:5:1
24+
|
25+
LL | const S: &'static mut str = &mut " hello ";
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered mutable reference in a `const`
27+
|
28+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
29+
= note: the raw bytes of the constant (size: 8, align: 4) {
30+
╾─alloc2──╼ 07 00 00 00 │ ╾──╼....
31+
}
32+
33+
error: aborting due to 4 previous errors
34+
35+
Some errors have detailed explanations: E0080, E0596, E0658, E0764.
36+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0764]: mutable references are not allowed in the final value of constants
2+
--> $DIR/issue-76510.rs:5:29
3+
|
4+
LL | const S: &'static mut str = &mut " hello ";
5+
| ^^^^^^^^^^^^^^
6+
7+
error[E0658]: mutation through a reference is not allowed in constants
8+
--> $DIR/issue-76510.rs:5:29
9+
|
10+
LL | const S: &'static mut str = &mut " hello ";
11+
| ^^^^^^^^^^^^^^
12+
|
13+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
14+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
15+
16+
error[E0596]: cannot borrow data in a `&` reference as mutable
17+
--> $DIR/issue-76510.rs:5:29
18+
|
19+
LL | const S: &'static mut str = &mut " hello ";
20+
| ^^^^^^^^^^^^^^ cannot borrow as mutable
21+
22+
error[E0080]: it is undefined behavior to use this value
23+
--> $DIR/issue-76510.rs:5:1
24+
|
25+
LL | const S: &'static mut str = &mut " hello ";
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered mutable reference in a `const`
27+
|
28+
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
29+
= note: the raw bytes of the constant (size: 16, align: 8) {
30+
╾───────alloc2────────╼ 07 00 00 00 00 00 00 00 │ ╾──────╼........
31+
}
32+
33+
error: aborting due to 4 previous errors
34+
35+
Some errors have detailed explanations: E0080, E0596, E0658, E0764.
36+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// stderr-per-bitwidth
2+
3+
use std::mem::{transmute, ManuallyDrop};
4+
5+
const S: &'static mut str = &mut " hello ";
6+
//~^ ERROR: mutable references are not allowed in the final value of constants
7+
//~| ERROR: mutation through a reference is not allowed in constants
8+
//~| ERROR: cannot borrow data in a `&` reference as mutable
9+
//~| ERROR: it is undefined behavior to use this value
10+
11+
const fn trigger() -> [(); unsafe {
12+
let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
13+
0
14+
}] {
15+
[(); 0]
16+
}
17+
18+
fn main() {}

src/tools/rustdoc-gui/tester.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {Options, runTest} = require('browser-ui-test');
1010
function showHelp() {
1111
console.log("rustdoc-js options:");
1212
console.log(" --doc-folder [PATH] : location of the generated doc folder");
13+
console.log(" --file [PATH] : file to run (can be repeated)");
1314
console.log(" --help : show this message then quit");
1415
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
1516
}
@@ -18,6 +19,7 @@ function parseOptions(args) {
1819
var opts = {
1920
"doc_folder": "",
2021
"tests_folder": "",
22+
"files": [],
2123
};
2224
var correspondances = {
2325
"--doc-folder": "doc_folder",
@@ -26,13 +28,18 @@ function parseOptions(args) {
2628

2729
for (var i = 0; i < args.length; ++i) {
2830
if (args[i] === "--doc-folder"
29-
|| args[i] === "--tests-folder") {
31+
|| args[i] === "--tests-folder"
32+
|| args[i] === "--file") {
3033
i += 1;
3134
if (i >= args.length) {
3235
console.log("Missing argument after `" + args[i - 1] + "` option.");
3336
return null;
3437
}
35-
opts[correspondances[args[i - 1]]] = args[i];
38+
if (args[i - 1] !== "--file") {
39+
opts[correspondances[args[i - 1]]] = args[i];
40+
} else {
41+
opts["files"].push(args[i]);
42+
}
3643
} else if (args[i] === "--help") {
3744
showHelp();
3845
process.exit(0);
@@ -78,7 +85,12 @@ async function main(argv) {
7885
}
7986

8087
let failed = false;
81-
let files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml");
88+
let files;
89+
if (opts["files"].length === 0) {
90+
files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml");
91+
} else {
92+
files = opts["files"].filter(file => path.extname(file) == ".goml");
93+
}
8294

8395
files.sort();
8496
for (var i = 0; i < files.length; ++i) {

0 commit comments

Comments
 (0)