forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#107625 - matthiaskrgr:rollup-xr9oldy, r=matth…
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#106575 (Suggest `move` in nested closure when appropriate) - rust-lang#106805 (Suggest `{var:?}` when finding `{?:var}` in inline format strings) - rust-lang#107500 (Add tests to assert current behavior of large future sizes) - rust-lang#107598 (Fix benchmarks in library/core with black_box) - rust-lang#107602 (Parse and recover from type ascription in patterns) - rust-lang#107608 (Use triple rather than arch for fuchsia test-runner) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
21 changed files
with
521 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2043,6 +2043,28 @@ impl<'tcx> Ty<'tcx> { | |
cf.is_break() | ||
} | ||
|
||
/// Checks whether a type recursively contains any closure | ||
/// | ||
/// Example: `Option<[[email protected]:4:20]>` returns true | ||
pub fn contains_closure(self) -> bool { | ||
struct ContainsClosureVisitor; | ||
|
||
impl<'tcx> TypeVisitor<'tcx> for ContainsClosureVisitor { | ||
type BreakTy = (); | ||
|
||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { | ||
if let ty::Closure(_, _) = t.kind() { | ||
ControlFlow::Break(()) | ||
} else { | ||
t.super_visit_with(self) | ||
} | ||
} | ||
} | ||
|
||
let cf = self.visit_with(&mut ContainsClosureVisitor); | ||
cf.is_break() | ||
} | ||
|
||
/// Returns the type and mutability of `*ty`. | ||
/// | ||
/// The parameter `explicit` indicates if this is an *explicit* dereference. | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.