Skip to content

Commit f9516a3

Browse files
committed
Avoid using the cell_leak feature
1 parent 07a6cc5 commit f9516a3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

rustfmt-core/rustfmt-lib/src/formatting/report.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::cell::{Ref, RefCell};
1+
use std::cell::RefCell;
22
use std::collections::{BTreeMap, BTreeSet, HashSet};
33
use std::rc::Rc;
44

@@ -92,8 +92,9 @@ impl FormatReport {
9292
/// various warnings and errors encountered during formatting.
9393
//
9494
// NOTE: Avoid using this method internally: use `format_result_as_rc` instead.
95-
pub fn format_result(&self) -> impl Iterator<Item = (&FileName, &FormatResult)> {
96-
Ref::leak(RefCell::borrow(&self.format_result)).iter()
95+
// FIXME(topecongiro): Avoid requiring a mutable reference.
96+
pub fn format_result(&mut self) -> impl Iterator<Item = (&FileName, &FormatResult)> {
97+
Rc::make_mut(&mut self.format_result).get_mut().iter()
9798
}
9899

99100
pub(crate) fn format_result_as_rc(&self) -> Rc<RefCell<BTreeMap<FileName, FormatResult>>> {

rustfmt-core/rustfmt-lib/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![deny(rust_2018_idioms)]
22
#![warn(unreachable_pub)]
3-
#![feature(cell_leak)]
43

54
#[macro_use]
65
extern crate lazy_static;

rustfmt-core/rustfmt-lib/src/test/configuration_snippet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl ConfigCodeBlock {
186186
return false;
187187
}
188188

189-
let report = report.unwrap();
189+
let mut report = report.unwrap();
190190
let result = report.format_result().next().unwrap();
191191
let text = result.1.formatted_text();
192192
!self.formatted_has_diff(text)

rustfmt-core/rustfmt-lib/src/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn idempotent_check(
651651
} else {
652652
read_config(filename)
653653
};
654-
let format_report = match format_file(filename, builder, config) {
654+
let mut format_report = match format_file(filename, builder, config) {
655655
Ok(report) => report,
656656
Err(_) => return Err(IdempotentCheckError::Parse),
657657
};

0 commit comments

Comments
 (0)