about summary refs log tree commit diff
path: root/src/tools
AgeCommit message (Collapse)AuthorLines
2024-06-04Rollup merge of #125930 - weihanglo:opt-dist-respect-cargo-config, r=KobzolGuillaume Gomez-2/+25
feat(opt-dist): new flag `--benchmark-cargo-config` This should be the last piece toward self-contained `opt-dist` (I believe). The flag propagates cargo configs to `rustc-perf --cargo-config`, which is particularly useful when the environment is air-gapped, and you want to use the default set of training crates vendored in the rustc-src tarball. It fixes the issue described in #125465 > * The current pinned rustc-perf uses `tempfile::Tempdir` as the working directory when collecting profiles from some of these packages. This "tmp" working directory usage make it impossible for Cargo to pick up the correct vendor sources setting in `.cargo/config.toml` bundled in the rustc-src tarball. [^1] > [^1]: https://github.com/rust-lang/rustc-perf/blob/4f313add609f43e928e98132358e8426ed3969ae/collector/src/compile/benchmark/mod.rs#L164-L173 See also * <https://github.com/rust-lang/rustc-perf/pull/1913> * <https://github.com/rust-lang/rust/pull/125465> * https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/tempfile.20in.20rustc-perf.20make.20it.20hard.20to.20configure.20vendor r​? Kobzol
2024-06-04Create `run-make` `env_var` and `env_var_os` helpersGuillaume Gomez-34/+44
2024-06-04Rollup merge of #125750 - compiler-errors:expect, r=lcnr许杰友 Jieyou Xu (Joe)-8/+8
Align `Term` methods with `GenericArg` methods, add `Term::expect_*` * `Term::ty` -> `Term::as_type`. * `Term::ct` -> `Term::as_const`. * Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc. I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is. r? types
2024-06-04Auto merge of #125380 - compiler-errors:wc-obj-safety, r=oli-obkbors-34/+0
Make `WHERE_CLAUSES_OBJECT_SAFETY` a regular object safety violation #### The issue In #50781, we have known about unsound `where` clauses in function arguments: ```rust trait Impossible {} trait Foo { fn impossible(&self) where Self: Impossible; } impl Foo for &() { fn impossible(&self) where Self: Impossible, {} } // `where` clause satisfied for the object, meaning that the function now *looks* callable. impl Impossible for dyn Foo {} fn main() { let x: &dyn Foo = &&(); x.impossible(); } ``` ... which currently segfaults at runtime because we try to call a method in the vtable that doesn't exist. :( #### What did u change This PR removes the `WHERE_CLAUSES_OBJECT_SAFETY` lint and instead makes it a regular object safety violation. I choose to make this into a hard error immediately rather than a `deny` because of the time that has passed since this lint was authored, and the single (1) regression (see below). That means that it's OK to mention `where Self: Trait` where clauses in your trait, but making such a trait into a `dyn Trait` object will report an object safety violation just like `where Self: Sized`, etc. ```rust trait Impossible {} trait Foo { fn impossible(&self) where Self: Impossible; // <~ This definition is valid, just not object-safe. } impl Foo for &() { fn impossible(&self) where Self: Impossible, {} } fn main() { let x: &dyn Foo = &&(); // <~ THIS is where we emit an error. } ``` #### Regressions From a recent crater run, there's only one crate that relies on this behavior: https://github.com/rust-lang/rust/pull/124305#issuecomment-2122381740. The crate looks unmaintained and there seems to be no dependents. #### Further We may later choose to relax this (e.g. when the where clause is implied by the supertraits of the trait or something), but this is not something I propose to do in this FCP. For example, given: ``` trait Tr { fn f(&self) where Self: Blanket; } impl<T: ?Sized> Blanket for T {} ``` Proving that some placeholder `S` implements `S: Blanket` would be sufficient to prove that the same (blanket) impl applies for both `Concerete: Blanket` and `dyn Trait: Blanket`. Repeating here that I don't think we need to implement this behavior right now. ---- r? lcnr
2024-06-03Align Term methods with GenericArg methodsMichael Goulet-8/+8
2024-06-03feat(opt-dist): new flag `--benchmark-cargo-config`Weihang Lo-2/+25
The flag propagates cargo configs to `rustc-perf --cargo-config`, which is particularly useful when the environment is air-gapped, and you want to use the default set of training crates vendored in the rustc-src tarball.
2024-06-03Auto merge of #125383 - Oneirical:bundle-them-up, r=jieyouxubors-5/+2
Rewrite `emit`, `mixing-formats` and `bare-outfile` `run-make` tests in `rmake.rs` format Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-msvc
2024-06-03chore: update src/tools/rustc-perfWeihang Lo-0/+0
This is needed for fixing the missing license issue. See https://github.com/rust-lang/rust/pull/125465.
2024-06-03Make WHERE_CLAUSES_OBJECT_SAFETY a regular object safety violationMichael Goulet-34/+0
2024-06-03Opt-in diagnostics reporting to avoid doing extra work in the new solverMichael Goulet-1/+1
2024-06-03Auto merge of #125912 - nnethercote:rustfmt-tests-mir-opt, r=oli-obkbors-18/+24
rustfmt `tests/mir-opt` Continuing the work started in #125759. Details in individual commit log messages. r? `@oli-obk`
2024-06-03Reformat `mir!` macro invocations to use braces.Nicholas Nethercote-18/+24
The `mir!` macro has multiple parts: - An optional return type annotation. - A sequence of zero or more local declarations. - A mandatory starting anonymous basic block, which is brace-delimited. - A sequence of zero of more additional named basic blocks. Some `mir!` invocations use braces with a "block" style, like so: ``` mir! { let _unit: (); { let non_copy = S(42); let ptr = std::ptr::addr_of_mut!(non_copy); // Inside `callee`, the first argument and `*ptr` are basically // aliasing places! Call(_unit = callee(Move(*ptr), ptr), ReturnTo(after_call), UnwindContinue()) } after_call = { Return() } } ``` Some invocations use parens with a "block" style, like so: ``` mir!( let x: [i32; 2]; let one: i32; { x = [42, 43]; one = 1; x = [one, 2]; RET = Move(x); Return() } ) ``` And some invocations uses parens with a "tighter" style, like so: ``` mir!({ SetDiscriminant(*b, 0); Return() }) ``` This last style is generally used for cases where just the mandatory starting basic block is present. Its braces are placed next to the parens. This commit changes all `mir!` invocations to use braces with a "block" style. Why? - Consistency is good. - The contents of the invocation is a block of code, so it's odd to use parens. They are more normally used for function-like macros. - Most importantly, the next commit will enable rustfmt for `tests/mir-opt/`. rustfmt is more aggressive about formatting macros that use parens than macros that use braces. Without this commit's changes, rustfmt would break a couple of `mir!` macro invocations that use braces within `tests/mir-opt` by inserting an extraneous comma. E.g.: ``` mir!(type RET = (i32, bool);, { // extraneous comma after ';' RET.0 = 1; RET.1 = true; Return() }) ``` Switching those `mir!` invocations to use braces avoids that problem, resulting in this, which is nicer to read as well as being valid syntax: ``` mir! { type RET = (i32, bool); { RET.0 = 1; RET.1 = true; Return() } } ```
2024-06-02Remove some allowed-makefilesOneirical-5/+2
2024-06-02Rollup merge of #125896 - jieyouxu:compiletest-rmake-comment, r=compiler-errorsJubilee-5/+5
compiletest: fix outdated rmake.rs comment Noticed in https://github.com/rust-lang/rust/pull/125827#discussion_r1623420820. I fixed the PR description but forgot to update the comment.
2024-06-02Rollup merge of #125890 - Nilstrieb:gay-compiletest, r=jieyouxuJubilee-6/+34
Improve compiletest expected/not found formatting compiletest, oh compiletest, you are truly one of the tools in this repository. You're the omnipresent gatekeeper, ensuring that every new change works, doesn't break the world, and is nice. We thank you for your work, for your tests, for your test runs, for your features that help writing tests, for all the stability and and good you have caused. Without you, Rust wouldn't exist as it does, without you, nothing would work, without you, we would all go insane from having changes break and having to test them all by hand. Thank you, compiletest. but holy shit i fucking hate your stupid debug output so much i simply cannot take this anymore aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa By changing a few magic lines in this file called "runtest.rs", we can cause compiletest to emit nicer messages. This is widely regarded as a good thing. We stop wasting vertical space, allowing more errors to be displayed at once. Additionally, we add colors, which make it so much more pretty *and* gay, both of which are very good and useful. There's a bit of fuckery needed to get the colors to work. `colored` checks whether stdout is a terminal. We also print to stdout, so that works well. But.... for some stupid reason that I absolutely refuse to even attempt to debug, stdout is *not* a terminal when executing tests *in a terminal*. But stderr is >:). So this just checks whether stderr is a terminal. If you have a use case where you dump compiletest stdout into a place where colors are not supported while having stderr be a terminal, then I'm sorry for you, but you are gonna get colors and you're gonna like it. Stop it with the usual environment variable, which `colored` also respects by default. ### before (bad, hurts your brain, makes you want to cry) ![image](https://github.com/rust-lang/rust/assets/48135649/cbeecb5d-fc25-460b-b192-9808f8fa2079) ## after (good, gay, makes you want to cry) ![image](https://github.com/rust-lang/rust/assets/48135649/a655b220-8841-443e-a825-72a835d56882) r? jieyouxu said he wants to review the PR
2024-06-02Rollup merge of #125808 - ↵Jubilee-13/+26
GuillaumeGomez:migrate-run-make-c-link-to-rust-dylib, r=jieyouxu Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. First commit comes from https://github.com/rust-lang/rust/pull/125773. r? `@jieyouxu`
2024-06-02compiletest: fix outdated rmake.rs comment许杰友 Jieyou Xu (Joe)-5/+5
2024-06-02Auto merge of #125892 - workingjubilee:rollup-gytt1q7, r=workingjubileebors-1/+0
Rollup of 3 pull requests Successful merges: - #125311 (Make repr(packed) vectors work with SIMD intrinsics) - #125849 (Migrate `run-make/emit-named-files` to `rmake.rs`) - #125851 (Add some more specific checks to the MIR validator) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-02Improve compiletest expected/not found formattingNilstrieb-6/+34
compiletest, oh compiletest, you are truly one of the tools in this repository. You're the omnipresent gatekeeper, ensuring that every new change works, doesn't break the world, and is nice. We thank you for your work, for your tests, for your test runs, for your features that help writing tests, for all the stability and and good you have caused. Without you, Rust wouldn't exist as it does, without you, nothing would work, without you, we would all go insane from having changes break and having to test them all by hand. Thank you, compiletest. but holy shit i fucking hate your stupid debug output so much i simply cannot take this anymore aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa By changing a few magic lines in this file called "runtest.rs", we can cause compiletest to emit nicer messages. This is widely regarded as a good thing. We stop wasting vertical space, allowing more errors to be displayed at once. Additionally, we add colors, which make it so much more pretty *and* gay, both of which are very good and useful. There's a bit of fuckery needed to get the colors to work. `colored` checks whether stdout is a terminal. We also print to stdout, so that works well. But.... for some stupid reason that I absolutely refuse to even attempt to debug, stdout is *not* a terminal when executing tests *in a terminal*. But stderr is >:). So this just checks whether stderr is a terminal. If you have a use case where you dump compiletest stdout into a place where colors are not supported while having stderr be a terminal, then I'm sorry for you, but you are gonna get colors and you're gonna like it. Stop it with the usual environment variable, which `colored` also respects by default.
2024-06-02Rollup merge of #125849 - GuillaumeGomez:migrate-emit-named-files, r=jieyouxuJubilee-1/+0
Migrate `run-make/emit-named-files` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? `@jieyouxu`
2024-06-02Auto merge of #125887 - lnicola:sync-from-ra, r=lnicolabors-191/+1715
Subtree update of `rust-analyzer` r? `@ghost`
2024-06-02Migrate `run-make/c-link-to-rust-dylib` to `rmake.rs`Guillaume Gomez-1/+0
2024-06-02Add `dynamic_lib_extension` and `read_dir` functions to `run-make-support` ↵Guillaume Gomez-12/+26
library
2024-06-02Auto merge of #17328 - Veykril:derive-helper-completions, r=Veykrilbors-98/+209
feat: Enable completions within derive helper attributes ![Code_zG5qInoQ6B](https://github.com/rust-lang/rust-analyzer/assets/3757771/db30b98d-4981-45e3-83a5-7ff23fbd3f66)
2024-06-02feat: Enable completions within derive helper attributesLukas Wirth-98/+209
2024-06-02compiletest: split rmake executable from scratch dir许杰友 Jieyou Xu (Joe)-9/+24
When implementing support for rmake.rs, I copied over the `$TMPDIR` directory logic from the legacy Makefile setup. In doing so, I also compiled recipe `rmake.rs` into executables which unfortunately are placed into `$TMPDIR` as well. This causes a problem on Windows where: - The `rmake.exe` executable is placed in `$TMPDIR`. - We run the `rmake.exe` as a process. - The process uses `rmake.exe` inside `$TMPDIR`. - Windows prevents the .exe file from being deleted when the process is still alive. - The recipe test code tries to `remove_dir_all($TMPDIR)`, which fails with access denied because `rmake.exe` is still being used. We fix this by separating the recipe executable and the sratch directory: ``` base_dir/ rmake.exe scratch/ ``` We construct a base directory, unique to each run-make test, under which we place rmake.exe alongside a `scratch/` directory. This `scratch/` directory is what is passed to rmake.rs tests as `$TMPDIR`, so now `remove_dir_all($TMPDIR)` has a chance to succeed because it no longer contains `rmake.exe`. Oops. This was a fun one to try figure out.
2024-06-02Auto merge of #125773 - GuillaumeGomez:migrate-run-make-cdylib, r=jieyouxubors-1/+7
Migrate run make cdylib Part of https://github.com/rust-lang/rust/issues/121876. r? `@jieyouxu`
2024-06-01Auto merge of #125775 - compiler-errors:uplift-closure-args, r=lcnrbors-2/+2
Uplift `{Closure,Coroutine,CoroutineClosure}Args` and friends to `rustc_type_ir` Part of converting the new solver's `structural_traits.rs` to be interner-agnostic. I decided against aliasing `ClosureArgs<TyCtxt<'tcx>>` to `ClosureArgs<'tcx>` because it seemed so rare. I could do so if desired, though. r? lcnr
2024-06-01Auto merge of #17326 - Veykril:fix-attr-derive-container, r=Veykrilbors-40/+48
fix: Fix container search failing for tokens originating within derive attributes
2024-06-01fix: Fix container search failing for tokens originating within derive ↵Lukas Wirth-40/+48
attributes
2024-06-01Uplift TypeRelation and RelateMichael Goulet-2/+2
2024-06-01Auto merge of #17302 - mladedav:dm/fix-clear, r=Veykrilbors-13/+30
fix diagnostics clearing when flychecks run per-workspace This might be causing #17300 or it's a different bug with the same functionality. I wonder if the decision to clear diagnostics should stay in the main loop or maybe the flycheck itself should track it and tell the mainloop? I have used a hash map but we could just as well use a vector since the IDs are `usizes` in some given range starting at 0. It would be probably faster but this just felt a bit cleaner and it allows us to change the ID to newtype later and we can just use a hasher that returns the underlying integer.
2024-06-01Move state trackig of diagnostic clearing inside `FlycheckActor`David Mládek-41/+31
2024-06-01Deduplicate supertrait_def_ids codeMark Rousskov-1/+1
2024-06-01Auto merge of #17278 - chenx97:flycheck-process-wrap, r=lnicolabors-45/+73
internal: replace command-group with process-wrap Because command-group no longer receives updates and depends on an older version of nix.
2024-06-01Migrate `run-make/emit-named-files` to `rmake.rs`Guillaume Gomez-1/+0
2024-06-01Migrate `run-make/cdylib` to `rmake.rs`Guillaume Gomez-1/+0
2024-06-01Add `Cc::output` methodGuillaume Gomez-0/+7
2024-06-01Auto merge of #125835 - weihanglo:update-cargo, r=weihanglobors-0/+0
Update cargo 9 commits in 431db31d0dbeda320caf8ef8535ea48eb3093407..7a6fad0984d28c8330974636972aa296b67c4513 2024-05-28 18:17:31 +0000 to 2024-05-31 22:26:03 +0000 - fix(config): Ensure `--config net.git-fetch-with-cli=true` is respected (rust-lang/cargo#13992) - Fix libcurl proxy documentation link (rust-lang/cargo#13990) - fix(new): Dont say were adding to a workspace when a regular package is in root (rust-lang/cargo#13987) - fix: adjust custom err from cert-check due to libgit2 1.8 change (rust-lang/cargo#13970) - fix(toml): Ensure targets are in a deterministic order (rust-lang/cargo#13989) - doc(cargo-package): explain no guarantee of vcs provenance (rust-lang/cargo#13984) - chore: fix some comments (rust-lang/cargo#13982) - feat: stabilize `cargo update --precise &lt;yanked&gt;` (rust-lang/cargo#13974) - Update openssl-src to 111.28.2+1.1.1w (rust-lang/cargo#13976) r? ghost
2024-05-31Update cargoWeihang Lo-0/+0
2024-05-31Auto merge of #125408 - chriskrycho:chriskrycho/book-updates, r=ehussbors-0/+13
Support mdBook preprocessors for TRPL in rustbook `rust-lang/book` recently added two mdBook preprocessors. Enable `rustbook` to use those preprocessors for books where they are requested by the `book.toml` by adding the preprocessors as path dependencies, and ignoring them where they are not requested, i.e. by all the books other than TRPL at present. Addresses rust-lang/book#3927
2024-05-31docs: Missing word typoLuke Franceschini-1/+1
2024-05-31Rollup merge of #125816 - Zalathar:demangler, r=oli-obkMatthias Krüger-15/+36
Don't build the `rust-demangler` binary for coverage tests The coverage-run tests invoke `llvm-cov`, which requires us to specify a command-line demangler that it can use to demangle Rust symbol names. Historically this used `src/tools/rust-demangler`, which means that we currently build two different command-line tools to help with the coverage tests (`rust-demangler` and `coverage-dump`). However, it occurred to me that if we add a demangler mode to `coverage-dump` (which is only a handful of lines and no extra dependencies), then we only need to build one helper binary for the coverage tests, and there is no need for tests to build `rust-demangler` at all. --- Note that the `rust-demangler` binary is separate from the `rustc-demangle` crate (which both `rust-demangler` and `coverage-dump` use as a dependency to do the actual demangling). --- So the main benefits/motivations here are: - Slightly faster builds after a fresh checkout or bootstrap bump. - Making it clear that currently no tests actually need the `rust-demangler` binary, since the coverage tests can use their own tool instead.
2024-05-31Remove unused rust-demangler support from compiletestZalathar-10/+0
2024-05-31Use `coverage-dump --demangle` as the demangler for coverage-run testsZalathar-5/+12
This avoids the need to build `rust-demangler` when running coverage tests, since we typically need to build `coverage-dump` anyway.
2024-05-31Add an alternate `--demangle` mode to coverage-dumpZalathar-0/+24
The coverage-dump tool already needs `rustc_demangle` for its own purposes, so the amount of extra code needed for a demangle mode is very small.
2024-05-31Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obkbors-0/+5
Implement `needs_async_drop` in rustc and optimize async drop glue This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948. Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-57/+50
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-31minor: replace command-group with process-wrapHenry Chen-45/+73
Because command-group no longer receives updates and depends on an older version of nix.
2024-05-30Auto merge of #125710 - RalfJung:compiletest-components, r=workingjubileebors-3/+9
compiletest: clarify COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS error COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS is a confusing name because elsewhere "needs" means "ignore when requirement not met", but here it means "fail when requirement not met".