Allow AST and HIR visitors to return ControlFlow#121256
Merged
bors merged 1 commit intorust-lang:masterfrom Feb 20, 2024
Merged
Allow AST and HIR visitors to return ControlFlow#121256bors merged 1 commit intorust-lang:masterfrom
ControlFlow#121256bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
Contributor
Author
|
r? @oli-obk |
Contributor
|
@bors r+ rollup yea this seems like the best solution going forward. |
Collaborator
saethlin
added a commit
to saethlin/rust
that referenced
this pull request
Feb 20, 2024
Allow AST and HIR visitors to return `ControlFlow` Alternative to rust-lang#108598. Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 20, 2024
Rollup of 8 pull requests Successful merges: - rust-lang#120718 (Add "algebraic" fast-math intrinsics, based on fast-math ops that cannot return poison) - rust-lang#121195 (unstable-book: Separate testing and production sanitizers) - rust-lang#121205 (Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.) - rust-lang#121233 (Move the extra directives for `Mode::CoverageRun` into `iter_header`) - rust-lang#121256 (Allow AST and HIR visitors to return `ControlFlow`) - rust-lang#121307 (Drive-by `DUMMY_SP` -> `Span` and fmt changes) - rust-lang#121310 (Remove an old hack for rustdoc) - rust-lang#121311 (Make `is_nonoverlapping` `#[inline]`) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 20, 2024
Rollup of 10 pull requests Successful merges: - rust-lang#120716 (Change leak check and suspicious auto trait lint warning messages) - rust-lang#121195 (unstable-book: Separate testing and production sanitizers) - rust-lang#121205 (Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.) - rust-lang#121233 (Move the extra directives for `Mode::CoverageRun` into `iter_header`) - rust-lang#121256 (Allow AST and HIR visitors to return `ControlFlow`) - rust-lang#121307 (Drive-by `DUMMY_SP` -> `Span` and fmt changes) - rust-lang#121308 (Add regression test for rust-lang#103369) - rust-lang#121310 (Remove an old hack for rustdoc) - rust-lang#121311 (Make `is_nonoverlapping` `#[inline]`) - rust-lang#121319 (return `ty::Error` when equating `ty::Error`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 20, 2024
Rollup merge of rust-lang#121256 - Jarcho:visitor2, r=oli-obk Allow AST and HIR visitors to return `ControlFlow` Alternative to rust-lang#108598. Since rust-lang/libs-team#187 was rejected, this implements our own version of the `Try` trait (`VisitorResult`) and the `try` macro (`try_visit`). Since this change still allows visitors to return `()`, no changes have been made to the existing ones. They can be done in a separate PR.
scottmcm
reviewed
Feb 23, 2024
| pub trait VisitorResult { | ||
| type Residual; | ||
| fn output() -> Self; | ||
| fn from_residual(residual: Self::Residual) -> Self; |
Member
There was a problem hiding this comment.
Man, I wish the real Try could be this simple, but no, we're stuck with error conversion support :(
The simpler one is definitely the right choice for this visitor, though 👍
This was referenced Feb 24, 2024
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
Mar 4, 2024
Convert the rest of the visitors to use `VisitorResult` Continuing from rust-lang#121256.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 5, 2024
Convert the rest of the visitors to use `VisitorResult` Continuing from rust-lang#121256.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Mar 8, 2024
Use `ControlFlow` in visitors. Follow up to rust-lang#121256 This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 8, 2024
Rollup merge of rust-lang#121563 - Jarcho:use_cf, r=petrochenkov Use `ControlFlow` in visitors. Follow up to rust-lang#121256 This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #108598.
Since rust-lang/libs-team#187 was rejected, this implements our own version of the
Trytrait (VisitorResult) and thetrymacro (try_visit). Since this change still allows visitors to return(), no changes have been made to the existing ones. They can be done in a separate PR.