Skip to content

Commit b570c88

Browse files
committed
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"
1 parent 7955bb3 commit b570c88

26 files changed

+45
-55
lines changed

Diff for: ci/date-check/src/main.rs

+13-23
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use std::{
33
convert::TryInto as _,
44
env, fmt, fs,
55
path::{Path, PathBuf},
6+
str::FromStr,
67
};
78

8-
use chrono::{Datelike as _, TimeZone as _, Utc};
9+
use chrono::{Datelike as _, Month, TimeZone as _, Utc};
910
use glob::glob;
1011
use regex::Regex;
1112

@@ -36,16 +37,7 @@ impl fmt::Display for Date {
3637
}
3738

3839
fn make_date_regex() -> Regex {
39-
Regex::new(
40-
r"(?x) # insignificant whitespace mode
41-
<!--\s*
42-
[dD]ate:\s*
43-
(?P<y>\d{4}) # year
44-
-
45-
(?P<m>\d{2}) # month
46-
\s*-->",
47-
)
48-
.unwrap()
40+
Regex::new(r"[aA]s of (\w+) (\d{4})").unwrap()
4941
}
5042

5143
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)>
5749
(
5850
cap.get(0).unwrap().range(),
5951
Date {
60-
year: cap["y"].parse().unwrap(),
61-
month: cap["m"].parse().unwrap(),
52+
year: cap[2].parse().unwrap(),
53+
month: Month::from_str(&cap[1]).unwrap().number_from_month(),
6254
},
6355
)
6456
})
@@ -183,20 +175,18 @@ mod tests {
183175
#[test]
184176
fn test_date_regex() {
185177
let regex = make_date_regex();
186-
assert!(regex.is_match("foo <!-- date: 2021-01 --> bar"));
187-
}
188-
189-
#[test]
190-
fn test_date_regex_capitalized() {
191-
let regex = make_date_regex();
192-
assert!(regex.is_match("foo <!-- Date: 2021-08 --> bar"));
178+
assert!(regex.is_match("As of July 2022"));
179+
assert!(regex.is_match("As of Jul 2022"));
180+
assert!(regex.is_match("As of july 2022"));
181+
assert!(regex.is_match("As of jul 2022"));
182+
assert!(regex.is_match("as of jul 2022"));
193183
}
194184

195185
#[test]
196186
fn test_collect_dates_from_file() {
197-
let text = "Test1\n<!-- date: 2021-01 -->\nTest2\nFoo<!-- date: 2021-02 \
198-
-->\nTest3\nTest4\nFoo<!-- date: 2021-03 -->Bar\n<!-- date: 2021-04 \
199-
-->\nTest5\nTest6\nTest7\n<!-- date: \n\n2021-05 -->\nTest8
187+
let text = "Test1\nAs of Jan 2021\nTest2\nAs of Feb 2021 \
188+
\nTest3\nTest4\nAs of march 2021Bar\nas of apr 2021 \
189+
\nTest5\nTest6\nTest7\n\n\nas of may 2021\nTest8
200190
";
201191
assert_eq!(
202192
collect_dates_from_file(&make_date_regex(), text),

Diff for: src/backend/backend-agnostic.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- toc -->
44

5-
As of <!-- date: 2021-10 --> October 2021, `rustc_codegen_ssa` provides an
5+
As of October 2021, `rustc_codegen_ssa` provides an
66
abstract interface for all backends to implement, to allow other codegen
77
backends (e.g. [Cranelift]).
88

Diff for: src/borrow_check/region_inference/member_constraints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ member constraints come in.
9494
## Choices are always lifetime parameters
9595

9696
At present, the "choice" regions from a member constraint are always lifetime
97-
parameters from the current function. As of <!-- date: 2021-10 --> October 2021,
97+
parameters from the current function. As of October 2021,
9898
this falls out from the placement of impl Trait, though in the future it may not
9999
be the case. We take some advantage of this fact, as it simplifies the current
100100
code. In particular, we don't have to consider a case like `'0 member of ['1,

Diff for: src/conventions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ special config, so this may result in different style from normal [`rustfmt`].
1414
Therefore, formatting this repository using `cargo fmt` is not recommended.
1515

1616
Instead, formatting should be done using `./x.py fmt`. It's a good habit to run
17-
`./x.py fmt` before every commit, as this reduces conflicts later.
17+
`./x.py fmt` before every commit, as this reduces conflicts later.
1818

1919
Formatting is checked by the `tidy` script. It runs automatically when you do
2020
`./x.py test` and can be run in isolation with `./x.py fmt --check`.
2121

2222
If you want to use format-on-save in your editor, the pinned version of
2323
`rustfmt` is built under `build/<target>/stage0/bin/rustfmt`. You'll have to
24-
pass the <!-- date: 2022-04 --> `--edition=2021` argument yourself when calling
24+
pass the <!-- as of April 2022 --> `--edition=2021` argument yourself when calling
2525
`rustfmt` directly.
2626

2727
[fmt]: https://github.com/rust-dev-tools/fmt-rfcs

Diff for: src/crates-io.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ reasons:
1212
- The dependency may have transitive dependencies that have one of the above
1313
problems.
1414

15-
As of <!-- date: 2022-02 --> February 2022, there is no official policy for vetting
15+
As of February 2022, there is no official policy for vetting
1616
new dependencies to the compiler. Generally, new dependencies are not added
1717
to the compiler unless there is a good reason to do so.
1818

Diff for: src/diagnostics/diagnostic-items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ A new diagnostic item can be added with these two steps:
4343
For the naming conventions of diagnostic items, please refer to
4444
[*Naming Conventions*](#naming-conventions).
4545

46-
2. As of <!-- date: 2022-02 --> February 2022, diagnostic items in code are
46+
2. As of February 2022, diagnostic items in code are
4747
accessed via symbols in [`rustc_span::symbol::sym`]. To add your newly
4848
created diagnostic item simply open the module file and add the name (In
4949
this case `Cat`) at the correct point in the list.

Diff for: src/diagnostics/lintstore.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default lint level and other metadata come from. These are normally defined by
1717
way of the [`declare_lint!`] macro, which boils down to a static with type
1818
`&rustc_session::lint::Lint`.
1919

20-
As of <!-- date: 2022-02 --> February 2022, we lint against direct declarations
20+
As of February 2022, we lint against direct declarations
2121
without the use of the macro today (although this may change in the future, as
2222
the macro is somewhat unwieldy to add new fields to, like all macros).
2323

Diff for: src/diagnostics/translation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ returned by `Emitter::fluent_bundle`. This bundle is used preferentially when
217217
translating messages, the fallback bundle is only used if the primary bundle is
218218
missing a message or not provided.
219219

220-
As of <!-- date: 2022-06 --> June 2022, there are no locale bundles
220+
As of June 2022, there are no locale bundles
221221
distributed with the compiler, but mechanisms are implemented for loading
222222
bundles.
223223

Diff for: src/git.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ no changes added to commit (use "git add" and/or "git commit -a")
157157
These changes are not changes to files: they are changes to submodules (more on
158158
this [later](#git-submodules)). To get rid of those, run `git submodule update`
159159
(or run any `x.py` command, which will automatically update the submodules).
160-
Note that there is (as of <!-- date: 2022-02 --> February 2022) a [bug][#77620] if you use
160+
Note that there is (as of February 2022) a [bug][#77620] if you use
161161
worktrees, submodules, and `x.py` in a commit hook. If you run into an error
162162
like:
163163

Diff for: src/llvm-coverage-instrumentation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ properly-configured variables in LLVM IR, according to very specific
222222
details of the [_LLVM Coverage Mapping Format_][coverage-mapping-format]
223223
(Version 6).[^llvm-and-covmap-versions]
224224

225-
[^llvm-and-covmap-versions]: The Rust compiler (as of <!-- date: 2021-12 -->
226-
December 2021) supports _LLVM Coverage Mapping Format_ Version 5 or 6. Version 5
225+
[^llvm-and-covmap-versions]: The Rust compiler (as of December 2021)
226+
supports _LLVM Coverage Mapping Format_ Version 5 or 6. Version 5
227227
was introduced in _LLVM 12_, which is (as of this writing) the minimum LLVM
228228
version supported by the current version of Rust. Version 6 was introduced in
229229
_LLVM 13_, which is currently the default LLVM version for Rust. The Rust

Diff for: src/opaque-types-type-alias-impl-trait.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ This declares an opaque type named `Foo`, of which the only information is that
1414
it implements `Bar`. Therefore, any of `Bar`'s interface can be used on a `Foo`,
1515
but nothing else (regardless of whether it implements any other traits).
1616

17-
Since there needs to be a concrete background type, you can (as of <!-- date:
18-
2021-01 --> January 2021) express that type by using the opaque type in a
19-
"defining use site".
17+
Since there needs to be a concrete background type,
18+
you can (as of January 2021) express that type
19+
by using the opaque type in a "defining use site".
2020

2121
```rust,ignore
2222
struct Struct;

Diff for: src/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Moreover, the compiler wasn't originally built to use a query system; the query
292292
system has been retrofitted into the compiler, so parts of it are not query-fied
293293
yet. Also, LLVM isn't our code, so that isn't querified either. The plan is to
294294
eventually query-fy all of the steps listed in the previous section,
295-
but as of <!-- date: 2021-11 --> November 2021, only the steps between HIR and
295+
but as of November 2021, only the steps between HIR and
296296
LLVM IR are query-fied. That is, lexing, parsing, name resolution, and macro
297297
expansion are done all at once for the whole program.
298298

Diff for: src/parallel-rustc.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Parallel Compilation
22

3-
As of <!-- date: 2022-05 --> May 2022, The only stage of the compiler
3+
As of May 2022, The only stage of the compiler
44
that is already parallel is codegen. The nightly compiler implements query evaluation,
55
but there is still a lot of work to be done. The lack of parallelism at other stages
66
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].
6060

6161
## Current Status
6262

63-
As of <!-- date: 2022-05 --> May 2022, work on explicitly parallelizing the
63+
As of May 2022, work on explicitly parallelizing the
6464
compiler has stalled. There is a lot of design and correctness work that needs
6565
to be done.
6666

@@ -76,7 +76,7 @@ These are the basic ideas in the effort to make `rustc` parallel:
7676

7777
[`rayon`]: https://crates.io/crates/rayon
7878

79-
As of <!-- date: 2022-05 --> May 2022, much of this effort is on hold due
79+
As of May 2022, much of this effort is on hold due
8080
to lack of manpower. We have a working prototype with promising performance
8181
gains in many cases. However, there are two blockers:
8282

Diff for: src/profiling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ The llvm-lines output is affected by several options.
108108

109109
MIR optimizations have little impact. Compared to the default `RUSTFLAGS="-Z
110110
mir-opt-level=1"`, level 0 adds 0.3GB and level 2 removes 0.2GB.
111-
As of <!-- date: 2022-07 --> July 2022,
111+
As of July 2022,
112112
inlining happens in LLVM and GCC codegen backends,
113113
missing only in the Cranelift one.

Diff for: src/queries/query-evaluation-model-in-detail.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ executed, no results are cached. But the context already provides access to
7676
"input" data, i.e. pieces of immutable data that were computed before the
7777
context was created and that queries can access to do their computations.
7878

79-
As of <!-- date: 2021-01 --> January 2021, this input data consists mainly of
79+
As of January 2021, this input data consists mainly of
8080
the HIR map, upstream crate metadata, and the command-line options the compiler
8181
was invoked with; but in the future inputs will just consist of command-line
8282
options and a list of source files -- the HIR map will itself be provided by a

Diff for: src/query.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- toc -->
44

55
As described in [the high-level overview of the compiler][hl], the Rust compiler
6-
is still (as of <!-- date: 2021-07 --> July 2021) transitioning from a
6+
is still (as of July 2021) transitioning from a
77
traditional "pass-based" setup to a "demand-driven" system. The compiler query
88
system is the key to rustc's demand-driven organization.
99
The idea is pretty simple. Instead of entirely independent passes

Diff for: src/rustc-driver-getting-diagnostics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
To get diagnostics from the compiler,
88
configure `rustc_interface::Config` to output diagnostic to a buffer,
99
and run `TyCtxt.analysis`. The following was tested
10-
with <!-- date: 2022-06 --> `nightly-2022-06-05` (See [here][example]
10+
with <!-- as of June 2022 --> `nightly-2022-06-05` (See [here][example]
1111
for the complete example):
1212

1313
[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs

Diff for: src/rustc-driver-interacting-with-the-ast.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Getting the type of an expression
66

77
To get the type of an expression, use the `global_ctxt` to get a `TyCtxt`.
8-
The following was tested with <!-- date: 2022-06 --> `nightly-2022-06-05`
8+
The following was tested with <!-- as of June 2022 --> `nightly-2022-06-05`
99
(see [here][example] for the complete example):
1010

1111
[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-interacting-with-the-ast.rs

Diff for: src/rustdoc-internals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ these passes, please let us know!)
6666

6767
[44136]: https://github.com/rust-lang/rust/issues/44136
6868

69-
Here is the list of passes as of <!-- date: 2022-05 --> May 2022:
69+
Here is the list of passes as of May 2022:
7070

7171
- `calculate-doc-coverage` calculates information used for the `--show-coverage`
7272
flag.

Diff for: src/salsa.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ want to watch [Salsa In More
99
Depth](https://www.youtube.com/watch?v=i_IhACacPRY), also by Niko
1010
Matsakis.
1111

12-
> As of <!-- date: 2022-04 --> April 2022, although Salsa is inspired by
12+
> As of April 2022, although Salsa is inspired by
1313
> (among other things) rustc's query system, it is not used directly in rustc.
1414
> It _is_ used in chalk and extensively in `rust-analyzer`, but there are no
1515
> medium or long-term concrete plans to integrate it into the compiler.

Diff for: src/tests/compiletest.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn main() {
452452

453453
## Revisions
454454

455-
Certain classes of tests support "revisions" (as of <!-- date: 2022-07 --> July 2022,
455+
Certain classes of tests support "revisions" (as of July 2022,
456456
this includes UI, assembly, codegen, debuginfo, incremental, and rustdoc UI tests,
457457
though incremental tests are somewhat different).
458458
Revisions allow a single test file to be used for multiple tests.

Diff for: src/the-parser.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lexing and Parsing
22

3-
As of <!-- date: 2021-01 --> January 2021, the lexer and parser are undergoing
3+
As of January 2021, the lexer and parser are undergoing
44
refactoring to allow extracting them into libraries.
55

66
The very first thing the compiler does is take the program (in Unicode

Diff for: src/thir.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The THIR ("Typed High-Level Intermediate Representation"), previously called HAIR for
66
"High-Level Abstract IR", is another IR used by rustc that is generated after
7-
[type checking]. It is (as of <!-- date: 2022-04 --> April 2022) only used for
7+
[type checking]. It is (as of April 2022) only used for
88
[MIR construction] and [exhaustiveness checking]. There is also
99
[an experimental unsafety checker][thir-unsafeck] that operates on the THIR as a replacement for
1010
the current MIR unsafety checker, and can be used instead of the MIR unsafety checker by passing

Diff for: src/traits/chalk.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Chalk-based trait solving
22

3-
[Chalk][chalk] is an experimental trait solver for Rust that is (as of <!--
4-
date: 2022-05 --> May 2022) under development by the [Types team].
3+
[Chalk][chalk] is an experimental trait solver for Rust that is
4+
(as of May 2022) under development by the [Types team].
55
Its goal is to enable a lot of trait system features and bug fixes
66
that are hard to implement (e.g. GATs or specialization). If you would like to
77
help in hacking on the new solver, drop by on the rust-lang Zulip in the [`#t-types`]

Diff for: src/traits/resolution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ the obligation contains unbound inference variables.
120120

121121
The subroutines that decide whether a particular impl/where-clause/etc applies
122122
to a particular obligation are collectively referred to as the process of
123-
_matching_. As of <!-- date: 2022-05 --> May 2022, this amounts to unifying
123+
_matching_. As of May 2022, this amounts to unifying
124124
the `Self` types, but in the future we may also recursively consider some of the
125125
nested obligations, in the case of an impl.
126126

Diff for: src/type-inference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ inference works, or perhaps this blog post on
7272
[Unification in the Chalk project]: http://smallcultfollowing.com/babysteps/blog/2017/03/25/unification-in-chalk-part-1/
7373

7474
All told, the inference context stores five kinds of inference variables
75-
(as of <!-- date: 2021-06 --> June 2021):
75+
(as of June 2021):
7676

7777
- Type variables, which come in three varieties:
7878
- General type variables (the most common). These can be unified with any

0 commit comments

Comments
 (0)