Rollup merge of #82353 - camelid:no-more-param_env-cell, r=jyn514

rustdoc: Remove unnecessary `Cell` around `param_env`

r? `@jyn514`
This commit is contained in:
Yuki Okushi 2021-02-22 18:26:09 +09:00 committed by GitHub
commit 4dfe69a6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -1519,7 +1519,7 @@ fn normalize(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
let normalized = cx.tcx.infer_ctxt().enter(|infcx| {
infcx
.at(&ObligationCause::dummy(), cx.param_env.get())
.at(&ObligationCause::dummy(), cx.param_env)
.normalize(lifted)
.map(|resolved| infcx.resolve_vars_if_possible(resolved.value))
});

View File

@ -26,10 +26,7 @@
use std::mem;
use std::rc::Rc;
use std::{
cell::{Cell, RefCell},
collections::hash_map::Entry,
};
use std::{cell::RefCell, collections::hash_map::Entry};
use crate::clean;
use crate::clean::inline::build_external_trait;
@ -49,7 +46,7 @@
/// Used for normalization.
///
/// Most of this logic is copied from rustc_lint::late.
crate param_env: Cell<ParamEnv<'tcx>>,
crate param_env: ParamEnv<'tcx>,
/// Later on moved into `cache`
crate renderinfo: RefCell<RenderInfo>,
/// Later on moved through `clean::Crate` into `cache`
@ -89,9 +86,9 @@ impl<'tcx> DocContext<'tcx> {
}
crate fn with_param_env<T, F: FnOnce(&mut Self) -> T>(&mut self, def_id: DefId, f: F) -> T {
let old_param_env = self.param_env.replace(self.tcx.param_env(def_id));
let old_param_env = mem::replace(&mut self.param_env, self.tcx.param_env(def_id));
let ret = f(self);
self.param_env.set(old_param_env);
self.param_env = old_param_env;
ret
}
@ -511,7 +508,7 @@ pub(crate) fn init_lints<F>(
let mut ctxt = DocContext {
tcx,
resolver,
param_env: Cell::new(ParamEnv::empty()),
param_env: ParamEnv::empty(),
external_traits: Default::default(),
active_extern_traits: Default::default(),
renderinfo: RefCell::new(renderinfo),