From b570c882df68335b02b169d68dfb269d04d67008 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 16 Jul 2022 03:55:15 +0200 Subject: [PATCH 01/20] make date-check lightweight This avoids having to write the date twice when updating date-check. Before "As of <-- 2022-07 --> July 2022" After "As of July 2022" --- ci/date-check/src/main.rs | 36 +++++++------------ src/backend/backend-agnostic.md | 2 +- .../region_inference/member_constraints.md | 2 +- src/conventions.md | 4 +-- src/crates-io.md | 2 +- src/diagnostics/diagnostic-items.md | 2 +- src/diagnostics/lintstore.md | 2 +- src/diagnostics/translation.md | 2 +- src/git.md | 2 +- src/llvm-coverage-instrumentation.md | 4 +-- src/opaque-types-type-alias-impl-trait.md | 6 ++-- src/overview.md | 2 +- src/parallel-rustc.md | 6 ++-- src/profiling.md | 2 +- .../query-evaluation-model-in-detail.md | 2 +- src/query.md | 2 +- src/rustc-driver-getting-diagnostics.md | 2 +- src/rustc-driver-interacting-with-the-ast.md | 2 +- src/rustdoc-internals.md | 2 +- src/salsa.md | 2 +- src/tests/compiletest.md | 2 +- src/the-parser.md | 2 +- src/thir.md | 2 +- src/traits/chalk.md | 4 +-- src/traits/resolution.md | 2 +- src/type-inference.md | 2 +- 26 files changed, 45 insertions(+), 55 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index bbea2bf38..a7fd5d671 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -3,9 +3,10 @@ use std::{ convert::TryInto as _, env, fmt, fs, path::{Path, PathBuf}, + str::FromStr, }; -use chrono::{Datelike as _, TimeZone as _, Utc}; +use chrono::{Datelike as _, Month, TimeZone as _, Utc}; use glob::glob; use regex::Regex; @@ -36,16 +37,7 @@ impl fmt::Display for Date { } fn make_date_regex() -> Regex { - Regex::new( - r"(?x) # insignificant whitespace mode - ", - ) - .unwrap() + Regex::new(r"[aA]s of (\w+) (\d{4})").unwrap() } fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> { @@ -57,8 +49,8 @@ fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> ( cap.get(0).unwrap().range(), Date { - year: cap["y"].parse().unwrap(), - month: cap["m"].parse().unwrap(), + year: cap[2].parse().unwrap(), + month: Month::from_str(&cap[1]).unwrap().number_from_month(), }, ) }) @@ -183,20 +175,18 @@ mod tests { #[test] fn test_date_regex() { let regex = make_date_regex(); - assert!(regex.is_match("foo bar")); - } - - #[test] - fn test_date_regex_capitalized() { - let regex = make_date_regex(); - assert!(regex.is_match("foo bar")); + assert!(regex.is_match("As of July 2022")); + assert!(regex.is_match("As of Jul 2022")); + assert!(regex.is_match("As of july 2022")); + assert!(regex.is_match("As of jul 2022")); + assert!(regex.is_match("as of jul 2022")); } #[test] fn test_collect_dates_from_file() { - let text = "Test1\n\nTest2\nFoo\nTest3\nTest4\nFooBar\n\nTest5\nTest6\nTest7\n\nTest8 + let text = "Test1\nAs of Jan 2021\nTest2\nAs of Feb 2021 \ + \nTest3\nTest4\nAs of march 2021Bar\nas of apr 2021 \ + \nTest5\nTest6\nTest7\n\n\nas of may 2021\nTest8 "; assert_eq!( collect_dates_from_file(&make_date_regex(), text), diff --git a/src/backend/backend-agnostic.md b/src/backend/backend-agnostic.md index 271e6a16f..17a1e8f7a 100644 --- a/src/backend/backend-agnostic.md +++ b/src/backend/backend-agnostic.md @@ -2,7 +2,7 @@ -As of October 2021, `rustc_codegen_ssa` provides an +As of October 2021, `rustc_codegen_ssa` provides an abstract interface for all backends to implement, to allow other codegen backends (e.g. [Cranelift]). diff --git a/src/borrow_check/region_inference/member_constraints.md b/src/borrow_check/region_inference/member_constraints.md index c7c107e1e..77776986a 100644 --- a/src/borrow_check/region_inference/member_constraints.md +++ b/src/borrow_check/region_inference/member_constraints.md @@ -94,7 +94,7 @@ member constraints come in. ## Choices are always lifetime parameters At present, the "choice" regions from a member constraint are always lifetime -parameters from the current function. As of October 2021, +parameters from the current function. As of October 2021, this falls out from the placement of impl Trait, though in the future it may not be the case. We take some advantage of this fact, as it simplifies the current code. In particular, we don't have to consider a case like `'0 member of ['1, diff --git a/src/conventions.md b/src/conventions.md index 15d125377..0f51fefcd 100644 --- a/src/conventions.md +++ b/src/conventions.md @@ -14,14 +14,14 @@ special config, so this may result in different style from normal [`rustfmt`]. Therefore, formatting this repository using `cargo fmt` is not recommended. Instead, formatting should be done using `./x.py fmt`. It's a good habit to run -`./x.py fmt` before every commit, as this reduces conflicts later. +`./x.py fmt` before every commit, as this reduces conflicts later. Formatting is checked by the `tidy` script. It runs automatically when you do `./x.py test` and can be run in isolation with `./x.py fmt --check`. If you want to use format-on-save in your editor, the pinned version of `rustfmt` is built under `build//stage0/bin/rustfmt`. You'll have to -pass the `--edition=2021` argument yourself when calling +pass the `--edition=2021` argument yourself when calling `rustfmt` directly. [fmt]: https://github.com/rust-dev-tools/fmt-rfcs diff --git a/src/crates-io.md b/src/crates-io.md index 8c8fd0c38..d7c7f25ed 100644 --- a/src/crates-io.md +++ b/src/crates-io.md @@ -12,7 +12,7 @@ reasons: - The dependency may have transitive dependencies that have one of the above problems. -As of February 2022, there is no official policy for vetting +As of February 2022, there is no official policy for vetting new dependencies to the compiler. Generally, new dependencies are not added to the compiler unless there is a good reason to do so. diff --git a/src/diagnostics/diagnostic-items.md b/src/diagnostics/diagnostic-items.md index b6b6e0fa9..0717444ce 100644 --- a/src/diagnostics/diagnostic-items.md +++ b/src/diagnostics/diagnostic-items.md @@ -43,7 +43,7 @@ A new diagnostic item can be added with these two steps: For the naming conventions of diagnostic items, please refer to [*Naming Conventions*](#naming-conventions). -2. As of February 2022, diagnostic items in code are +2. As of February 2022, diagnostic items in code are accessed via symbols in [`rustc_span::symbol::sym`]. To add your newly created diagnostic item simply open the module file and add the name (In this case `Cat`) at the correct point in the list. diff --git a/src/diagnostics/lintstore.md b/src/diagnostics/lintstore.md index 39007f8d1..78b6da27a 100644 --- a/src/diagnostics/lintstore.md +++ b/src/diagnostics/lintstore.md @@ -17,7 +17,7 @@ default lint level and other metadata come from. These are normally defined by way of the [`declare_lint!`] macro, which boils down to a static with type `&rustc_session::lint::Lint`. -As of February 2022, we lint against direct declarations +As of February 2022, we lint against direct declarations without the use of the macro today (although this may change in the future, as the macro is somewhat unwieldy to add new fields to, like all macros). diff --git a/src/diagnostics/translation.md b/src/diagnostics/translation.md index 5c078ffb3..07599f516 100644 --- a/src/diagnostics/translation.md +++ b/src/diagnostics/translation.md @@ -217,7 +217,7 @@ returned by `Emitter::fluent_bundle`. This bundle is used preferentially when translating messages, the fallback bundle is only used if the primary bundle is missing a message or not provided. -As of June 2022, there are no locale bundles +As of June 2022, there are no locale bundles distributed with the compiler, but mechanisms are implemented for loading bundles. diff --git a/src/git.md b/src/git.md index f16c22d93..a32e3cd4d 100644 --- a/src/git.md +++ b/src/git.md @@ -157,7 +157,7 @@ no changes added to commit (use "git add" and/or "git commit -a") These changes are not changes to files: they are changes to submodules (more on this [later](#git-submodules)). To get rid of those, run `git submodule update` (or run any `x.py` command, which will automatically update the submodules). -Note that there is (as of February 2022) a [bug][#77620] if you use +Note that there is (as of February 2022) a [bug][#77620] if you use worktrees, submodules, and `x.py` in a commit hook. If you run into an error like: diff --git a/src/llvm-coverage-instrumentation.md b/src/llvm-coverage-instrumentation.md index ea4bdfca6..d6d3880b5 100644 --- a/src/llvm-coverage-instrumentation.md +++ b/src/llvm-coverage-instrumentation.md @@ -222,8 +222,8 @@ properly-configured variables in LLVM IR, according to very specific details of the [_LLVM Coverage Mapping Format_][coverage-mapping-format] (Version 6).[^llvm-and-covmap-versions] -[^llvm-and-covmap-versions]: The Rust compiler (as of -December 2021) supports _LLVM Coverage Mapping Format_ Version 5 or 6. Version 5 +[^llvm-and-covmap-versions]: The Rust compiler (as of December 2021) +supports _LLVM Coverage Mapping Format_ Version 5 or 6. Version 5 was introduced in _LLVM 12_, which is (as of this writing) the minimum LLVM version supported by the current version of Rust. Version 6 was introduced in _LLVM 13_, which is currently the default LLVM version for Rust. The Rust diff --git a/src/opaque-types-type-alias-impl-trait.md b/src/opaque-types-type-alias-impl-trait.md index 2be072dd2..a2d513a63 100644 --- a/src/opaque-types-type-alias-impl-trait.md +++ b/src/opaque-types-type-alias-impl-trait.md @@ -14,9 +14,9 @@ This declares an opaque type named `Foo`, of which the only information is that it implements `Bar`. Therefore, any of `Bar`'s interface can be used on a `Foo`, but nothing else (regardless of whether it implements any other traits). -Since there needs to be a concrete background type, you can (as of January 2021) express that type by using the opaque type in a -"defining use site". +Since there needs to be a concrete background type, +you can (as of January 2021) express that type +by using the opaque type in a "defining use site". ```rust,ignore struct Struct; diff --git a/src/overview.md b/src/overview.md index de6c88e7e..fb49c8638 100644 --- a/src/overview.md +++ b/src/overview.md @@ -292,7 +292,7 @@ Moreover, the compiler wasn't originally built to use a query system; the query system has been retrofitted into the compiler, so parts of it are not query-fied yet. Also, LLVM isn't our code, so that isn't querified either. The plan is to eventually query-fy all of the steps listed in the previous section, -but as of November 2021, only the steps between HIR and +but as of November 2021, only the steps between HIR and LLVM IR are query-fied. That is, lexing, parsing, name resolution, and macro expansion are done all at once for the whole program. diff --git a/src/parallel-rustc.md b/src/parallel-rustc.md index 4aa13d781..4400e2b64 100644 --- a/src/parallel-rustc.md +++ b/src/parallel-rustc.md @@ -1,6 +1,6 @@ # Parallel Compilation -As of May 2022, The only stage of the compiler +As of May 2022, The only stage of the compiler that is already parallel is codegen. The nightly compiler implements query evaluation, but there is still a lot of work to be done. The lack of parallelism at other stages also represents an opportunity for improving compiler performance. One can try out the current @@ -60,7 +60,7 @@ this issue can be found [here][parallel-rustdoc]. ## Current Status -As of May 2022, work on explicitly parallelizing the +As of May 2022, work on explicitly parallelizing the compiler has stalled. There is a lot of design and correctness work that needs to be done. @@ -76,7 +76,7 @@ These are the basic ideas in the effort to make `rustc` parallel: [`rayon`]: https://crates.io/crates/rayon -As of May 2022, much of this effort is on hold due +As of May 2022, much of this effort is on hold due to lack of manpower. We have a working prototype with promising performance gains in many cases. However, there are two blockers: diff --git a/src/profiling.md b/src/profiling.md index ada497d88..f0fc76f59 100644 --- a/src/profiling.md +++ b/src/profiling.md @@ -108,6 +108,6 @@ The llvm-lines output is affected by several options. MIR optimizations have little impact. Compared to the default `RUSTFLAGS="-Z mir-opt-level=1"`, level 0 adds 0.3GB and level 2 removes 0.2GB. -As of July 2022, +As of July 2022, inlining happens in LLVM and GCC codegen backends, missing only in the Cranelift one. diff --git a/src/queries/query-evaluation-model-in-detail.md b/src/queries/query-evaluation-model-in-detail.md index b84a5dac4..43ffe0a1d 100644 --- a/src/queries/query-evaluation-model-in-detail.md +++ b/src/queries/query-evaluation-model-in-detail.md @@ -76,7 +76,7 @@ executed, no results are cached. But the context already provides access to "input" data, i.e. pieces of immutable data that were computed before the context was created and that queries can access to do their computations. -As of January 2021, this input data consists mainly of +As of January 2021, this input data consists mainly of the HIR map, upstream crate metadata, and the command-line options the compiler was invoked with; but in the future inputs will just consist of command-line options and a list of source files -- the HIR map will itself be provided by a diff --git a/src/query.md b/src/query.md index 95e570dfc..222e90742 100644 --- a/src/query.md +++ b/src/query.md @@ -3,7 +3,7 @@ As described in [the high-level overview of the compiler][hl], the Rust compiler -is still (as of July 2021) transitioning from a +is still (as of July 2021) transitioning from a traditional "pass-based" setup to a "demand-driven" system. The compiler query system is the key to rustc's demand-driven organization. The idea is pretty simple. Instead of entirely independent passes diff --git a/src/rustc-driver-getting-diagnostics.md b/src/rustc-driver-getting-diagnostics.md index 327415e5a..bac16138c 100644 --- a/src/rustc-driver-getting-diagnostics.md +++ b/src/rustc-driver-getting-diagnostics.md @@ -7,7 +7,7 @@ To get diagnostics from the compiler, configure `rustc_interface::Config` to output diagnostic to a buffer, and run `TyCtxt.analysis`. The following was tested -with `nightly-2022-06-05` (See [here][example] +with `nightly-2022-06-05` (See [here][example] for the complete example): [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs diff --git a/src/rustc-driver-interacting-with-the-ast.md b/src/rustc-driver-interacting-with-the-ast.md index d70264fe4..7eae2fb71 100644 --- a/src/rustc-driver-interacting-with-the-ast.md +++ b/src/rustc-driver-interacting-with-the-ast.md @@ -5,7 +5,7 @@ ## Getting the type of an expression To get the type of an expression, use the `global_ctxt` to get a `TyCtxt`. -The following was tested with `nightly-2022-06-05` +The following was tested with `nightly-2022-06-05` (see [here][example] for the complete example): [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-interacting-with-the-ast.rs diff --git a/src/rustdoc-internals.md b/src/rustdoc-internals.md index 91bb0c358..1ac74b119 100644 --- a/src/rustdoc-internals.md +++ b/src/rustdoc-internals.md @@ -66,7 +66,7 @@ these passes, please let us know!) [44136]: https://github.com/rust-lang/rust/issues/44136 -Here is the list of passes as of May 2022: +Here is the list of passes as of May 2022: - `calculate-doc-coverage` calculates information used for the `--show-coverage` flag. diff --git a/src/salsa.md b/src/salsa.md index afa01eda2..96215186e 100644 --- a/src/salsa.md +++ b/src/salsa.md @@ -9,7 +9,7 @@ want to watch [Salsa In More Depth](https://www.youtube.com/watch?v=i_IhACacPRY), also by Niko Matsakis. -> As of April 2022, although Salsa is inspired by +> As of April 2022, although Salsa is inspired by > (among other things) rustc's query system, it is not used directly in rustc. > It _is_ used in chalk and extensively in `rust-analyzer`, but there are no > medium or long-term concrete plans to integrate it into the compiler. diff --git a/src/tests/compiletest.md b/src/tests/compiletest.md index 5c3dcf54b..a01fc4de0 100644 --- a/src/tests/compiletest.md +++ b/src/tests/compiletest.md @@ -452,7 +452,7 @@ fn main() { ## Revisions -Certain classes of tests support "revisions" (as of July 2022, +Certain classes of tests support "revisions" (as of July 2022, this includes UI, assembly, codegen, debuginfo, incremental, and rustdoc UI tests, though incremental tests are somewhat different). Revisions allow a single test file to be used for multiple tests. diff --git a/src/the-parser.md b/src/the-parser.md index ff43220c1..c37083c78 100644 --- a/src/the-parser.md +++ b/src/the-parser.md @@ -1,6 +1,6 @@ # Lexing and Parsing -As of January 2021, the lexer and parser are undergoing +As of January 2021, the lexer and parser are undergoing refactoring to allow extracting them into libraries. The very first thing the compiler does is take the program (in Unicode diff --git a/src/thir.md b/src/thir.md index 4f8e6512c..2f75f4c7d 100644 --- a/src/thir.md +++ b/src/thir.md @@ -4,7 +4,7 @@ The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for "High-Level Abstract IR", is another IR used by rustc that is generated after -[type checking]. It is (as of April 2022) only used for +[type checking]. It is (as of April 2022) only used for [MIR construction] and [exhaustiveness checking]. There is also [an experimental unsafety checker][thir-unsafeck] that operates on the THIR as a replacement for the current MIR unsafety checker, and can be used instead of the MIR unsafety checker by passing diff --git a/src/traits/chalk.md b/src/traits/chalk.md index d4045c460..3708f6b3e 100644 --- a/src/traits/chalk.md +++ b/src/traits/chalk.md @@ -1,7 +1,7 @@ # Chalk-based trait solving -[Chalk][chalk] is an experimental trait solver for Rust that is (as of May 2022) under development by the [Types team]. +[Chalk][chalk] is an experimental trait solver for Rust that is +(as of May 2022) under development by the [Types team]. Its goal is to enable a lot of trait system features and bug fixes that are hard to implement (e.g. GATs or specialization). If you would like to help in hacking on the new solver, drop by on the rust-lang Zulip in the [`#t-types`] diff --git a/src/traits/resolution.md b/src/traits/resolution.md index c22ee6de6..0ffcc7ee4 100644 --- a/src/traits/resolution.md +++ b/src/traits/resolution.md @@ -120,7 +120,7 @@ the obligation contains unbound inference variables. The subroutines that decide whether a particular impl/where-clause/etc applies to a particular obligation are collectively referred to as the process of -_matching_. As of May 2022, this amounts to unifying +_matching_. As of May 2022, this amounts to unifying the `Self` types, but in the future we may also recursively consider some of the nested obligations, in the case of an impl. diff --git a/src/type-inference.md b/src/type-inference.md index 4be9211ee..e4fc248e4 100644 --- a/src/type-inference.md +++ b/src/type-inference.md @@ -72,7 +72,7 @@ inference works, or perhaps this blog post on [Unification in the Chalk project]: http://smallcultfollowing.com/babysteps/blog/2017/03/25/unification-in-chalk-part-1/ All told, the inference context stores five kinds of inference variables -(as of June 2021): +(as of June 2021): - Type variables, which come in three varieties: - General type variables (the most common). These can be unified with any From 5b5ab38144f1a19ba6164a776c8e608a7d1180cf Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 16 Jul 2022 03:59:01 +0200 Subject: [PATCH 02/20] please clippy --- ci/date-check/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index a7fd5d671..1da49311c 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -44,7 +44,7 @@ fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> let mut line = 1; let mut end_of_last_cap = 0; date_regex - .captures_iter(&text) + .captures_iter(text) .map(|cap| { ( cap.get(0).unwrap().range(), From 5524470c1cf2661bcf19ae83ea33327ddce104f4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 17 Jul 2022 22:44:57 +0200 Subject: [PATCH 03/20] update date-check docs --- src/contributing.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/contributing.md b/src/contributing.md index 45f8c9033..487a41414 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -439,15 +439,8 @@ Just a few things to keep in mind: - The date the comment was added, e.g. instead of writing _"Currently, ..."_ or _"As of now, ..."_, consider writing _"As of January 2021, ..."_. - Try to format the date as ` ` to ease search. - - - Additionally, include a machine-readable comment of the form `` (if the current month is April 2022). We have an automated - tool that uses these (in `ci/date-check`). - - So, for the month of April 2022, the comment would look like: `As of April 2022`. Make sure to put the comment *between* `as of` - and `April 2022`; see [PR #1066][rdg#1066] for the rationale. + We have CI action (in `"~/.github/workflows/date-check.yml"`) + that generates an issue if any of these are over 6 months old. - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not @@ -459,7 +452,6 @@ Just a few things to keep in mind: [rdg]: https://rustc-dev-guide.rust-lang.org/ [rdgrepo]: https://github.com/rust-lang/rustc-dev-guide -[rdg#1066]: https://github.com/rust-lang/rustc-dev-guide/pull/1066 ## Issue Triage From d946154764d0cc2bd8ddd43819fc0b73e2ee48a8 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 18 Jul 2022 20:50:58 +0200 Subject: [PATCH 04/20] accept review suggestion Co-authored-by: Noah Lev --- src/contributing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/contributing.md b/src/contributing.md index 487a41414..6a9186cee 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -439,8 +439,8 @@ Just a few things to keep in mind: - The date the comment was added, e.g. instead of writing _"Currently, ..."_ or _"As of now, ..."_, consider writing _"As of January 2021, ..."_. - We have CI action (in `"~/.github/workflows/date-check.yml"`) - that generates an issue if any of these are over 6 months old. + We have a CI action (in `~/.github/workflows/date-check.yml`) + that generates a monthly issue with any of these that are over 6 months old. - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not From 9eef34fedd36fc21445aebb63e759361b6765ce7 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 18 Jul 2022 22:18:42 +0200 Subject: [PATCH 05/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#pullrequestreview-1042163557 --- src/contributing.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/contributing.md b/src/contributing.md index 6a9186cee..0a868c93b 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -442,6 +442,12 @@ Just a few things to keep in mind: We have a CI action (in `~/.github/workflows/date-check.yml`) that generates a monthly issue with any of these that are over 6 months old. + The following formats are accepted: + - Jan 2021 + - January 2021 + - jan 2021 + - january 2021 + - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not outdated. From c9fcae3d6b462a83db07bef1205eccd008ea0c24 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 18 Jul 2022 22:24:09 +0200 Subject: [PATCH 06/20] accept review suggestion Co-authored-by: Noah Lev --- ci/date-check/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 1da49311c..20fb514c7 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -37,7 +37,7 @@ impl fmt::Display for Date { } fn make_date_regex() -> Regex { - Regex::new(r"[aA]s of (\w+) (\d{4})").unwrap() + Regex::new(r"[aA]s\s+of\s+(\w+)\s+(\d{4})").unwrap() } fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> { From f4803a77e3a6c6883497dd115092a04e0a87fd9e Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 18 Jul 2022 22:26:28 +0200 Subject: [PATCH 07/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#pullrequestreview-1042167261 --- ci/date-check/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 20fb514c7..bb92f0198 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -186,7 +186,7 @@ mod tests { fn test_collect_dates_from_file() { let text = "Test1\nAs of Jan 2021\nTest2\nAs of Feb 2021 \ \nTest3\nTest4\nAs of march 2021Bar\nas of apr 2021 \ - \nTest5\nTest6\nTest7\n\n\nas of may 2021\nTest8 + \nTest5\nTest6\nTest7\n\n\nas of\n\n may 2021\nTest8 "; assert_eq!( collect_dates_from_file(&make_date_regex(), text), @@ -220,7 +220,7 @@ mod tests { } ), ( - 14, + 16, Date { year: 2021, month: 5, From e82c2457b42c93f92b235d9461a7ba09ed92bd76 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sat, 30 Jul 2022 21:58:09 +0200 Subject: [PATCH 08/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#issuecomment-1189105017 --- ci/date-check/src/main.rs | 171 +++++++++++++----- src/backend/backend-agnostic.md | 2 +- src/backend/updating-llvm.md | 4 +- .../region_inference/member_constraints.md | 2 +- src/contributing.md | 24 ++- src/conventions.md | 2 +- src/crates-io.md | 2 +- src/diagnostics/diagnostic-items.md | 2 +- src/diagnostics/lintstore.md | 2 +- src/diagnostics/translation.md | 2 +- src/git.md | 2 +- src/llvm-coverage-instrumentation.md | 5 +- src/opaque-types-type-alias-impl-trait.md | 2 +- src/overview.md | 2 +- src/parallel-rustc.md | 8 +- src/profiling.md | 2 +- .../query-evaluation-model-in-detail.md | 2 +- src/query.md | 2 +- src/rustc-driver-getting-diagnostics.md | 2 +- src/rustc-driver-interacting-with-the-ast.md | 2 +- src/rustdoc-internals.md | 2 +- src/salsa.md | 2 +- src/tests/compiletest.md | 2 +- src/the-parser.md | 2 +- src/thir.md | 2 +- src/traits/chalk.md | 2 +- src/traits/resolution.md | 2 +- src/type-inference.md | 2 +- 28 files changed, 178 insertions(+), 80 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index bb92f0198..2a9da89ec 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -8,7 +8,7 @@ use std::{ use chrono::{Datelike as _, Month, TimeZone as _, Utc}; use glob::glob; -use regex::Regex; +use regex::{Regex, RegexSet}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] struct Date { @@ -36,41 +36,56 @@ impl fmt::Display for Date { } } -fn make_date_regex() -> Regex { - Regex::new(r"[aA]s\s+of\s+(\w+)\s+(\d{4})").unwrap() +fn make_date_regex() -> Vec { + let patterns = [ + r"", + r"\s+(\w+)\s+(\d+{4})", + ]; + let set = RegexSet::new(&patterns).unwrap(); + set.patterns() + .iter() + .map(|pattern| Regex::new(pattern).unwrap()) + .collect() } -fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> { - let mut line = 1; - let mut end_of_last_cap = 0; - date_regex - .captures_iter(text) - .map(|cap| { - ( - cap.get(0).unwrap().range(), - Date { - year: cap[2].parse().unwrap(), - month: Month::from_str(&cap[1]).unwrap().number_from_month(), - }, - ) - }) - .map(|(byte_range, date)| { - line += text[end_of_last_cap..byte_range.end] - .chars() - .filter(|c| *c == '\n') - .count(); - end_of_last_cap = byte_range.end; - (line, date) - }) - .collect() +fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Date)> { + let mut output = Vec::new(); + for date_regex in date_regexes { + let mut line = 1; + let mut end_of_last_cap = 0; + let results: Vec<_> = date_regex + .captures_iter(text) + .filter_map(|cap| { + if let (Some(year), Some(month)) = (cap.get(2), cap.get(1)) { + let year = year.as_str().parse().expect("year"); + let month = Month::from_str(month.as_str()) + .expect("month") + .number_from_month(); + Some((cap.get(0).expect("all").range(), Date { year, month })) + } else { + None + } + }) + .map(|(byte_range, date)| { + line += text[end_of_last_cap..byte_range.end] + .chars() + .filter(|c| *c == '\n') + .count(); + end_of_last_cap = byte_range.end; + (line, date) + }) + .collect(); + output.extend(results); + } + output } fn collect_dates(paths: impl Iterator) -> BTreeMap> { - let date_regex = make_date_regex(); + let date_regexes = make_date_regex(); let mut data = BTreeMap::new(); for path in paths { let text = fs::read_to_string(&path).unwrap(); - let dates = collect_dates_from_file(&date_regex, &text); + let dates = collect_dates_from_file(&date_regexes, &text); if !dates.is_empty() { data.insert(path, dates); } @@ -174,59 +189,129 @@ mod tests { #[test] fn test_date_regex() { - let regex = make_date_regex(); - assert!(regex.is_match("As of July 2022")); - assert!(regex.is_match("As of Jul 2022")); - assert!(regex.is_match("As of july 2022")); - assert!(regex.is_match("As of jul 2022")); - assert!(regex.is_match("as of jul 2022")); + let regexes = &make_date_regex(); + assert!(regexes[0].is_match("")); + assert!(regexes[0].is_match("")); + assert!(regexes[0].is_match("")); + assert!(regexes[0].is_match("")); + assert!(regexes[1].is_match(" jan 2021")); + assert!(regexes[1].is_match(" january 2021")); + assert!(regexes[1].is_match(" Jan 2021")); + assert!(regexes[1].is_match(" January 2021")); } #[test] fn test_collect_dates_from_file() { - let text = "Test1\nAs of Jan 2021\nTest2\nAs of Feb 2021 \ - \nTest3\nTest4\nAs of march 2021Bar\nas of apr 2021 \ - \nTest5\nTest6\nTest7\n\n\nas of\n\n may 2021\nTest8 + let text = r" +Test1 + +Test2 +Foo +Test3 +Test4 +FooBar + +Test5 +Test6 +Test7 + +Test8 +Test1 + jan 2021 +Test2 +Foo february 2021 +Test3 +Test4 +Foo mar 2021 Bar + apr 2021 +Test5 +Test6 +Test7 + may 2021 +Test8 \ "; assert_eq!( collect_dates_from_file(&make_date_regex(), text), vec![ ( - 2, + 3, + Date { + year: 2021, + month: 1, + } + ), + ( + 6, + Date { + year: 2021, + month: 2, + } + ), + ( + 9, + Date { + year: 2021, + month: 3, + } + ), + ( + 11, + Date { + year: 2021, + month: 4, + } + ), + ( + 17, + Date { + year: 2021, + month: 5, + } + ), + ( + 20, Date { year: 2021, month: 1, } ), ( - 4, + 23, Date { year: 2021, month: 2, } ), ( - 7, + 26, Date { year: 2021, month: 3, } ), ( - 8, + 28, Date { year: 2021, month: 4, } ), ( - 16, + 34, Date { year: 2021, month: 5, } ), - ] + ], ); } } diff --git a/src/backend/backend-agnostic.md b/src/backend/backend-agnostic.md index 17a1e8f7a..c88f06f8c 100644 --- a/src/backend/backend-agnostic.md +++ b/src/backend/backend-agnostic.md @@ -2,7 +2,7 @@ -As of October 2021, `rustc_codegen_ssa` provides an +As of October 2021, `rustc_codegen_ssa` provides an abstract interface for all backends to implement, to allow other codegen backends (e.g. [Cranelift]). diff --git a/src/backend/updating-llvm.md b/src/backend/updating-llvm.md index 0de0767b6..8c9c60f5f 100644 --- a/src/backend/updating-llvm.md +++ b/src/backend/updating-llvm.md @@ -66,8 +66,8 @@ Example PRs look like: ## Feature updates -> Note that this information is as of the time of this writing (October 2021). The process for updating LLVM changes with +> Note that this information is as of the time of this writing, + October 2021. The process for updating LLVM changes with practically all LLVM updates, so this may be out of date! Unlike bugfixes, updating to pick up a new feature of LLVM typically requires a diff --git a/src/borrow_check/region_inference/member_constraints.md b/src/borrow_check/region_inference/member_constraints.md index 77776986a..e236e0124 100644 --- a/src/borrow_check/region_inference/member_constraints.md +++ b/src/borrow_check/region_inference/member_constraints.md @@ -94,7 +94,7 @@ member constraints come in. ## Choices are always lifetime parameters At present, the "choice" regions from a member constraint are always lifetime -parameters from the current function. As of October 2021, +parameters from the current function. As of October 2021, this falls out from the placement of impl Trait, though in the future it may not be the case. We take some advantage of this fact, as it simplifies the current code. In particular, we don't have to consider a case like `'0 member of ['1, diff --git a/src/contributing.md b/src/contributing.md index 0a868c93b..6c445763f 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -437,17 +437,29 @@ Just a few things to keep in mind: the project. - The date the comment was added, e.g. instead of writing _"Currently, ..."_ - or _"As of now, ..."_, consider writing - _"As of January 2021, ..."_. - We have a CI action (in `~/.github/workflows/date-check.yml`) - that generates a monthly issue with any of these that are over 6 months old. - - The following formats are accepted: + or _"As of now, ..."_, + consider adding the date, in one of the following formats: - Jan 2021 - January 2021 - jan 2021 - january 2021 + There is a CI action (in "~/.github/workflows/date-check.yml") + that generates a monthly issue with any of these that are over 6 months old. + + For the action to pick the date, add this annotation: + + + + Example: + + As of Jul 2022, the foo did the bar. + + For cases where the date should not be part of the visible rendered output, + use the following instead: + + + - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not outdated. diff --git a/src/conventions.md b/src/conventions.md index 0f51fefcd..0d5f17b99 100644 --- a/src/conventions.md +++ b/src/conventions.md @@ -21,7 +21,7 @@ Formatting is checked by the `tidy` script. It runs automatically when you do If you want to use format-on-save in your editor, the pinned version of `rustfmt` is built under `build//stage0/bin/rustfmt`. You'll have to -pass the `--edition=2021` argument yourself when calling +pass the `--edition=2021` argument yourself when calling `rustfmt` directly. [fmt]: https://github.com/rust-dev-tools/fmt-rfcs diff --git a/src/crates-io.md b/src/crates-io.md index d7c7f25ed..83751c942 100644 --- a/src/crates-io.md +++ b/src/crates-io.md @@ -12,7 +12,7 @@ reasons: - The dependency may have transitive dependencies that have one of the above problems. -As of February 2022, there is no official policy for vetting +As of February 2022, there is no official policy for vetting new dependencies to the compiler. Generally, new dependencies are not added to the compiler unless there is a good reason to do so. diff --git a/src/diagnostics/diagnostic-items.md b/src/diagnostics/diagnostic-items.md index 0717444ce..d83f079d5 100644 --- a/src/diagnostics/diagnostic-items.md +++ b/src/diagnostics/diagnostic-items.md @@ -43,7 +43,7 @@ A new diagnostic item can be added with these two steps: For the naming conventions of diagnostic items, please refer to [*Naming Conventions*](#naming-conventions). -2. As of February 2022, diagnostic items in code are +2. As of February 2022, diagnostic items in code are accessed via symbols in [`rustc_span::symbol::sym`]. To add your newly created diagnostic item simply open the module file and add the name (In this case `Cat`) at the correct point in the list. diff --git a/src/diagnostics/lintstore.md b/src/diagnostics/lintstore.md index 78b6da27a..2ba5d6771 100644 --- a/src/diagnostics/lintstore.md +++ b/src/diagnostics/lintstore.md @@ -17,7 +17,7 @@ default lint level and other metadata come from. These are normally defined by way of the [`declare_lint!`] macro, which boils down to a static with type `&rustc_session::lint::Lint`. -As of February 2022, we lint against direct declarations +As of February 2022, we lint against direct declarations without the use of the macro today (although this may change in the future, as the macro is somewhat unwieldy to add new fields to, like all macros). diff --git a/src/diagnostics/translation.md b/src/diagnostics/translation.md index 07599f516..86ce68543 100644 --- a/src/diagnostics/translation.md +++ b/src/diagnostics/translation.md @@ -217,7 +217,7 @@ returned by `Emitter::fluent_bundle`. This bundle is used preferentially when translating messages, the fallback bundle is only used if the primary bundle is missing a message or not provided. -As of June 2022, there are no locale bundles +As of June 2022, there are no locale bundles distributed with the compiler, but mechanisms are implemented for loading bundles. diff --git a/src/git.md b/src/git.md index a32e3cd4d..d32274c64 100644 --- a/src/git.md +++ b/src/git.md @@ -157,7 +157,7 @@ no changes added to commit (use "git add" and/or "git commit -a") These changes are not changes to files: they are changes to submodules (more on this [later](#git-submodules)). To get rid of those, run `git submodule update` (or run any `x.py` command, which will automatically update the submodules). -Note that there is (as of February 2022) a [bug][#77620] if you use +Note that there is (as of February 2022) a [bug][#77620] if you use worktrees, submodules, and `x.py` in a commit hook. If you run into an error like: diff --git a/src/llvm-coverage-instrumentation.md b/src/llvm-coverage-instrumentation.md index d6d3880b5..b186f4820 100644 --- a/src/llvm-coverage-instrumentation.md +++ b/src/llvm-coverage-instrumentation.md @@ -222,9 +222,10 @@ properly-configured variables in LLVM IR, according to very specific details of the [_LLVM Coverage Mapping Format_][coverage-mapping-format] (Version 6).[^llvm-and-covmap-versions] -[^llvm-and-covmap-versions]: The Rust compiler (as of December 2021) +[^llvm-and-covmap-versions]: The Rust compiler (as of December 2021) supports _LLVM Coverage Mapping Format_ Version 5 or 6. Version 5 -was introduced in _LLVM 12_, which is (as of this writing) the minimum LLVM +was introduced in _LLVM 12_, +which is (as of this writing) the minimum LLVM version supported by the current version of Rust. Version 6 was introduced in _LLVM 13_, which is currently the default LLVM version for Rust. The Rust compiler will automatically use the most up-to-date coverage mapping format diff --git a/src/opaque-types-type-alias-impl-trait.md b/src/opaque-types-type-alias-impl-trait.md index a2d513a63..956f56828 100644 --- a/src/opaque-types-type-alias-impl-trait.md +++ b/src/opaque-types-type-alias-impl-trait.md @@ -15,7 +15,7 @@ it implements `Bar`. Therefore, any of `Bar`'s interface can be used on a `Foo`, but nothing else (regardless of whether it implements any other traits). Since there needs to be a concrete background type, -you can (as of January 2021) express that type +you can (as of January 2021) express that type by using the opaque type in a "defining use site". ```rust,ignore diff --git a/src/overview.md b/src/overview.md index fb49c8638..c7da92542 100644 --- a/src/overview.md +++ b/src/overview.md @@ -292,7 +292,7 @@ Moreover, the compiler wasn't originally built to use a query system; the query system has been retrofitted into the compiler, so parts of it are not query-fied yet. Also, LLVM isn't our code, so that isn't querified either. The plan is to eventually query-fy all of the steps listed in the previous section, -but as of November 2021, only the steps between HIR and +but as of November 2021, only the steps between HIR and LLVM IR are query-fied. That is, lexing, parsing, name resolution, and macro expansion are done all at once for the whole program. diff --git a/src/parallel-rustc.md b/src/parallel-rustc.md index 4400e2b64..a69bdec91 100644 --- a/src/parallel-rustc.md +++ b/src/parallel-rustc.md @@ -1,6 +1,6 @@ # Parallel Compilation -As of May 2022, The only stage of the compiler +As of May 2022, The only stage of the compiler that is already parallel is codegen. The nightly compiler implements query evaluation, but there is still a lot of work to be done. The lack of parallelism at other stages also represents an opportunity for improving compiler performance. One can try out the current @@ -54,13 +54,13 @@ When a query `foo` is evaluated, the cache table for `foo` is locked. ## Rustdoc -As of May 2022, there are still a number of steps +As of May 2022, there are still a number of steps to complete before rustdoc rendering can be made parallel. More details on this issue can be found [here][parallel-rustdoc]. ## Current Status -As of May 2022, work on explicitly parallelizing the +As of May 2022, work on explicitly parallelizing the compiler has stalled. There is a lot of design and correctness work that needs to be done. @@ -76,7 +76,7 @@ These are the basic ideas in the effort to make `rustc` parallel: [`rayon`]: https://crates.io/crates/rayon -As of May 2022, much of this effort is on hold due +As of May 2022, much of this effort is on hold due to lack of manpower. We have a working prototype with promising performance gains in many cases. However, there are two blockers: diff --git a/src/profiling.md b/src/profiling.md index f0fc76f59..e1666e237 100644 --- a/src/profiling.md +++ b/src/profiling.md @@ -108,6 +108,6 @@ The llvm-lines output is affected by several options. MIR optimizations have little impact. Compared to the default `RUSTFLAGS="-Z mir-opt-level=1"`, level 0 adds 0.3GB and level 2 removes 0.2GB. -As of July 2022, +As of July 2022, inlining happens in LLVM and GCC codegen backends, missing only in the Cranelift one. diff --git a/src/queries/query-evaluation-model-in-detail.md b/src/queries/query-evaluation-model-in-detail.md index 43ffe0a1d..8a08f1e04 100644 --- a/src/queries/query-evaluation-model-in-detail.md +++ b/src/queries/query-evaluation-model-in-detail.md @@ -76,7 +76,7 @@ executed, no results are cached. But the context already provides access to "input" data, i.e. pieces of immutable data that were computed before the context was created and that queries can access to do their computations. -As of January 2021, this input data consists mainly of +As of January 2021, this input data consists mainly of the HIR map, upstream crate metadata, and the command-line options the compiler was invoked with; but in the future inputs will just consist of command-line options and a list of source files -- the HIR map will itself be provided by a diff --git a/src/query.md b/src/query.md index 222e90742..3d60059bd 100644 --- a/src/query.md +++ b/src/query.md @@ -3,7 +3,7 @@ As described in [the high-level overview of the compiler][hl], the Rust compiler -is still (as of July 2021) transitioning from a +is still (as of July 2021) transitioning from a traditional "pass-based" setup to a "demand-driven" system. The compiler query system is the key to rustc's demand-driven organization. The idea is pretty simple. Instead of entirely independent passes diff --git a/src/rustc-driver-getting-diagnostics.md b/src/rustc-driver-getting-diagnostics.md index bac16138c..5ce93c3df 100644 --- a/src/rustc-driver-getting-diagnostics.md +++ b/src/rustc-driver-getting-diagnostics.md @@ -7,7 +7,7 @@ To get diagnostics from the compiler, configure `rustc_interface::Config` to output diagnostic to a buffer, and run `TyCtxt.analysis`. The following was tested -with `nightly-2022-06-05` (See [here][example] +with `nightly-2022-06-05` (See [here][example] for the complete example): [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs diff --git a/src/rustc-driver-interacting-with-the-ast.md b/src/rustc-driver-interacting-with-the-ast.md index 7eae2fb71..ce53f3861 100644 --- a/src/rustc-driver-interacting-with-the-ast.md +++ b/src/rustc-driver-interacting-with-the-ast.md @@ -5,7 +5,7 @@ ## Getting the type of an expression To get the type of an expression, use the `global_ctxt` to get a `TyCtxt`. -The following was tested with `nightly-2022-06-05` +The following was tested with `nightly-2022-06-05` (see [here][example] for the complete example): [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-interacting-with-the-ast.rs diff --git a/src/rustdoc-internals.md b/src/rustdoc-internals.md index 1ac74b119..f21c8725c 100644 --- a/src/rustdoc-internals.md +++ b/src/rustdoc-internals.md @@ -66,7 +66,7 @@ these passes, please let us know!) [44136]: https://github.com/rust-lang/rust/issues/44136 -Here is the list of passes as of May 2022: +Here is the list of passes as of May 2022: - `calculate-doc-coverage` calculates information used for the `--show-coverage` flag. diff --git a/src/salsa.md b/src/salsa.md index 96215186e..872308e78 100644 --- a/src/salsa.md +++ b/src/salsa.md @@ -9,7 +9,7 @@ want to watch [Salsa In More Depth](https://www.youtube.com/watch?v=i_IhACacPRY), also by Niko Matsakis. -> As of April 2022, although Salsa is inspired by +> As of April 2022, although Salsa is inspired by > (among other things) rustc's query system, it is not used directly in rustc. > It _is_ used in chalk and extensively in `rust-analyzer`, but there are no > medium or long-term concrete plans to integrate it into the compiler. diff --git a/src/tests/compiletest.md b/src/tests/compiletest.md index a01fc4de0..70cef2ad3 100644 --- a/src/tests/compiletest.md +++ b/src/tests/compiletest.md @@ -452,7 +452,7 @@ fn main() { ## Revisions -Certain classes of tests support "revisions" (as of July 2022, +Certain classes of tests support "revisions" (as of July 2022, this includes UI, assembly, codegen, debuginfo, incremental, and rustdoc UI tests, though incremental tests are somewhat different). Revisions allow a single test file to be used for multiple tests. diff --git a/src/the-parser.md b/src/the-parser.md index c37083c78..3482d2d75 100644 --- a/src/the-parser.md +++ b/src/the-parser.md @@ -1,6 +1,6 @@ # Lexing and Parsing -As of January 2021, the lexer and parser are undergoing +As of January 2021, the lexer and parser are undergoing refactoring to allow extracting them into libraries. The very first thing the compiler does is take the program (in Unicode diff --git a/src/thir.md b/src/thir.md index 2f75f4c7d..04af75f9e 100644 --- a/src/thir.md +++ b/src/thir.md @@ -4,7 +4,7 @@ The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for "High-Level Abstract IR", is another IR used by rustc that is generated after -[type checking]. It is (as of April 2022) only used for +[type checking]. It is (as of April 2022) only used for [MIR construction] and [exhaustiveness checking]. There is also [an experimental unsafety checker][thir-unsafeck] that operates on the THIR as a replacement for the current MIR unsafety checker, and can be used instead of the MIR unsafety checker by passing diff --git a/src/traits/chalk.md b/src/traits/chalk.md index 3708f6b3e..78deb3675 100644 --- a/src/traits/chalk.md +++ b/src/traits/chalk.md @@ -1,7 +1,7 @@ # Chalk-based trait solving [Chalk][chalk] is an experimental trait solver for Rust that is -(as of May 2022) under development by the [Types team]. +(as of May 2022) under development by the [Types team]. Its goal is to enable a lot of trait system features and bug fixes that are hard to implement (e.g. GATs or specialization). If you would like to help in hacking on the new solver, drop by on the rust-lang Zulip in the [`#t-types`] diff --git a/src/traits/resolution.md b/src/traits/resolution.md index 0ffcc7ee4..195fe6050 100644 --- a/src/traits/resolution.md +++ b/src/traits/resolution.md @@ -120,7 +120,7 @@ the obligation contains unbound inference variables. The subroutines that decide whether a particular impl/where-clause/etc applies to a particular obligation are collectively referred to as the process of -_matching_. As of May 2022, this amounts to unifying +_matching_. As of May 2022, this amounts to unifying the `Self` types, but in the future we may also recursively consider some of the nested obligations, in the case of an impl. diff --git a/src/type-inference.md b/src/type-inference.md index e4fc248e4..c3467a3a8 100644 --- a/src/type-inference.md +++ b/src/type-inference.md @@ -72,7 +72,7 @@ inference works, or perhaps this blog post on [Unification in the Chalk project]: http://smallcultfollowing.com/babysteps/blog/2017/03/25/unification-in-chalk-part-1/ All told, the inference context stores five kinds of inference variables -(as of June 2021): +(as of June 2021): - Type variables, which come in three varieties: - General type variables (the most common). These can be unified with any From df6b80508d59cac399d8cd94b9fb6d9d2caf94e6 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 21:00:03 +0200 Subject: [PATCH 09/20] this breaks markdown --- src/backend/updating-llvm.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/updating-llvm.md b/src/backend/updating-llvm.md index 8c9c60f5f..bd5b1277d 100644 --- a/src/backend/updating-llvm.md +++ b/src/backend/updating-llvm.md @@ -66,9 +66,9 @@ Example PRs look like: ## Feature updates -> Note that this information is as of the time of this writing, - October 2021. The process for updating LLVM changes with -practically all LLVM updates, so this may be out of date! +> Note that this information is as of the time of this writing, October 2021. The process for updating LLVM changes with +> practically all LLVM updates, so this may be out of date! Unlike bugfixes, updating to pick up a new feature of LLVM typically requires a lot more work. This is where we can't reasonably cherry-pick commits backwards From 3faf82c00ef1e511943bd9cd7f0e6a3ef636671a Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:00:27 +0200 Subject: [PATCH 10/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934018268 This led to a more robust regex, though making the tool more picky. It also found a wrong date format that was missed. --- ci/date-check/src/main.rs | 18 ++++++++++++++++-- src/building/suggested.md | 2 +- src/contributing.md | 5 +++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 2a9da89ec..273e07a69 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -38,8 +38,8 @@ impl fmt::Display for Date { fn make_date_regex() -> Vec { let patterns = [ - r"", - r"\s+(\w+)\s+(\d+{4})", + r"", + r"\s+(\D+)\s+(\d{4})\b", ]; let set = RegexSet::new(&patterns).unwrap(); set.patterns() @@ -198,6 +198,20 @@ mod tests { assert!(regexes[1].is_match(" january 2021")); assert!(regexes[1].is_match(" Jan 2021")); assert!(regexes[1].is_match(" January 2021")); + + assert!(regexes[1].is_match(" jan 2021 ")); + assert!(regexes[1].is_match(" jan 2021.")); + } + + #[test] + fn test_date_regex_fail() { + let regexes = &make_date_regex(); + assert!(!regexes[0].is_match("")); + assert!(!regexes[0].is_match("")); + assert!(!regexes[0].is_match("")); + assert!(!regexes[1].is_match(" jan 221")); + assert!(!regexes[1].is_match(" jan 20222")); + assert!(!regexes[1].is_match(" 01 2021")); } #[test] diff --git a/src/building/suggested.md b/src/building/suggested.md index 1c2229335..3e077977d 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -22,7 +22,7 @@ You can also install the hook as a step of running `./x.py setup`! a file. By default, `rust-analyzer` runs the `cargo check` and `rustfmt` commands, but you can override these commands to use more adapted versions of these tools when hacking on `rustc`. For example, for Visual Studio Code, -you can write: +you can write: ```JSON { diff --git a/src/contributing.md b/src/contributing.md index 6c445763f..2a337c807 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -447,9 +447,10 @@ Just a few things to keep in mind: There is a CI action (in "~/.github/workflows/date-check.yml") that generates a monthly issue with any of these that are over 6 months old. - For the action to pick the date, add this annotation: + For the action to pick the date, + add a special annotation before specifying the date: - + Jul 2022 Example: From 74b9b456c16f8a6bf49d68fe8646e70c4a5afa0f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:09:30 +0200 Subject: [PATCH 11/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934018419 --- ci/date-check/src/main.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 273e07a69..c022a05a8 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -8,7 +8,7 @@ use std::{ use chrono::{Datelike as _, Month, TimeZone as _, Utc}; use glob::glob; -use regex::{Regex, RegexSet}; +use regex::Regex; #[derive(Debug, Copy, Clone, PartialEq, Eq)] struct Date { @@ -37,15 +37,10 @@ impl fmt::Display for Date { } fn make_date_regex() -> Vec { - let patterns = [ - r"", - r"\s+(\D+)\s+(\d{4})\b", - ]; - let set = RegexSet::new(&patterns).unwrap(); - set.patterns() - .iter() - .map(|pattern| Regex::new(pattern).unwrap()) - .collect() + Vec::from([ + Regex::new(r"").unwrap(), + Regex::new(r"\s+(\D+)\s+(\d{4})\b").unwrap(), + ]) } fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Date)> { From ea2f1c2977ab7e4ef6613699acfa42b7a2525bff Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:30:14 +0200 Subject: [PATCH 12/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934018816 --- ci/date-check/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index c022a05a8..21f04f1e0 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -72,6 +72,7 @@ fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Da .collect(); output.extend(results); } + output.sort_by(|a, b| a.0.cmp(&b.0)); output } From e697cb6cbe9c50a122edc8bc00e3878e211e1764 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:34:30 +0200 Subject: [PATCH 13/20] accept review suggestion This was reverted by mistake Co-authored-by: Noah Lev --- src/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contributing.md b/src/contributing.md index 2a337c807..217a8fb15 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -444,7 +444,7 @@ Just a few things to keep in mind: - jan 2021 - january 2021 - There is a CI action (in "~/.github/workflows/date-check.yml") + There is a CI action (in `~/.github/workflows/date-check.yml`) that generates a monthly issue with any of these that are over 6 months old. For the action to pick the date, From dcfb9730663e57a852d4d35f6db5b9942eed8967 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:43:59 +0200 Subject: [PATCH 14/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934019395 --- src/contributing.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/contributing.md b/src/contributing.md index 217a8fb15..e59bb0a77 100644 --- a/src/contributing.md +++ b/src/contributing.md @@ -450,16 +450,22 @@ Just a few things to keep in mind: For the action to pick the date, add a special annotation before specifying the date: - Jul 2022 + ```md + Jul 2022 + ``` Example: - As of Jul 2022, the foo did the bar. + ```md + As of Jul 2022, the foo did the bar. + ``` For cases where the date should not be part of the visible rendered output, use the following instead: - + ```md + + ``` - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not From ade29246e2f60f25901f5362a84be00dca2f8154 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 22:55:22 +0200 Subject: [PATCH 15/20] use a more simple fn --- ci/date-check/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 21f04f1e0..ddbabc116 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -72,7 +72,7 @@ fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Da .collect(); output.extend(results); } - output.sort_by(|a, b| a.0.cmp(&b.0)); + output.sort_by_key(|a| a.0); output } From 2a5b586c24d4bed7b78227d5a5481bbb6b47e5ff Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 23:26:41 +0200 Subject: [PATCH 16/20] address review comment https://github.com/rust-lang/rustc-dev-guide/pull/1394#discussion_r934018981 Much more clean --- ci/date-check/src/main.rs | 109 +++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index ddbabc116..069e2179d 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -36,52 +36,51 @@ impl fmt::Display for Date { } } -fn make_date_regex() -> Vec { - Vec::from([ - Regex::new(r"").unwrap(), - Regex::new(r"\s+(\D+)\s+(\d{4})\b").unwrap(), - ]) +fn make_date_regex() -> Regex { + Regex::new( + r"(?x) + (?:)| + (?:\s+(\D+)\s+(\d{4})\b) + ", + ) + .unwrap() } -fn collect_dates_from_file(date_regexes: &[Regex], text: &str) -> Vec<(usize, Date)> { - let mut output = Vec::new(); - for date_regex in date_regexes { - let mut line = 1; - let mut end_of_last_cap = 0; - let results: Vec<_> = date_regex - .captures_iter(text) - .filter_map(|cap| { - if let (Some(year), Some(month)) = (cap.get(2), cap.get(1)) { - let year = year.as_str().parse().expect("year"); - let month = Month::from_str(month.as_str()) - .expect("month") - .number_from_month(); - Some((cap.get(0).expect("all").range(), Date { year, month })) - } else { - None - } - }) - .map(|(byte_range, date)| { - line += text[end_of_last_cap..byte_range.end] - .chars() - .filter(|c| *c == '\n') - .count(); - end_of_last_cap = byte_range.end; - (line, date) - }) - .collect(); - output.extend(results); - } - output.sort_by_key(|a| a.0); - output +fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> { + let mut line = 1; + let mut end_of_last_cap = 0; + date_regex + .captures_iter(text) + .filter_map(|cap| { + if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) = + (cap.get(1), cap.get(2), cap.get(3), cap.get(4)) + { + let year = year.as_str().parse().expect("year"); + let month = Month::from_str(month.as_str()) + .expect("month") + .number_from_month(); + Some((cap.get(0).expect("all").range(), Date { year, month })) + } else { + None + } + }) + .map(|(byte_range, date)| { + line += text[end_of_last_cap..byte_range.end] + .chars() + .filter(|c| *c == '\n') + .count(); + end_of_last_cap = byte_range.end; + (line, date) + }) + .collect() } fn collect_dates(paths: impl Iterator) -> BTreeMap> { - let date_regexes = make_date_regex(); + let date_regex = make_date_regex(); let mut data = BTreeMap::new(); for path in paths { let text = fs::read_to_string(&path).unwrap(); - let dates = collect_dates_from_file(&date_regexes, &text); + let dates = collect_dates_from_file(&date_regex, &text); if !dates.is_empty() { data.insert(path, dates); } @@ -185,29 +184,29 @@ mod tests { #[test] fn test_date_regex() { - let regexes = &make_date_regex(); - assert!(regexes[0].is_match("")); - assert!(regexes[0].is_match("")); - assert!(regexes[0].is_match("")); - assert!(regexes[0].is_match("")); - assert!(regexes[1].is_match(" jan 2021")); - assert!(regexes[1].is_match(" january 2021")); - assert!(regexes[1].is_match(" Jan 2021")); - assert!(regexes[1].is_match(" January 2021")); + let regex = &make_date_regex(); + assert!(regex.is_match("")); + assert!(regex.is_match("")); + assert!(regex.is_match("")); + assert!(regex.is_match("")); + assert!(regex.is_match(" jan 2021")); + assert!(regex.is_match(" january 2021")); + assert!(regex.is_match(" Jan 2021")); + assert!(regex.is_match(" January 2021")); - assert!(regexes[1].is_match(" jan 2021 ")); - assert!(regexes[1].is_match(" jan 2021.")); + assert!(regex.is_match(" jan 2021 ")); + assert!(regex.is_match(" jan 2021.")); } #[test] fn test_date_regex_fail() { let regexes = &make_date_regex(); - assert!(!regexes[0].is_match("")); - assert!(!regexes[0].is_match("")); - assert!(!regexes[0].is_match("")); - assert!(!regexes[1].is_match(" jan 221")); - assert!(!regexes[1].is_match(" jan 20222")); - assert!(!regexes[1].is_match(" 01 2021")); + assert!(!regexes.is_match("")); + assert!(!regexes.is_match("")); + assert!(!regexes.is_match("")); + assert!(!regexes.is_match(" jan 221")); + assert!(!regexes.is_match(" jan 20222")); + assert!(!regexes.is_match(" 01 2021")); } #[test] From 483a0a5ab774c7de5557229539249f696e199050 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 31 Jul 2022 23:29:36 +0200 Subject: [PATCH 17/20] nit --- ci/date-check/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 069e2179d..95c38038a 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -39,7 +39,8 @@ impl fmt::Display for Date { fn make_date_regex() -> Regex { Regex::new( r"(?x) - (?:)| + (?:) + | (?:\s+(\D+)\s+(\d{4})\b) ", ) From 456008cc35de0597d26fec0030ee5db8a0c2fb65 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Tue, 2 Aug 2022 05:38:20 +0200 Subject: [PATCH 18/20] accept review suggestion Co-authored-by: Noah Lev --- ci/date-check/src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 95c38038a..710aadf61 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -38,10 +38,18 @@ impl fmt::Display for Date { fn make_date_regex() -> Regex { Regex::new( - r"(?x) - (?:) + r"(?x) # insignificant whitespace mode + ( + ) | - (?:\s+(\D+)\s+(\d{4})\b) + (\s+ + (?P\D+)\s+ + (?P\d{4})\b + ) ", ) .unwrap() From c60a8882da2395d42a2fa2e8ccf93f9c0cb3fbda Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 1 Aug 2022 22:08:20 +0200 Subject: [PATCH 19/20] avoid a failed regex Also, test new shape --- ci/date-check/src/main.rs | 12 +++++++++++- src/backend/updating-llvm.md | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index 710aadf61..e8da89f6b 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -254,7 +254,10 @@ Test7 may 2021 -Test8 \ +Test8 + june 2021. "; assert_eq!( collect_dates_from_file(&make_date_regex(), text), @@ -329,6 +332,13 @@ Test8 \ month: 5, } ), + ( + 38, + Date { + year: 2021, + month: 6, + } + ), ], ); } diff --git a/src/backend/updating-llvm.md b/src/backend/updating-llvm.md index bd5b1277d..fdee14e95 100644 --- a/src/backend/updating-llvm.md +++ b/src/backend/updating-llvm.md @@ -67,8 +67,8 @@ Example PRs look like: ## Feature updates > Note that this information is as of the time of this writing, October 2021. The process for updating LLVM changes with -> practically all LLVM updates, so this may be out of date! +date-check --> October 2021. The process for updating LLVM changes with +practically all LLVM updates, so this may be out of date! Unlike bugfixes, updating to pick up a new feature of LLVM typically requires a lot more work. This is where we can't reasonably cherry-pick commits backwards From 86ecc94580b547a65be0fa7b09db71b626470fea Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Tue, 2 Aug 2022 05:48:31 +0200 Subject: [PATCH 20/20] adjust to new regex (which uses named groups) New regex was introduced by 456008cc35de0597d26fec0030ee5db8a0c2fb65 --- ci/date-check/src/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index e8da89f6b..626278ddb 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -61,9 +61,12 @@ fn collect_dates_from_file(date_regex: &Regex, text: &str) -> Vec<(usize, Date)> date_regex .captures_iter(text) .filter_map(|cap| { - if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) = - (cap.get(1), cap.get(2), cap.get(3), cap.get(4)) - { + if let (Some(month), Some(year), None, None) | (None, None, Some(month), Some(year)) = ( + cap.name("m1"), + cap.name("y1"), + cap.name("m2"), + cap.name("y2"), + ) { let year = year.as_str().parse().expect("year"); let month = Month::from_str(month.as_str()) .expect("month") @@ -229,7 +232,7 @@ FooBar - Test5 Test6