about summary refs log tree commit diff
path: root/src/tools/tidy
AgeCommit message (Collapse)AuthorLines
2024-04-13reduce tidy overheads in run-make checksonur-ozkan-9/+24
This change makes tidy to handle run-make checks with a single iteration, avoiding the need for multiple iterations and copying. Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-04-11Remove unused cargo-platform dependencybjorn3-1/+0
2024-04-11Remove wasm dep filter from tidybjorn3-33/+7
It incorrectly filters out non-wasm dependencies too.
2024-04-10move testKalle Wachsmuth-2/+1
2024-04-10Rollup merge of #123568 - Oneirical:delete-tests, r=wesleywiserMatthias Krüger-1/+1
Clean up tests/ui by removing `does-nothing.rs` In [a previous PR](https://github.com/rust-lang/rust/pull/123297#issuecomment-2039887806), it was suggested that this test be removed: > it's testing a basic diagnostic for an unknown variable (added over a decade ago for https://github.com/rust-lang/rust/issues/154) that is already covered by probably dozens or hundreds of other tests. It was then suggested that [opening a new PR](https://github.com/rust-lang/rust/pull/123563#discussion_r1554654102) for this would be more organized. I'm setting this as a draft, as: 1. The tests/ui directory is rather disorganized, a large quantity of tests are not even contained inside their own directories. This PR could turn into "clean up the UI tests directory", if I were to place everything into categories (for example, everything related to CLI flags could get placed in a cli directory). 2. This will have a merge conflict with #123563 should that get merged. I trust that _this time_, I won't run into [The Incident](https://github.com/rust-lang/rust/pull/123297#issuecomment-2041137569) while rebasing. Edit: Yay, I did it properly!
2024-04-10Rollup merge of #121884 - 5225225:rmake-exit-code, r=jieyouxuMatthias Krüger-1/+0
Port exit-code run-make test to use rust As part of https://github.com/rust-lang/rust/issues/121876 ~~As draft because formatting will fail because `x fmt` isn't working for me for some reason, I'll debug that later, just opening this now for review, will mark as ready when formatting is fixed~~ (misleading message from x fmt) cc `@jieyouxu`
2024-04-09remove does-nothing.rsOneirical-1/+1
fix: restore issues_entry_limit
2024-04-09Auto merge of #123683 - pietroalbini:pa-cve-2024-24576-nightly, r=pietroalbinibors-0/+3
Backport fix of CVE-2024-24576 See https://blog.rust-lang.org/2024/04/09/cve-2024-24576.html r? `@ghost`
2024-04-09allow the test bat files in tidyPietro Albini-0/+3
2024-04-09Rollup merge of #122768 - oli-obk:why_is_E0699_so_bad, r=WaffleLapkinMatthias Krüger-14/+31
Use the more informative generic type inference failure error on method calls on raw pointers
2024-04-08Mark some tests as known-bugs and add the test case from the corresponding issueOli Scherer-1/+0
2024-04-08move exit-code to rmake5225225-1/+0
2024-04-07Move testsCaio-26/+26
2024-04-07Rollup merge of #123563 - Oneirical:version, r=jieyouxuMatthias Krüger-2/+1
Rewrite `version` test run-make as an UI test Claiming the simple `version` test from #121876. Reasoning: As discussed in #123297, 10 years ago, some changes to CLI flags warranted the creation of the `version` test. Since it's not actually executing the compiled binary, it has no purpose being a `run-make` test and should instead be an UI test. This is the exact same change as it was shown on my closed PR #123297. Changes were ready, but I did a major Git mishap while trying to fix a tidy error and messed up my branch. The details of this error are explained [here](https://github.com/rust-lang/rust/pull/123297#issuecomment-2041152379).
2024-04-06Rewrite version test as UI testOneirical-2/+1
fix: re-add stout ignore restore does-nothing fix: universal check-pass
2024-04-06optimize tidy check on `src/tools/tidy/src/issues.txt`onur-ozkan-4397/+4402
This change applies to the following: - Handles `is_sorted` in the first iteration without needing a second. - Fixes line sorting on `--bless`. - Reads `issues.txt` as str rather than making it part of the source code. Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-04-05Rollup merge of #123474 - jieyouxu:issue-7349-port, r=Mark-SimulacrumGuillaume Gomez-1/+0
Port `run-make/issue-7349` to a codegen test The test does not need to be a run-make test, it can use the codegen test infrastructure. Also took the opportunity to rename the test to `no-redundant-item-monomorphization` so it's not just some opaque issue number. Part of #121876.
2024-04-05Rollup merge of #123149 - jieyouxu:rmake-arguments-non-c-like-enum, ↵Guillaume Gomez-1/+0
r=Mark-Simulacrum Port argument-non-c-like-enum to Rust Part of #121876.
2024-04-05Rollup merge of #122334 - GuillaumeGomez:vendor-cg_gcc, r=Mark-SimulacrumGuillaume Gomez-4/+1
Vendor rustc_codegen_gcc I used https://github.com/rust-lang/rust/pull/115274 as base for this update. r? `@bjorn3`
2024-04-04Rollup merge of #123407 - GuillaumeGomez:js-failed-theme, r=notriddleJacob Pratt-2/+5
Default to light theme if JS is enabled but not working It doesn't [fix] #123399 but it allows to reduce the problem: * if JS is completely disabled, then `noscript.css` will be applied * if JS failed for any reason, then the light theme will be applied (because `noscript.css` won't be applied) r? `@notriddle`
2024-04-04Port issue-7349 to a codegen test许杰友 Jieyou Xu (Joe)-1/+0
2024-04-04Rollup merge of #122448 - high-cloud:move-hir-tree, r=oli-obkMatthias Krüger-1/+0
Port hir-tree run-make test to ui test As part of #121876 cc `@jieyouxu`
2024-04-04move hir-tree test from run-make to ui testYaodong Yang-1/+0
2024-04-04Auto merge of #119820 - lcnr:leak-check-2, r=jackh726bors-1/+0
instantiate higher ranked goals outside of candidate selection This PR modifies `evaluate` to more eagerly instantiate higher-ranked goals, preventing the `leak_check` during candidate selection from detecting placeholder errors involving that binder. For a general background regarding higher-ranked region solving and the leak check, see https://hackmd.io/qd9Wp03cQVy06yOLnro2Kg. > The first is something called the **leak check**. You can think of it as a "quick and dirty" approximation for the region check, which will come later. The leak check detects some kinds of errors early, essentially deciding between "this set of outlives constraints are guaranteed to result in an error eventually" or "this set of outlives constraints may be solvable". ## The ideal future We would like to end up with the following idealized design to handle universal binders: ```rust fn enter_forall<'tcx, T, R>( forall: Binder<'tcx, T>, f: impl FnOnce(T) -> R, ) -> R { let new_universe = infcx.increment_universe_index(); let value = instantiate_binder_with_placeholders_in(new_universe, forall); let result = f(value); eagerly_handle_higher_ranked_region_constraints_in(new_universe); infcx.decrement_universe_index(); assert!(!result.has_placeholders_in_or_above(new_universe)); result } ``` That is, when universally instantiating a binder, anything using the placeholders has to happen inside of a limited scope (the closure `f`). After this closure has completed, all constraints involving placeholders are known. We then handle any *external constraints* which name these placeholders. We destructure `TypeOutlives` constraints involving placeholders and eagerly handle any region constraints involving these placeholders. We do not return anything mentioning the placeholders created inside of this function to the caller. Being able to eagerly handle *all* region constraints involving placeholders will be difficult due to complex `TypeOutlives` constraints, involving inference variables or alias types, and higher ranked implied bounds. The exact issues and possible solutions are out of scope of this FCP. #### How does the leak check fit into this The `leak_check` is an underapproximation of `eagerly_handle_higher_ranked_region_constraints_in`. It detects some kinds of errors involving placeholders from `new_universe`, but not all of them. It only looks at region outlives constraints, ignoring `TypeOutlives`, and checks whether one of the following two conditions are met for **placeholders in or above `new_universe`**, in which case it results in an error: - `'!p1: '!p2` a placeholder `'!p2` outlives a different placeholder `'!p1` - `'!p1: '?2` an inference variable `'?2` outlives a placeholder `'!p1` *which it cannot name* It does not handle all higher ranked region constraints, so we still return constraints involving placeholders from `new_universe` which are then (re)checked by `lexical_region_resolve` or MIR borrowck. As we check higher ranked constraints in the full regionck anyways, the `leak_check` is not soundness critical. It's current only purpose is to move some higher ranked region errors earlier, enabling it to guide type inference and trait solving. Adding additional uses of the `leak_check` in the future would only strengthen inference and is therefore not breaking. ## Where do we use currently use the leak check The `leak_check` is currently used in two places: Coherence does not use a proper regionck, only relying on the `leak_check` called [at the end of the implicit negative overlap check](https://github.com/rust-lang/rust/blob/8b94152af68a0ed6d6af0b5ba57491e40481008e/compiler/rustc_trait_selection/src/traits/coherence.rs#L235-L238). During coherence all parameters are instantiated with inference variables, so the only possible region errors are higher-ranked. We currently also sometimes make guesses when destructuring `TypeOutlives` constraints which can theoretically result in incorrect errors. This could result in overlapping impls. We also use the `leak_check` [at the end of `fn evaluation_probe`](https://github.com/rust-lang/rust/blob/8b94152af68a0ed6d6af0b5ba57491e40481008e/compiler/rustc_trait_selection/src/traits/select/mod.rs#L607-L610). This function is used during candidate assembly for `Trait` goals. Most notably we use [inside of `evaluate_candidate` during winnowing](https://github.com/rust-lang/rust/blob/0e4243538b9119654c22dce688f8a63c81864de9/compiler/rustc_trait_selection/src/traits/select/mod.rs#L491-L502). Conceptionally, it is as if we compute each candidate in a separate `enter_forall`. ## The current use in `fn evaluation_probe` is undesirable Because we only instantiate a higher-ranked goal once inside of `fn evaluation_probe`, errors involving placeholders from that binder can impact selection. This results in inconsistent behavior ([playground]( *[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=dac60ebdd517201788899ffa77364831)*)): ```rust trait Leak<'a> {} impl Leak<'_> for Box<u32> {} impl Leak<'static> for Box<u16> {} fn impls_leak<T: for<'a> Leak<'a>>() {} trait IndirectLeak<'a> {} impl<'a, T: Leak<'a>> IndirectLeak<'a> for T {} fn impls_indirect_leak<T: for<'a> IndirectLeak<'a>>() {} fn main() { // ok // // The `Box<u16>` impls fails the leak check, // meaning that we apply the `Box<u32>` impl. impls_leak::<Box<_>>(); // error: type annotations needed // // While the `Box<u16>` impl would fail the leak check // we have already instantiated the binder while applying // the generic `IndirectLeak` impl, so during candidate // selection of `Leak` we do not detect the placeholder error. // Evaluation of `Box<_>: Leak<'!a>` is therefore ambiguous, // resulting in `for<'a> Box<_>: Leak<'a>` also being ambiguous. impls_indirect_leak::<Box<_>>(); } ``` We generally prefer `where`-bounds over implementations during candidate selection, both for [trait goals](https://github.com/rust-lang/rust/blob/11f32b73e0dc9287e305b5b9980d24aecdc8c17f/compiler/rustc_trait_selection/src/traits/select/mod.rs#L1863-L1887) and during [normalization](https://github.com/rust-lang/rust/blob/11f32b73e0dc9287e305b5b9980d24aecdc8c17f/compiler/rustc_trait_selection/src/traits/project.rs#L184-L198). However, we currently **do not** use the `leak_check` during candidate assembly in normalizing. This can result in inconsistent behavior: ```rust trait Trait<'a> { type Assoc; } impl<'a, T> Trait<'a> for T { type Assoc = usize; } fn trait_bound<T: for<'a> Trait<'a>>() {} fn projection_bound<T: for<'a> Trait<'a, Assoc = usize>>() {} // A function with a trivial where-bound which is more // restrictive than the impl. fn function<T: Trait<'static, Assoc = usize>>() { // ok // // Proving `for<'a> T: Trait<'a>` using the where-bound results // in a leak check failure, so we use the more general impl, // causing this to succeed. trait_bound::<T>(); // error // // Proving the `Projection` goal `for<'a> T: Trait<'a, Assoc = usize>` // does not use the leak check when trying the where-bound, causing us // to prefer it over the impl, resulting in a placeholder error. projection_bound::<T>(); // error // // Trying to normalize the type `for<'a> fn(<T as Trait<'a>>::Assoc)` // only gets to `<T as Trait<'a>>::Assoc` once `'a` has been already // instantiated, causing us to prefer the where-bound over the impl // resulting in a placeholder error. Even if were were to also use the // leak check during candidate selection for normalization, this // case would still not compile. let _higher_ranked_norm: for<'a> fn(<T as Trait<'a>>::Assoc) = |_| (); } ``` This is also likely to be more performant. It enables more caching in the new trait solver by simply [recursively calling the canonical query][new solver] after instantiating the higher-ranked goal. It is also unclear how to add the leak check to normalization in the new solver. To handle https://github.com/rust-lang/trait-system-refactor-initiative/issues/1 `Projection` goals are implemented via `AliasRelate`. This again means that we instantiate the binder before ever normalizing any alias. Even if we were to avoid this, we lose the ability to [cache normalization by itself, ignoring the expected `term`](https://github.com/rust-lang/rust/blob/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs#L34-L49). We cannot replace the `term` with an inference variable before instantiating the binder, as otherwise `for<'a> T: Trait<Assoc<'a> = &'a ()>` breaks. If we only replace the term after instantiating the binder, we cannot easily evaluate the goal in a separate context, as [we'd then lose the information necessary for the leak check](https://github.com/rust-lang/rust/blob/11f32b73e0dc9287e305b5b9980d24aecdc8c17f/compiler/rustc_next_trait_solver/src/canonicalizer.rs#L230-L232). Adding this information to the canonical input also seems non-trivial. ## Proposed solution I propose to instantiate the binder outside of candidate assembly, causing placeholders from higher-ranked goals to get ignored while selecting their candidate. This mostly[^1] matches the [current behavior of the new solver][new solver]. The impact of this change is therefore as follows: ```rust trait Leak<'a> {} impl Leak<'_> for Box<u32> {} impl Leak<'static> for Box<u16> {} fn impls_leak<T: for<'a> Leak<'a>>() {} trait IndirectLeak<'a> {} impl<'a, T: Leak<'a>> IndirectLeak<'a> for T {} fn impls_indirect_leak<T: for<'a> IndirectLeak<'a>>() {} fn guide_selection() { // ok -> ambiguous impls_leak::<Box<_>>(); // ambiguous impls_indirect_leak::<Box<_>>(); } trait Trait<'a> { type Assoc; } impl<'a, T> Trait<'a> for T { type Assoc = usize; } fn trait_bound<T: for<'a> Trait<'a>>() {} fn projection_bound<T: for<'a> Trait<'a, Assoc = usize>>() {} // A function which a trivial where-bound which is more // restrictive than the impl. fn function<T: Trait<'static, Assoc = usize>>() { // ok -> error trait_bound::<T>(); // error projection_bound::<T>(); // error let _higher_ranked_norm: for<'a> fn(<T as Trait<'a>>::Assoc) = |_| (); } ``` This does not change the behavior if candidates have higher ranked nested goals, as in this case the `leak_check` causes the nested goal to result in an error ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a74c25300b23db9022226de99d8a2fa6)): ```rust trait LeakCheckFailure<'a> {} impl LeakCheckFailure<'static> for () {} trait Trait<T> {} impl Trait<u32> for () where for<'a> (): LeakCheckFailure<'a> {} impl Trait<u16> for () {} fn impls_trait<T: Trait<U>, U>() {} fn main() { // ok // // It does not matter whether candidate assembly // considers the placeholders from higher-ranked goal. // // Either `for<'a> (): LeakCheckFailure<'a>` has no // applicable candidate or it has a single applicable candidate // when then later results in an error. This allows us to // infer `U` to `u16`. impls_trait::<(), _>() } ``` ## Impact on existing crates This is a **breaking change**. [A crater run](https://github.com/rust-lang/rust/pull/119820#issuecomment-1926862174) found 17 regressed crates with 7 root causes. For a full analysis of all affected crates, see https://gist.github.com/lcnr/7c1c652f30567048ea240554a36ed95c. --- I believe this breakage to be acceptable and would merge this change. I am confident that the new position of the leak check matches our idealized future and cannot envision any other consistent alternative. Where possible, I intend to open PRs fixing/avoiding the regressions before landing this PR. I originally intended to remove the `coherence_leak_check` lint in the same PR. However, while I am confident in the *position* of the leak check, deciding on its exact behavior is left as future work, cc #112999. This PR therefore only moves the leak check while keeping the lint when relying on it in coherence. [new solver]: https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs#L479-L484 [^1]: the new solver has a separate cause of inconsistent behavior rn https://github.com/rust-lang/trait-system-refactor-initiative/issues/53#issuecomment-1914310171 r? `@nikomatsakis`
2024-04-03rebase oddityBoxy-1/+0
2024-04-03Rollup merge of #123291 - c410-f3r:testsssssss, r=petrochenkovMatthias Krüger-11/+9
Move some tests r? `@petrochenkov`
2024-04-03Update `rustdoc_css_themes.rs` to take into account new selectorsGuillaume Gomez-2/+5
2024-04-01Rebless allow list许杰友 Jieyou Xu (Joe)-1/+0
2024-03-31Move some testsCaio-11/+9
2024-03-30Rewrite core-no-fp-fmt-parse in RustOneirical-1/+0
Rewrite core-no-fp-fmt-parse in Rust fix: missing import fix: tidiness check more tidy checks remove tidy line length ignore new helper functions + arg_path generic fix: remove unused import delete arg_path, change arg_path to input
2024-03-27Add FIXME to remind removing the check once all tests are ported over许杰友 Jieyou Xu (Joe)-0/+1
2024-03-27Point out you can use --bless to update allow list for removed entries许杰友 Jieyou Xu (Joe)-1/+2
2024-03-27Use a line-separated plain-text allowlist instead许杰友 Jieyou Xu (Joe)-359/+341
2024-03-27Add run-make/link-framework/Makefile to allowlist许杰友 Jieyou Xu (Joe)-0/+1
2024-03-27Rename expected_run_make_makefiles -> allowed_run_make_makefiles许杰友 Jieyou Xu (Joe)-9/+9
2024-03-27Pass tests_path and src_path separately许杰友 Jieyou Xu (Joe)-5/+3
2024-03-27Add comment for `include!()` usage许杰友 Jieyou Xu (Joe)-0/+3
2024-03-27Add tidy check to error on new `Makefile`s in `tests/run-make`许杰友 Jieyou Xu (Joe)-0/+443
2024-03-26Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJungbors-0/+3
Print a backtrace in const eval if interrupted Demo: ```rust #![feature(const_eval_limit)] #![const_eval_limit = "0"] const OW: u64 = { let mut res: u64 = 0; let mut i = 0; while i < u64::MAX { res = res.wrapping_add(i); i += 1; } res }; fn main() { println!("{}", OW); } ``` ``` ╭ ➜ ben@archlinux:~/rust ╰ ➤ rustc +stage1 spin.rs ^Cerror[E0080]: evaluation of constant value failed --> spin.rs:8:33 | 8 | res = res.wrapping_add(i); | ^ Compilation was interrupted note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. ```
2024-03-25Rollup merge of #122842 - pacak:explicit_name, r=michaelwoeristerMatthias Krüger-1/+1
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name Fixes #122509 You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example. In case compilation produced more than a single file `rustc` runs following check to emit some warnings: ```rust if crate_output.outputs.contains_key(&output_type) { // 2) Multiple codegen units, with `--emit foo=some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringEmitPath { extension }); } else if crate_output.single_output_file.is_some() { // 3) Multiple codegen units, with `-o some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringOutput { extension }); } else { // 4) Multiple codegen units, but no explicit name. We // just leave the `foo.0.x` files in place. // (We don't have to do any work in this case.) } ``` Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`. To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-22tests/ui: Add a directory for warnings, add a testMichael Baikov-1/+1
2024-03-21Avoid noop rewrite of issues.txtJubilee Young-2/+3
This can trigger incremental rebuilds since incr doesn't realize nothing changed.
2024-03-20Make tidy error code parsing robust against commentsOli Scherer-13/+30
2024-03-20Use the more informative generic type inference failure error on method ↵Oli Scherer-1/+1
calls on raw pointers
2024-03-19Auto merge of #116935 - oli-obk:different_lifetime_taits_in_same_sig, ↵bors-1/+0
r=compiler-errors Prevent opaque types being instantiated twice with different regions within the same function addresses https://github.com/orgs/rust-lang/projects/22/views/1?pane=issue&itemId=41329537 r? `@compiler-errors`
2024-03-19Fix incorrect mutable suggestion information for binding in ref pattern.surechen-1/+0
For ref pattern in func param, the mutability suggestion has to apply to the binding. For example: `fn foo(&x: &i32)` -> `fn foo(&(mut x): &i32)` fixes #122415
2024-03-18Prevent opaque types being instantiated twice with different regions within ↵Oli Scherer-1/+0
the same function
2024-03-17Move `option_env!` and `env!` tests to the `env-macro` directorybeetrees-3/+1
2024-03-17Print a backtrace in const eval if interruptedBen Kimock-0/+3
2024-03-14one must imagine tidy happylcnr-1/+0