Repository: tikv/tikv
File: components/resolved_ts/src/endpoint.rs (Rust)

Code before:
        self.memory_quota.free(size);
        RTS_CHANNEL_PENDING_CMD_BYTES.sub(size as i64);
        for batch in cmd_batch {
            if batch.is_empty() {
                continue;
            }
            if let Some(observe_region) = self.regions.get_mut(&batch.region_id) {
                let observe_id = batch.rts_id;
                let region_id = observe_region.meta.id;
                if observe_region.handle.id == observe_id {
                    let logs = ChangeLog::encode_change_log(region_id, batch);
                    if let Err(e) = observe_region.track_change_log(&logs) {
                        drop(observe_region);
                        match e {
                            cause @ Error::MemoryQuotaExceeded(_) => {
                                self.re_register_all_regions(Some(cause.to_string().as_str()));
                            }
                            cause @ Error::Other(_) => {
                                self.re_register_region(
                                    region_id,
                                    observe_id,
                                    Some(cause.to_string().as_str()),
                                    None,
                                );
                            }
                        };
                    }
                } else {
                    debug!("resolved ts CmdBatch discarded";
                        "region_id" => batch.region_id,
                        "observe_id" => ?batch.rts_id,
                        "current" => ?observe_region.handle.id,
                    );
                }
            }
        }
        fail_point!("resolved_ts_after_handle_change_log");
    }

    fn handle_scan_locks(
        &mut self,
        region_id: u64,
        observe_id: ObserveId,
        entries: ScanEntries,
        apply_index: u64,
    ) {
        let mut memory_quota_exceeded = None;
        if let Some(observe_region) = self.regions.get_mut(&region_id) {
            if observe_region.handle.id == observe_id {
                if let Err(Error::MemoryQuotaExceeded(e)) =
                    observe_region.track_scan_locks(entries, apply_index)

Review comment (suggestion):
There's a stray semicolon after a match expression. In Rust, match is an expression that returns a value, but here both branches of the match (lines 959-961 and 962-969) have no return value. The semicolon on line 970 is unnecessary and makes the code less clear. Consider removing it or ensuring the match expression is properly structured.
```suggestion
                        }
```

Code after:
        self.memory_quota.free(size);
        RTS_CHANNEL_PENDING_CMD_BYTES.sub(size as i64);
        for batch in cmd_batch {
            if batch.is_empty() {
                continue;
            }
            if let Some(observe_region) = self.regions.get_mut(&batch.region_id) {
                let observe_id = batch.rts_id;
                let region_id = observe_region.meta.id;
                if observe_region.handle.id == observe_id {
                    let logs = ChangeLog::encode_change_log(region_id, batch);
                    if let Err(e) = observe_region.track_change_log(&logs) {
                        drop(observe_region);
                        match e {
                            cause @ Error::MemoryQuotaExceeded(_) => {
                                self.re_register_all_regions(Some(&cause.to_string()));
                            }
                            cause @ Error::Other(_) => {
                                self.re_register_region(
                                    region_id,
                                    observe_id,
                                    Some(&cause.to_string()),
                                    None,
                                );
                            }
                        };
                    }
                } else {
                    debug!("resolved ts CmdBatch discarded";
                        "region_id" => batch.region_id,
                        "observe_id" => ?batch.rts_id,
                        "current" => ?observe_region.handle.id,
                    );
                }
            }
        }
        fail_point!("resolved_ts_after_handle_change_log");
    }

    fn handle_scan_locks(
        &mut self,
        region_id: u64,
        observe_id: ObserveId,
        entries: ScanEntries,
        apply_index: u64,
    ) {
        let mut memory_quota_exceeded = None;
        if let Some(observe_region) = self.regions.get_mut(&region_id) {
            if observe_region.handle.id == observe_id {
                if let Err(Error::MemoryQuotaExceeded(e)) =
                    observe_region.track_scan_locks(entries, apply_index)