std: Remove `RefCell::set()`
This commit is contained in:
parent
7bcfe2ee10
commit
3961957bd6
|
@ -212,9 +212,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
|
|||
let time_passes = sess.time_passes();
|
||||
|
||||
sess.building_library.set(session::building_library(&sess.opts, &krate));
|
||||
sess.crate_types.set(session::collect_crate_types(sess,
|
||||
krate.attrs
|
||||
.as_slice()));
|
||||
*sess.crate_types.borrow_mut() = session::collect_crate_types(sess, krate.attrs.as_slice());
|
||||
|
||||
time(time_passes, "gated feature checking", (), |_|
|
||||
front::feature_gate::check_crate(sess, &krate));
|
||||
|
|
|
@ -123,13 +123,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
|
|||
|
||||
fn configure_main(this: &mut EntryContext) {
|
||||
if this.start_fn.is_some() {
|
||||
this.session.entry_fn.set(this.start_fn);
|
||||
*this.session.entry_fn.borrow_mut() = this.start_fn;
|
||||
this.session.entry_type.set(Some(session::EntryStart));
|
||||
} else if this.attr_main_fn.is_some() {
|
||||
this.session.entry_fn.set(this.attr_main_fn);
|
||||
*this.session.entry_fn.borrow_mut() = this.attr_main_fn;
|
||||
this.session.entry_type.set(Some(session::EntryMain));
|
||||
} else if this.main_fn.is_some() {
|
||||
this.session.entry_fn.set(this.main_fn);
|
||||
*this.session.entry_fn.borrow_mut() = this.main_fn;
|
||||
this.session.entry_type.set(Some(session::EntryMain));
|
||||
} else {
|
||||
if !this.session.building_library.get() {
|
||||
|
|
|
@ -553,20 +553,20 @@ impl NameBindings {
|
|||
let type_def = self.type_def.borrow().clone();
|
||||
match type_def {
|
||||
None => {
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
is_public: is_public,
|
||||
module_def: Some(module_),
|
||||
type_def: None,
|
||||
type_span: Some(sp)
|
||||
}));
|
||||
});
|
||||
}
|
||||
Some(type_def) => {
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
is_public: is_public,
|
||||
module_def: Some(module_),
|
||||
type_span: Some(sp),
|
||||
type_def: type_def.type_def
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,12 +584,12 @@ impl NameBindings {
|
|||
None => {
|
||||
let module = @Module::new(parent_link, def_id, kind,
|
||||
external, is_public);
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
is_public: is_public,
|
||||
module_def: Some(module),
|
||||
type_def: None,
|
||||
type_span: None,
|
||||
}))
|
||||
});
|
||||
}
|
||||
Some(type_def) => {
|
||||
match type_def.module_def {
|
||||
|
@ -599,12 +599,12 @@ impl NameBindings {
|
|||
kind,
|
||||
external,
|
||||
is_public);
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
is_public: is_public,
|
||||
module_def: Some(module),
|
||||
type_def: type_def.type_def,
|
||||
type_span: None,
|
||||
}))
|
||||
});
|
||||
}
|
||||
Some(module_def) => module_def.kind.set(kind),
|
||||
}
|
||||
|
@ -618,31 +618,31 @@ impl NameBindings {
|
|||
let type_def = self.type_def.borrow().clone();
|
||||
match type_def {
|
||||
None => {
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
module_def: None,
|
||||
type_def: Some(def),
|
||||
type_span: Some(sp),
|
||||
is_public: is_public,
|
||||
}));
|
||||
});
|
||||
}
|
||||
Some(type_def) => {
|
||||
self.type_def.set(Some(TypeNsDef {
|
||||
*self.type_def.borrow_mut() = Some(TypeNsDef {
|
||||
type_def: Some(def),
|
||||
type_span: Some(sp),
|
||||
module_def: type_def.module_def,
|
||||
is_public: is_public,
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Records a value definition.
|
||||
fn define_value(&self, def: Def, sp: Span, is_public: bool) {
|
||||
self.value_def.set(Some(ValueNsDef {
|
||||
*self.value_def.borrow_mut() = Some(ValueNsDef {
|
||||
def: def,
|
||||
value_span: Some(sp),
|
||||
is_public: is_public,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the module node if applicable.
|
||||
|
@ -2417,8 +2417,8 @@ impl<'a> Resolver<'a> {
|
|||
match value_result {
|
||||
BoundResult(target_module, name_bindings) => {
|
||||
debug!("(resolving single import) found value target");
|
||||
import_resolution.value_target.set(
|
||||
Some(Target::new(target_module, name_bindings)));
|
||||
*import_resolution.value_target.borrow_mut() =
|
||||
Some(Target::new(target_module, name_bindings));
|
||||
import_resolution.value_id.set(directive.id);
|
||||
value_used_public = name_bindings.defined_in_public_namespace(ValueNS);
|
||||
}
|
||||
|
@ -2431,8 +2431,8 @@ impl<'a> Resolver<'a> {
|
|||
BoundResult(target_module, name_bindings) => {
|
||||
debug!("(resolving single import) found type target: {:?}",
|
||||
{ name_bindings.type_def.borrow().clone().unwrap().type_def });
|
||||
import_resolution.type_target.set(
|
||||
Some(Target::new(target_module, name_bindings)));
|
||||
*import_resolution.type_target.borrow_mut() =
|
||||
Some(Target::new(target_module, name_bindings));
|
||||
import_resolution.type_id.set(directive.id);
|
||||
type_used_public = name_bindings.defined_in_public_namespace(TypeNS);
|
||||
}
|
||||
|
@ -2537,10 +2537,10 @@ impl<'a> Resolver<'a> {
|
|||
// Simple: just copy the old import resolution.
|
||||
let new_import_resolution =
|
||||
@ImportResolution::new(id, is_public);
|
||||
new_import_resolution.value_target.set(
|
||||
get(&target_import_resolution.value_target));
|
||||
new_import_resolution.type_target.set(
|
||||
get(&target_import_resolution.type_target));
|
||||
*new_import_resolution.value_target.borrow_mut() =
|
||||
get(&target_import_resolution.value_target);
|
||||
*new_import_resolution.type_target.borrow_mut() =
|
||||
get(&target_import_resolution.type_target);
|
||||
|
||||
import_resolutions.insert
|
||||
(*ident, new_import_resolution);
|
||||
|
@ -2554,8 +2554,7 @@ impl<'a> Resolver<'a> {
|
|||
// Continue.
|
||||
}
|
||||
Some(value_target) => {
|
||||
dest_import_resolution.value_target.set(
|
||||
Some(value_target));
|
||||
*dest_import_resolution.value_target.borrow_mut() = Some(value_target);
|
||||
}
|
||||
}
|
||||
match *target_import_resolution.type_target.borrow() {
|
||||
|
@ -2563,8 +2562,7 @@ impl<'a> Resolver<'a> {
|
|||
// Continue.
|
||||
}
|
||||
Some(type_target) => {
|
||||
dest_import_resolution.type_target.set(
|
||||
Some(type_target));
|
||||
*dest_import_resolution.type_target.borrow_mut() = Some(type_target);
|
||||
}
|
||||
}
|
||||
dest_import_resolution.is_public.set(is_public);
|
||||
|
@ -2636,14 +2634,14 @@ impl<'a> Resolver<'a> {
|
|||
// Merge the child item into the import resolution.
|
||||
if name_bindings.defined_in_public_namespace(ValueNS) {
|
||||
debug!("(resolving glob import) ... for value target");
|
||||
dest_import_resolution.value_target.set(
|
||||
Some(Target::new(containing_module, name_bindings)));
|
||||
*dest_import_resolution.value_target.borrow_mut() =
|
||||
Some(Target::new(containing_module, name_bindings));
|
||||
dest_import_resolution.value_id.set(id);
|
||||
}
|
||||
if name_bindings.defined_in_public_namespace(TypeNS) {
|
||||
debug!("(resolving glob import) ... for type target");
|
||||
dest_import_resolution.type_target.set(
|
||||
Some(Target::new(containing_module, name_bindings)));
|
||||
*dest_import_resolution.type_target.borrow_mut() =
|
||||
Some(Target::new(containing_module, name_bindings));
|
||||
dest_import_resolution.type_id.set(id);
|
||||
}
|
||||
dest_import_resolution.is_public.set(is_public);
|
||||
|
|
|
@ -1209,7 +1209,7 @@ pub fn init_function<'a>(
|
|||
param_substs: Option<@param_substs>) {
|
||||
let entry_bcx = fcx.new_temp_block("entry-block");
|
||||
|
||||
fcx.entry_bcx.set(Some(entry_bcx));
|
||||
*fcx.entry_bcx.borrow_mut() = Some(entry_bcx);
|
||||
|
||||
// Use a dummy instruction as the insertion point for all allocas.
|
||||
// This is later removed in FunctionContext::cleanup.
|
||||
|
|
|
@ -322,7 +322,7 @@ impl<'a> FunctionContext<'a> {
|
|||
.unwrap());
|
||||
}
|
||||
// Remove the cycle between fcx and bcx, so memory can be freed
|
||||
self.entry_bcx.set(None);
|
||||
*self.entry_bcx.borrow_mut() = None;
|
||||
}
|
||||
|
||||
pub fn get_llreturn(&self) -> BasicBlockRef {
|
||||
|
|
|
@ -3333,7 +3333,7 @@ pub fn check_block_with_expected(fcx: &FnCtxt,
|
|||
};
|
||||
});
|
||||
|
||||
fcx.ps.set(prev);
|
||||
*fcx.ps.borrow_mut() = prev;
|
||||
}
|
||||
|
||||
pub fn check_const(ccx: &CrateCtxt,
|
||||
|
|
|
@ -164,16 +164,6 @@ impl<T> RefCell<T> {
|
|||
None => fail!("RefCell<T> already borrowed")
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the value, replacing what was there.
|
||||
///
|
||||
/// # Failure
|
||||
///
|
||||
/// Fails if the value is currently borrowed.
|
||||
#[inline]
|
||||
pub fn set(&self, value: T) {
|
||||
*self.borrow_mut() = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for RefCell<T> {
|
||||
|
|
|
@ -652,7 +652,7 @@ mod tests {
|
|||
fn drop(&mut self) {
|
||||
let ii = &*self.i;
|
||||
let i = ii.borrow().clone();
|
||||
ii.set(i + 1);
|
||||
*ii.borrow_mut() = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ enum taggy {
|
|||
|
||||
fn f() {
|
||||
let a_box = @RefCell::new(nil);
|
||||
a_box.set(cons(a_box));
|
||||
*a_box.borrow_mut() = cons(a_box);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
@ -23,7 +23,7 @@ struct Pointy {
|
|||
|
||||
pub fn main() {
|
||||
let m = @RefCell::new(Pointy { x : no_pointy });
|
||||
m.set(Pointy {
|
||||
*m.borrow_mut() = Pointy {
|
||||
x: yes_pointy(m)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue