[Merged by Bors] - chore: automatically replace erw with rw that work as well#17615
[Merged by Bors] - chore: automatically replace erw with rw that work as well#17615Vierkantor wants to merge 3 commits intomasterfrom
erw with rw that work as well#17615Conversation
PR summary c989268a7eImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>The doc-module for |
|
Here's the |
|
Thanks 🎉 If CI passes, please remove the label bors d+ |
|
✌️ Vierkantor can now approve this pull request. To approve and merge a pull request, simply reply with |
This PR goes through the diff of #17615, which automatically replaced `erw` with `rw`) to clean up as follows: * delete obsolote comments * merge adjacent `rw` calls * restore old code that broke at some point but now works again
|
It builds now, so: bors r+ |
This is an automatically generated PR, replacing 259 `erw` calls with `rw` for free. I'm working on a follow-up that manually deals with the context around these `erw`s: deleting now-useless comments about `erw` and merging adjacent `rw` calls into one. Keeping the automatically generated changes apart from the manual ones should help with reviewing.
# How to reproduce this PR
Check out the branch `erw-to-rw-setup`. Run the command
```bash
lake build | grep '^info:' | awk -F ":" '{ print "-i ‘.bak’ -e "$3"s/erw/rw/ "$2; }' | xargs -L 1 sed
```
and `git diff` should show you exactly the same modifications as in this PR.
# Technical details
In `Mathlib.Tactic.Core` I added the following rule to `erw`:
```lean
import Mathlib.Tactic.TryThis
/-- if we call `erw`, first try running regular `rw` and warn if that succeds. -/
macro_rules
| `(tactic| erw $s $(loc)?) =>
`(tactic| try_this rw $(.none)? $s $(loc)?)
```
This makes `erw` display a "Try this:" message if `rw` would have succeeded as well. Beware that this does not mean that the file compiles just as well after doing the replacement, since a `rw` could succeed by rewriting a different term, so subsequent tactics fail. This is important for running the script!
With that edit in place, it's possible to run the script. This will parse the `lake build` output, looking for the lines produced by the macro rule, and replace `erw` with `rw` on the lines that it indicates. Note that it assumes there is at most one `erw` on one line; that was true at least when I ran the script.
|
This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried. |
This is an automatically generated PR, replacing 259 `erw` calls with `rw` for free. I'm working on a follow-up that manually deals with the context around these `erw`s: deleting now-useless comments about `erw` and merging adjacent `rw` calls into one. Keeping the automatically generated changes apart from the manual ones should help with reviewing.
# How to reproduce this PR
Check out the branch `erw-to-rw-setup`. Run the command
```bash
lake build | grep '^info:' | awk -F ":" '{ print "-i ‘.bak’ -e "$3"s/erw/rw/ "$2; }' | xargs -L 1 sed
```
and `git diff` should show you exactly the same modifications as in this PR.
# Technical details
In `Mathlib.Tactic.Core` I added the following rule to `erw`:
```lean
import Mathlib.Tactic.TryThis
/-- if we call `erw`, first try running regular `rw` and warn if that succeds. -/
macro_rules
| `(tactic| erw $s $(loc)?) =>
`(tactic| try_this rw $(.none)? $s $(loc)?)
```
This makes `erw` display a "Try this:" message if `rw` would have succeeded as well. Beware that this does not mean that the file compiles just as well after doing the replacement, since a `rw` could succeed by rewriting a different term, so subsequent tactics fail. This is important for running the script!
With that edit in place, it's possible to run the script. This will parse the `lake build` output, looking for the lines produced by the macro rule, and replace `erw` with `rw` on the lines that it indicates. Note that it assumes there is at most one `erw` on one line; that was true at least when I ran the script.
|
Pull request successfully merged into master. Build succeeded: |
erw with rw that work as wellerw with rw that work as well
This PR goes through the diff of #17615, which automatically replaced `erw` with `rw`) to clean up as follows: * delete obsolote comments * merge adjacent `rw` calls * restore old code that broke at some point but now works again
This PR goes through the diff of #17615, which automatically replaced `erw` with `rw`, to clean up as follows: * delete obsolote comments * merge adjacent `rw` calls * restore old code that was commented out when it broke at some point but now works again Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
This is an automatically generated PR, replacing 259
erwcalls withrwfor free. I'm working on a follow-up that manually deals with the context around theseerws: deleting now-useless comments abouterwand merging adjacentrwcalls into one. Keeping the automatically generated changes apart from the manual ones should help with reviewing.How to reproduce this PR
Check out the branch
erw-to-rw-setup. Run the commandand
git diffshould show you exactly the same modifications as in this PR.Technical details
In
Mathlib.Tactic.CoreI added the following rule toerw:This makes
erwdisplay a "Try this:" message ifrwwould have succeeded as well. Beware that this does not mean that the file compiles just as well after doing the replacement, since arwcould succeed by rewriting a different term, so subsequent tactics fail. This is important for running the script!With that edit in place, it's possible to run the script. This will parse the
lake buildoutput, looking for the lines produced by the macro rule, and replaceerwwithrwon the lines that it indicates. Note that it assumes there is at most oneerwon one line; that was true at least when I ran the script.