Skip to content

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Feb 18, 2024

Alternative to #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.

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2024

r? @pnkfelix

rustbot has assigned @pnkfelix.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 18, 2024
@Jarcho
Copy link
Contributor Author

Jarcho commented Feb 18, 2024

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned pnkfelix Feb 18, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Feb 19, 2024

@bors r+ rollup

yea this seems like the best solution going forward.

@bors
Copy link
Collaborator

bors commented Feb 19, 2024

📌 Commit 864cee3 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 19, 2024
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
@bors bors merged commit 46cab11 into rust-lang:master Feb 20, 2024
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
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.
pub trait VisitorResult {
type Residual;
fn output() -> Self;
fn from_residual(residual: Self::Residual) -> Self;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants