about summary refs log tree commit diff
path: root/src/tools
AgeCommit message (Collapse)AuthorLines
2023-04-21Bless miri.Camille GILLOT-11/+20
2023-04-21Auto merge of #109002 - michaelvanstraten:master, r=petrochenkovbors-1/+5
Added byte position range for `proc_macro::Span` Currently, the [`Debug`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#impl-Debug-for-Span) implementation for [`proc_macro::Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) calls the debug function implemented in the trait implementation of `server::Span` for the type `Rustc` in the `rustc-expand` crate. The current implementation, of the referenced function, looks something like this: ```rust fn debug(&mut self, span: Self::Span) -> String { if self.ecx.ecfg.span_debug { format!("{:?}", span) } else { format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0) } } ``` It returns the byte position of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#) as an interpolated string. Because this is currently the only way to get a spans position in the file, I might lead someone, who is interested in this information, to parsing this interpolated string back into a range of bytes, which I think is a very non-rusty way. The proposed `position()`, method implemented in this PR, gives the ability to directly get this info. It returns a [`std::ops::Range`](https://doc.rust-lang.org/std/ops/struct.Range.html#) wrapping the lowest and highest byte of the [`Span`](https://doc.rust-lang.org/beta/proc_macro/struct.Span.html#). I put it behind the `proc_macro_span` feature flag because many of the other functions that have a similar footprint also are annotated with it, I don't actually know if this is right. It would be great if somebody could take a look at this, thank you very much in advanced.
2023-04-21Auto merge of #96840 - cjgillot:query-feed, r=oli-obkbors-10/+4
Allow to feed a value in another query's cache and remove `WithOptConstParam` I used it to remove `WithOptConstParam` queries, as an example. The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`. There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle. The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`. When replayed, we may the following cases: - `typeck` is green, in that case `type_of` is green too, and all is right; - `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash; - `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`. As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly. There is an open question about loading from the on-disk cache. If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour. I specifically allowed to feed the value to `type_of` from inside a call to `type_of`. In that case, the dep-graph will check that the fingerprints of both values match. This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`. The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`. The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-21Auto merge of #110370 - c410-f3r:dqewdas, r=petrochenkovbors-1/+1
Move test files r? `@petrochenkov`
2023-04-20Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obkbors-0/+3
Enable flatten-format-args by default. Part of https://github.com/rust-lang/rust/issues/99012. This enables the `flatten-format-args` feature that was added by https://github.com/rust-lang/rust/pull/106824: > This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir: > > ```rust > println!("Hello, {}!", "World"); > println!("Hello, World!"); > ``` > > ```rust > println!("[info] {}", format_args!("error")); > println!("[info] error"); > ``` > > ```rust > println!("[{}] {}", status, format_args!("error: {}", msg)); > println!("[{}] error: {}", status, msg); > ``` > > ```rust > println!("{} + {} = {}", 1, 2, 1 + 2); > println!("1 + 2 = {}", 1 + 2); > ``` > > And so on. > > This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`. > > It also means that `dbg!(x)` will have its file, line, and expression name inlined: > > ```rust > eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before > eprintln!("[example.rs:1] x = {:#?}", x); // after > ``` > > Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot. This is mostly an optimization, except that it will be visible through [`fmt::Arguments::as_str()`](https://doc.rust-lang.org/nightly/std/fmt/struct.Arguments.html#method.as_str). In https://github.com/rust-lang/rust/pull/106823, there was already a libs-api FCP about the documentation of `fmt::Arguments::as_str()` to allow it to give `Some` rather than `None` depending on optimizations like this. That was just a documentation update though. This PR is the one that actually makes the user visible change: ```rust assert_eq!(format_args!("abc").as_str(), Some("abc")); // Unchanged. assert_eq!(format_args!("ab{}", "c").as_str(), Some("abc")); // Was `None` before! ```
2023-04-20Move test filesCaio-1/+1
2023-04-20Remove WithOptconstParam.Camille GILLOT-10/+4
2023-04-20Auto merge of #110612 - matthiaskrgr:rollup-y2hbjws, r=matthiaskrgrbors-8/+18
Rollup of 4 pull requests Successful merges: - #108795 (Add support for the x86_64h-apple-darwin target) - #110558 (Add Call terminator to SMIR) - #110565 (linkchecker: running from a directory separate from the book) - #110599 (Remove an unused `&[Ty]` <-> `&[GenericArg]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-20Rollup merge of #110565 - weihanglo:linkchecker, r=ehussMatthias Krüger-8/+18
linkchecker: running from a directory separate from the book Since rust-lang/cargo#11851, Cargo became a Cargo workspace of itself. However, since `src/tools/linkchecker` cannot run inside a workspace, Cargo needs a workaround that excludes `src/doc` from workspace member probing. To remove this hack, this PR adds a new optional argument `--path` for `linkchecker.sh`. With this new argument, `linkchecker.sh` can be run from a directory separate from the book. This also benefits other projects using linkchecker, as they can run it under target directory or any other directory, reducing leftover.
2023-04-20Auto merge of #110444 - ferrocene:comptest-lines, r=Mark-Simulacrumbors-8/+68
Add compare-output-lines-by-subset flag to compiletest For [ferrocene](github.com/ferrocene/) we have some compiletests that check the output of the cli arguments to the compiler, including printing things like the target list (`--print target-list`). Unfortunately those tend to change quite often so when we sync we end up with some outputs we have to re-bless constantly, even though the exact output doesn't really matter. We added a new compiletest flag to aid writing these kinds of tests: `compare-output-lines-by-subset`. It checks whether the lines of the expected output are a subset (or equal) to the lines of the actual output. If the expected output is empty it will fail unless the actual output is also empty. We opened this PR hoping the flag might be helpful for other tests in the future (especially if CLI-related tests are added in the future in the rust-lang/rust repo itself).
2023-04-20Add compare-output-lines-by-subset flag to compiletestLukas Wirth-8/+68
2023-04-20linkchecker: running from a directory separate from the bookWeihang Lo-8/+18
Since rust-lang/cargo#11851, Cargo became a Cargo workspace of itself. However, since `src/tools/linkchecker` cannot run inside a workspace, Cargo needs a workaround that excludes `src/doc` from workspace member probing. To remove this hack, this PR adds a new optional argument `--path` for `linkchecker.sh`. With this new argument, `linkchecker.sh` can be run from a directory separate from the book. This also benefits other projects using linkchecker, as they can run it under target directory or any other directory, reducing leftover.
2023-04-20Allow overwriting the sysroot compile flag in compile testsLukas Wirth-2/+5
2023-04-19Auto merge of #110546 - matthiaskrgr:rollup-346kik6, r=matthiaskrgrbors-1/+11
Rollup of 10 pull requests Successful merges: - #110123 ('./configure' now checks if 'config.toml' exists before writing to that destination) - #110429 (Spelling src bootstrap) - #110430 (Spelling src ci) - #110515 (Don't special-case download-rustc in `maybe_install_llvm`) - #110521 (Fix `x test lint-docs linkchecker` when download-rustc is enabled) - #110525 (Fix `tests/run-make-translation` when download-rustc is enabled) - #110531 (small type system cleanup) - #110533 (Missing blanket impl trait not public) - #110540 (Fix wrong comment in rustc_hir/src/hir.rs) - #110541 (Fix various configure bugs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-19Auto merge of #110496 - WaffleLapkin:🏳️‍⚧️sound, r=compiler-errorsbors-1/+1
Don't transmute `&List<GenericArg>` <-> `&List<Ty>` In #93505 we allowed safely transmuting between `&List<GenericArg<'_>>` and `&List<Ty<'_>>`. This was possible because `GenericArg` is a tagged pointer and the tag for types is `0b00`, such that a `GenericArg` with a type inside has the same layout as `Ty`. While this was meant as an optimization, it doesn't look like it was actually any perf or max-rss win (see https://github.com/rust-lang/rust/pull/94799#issuecomment-1064340003, https://github.com/rust-lang/rust/pull/94841, https://github.com/rust-lang/rust/pull/110496#issuecomment-1513799140). Additionally the way it was done is quite fragile — `unsafe` code was not properly documented or contained in a module, types were not marked as `repr(C)` (making the transmutes possibly unsound). All of this makes the code maintenance harder and blocks other possible optimizations (as an example I've found out about these `transmutes` when my change caused them to sigsegv compiler). Thus, I think we can safely (pun intended) remove those transmutes, making maintenance easier, optimizations possible, code less cursed, etc. r? `@compiler-errors`
2023-04-19Rollup merge of #110521 - jyn514:test-lint-docs, r=albertlarsan68Matthias Krüger-1/+11
Fix `x test lint-docs linkchecker` when download-rustc is enabled Bootstrap was setting LD_LIBRARY_PATH for bootstrap tools in `tool_cmd`, and rustc inherited that environment. That broke when download-rustc was enabled; see the new comment for details. Fixes https://github.com/rust-lang/rust/issues/110354
2023-04-19Rollup merge of #110476 - compiler-errors:ty-err-ctxt-good-path, r=lcnrMatthias Krüger-1/+20
Delay a good path bug on drop for `TypeErrCtxt` (instead of a regular delayed bug) r? `@lcnr` Perhaps we should just delete the `Drop` impl altogether though? Fixes rust-lang/rust-clippy#10645 `@matthiaskrgr:` I don't know how to make a clippy test for this. Any idea? Clippy's UI tests run with `-D warnings` and I have no idea how to switch it off to make a test that triggers this ICE in the clippy test suite 🤣
2023-04-18Fix `x test lint-docs` when download-rustc is enabledjyn-1/+11
Bootstrap was setting LD_LIBRARY_PATH for bootstrap tools in `tool_cmd`, and rustc inherited that environment. That broke when download-rustc was enabled; see the new comment for details.
2023-04-18clippy: add test for https://github.com/rust-lang/rust-clippy/issues/10645Matthias Krüger-1/+20
2023-04-18Remove very useless `as_substs` usage from clippyMaybe Waffle-1/+1
2023-04-18Auto merge of #110478 - jyn514:stage1-fulldeps, r=albertlarsan68bors-2/+7
Support `x test --stage 1 ui-fulldeps` `@Nilstrieb` had an excellent idea the other day: the same way that rustdoc is able to load `rustc_driver` from the sysroot, ui-fulldeps tests should also be able to load it from the sysroot. That allows us to run fulldeps tests with stage1, without having to fully rebuild the compiler twice. It does unfortunately have the downside that we're building the tests with the *bootstrap* compiler, not the in-tree sources, but since most of the fulldeps tests are for the *API* of the compiler, that seems ok. I think it's possible to extend this to `run-make-fulldeps`, but I've run out of energy for tonight. - Move `plugin` tests into a subdirectory. Plugins are loaded at runtime with `dlopen` and so require the ABI of the running compile to match the ABI of the compiler linked with `rustc_driver`. As a result they can't be supported in stage 1 and have to use `// ignore-stage1`. - Remove `ignore-stage1` from most non-plugin tests - Ignore diagnostic tests in stage 1. Even though this requires a stage 2 build to load rustc_driver, it's primarily testing the error message that the *running* compiler emits when the diagnostic struct is malformed. - Pass `-Zforce-unstable-if-unmarked` in stage1, not just stage2. That allows running `hash-stable-is-unstable` in stage1, since it now suggests adding `rustc_private` to enable loading the crates. - Add libLLVM.so to the stage0 target sysroot, to allow fulldeps tests that act as custom drivers to load it at runtime. - Pass `--sysroot stage0-sysroot` in compiletest so that we use the correct version of std. - Move a few lint tests from ui-fulldeps to ui These had an `aux-build:lint-group-plugin-test.rs` that they never actually loaded with `feature(plugin)` nor tested. I removed the unused aux-build and they pass fine with stage 1. Fixes https://github.com/rust-lang/rust/issues/75905.
2023-04-18Rollup merge of #109981 - duckymirror:issue-107094, r=albertlarsan68Matthias Krüger-0/+20
Set commit information environment variables when building tools This fixes #107094. ~I'm trying to add a regression test for this issue.~ **Update**: I've added a test and a new test header `needs-git-hash` which makes sure it doesn't run when commit hashes are ignored (`bootstrap`'s `ignore-git` option).
2023-04-17Support `x test --stage 1 ui-fulldeps`jyn-2/+7
Nils had an excellent idea the other day: the same way that rustdoc is able to load `rustc_driver` from the sysroot, ui-fulldeps tests should also be able to load it from the sysroot. That allows us to run fulldeps tests with stage1, without having to fully rebuild the compiler twice. It does unfortunately have the downside that we're running the tests on the *bootstrap* compiler, not the in-tree sources, but since most of the fulldeps tests are for the *API* of the compiler, that seems ok. I think it's possible to extend this to `run-make-fulldeps`, but I've run out of energy for tonight. - Move `plugin` tests into a subdirectory. Plugins are loaded at runtime with `dlopen` and so require the ABI of the running compile to match the ABI of the compiler linked with `rustc_driver`. As a result they can't be supported in stage 1 and have to use `// ignore-stage1`. - Remove `ignore-stage1` from most non-plugin tests - Ignore diagnostic tests in stage 1. Even though this requires a stage 2 build to load rustc_driver, it's primarily testing the error message that the *running* compiler emits when the diagnostic struct is malformed. - Pass `-Zforce-unstable-if-unmarked` in stage1, not just stage2. That allows running `hash-stable-is-unstable` in stage1, since it now suggests adding `rustc_private` to enable loading the crates. - Add libLLVM.so to the stage0 target sysroot, to allow fulldeps tests that act as custom drivers to load it at runtime. - Pass `--sysroot stage0-sysroot` in compiletest so that we use the correct version of std.
2023-04-17Force -Zflatten-format-args=no in Clippy.Mara Bos-0/+3
2023-04-17Auto merge of #110440 - matthiaskrgr:rollup-eit19vi, r=matthiaskrgrbors-5/+5
Rollup of 7 pull requests Successful merges: - #110038 (Erase regions when confirming transmutability candidate) - #110341 (rustdoc: stop passing a title to `replaceState` second argument) - #110388 (Add a message for if an overflow occurs in `core::intrinsics::is_nonoverlapping`.) - #110404 (fix clippy::toplevel_ref_arg and ::manual_map) - #110421 (Spelling librustdoc) - #110423 (Spelling srcdoc) - #110433 (Windows: map a few more error codes to ErrorKind) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-17Rollup merge of #110421 - jsoref:spelling-librustdoc, r=notriddleMatthias Krüger-5/+5
Spelling librustdoc This is split from https://github.com/rust-lang/rust/pull/110392 There's one change to src/tools/rustdoc-gui/tester.js which feels like a reasonable thing to piggy-back here.
2023-04-17Auto merge of #109588 - Nilstrieb:dropless-expr, r=compiler-errorsbors-5/+5
Alloc `hir::Lit` in an arena to remove the destructor from `Expr` This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena.
2023-04-16Spelling librustdocJosh Soref-5/+5
* associated * collected * correspondence * inlining * into * javascript * multiline * variadic Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Auto merge of #109061 - saethlin:leak-backtraces, r=oli-obkbors-44/+173
Add a backtrace to Allocation, display it in leak reports This addresses https://github.com/rust-lang/miri/issues/2813 Information like this from diagnostics is indispensable for diagnosing problems that are difficult to reproduce such as https://github.com/rust-lang/miri-test-libstd/actions/runs/4395316008/jobs/7697019211#step:4:770 (which has not been reproduced or diagnosed).
2023-04-16chore: remove `rustc-workspace-hack`Weihang Lo-49/+0
Co-authored-by: Scott Schafer <schaferjscott@gmail.com> Co-authored-by: Eric Huss <eric@huss.org>
2023-04-16chore: remove Cargo features in rustc-workspace-hackWeihang Lo-84/+1
2023-04-16tidy: `check_crate_duplicate` is no longer usefulWeihang Lo-47/+8
After cargo becomes a workspace, no one uses `check_crate_duplicate` to check if cargo is a dependency anymore.
2023-04-16chore: allow `cargo` to have its own workspaceWeihang Lo-28/+40
This also * bumps cargo to the latest in rust-lang/cargo. * adds 0BSD to allowed list of licenses Co-authored-by: Scott Schafer <schaferjscott@gmail.com> Co-authored-by: Eric Huss <eric@huss.org>
2023-04-16Alloc `hir::Lit` in an arena to remove the destructor from `Expr`Nilstrieb-5/+5
This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on.
2023-04-16Improve doc comment of AllocExtra's backtraceBen Kimock-1/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-04-16Add a flag to disable leak backtracesBen Kimock-9/+52
2023-04-16Report a backtrace for memory leaks under MiriBen Kimock-42/+127
2023-04-16Add needs-git-hash header to compiletestErik Hofmayer-0/+20
This header can be used for tests which check the output of `--version --verbose` commands.
2023-04-15Auto merge of #110319 - ferrocene:pa-more-ignore-reasons, r=ehussbors-187/+458
[compiletest] Add more test ignore reasons, `needs-` validation, and improved error messages This PR makes more improvements to the way compiletest ignoring headers are handled, following up on #108905: * Human-readable ignore reasons have been added for the remaining ignore causes (`needs-*` directives, `*llvm*` directives, and debugger version directives). All ignored tests should now have a human-readable reason. * The code handling `needs-*` directives has been refactored, and now invalid `needs-*` directive emit errors like `ignore-*` and `only-*`. * All errors are now displayed at startup (with line numbers) rather than just the first error of the first file. This PR is best reviewed commit-by-commit. r? `@ehuss`
2023-04-14Auto merge of #110197 - cjgillot:codegen-discr, r=pnkfelixbors-1/+1
Do not attempt to commute comparison and cast to codegen discriminants The general algorithm to compute a discriminant is: ``` relative_tag = tag - niche_start is_niche = relative_tag <= (ule) relative_max discr = if is_niche { cast(relative_tag) + niche_variants.start() } else { untagged_variant } ``` We have an optimization branch which attempts to merge the addition and the subtraction by commuting them with the cast. We currently get this optimization wrong. This PR takes the easiest and safest way: remove the optimization, and let LLVM handle it. (Perf may not agree with that course of action :sweat_smile:) There may be a less invasive solution, but I don't have the necessary knowledge of LLVM semantics to find it. Cranelift has the same optimization, which should be handled similarly. cc `@nikic` and `@bjorn3` if you have a better solution. Fixes https://github.com/rust-lang/rust/issues/110128
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-6/+2
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-14Pacify tidy.Camille GILLOT-1/+1
2023-04-14Rollup merge of #106249 - Ezrashaw:suggest-test-tool, r=jyn514,albertlarsan68Yuki Okushi-0/+200
Create "suggested tests" tool in `rustbuild` Not the claimed person in #97339 but: I've done a very rough implementation of this feature in-tree. I'm very new to `rustc` development (outside of docs) so some help would be greatly appreciated. The UI of this new subcommand obviously will change and I need some mentoring with the `--run` flag. r? ```@jyn514```
2023-04-14mark needs-llvm-components as being handled elsewherePietro Albini-0/+5
2023-04-14use a shared headers cachePietro Albini-9/+28
2023-04-14add line numbers to error messagesPietro Albini-6/+8
2023-04-14show all invalid directives errors rather than just the first onePietro Albini-5/+36
2023-04-14refactor ignore- and only- to use decisionsPietro Albini-53/+50
2023-04-14rename rust-lldb to needs-rust-lldb for consistencyPietro Albini-9/+6
2023-04-14refactor needs, validate them, and add ignore reasonsPietro Albini-104/+250