Auto merge of #146285 - matthiaskrgr:rollup-oaokoo3, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#146200 (Simplify rustdoc-gui tester by calling directly browser-ui-test)
 - rust-lang/rust#146236 (gpu offload: change suspicious map into filter)
 - rust-lang/rust#146240 (DynamicConfig: use canonical clone impl)
 - rust-lang/rust#146251 (rustc_middle: clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-09-07 01:04:57 +00:00
commit f4b2f68e04
12 changed files with 55 additions and 890 deletions

View file

@ -193,7 +193,7 @@ fn gen_define_handling<'ll>(
// reference) types.
let num_ptr_types = types
.iter()
.map(|&x| matches!(cx.type_kind(x), rustc_codegen_ssa::common::TypeKind::Pointer))
.filter(|&x| matches!(cx.type_kind(x), rustc_codegen_ssa::common::TypeKind::Pointer))
.count();
// We do not know their size anymore at this level, so hardcode a placeholder.

View file

@ -579,7 +579,7 @@ impl<'tcx> Display for Const<'tcx> {
}
///////////////////////////////////////////////////////////////////////////
/// Const-related utilities
// Const-related utilities
impl<'tcx> TyCtxt<'tcx> {
pub fn span_as_caller_location(self, span: Span) -> ConstValue {

View file

@ -408,14 +408,14 @@ impl<'tcx> Place<'tcx> {
self.as_ref().project_deeper(more_projections, tcx)
}
pub fn ty_from<D: ?Sized>(
pub fn ty_from<D>(
local: Local,
projection: &[PlaceElem<'tcx>],
local_decls: &D,
tcx: TyCtxt<'tcx>,
) -> PlaceTy<'tcx>
where
D: HasLocalDecls<'tcx>,
D: ?Sized + HasLocalDecls<'tcx>,
{
PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
}
@ -529,9 +529,9 @@ impl<'tcx> PlaceRef<'tcx> {
Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
}
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
where
D: HasLocalDecls<'tcx>,
D: ?Sized + HasLocalDecls<'tcx>,
{
Place::ty_from(self.local, self.projection, local_decls, tcx)
}
@ -630,9 +630,9 @@ impl<'tcx> Operand<'tcx> {
if let ty::FnDef(def_id, args) = *const_ty.kind() { Some((def_id, args)) } else { None }
}
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
where
D: HasLocalDecls<'tcx>,
D: ?Sized + HasLocalDecls<'tcx>,
{
match self {
&Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
@ -640,9 +640,9 @@ impl<'tcx> Operand<'tcx> {
}
}
pub fn span<D: ?Sized>(&self, local_decls: &D) -> Span
pub fn span<D>(&self, local_decls: &D) -> Span
where
D: HasLocalDecls<'tcx>,
D: ?Sized + HasLocalDecls<'tcx>,
{
match self {
&Operand::Copy(ref l) | &Operand::Move(ref l) => {
@ -674,7 +674,7 @@ impl<'tcx> ConstOperand<'tcx> {
}
///////////////////////////////////////////////////////////////////////////
/// Rvalues
// Rvalues
pub enum RvalueInitializationState {
Shallow,
@ -721,9 +721,9 @@ impl<'tcx> Rvalue<'tcx> {
}
}
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
where
D: HasLocalDecls<'tcx>,
D: ?Sized + HasLocalDecls<'tcx>,
{
match *self {
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),

View file

@ -216,10 +216,7 @@ impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::ParamEnv<'tcx> {
#[inline]
fn decode_arena_allocable<'tcx, D: TyDecoder<'tcx>, T: ArenaAllocatable<'tcx> + Decodable<D>>(
decoder: &mut D,
) -> &'tcx T
where
D: TyDecoder<'tcx>,
{
) -> &'tcx T {
decoder.interner().arena.alloc(Decodable::decode(decoder))
}
@ -230,10 +227,7 @@ fn decode_arena_allocable_slice<
T: ArenaAllocatable<'tcx> + Decodable<D>,
>(
decoder: &mut D,
) -> &'tcx [T]
where
D: TyDecoder<'tcx>,
{
) -> &'tcx [T] {
decoder.interner().arena.alloc_from_iter(<Vec<T> as Decodable<D>>::decode(decoder))
}

View file

@ -58,7 +58,7 @@ impl<'tcx, C: QueryCache, const ANON: bool, const DEPTH_LIMIT: bool, const FEEDA
for DynamicConfig<'tcx, C, ANON, DEPTH_LIMIT, FEEDABLE>
{
fn clone(&self) -> Self {
DynamicConfig { dynamic: self.dynamic }
*self
}
}

473
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"dependencies": {
"browser-ui-test": "^0.21.3",
"browser-ui-test": "^0.22.0",
"es-check": "^6.2.1",
"eslint": "^8.57.1",
"eslint-js": "github:eslint/js",

View file

@ -71,22 +71,28 @@ fn main() -> Result<(), ()> {
let mut command = Command::new(&config.nodejs);
command
.arg(config.rust_src.join("src/tools/rustdoc-gui/tester.js"))
.arg(local_node_modules.join(".bin/browser-ui-test"))
.arg("--jobs")
.arg(&config.jobs)
.arg("--doc-folder")
.arg("--variable")
.arg("DOC_PATH")
.arg(config.out_dir.join("doc"))
.arg("--tests-folder")
.arg(config.rust_src.join("tests/rustdoc-gui"));
.arg("--allow-file-access-from-files")
.arg("--display-format")
.arg("compact");
if local_node_modules.exists() {
// Link the local node_modules if exists.
// Link the local node_modules if it exists.
// This is useful when we run rustdoc-gui-test from outside of the source root.
command.env("NODE_PATH", local_node_modules);
}
for file in &config.goml_files {
command.arg("--file").arg(file);
if config.goml_files.is_empty() {
command.arg("--test-folder").arg(config.rust_src.join("tests/rustdoc-gui"));
} else {
for file in &config.goml_files {
command.arg("--test-file").arg(config.rust_src.join("tests/rustdoc-gui").join(file));
}
}
command.args(&config.test_args);

View file

@ -1,96 +0,0 @@
module.exports = {
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"rules": {
"linebreak-style": [
"error",
"unix"
],
"semi": [
"error",
"always"
],
"quotes": [
"error",
"double"
],
"linebreak-style": [
"error",
"unix"
],
"no-trailing-spaces": "error",
"no-var": ["error"],
"prefer-const": ["error"],
"prefer-arrow-callback": ["error"],
"brace-style": [
"error",
"1tbs",
{ "allowSingleLine": false }
],
"keyword-spacing": [
"error",
{ "before": true, "after": true }
],
"arrow-spacing": [
"error",
{ "before": true, "after": true }
],
"key-spacing": [
"error",
{ "beforeColon": false, "afterColon": true, "mode": "strict" }
],
"func-call-spacing": ["error", "never"],
"space-infix-ops": "error",
"space-before-function-paren": ["error", "never"],
"space-before-blocks": "error",
"comma-dangle": ["error", "always-multiline"],
"comma-style": ["error", "last"],
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
"eol-last": ["error", "always"],
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"eqeqeq": "error",
"no-const-assign": "error",
"no-debugger": "error",
"no-dupe-args": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-ex-assign": "error",
"no-fallthrough": "error",
"no-invalid-regexp": "error",
"no-import-assign": "error",
"no-self-compare": "error",
"no-template-curly-in-string": "error",
"block-scoped-var": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-confusing-arrow": "error",
"no-div-regex": "error",
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-label-var": "error",
"no-lonely-if": "error",
"no-mixed-operators": "error",
"no-multi-assign": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-sequences": "error",
"no-div-regex": "error",
}
};

View file

@ -1,309 +0,0 @@
// This package needs to be install:
//
// ```
// npm install browser-ui-test
// ```
const fs = require("fs");
const path = require("path");
const os = require("os");
const {Options, runTest} = require("browser-ui-test");
// If a test fails or errors, we will retry it two more times in case it was a flaky failure.
const NB_RETRY = 3;
function showHelp() {
console.log("rustdoc-js options:");
console.log(" --doc-folder [PATH] : location of the generated doc folder");
console.log(" --file [PATH] : file to run (can be repeated)");
console.log(" --debug : show extra information about script run");
console.log(" --show-text : render font in pages");
console.log(" --no-headless : disable headless mode");
console.log(" --help : show this message then quit");
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
console.log(" --jobs [NUMBER] : number of threads to run tests on");
console.log(" --executable-path [PATH] : path of the browser's executable to be used");
}
function isNumeric(s) {
return /^\d+$/.test(s);
}
function parseOptions(args) {
const opts = {
"doc_folder": "",
"tests_folder": "",
"files": [],
"debug": false,
"show_text": false,
"no_headless": false,
"jobs": -1,
"executable_path": null,
};
const correspondences = {
"--doc-folder": "doc_folder",
"--tests-folder": "tests_folder",
"--debug": "debug",
"--show-text": "show_text",
"--no-headless": "no_headless",
"--executable-path": "executable_path",
};
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
if (arg === "--doc-folder"
|| arg === "--tests-folder"
|| arg === "--file"
|| arg === "--jobs"
|| arg === "--executable-path") {
i += 1;
if (i >= args.length) {
console.log("Missing argument after `" + arg + "` option.");
return null;
}
const arg_value = args[i];
if (arg === "--jobs") {
if (!isNumeric(arg_value)) {
console.log(
"`--jobs` option expects a positive number, found `" + arg_value + "`");
return null;
}
opts["jobs"] = parseInt(arg_value);
} else if (arg !== "--file") {
opts[correspondences[arg]] = arg_value;
} else {
opts["files"].push(arg_value);
}
} else if (arg === "--help") {
showHelp();
process.exit(0);
} else if (correspondences[arg]) {
opts[correspondences[arg]] = true;
} else {
console.log("Unknown option `" + arg + "`.");
console.log("Use `--help` to see the list of options");
return null;
}
}
if (opts["tests_folder"].length < 1) {
console.log("Missing `--tests-folder` option.");
} else if (opts["doc_folder"].length < 1) {
console.log("Missing `--doc-folder` option.");
} else {
return opts;
}
return null;
}
/// Print single char status information without \n
function char_printer(n_tests) {
const max_per_line = 10;
let current = 0;
return {
successful: function() {
current += 1;
if (current % max_per_line === 0) {
process.stdout.write(`. (${current}/${n_tests})${os.EOL}`);
} else {
process.stdout.write(".");
}
},
erroneous: function() {
current += 1;
if (current % max_per_line === 0) {
process.stderr.write(`F (${current}/${n_tests})${os.EOL}`);
} else {
process.stderr.write("F");
}
},
finish: function() {
if (current % max_per_line === 0) {
// Don't output if we are already at a matching line end
console.log("");
} else {
const spaces = " ".repeat(max_per_line - (current % max_per_line));
process.stdout.write(`${spaces} (${current}/${n_tests})${os.EOL}${os.EOL}`);
}
},
};
}
// Sort array by .file_name property
function by_filename(a, b) {
return a.file_name - b.file_name;
}
async function runTests(opts, framework_options, files, results, status_bar, showTestFailures) {
const tests_queue = [];
for (const testPath of files) {
const callback = runTest(testPath, {"options": framework_options})
.then(out => {
const [output, nb_failures] = out;
results[nb_failures === 0 ? "successful" : "failed"].push({
file_name: testPath,
output: output,
});
if (nb_failures === 0) {
status_bar.successful();
} else if (showTestFailures) {
status_bar.erroneous();
}
})
.catch(err => {
results.errored.push({
file_name: testPath,
output: err,
});
if (showTestFailures) {
status_bar.erroneous();
}
})
.finally(() => {
// We now remove the promise from the tests_queue.
tests_queue.splice(tests_queue.indexOf(callback), 1);
});
tests_queue.push(callback);
if (opts["jobs"] > 0 && tests_queue.length >= opts["jobs"]) {
await Promise.race(tests_queue);
}
}
if (tests_queue.length > 0) {
await Promise.all(tests_queue);
}
}
function createEmptyResults() {
return {
successful: [],
failed: [],
errored: [],
};
}
async function main(argv) {
const opts = parseOptions(argv.slice(2));
if (opts === null) {
process.exit(1);
}
// Print successful tests too
let debug = false;
// Run tests in sequentially
let headless = true;
const framework_options = new Options();
try {
// This is more convenient that setting fields one by one.
const args = [
"--variable", "DOC_PATH", opts["doc_folder"].split("\\").join("/"),
"--allow-file-access-from-files",
];
if (opts["debug"]) {
debug = true;
args.push("--debug");
}
if (opts["show_text"]) {
args.push("--show-text");
}
if (opts["no_headless"]) {
args.push("--no-headless");
headless = false;
}
if (opts["executable_path"] !== null) {
args.push("--executable-path");
args.push(opts["executable_path"]);
}
framework_options.parseArguments(args);
} catch (error) {
console.error(`invalid argument: ${error}`);
process.exit(1);
}
let files;
if (opts["files"].length === 0) {
files = fs.readdirSync(opts["tests_folder"]);
} else {
files = opts["files"];
}
files = files.filter(file => path.extname(file) === ".goml");
if (files.length === 0) {
console.error("rustdoc-gui: No test selected");
process.exit(2);
}
files.forEach((file_name, index) => {
files[index] = path.join(opts["tests_folder"], file_name);
});
files.sort();
if (!headless) {
opts["jobs"] = 1;
console.log("`--no-headless` option is active, disabling concurrency for running tests.");
}
if (opts["jobs"] < 1) {
const len = files.length;
console.log(
`Running ${len} rustdoc-gui (UNBOUNDED concurrency; use "-j#" for a limit) ...`,
);
process.setMaxListeners(files.length + 1);
} else if (headless) {
console.log(`Running ${files.length} rustdoc-gui (${opts["jobs"]} concurrently) ...`);
process.setMaxListeners(opts["jobs"] + 1);
} else {
console.log(`Running ${files.length} rustdoc-gui ...`);
}
const originalFilesLen = files.length;
const results = createEmptyResults();
const status_bar = char_printer(files.length);
let new_results;
for (let it = 0; it < NB_RETRY && files.length > 0; ++it) {
new_results = createEmptyResults();
await runTests(opts, framework_options, files, new_results, status_bar, it + 1 >= NB_RETRY);
Array.prototype.push.apply(results.successful, new_results.successful);
// We generate the new list of files with the previously failing tests.
files = Array.prototype.concat(new_results.failed, new_results.errored).map(
f => f["file_name"]);
if (files.length > originalFilesLen / 2) {
// If we have too many failing tests, it's very likely not flaky failures anymore so
// no need to retry.
break;
}
}
status_bar.finish();
Array.prototype.push.apply(results.failed, new_results.failed);
Array.prototype.push.apply(results.errored, new_results.errored);
if (debug) {
results.successful.sort(by_filename);
results.successful.forEach(r => {
console.log(r.output);
});
}
if (results.failed.length > 0) {
console.log("");
results.failed.sort(by_filename);
results.failed.forEach(r => {
console.log(r.file_name, r.output);
});
}
if (results.errored.length > 0) {
console.log(os.EOL);
// print run errors on the bottom so developers see them better
results.errored.sort(by_filename);
results.errored.forEach(r => {
console.error(r.file_name, r.output);
});
}
if (results.failed.length > 0 || results.errored.length > 0) {
process.exit(1);
}
process.exit(0);
}
main(process.argv);

View file

@ -79,12 +79,6 @@ pub(super) fn lint(
tools_path.join("rustdoc-js"),
bless,
)?;
run_eslint(
outdir,
&[tools_path.join("rustdoc-gui/tester.js")],
tools_path.join("rustdoc-gui"),
bless,
)?;
Ok(())
}

View file

@ -235,7 +235,6 @@ trigger_files = [
"src/etc/htmldocck.py",
"src/tools/jsondocck",
"src/tools/jsondoclint",
"src/tools/rustdoc-gui",
"src/tools/rustdoc-js",
"src/tools/rustdoc-themes",