mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
Remove Copy
and destructure Snapshot
(#4358)
This commit is contained in:
parent
ea3d3a655d
commit
f4f88308ae
1 changed files with 11 additions and 5 deletions
|
@ -20,7 +20,7 @@ use crate::node::{NodeId, Nodes};
|
||||||
use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};
|
use crate::scope::{Scope, ScopeId, ScopeKind, Scopes};
|
||||||
|
|
||||||
/// A snapshot of the [`Context`] at a given point in the AST traversal.
|
/// A snapshot of the [`Context`] at a given point in the AST traversal.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct Snapshot {
|
pub struct Snapshot {
|
||||||
scope_id: ScopeId,
|
scope_id: ScopeId,
|
||||||
stmt_id: Option<NodeId>,
|
stmt_id: Option<NodeId>,
|
||||||
|
@ -457,9 +457,15 @@ impl<'a> Context<'a> {
|
||||||
|
|
||||||
/// Restore the context to the given [`Snapshot`].
|
/// Restore the context to the given [`Snapshot`].
|
||||||
pub fn restore(&mut self, snapshot: Snapshot) {
|
pub fn restore(&mut self, snapshot: Snapshot) {
|
||||||
self.scope_id = snapshot.scope_id;
|
let Snapshot {
|
||||||
self.stmt_id = snapshot.stmt_id;
|
scope_id,
|
||||||
self.in_annotation = snapshot.in_annotation;
|
stmt_id,
|
||||||
self.in_type_checking_block = snapshot.in_type_checking_block;
|
in_annotation,
|
||||||
|
in_type_checking_block,
|
||||||
|
} = snapshot;
|
||||||
|
self.scope_id = scope_id;
|
||||||
|
self.stmt_id = stmt_id;
|
||||||
|
self.in_annotation = in_annotation;
|
||||||
|
self.in_type_checking_block = in_type_checking_block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue