Auto merge of #98255 - Dylan-DPC:rollup-hr129rg, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #98105 (rustdoc: remove tuple link on round braces) - #98136 (Rename `impl_constness` to `constness`) - #98146 (Remove --memory-init-file flag when linking with Emscripten) - #98219 (Skip late bound regions in GATSubstCollector) - #98233 (Remove accidental uses of `&A: Allocator`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
68d0b29098
@ -1120,8 +1120,6 @@ impl<'a> Linker for EmLinker<'a> {
|
|||||||
OptLevel::Size => "-Os",
|
OptLevel::Size => "-Os",
|
||||||
OptLevel::SizeMin => "-Oz",
|
OptLevel::SizeMin => "-Oz",
|
||||||
});
|
});
|
||||||
// Unusable until https://github.com/rust-lang/rust/issues/38454 is resolved
|
|
||||||
self.cmd.args(&["--memory-init-file", "0"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pgo_gen(&mut self) {
|
fn pgo_gen(&mut self) {
|
||||||
|
@ -17,13 +17,14 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
|
|||||||
|
|
||||||
pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
let parent_id = tcx.local_parent(def_id);
|
let parent_id = tcx.local_parent(def_id);
|
||||||
tcx.def_kind(parent_id) == DefKind::Impl
|
tcx.def_kind(parent_id) == DefKind::Impl && tcx.constness(parent_id) == hir::Constness::Const
|
||||||
&& tcx.impl_constness(parent_id) == hir::Constness::Const
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether the function has a `const` modifier or, in case it is an intrinsic, whether
|
/// Checks whether an item is considered to be `const`. If it is a constructor, it is const. If
|
||||||
/// said intrinsic has a `rustc_const_{un,}stable` attribute.
|
/// it is a trait impl/function, return if it has a `const` modifier. If it is an intrinsic,
|
||||||
fn impl_constness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Constness {
|
/// report whether said intrinsic has a `rustc_const_{un,}stable` attribute. Otherwise, return
|
||||||
|
/// `Constness::NotConst`.
|
||||||
|
fn constness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Constness {
|
||||||
let def_id = def_id.expect_local();
|
let def_id = def_id.expect_local();
|
||||||
let node = tcx.hir().get_by_def_id(def_id);
|
let node = tcx.hir().get_by_def_id(def_id);
|
||||||
|
|
||||||
@ -77,5 +78,5 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers) {
|
pub fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers { impl_constness, is_promotable_const_fn, ..*providers };
|
*providers = Providers { constness, is_promotable_const_fn, ..*providers };
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
|||||||
callee = did;
|
callee = did;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
|
if let hir::Constness::NotConst = tcx.constness(data.impl_def_id) {
|
||||||
self.check_op(ops::FnCallNonConst {
|
self.check_op(ops::FnCallNonConst {
|
||||||
caller,
|
caller,
|
||||||
callee,
|
callee,
|
||||||
|
@ -214,7 +214,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||||||
impl_parent => { table }
|
impl_parent => { table }
|
||||||
impl_polarity => { table_direct }
|
impl_polarity => { table_direct }
|
||||||
impl_defaultness => { table_direct }
|
impl_defaultness => { table_direct }
|
||||||
impl_constness => { table_direct }
|
constness => { table_direct }
|
||||||
coerce_unsized_info => { table }
|
coerce_unsized_info => { table }
|
||||||
mir_const_qualif => { table }
|
mir_const_qualif => { table }
|
||||||
rendered_const => { table }
|
rendered_const => { table }
|
||||||
|
@ -1063,7 +1063,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
self.tables.constness.set(def_id.index, hir::Constness::Const);
|
||||||
record_array!(self.tables.children[def_id] <- variant.fields.iter().map(|f| {
|
record_array!(self.tables.children[def_id] <- variant.fields.iter().map(|f| {
|
||||||
assert!(f.did.is_local());
|
assert!(f.did.is_local());
|
||||||
f.did.index
|
f.did.index
|
||||||
@ -1092,7 +1092,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
record!(self.tables.kind[def_id] <- EntryKind::Variant(self.lazy(data)));
|
||||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
self.tables.constness.set(def_id.index, hir::Constness::Const);
|
||||||
self.encode_item_type(def_id);
|
self.encode_item_type(def_id);
|
||||||
if variant.ctor_kind == CtorKind::Fn {
|
if variant.ctor_kind == CtorKind::Fn {
|
||||||
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
|
||||||
@ -1175,7 +1175,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
||||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
self.tables.constness.set(def_id.index, hir::Constness::Const);
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data)));
|
record!(self.tables.kind[def_id] <- EntryKind::Struct(self.lazy(data)));
|
||||||
self.encode_item_type(def_id);
|
self.encode_item_type(def_id);
|
||||||
if variant.ctor_kind == CtorKind::Fn {
|
if variant.ctor_kind == CtorKind::Fn {
|
||||||
@ -1226,7 +1226,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
|
self.tables.asyncness.set(def_id.index, m_sig.header.asyncness);
|
||||||
self.tables.impl_constness.set(def_id.index, hir::Constness::NotConst);
|
self.tables.constness.set(def_id.index, hir::Constness::NotConst);
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
||||||
container,
|
container,
|
||||||
has_self: trait_item.fn_has_self_parameter,
|
has_self: trait_item.fn_has_self_parameter,
|
||||||
@ -1290,7 +1290,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
} else {
|
} else {
|
||||||
hir::Constness::NotConst
|
hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
self.tables.impl_constness.set(def_id.index, constness);
|
self.tables.constness.set(def_id.index, constness);
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
record!(self.tables.kind[def_id] <- EntryKind::AssocFn(self.lazy(AssocFnData {
|
||||||
container,
|
container,
|
||||||
has_self: impl_item.fn_has_self_parameter,
|
has_self: impl_item.fn_has_self_parameter,
|
||||||
@ -1413,7 +1413,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
hir::ItemKind::Fn(ref sig, .., body) => {
|
hir::ItemKind::Fn(ref sig, .., body) => {
|
||||||
self.tables.asyncness.set(def_id.index, sig.header.asyncness);
|
self.tables.asyncness.set(def_id.index, sig.header.asyncness);
|
||||||
record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
||||||
self.tables.impl_constness.set(def_id.index, sig.header.constness);
|
self.tables.constness.set(def_id.index, sig.header.constness);
|
||||||
EntryKind::Fn
|
EntryKind::Fn
|
||||||
}
|
}
|
||||||
hir::ItemKind::Macro(ref macro_def, _) => {
|
hir::ItemKind::Macro(ref macro_def, _) => {
|
||||||
@ -1437,7 +1437,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
hir::ItemKind::Struct(ref struct_def, _) => {
|
hir::ItemKind::Struct(ref struct_def, _) => {
|
||||||
let adt_def = self.tcx.adt_def(def_id);
|
let adt_def = self.tcx.adt_def(def_id);
|
||||||
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
record!(self.tables.repr_options[def_id] <- adt_def.repr());
|
||||||
self.tables.impl_constness.set(def_id.index, hir::Constness::Const);
|
self.tables.constness.set(def_id.index, hir::Constness::Const);
|
||||||
|
|
||||||
// Encode def_ids for each field and method
|
// Encode def_ids for each field and method
|
||||||
// for methods, write all the stuff get_trait_method
|
// for methods, write all the stuff get_trait_method
|
||||||
@ -1468,7 +1468,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
|
hir::ItemKind::Impl(hir::Impl { defaultness, constness, .. }) => {
|
||||||
self.tables.impl_defaultness.set(def_id.index, *defaultness);
|
self.tables.impl_defaultness.set(def_id.index, *defaultness);
|
||||||
self.tables.impl_constness.set(def_id.index, *constness);
|
self.tables.constness.set(def_id.index, *constness);
|
||||||
|
|
||||||
let trait_ref = self.tcx.impl_trait_ref(def_id);
|
let trait_ref = self.tcx.impl_trait_ref(def_id);
|
||||||
if let Some(trait_ref) = trait_ref {
|
if let Some(trait_ref) = trait_ref {
|
||||||
@ -1934,7 +1934,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||||||
} else {
|
} else {
|
||||||
hir::Constness::NotConst
|
hir::Constness::NotConst
|
||||||
};
|
};
|
||||||
self.tables.impl_constness.set(def_id.index, constness);
|
self.tables.constness.set(def_id.index, constness);
|
||||||
record!(self.tables.kind[def_id] <- EntryKind::ForeignFn);
|
record!(self.tables.kind[def_id] <- EntryKind::ForeignFn);
|
||||||
}
|
}
|
||||||
hir::ForeignItemKind::Static(..) => {
|
hir::ForeignItemKind::Static(..) => {
|
||||||
|
@ -364,7 +364,7 @@ define_tables! {
|
|||||||
thir_abstract_const: Table<DefIndex, LazyValue<&'static [thir::abstract_const::Node<'static>]>>,
|
thir_abstract_const: Table<DefIndex, LazyValue<&'static [thir::abstract_const::Node<'static>]>>,
|
||||||
impl_parent: Table<DefIndex, RawDefId>,
|
impl_parent: Table<DefIndex, RawDefId>,
|
||||||
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
impl_polarity: Table<DefIndex, ty::ImplPolarity>,
|
||||||
impl_constness: Table<DefIndex, hir::Constness>,
|
constness: Table<DefIndex, hir::Constness>,
|
||||||
is_intrinsic: Table<DefIndex, ()>,
|
is_intrinsic: Table<DefIndex, ()>,
|
||||||
impl_defaultness: Table<DefIndex, hir::Defaultness>,
|
impl_defaultness: Table<DefIndex, hir::Defaultness>,
|
||||||
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
|
// FIXME(eddyb) perhaps compute this on the fly if cheap enough?
|
||||||
|
@ -590,9 +590,9 @@ rustc_queries! {
|
|||||||
/// not have the feature gate active).
|
/// not have the feature gate active).
|
||||||
///
|
///
|
||||||
/// **Do not call this function manually.** It is only meant to cache the base data for the
|
/// **Do not call this function manually.** It is only meant to cache the base data for the
|
||||||
/// `is_const_fn` function.
|
/// `is_const_fn` function. Consider using `is_const_fn` or `is_const_fn_raw` instead.
|
||||||
query impl_constness(key: DefId) -> hir::Constness {
|
query constness(key: DefId) -> hir::Constness {
|
||||||
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
|
desc { |tcx| "checking if item is const: `{}`", tcx.def_path_str(key) }
|
||||||
cache_on_disk_if { key.is_local() }
|
cache_on_disk_if { key.is_local() }
|
||||||
separate_provide_extern
|
separate_provide_extern
|
||||||
}
|
}
|
||||||
|
@ -2341,7 +2341,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_const_fn_raw(self, def_id: DefId) -> bool {
|
pub fn is_const_fn_raw(self, def_id: DefId) -> bool {
|
||||||
matches!(self.def_kind(def_id), DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..))
|
matches!(self.def_kind(def_id), DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..))
|
||||||
&& self.impl_constness(def_id) == hir::Constness::Const
|
&& self.constness(def_id) == hir::Constness::Const
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -376,7 +376,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
let (did, constness) = self.find_map_relevant_impl(drop_trait, ty, |impl_did| {
|
let (did, constness) = self.find_map_relevant_impl(drop_trait, ty, |impl_did| {
|
||||||
if let Some(item_id) = self.associated_item_def_ids(impl_did).first() {
|
if let Some(item_id) = self.associated_item_def_ids(impl_did).first() {
|
||||||
if validate(self, impl_did).is_ok() {
|
if validate(self, impl_did).is_ok() {
|
||||||
return Some((*item_id, self.impl_constness(impl_did)));
|
return Some((*item_id, self.constness(impl_did)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -2,10 +2,10 @@ use super::{wasm32_unknown_emscripten, LinkerFlavor, Target};
|
|||||||
|
|
||||||
pub fn target() -> Target {
|
pub fn target() -> Target {
|
||||||
let mut target = wasm32_unknown_emscripten::target();
|
let mut target = wasm32_unknown_emscripten::target();
|
||||||
target
|
target.post_link_args.entry(LinkerFlavor::Em).or_default().extend(vec![
|
||||||
.post_link_args
|
"-sWASM=0".into(),
|
||||||
.entry(LinkerFlavor::Em)
|
"--memory-init-file".into(),
|
||||||
.or_default()
|
"0".into(),
|
||||||
.extend(vec!["-s".into(), "WASM=0".into()]);
|
]);
|
||||||
target
|
target
|
||||||
}
|
}
|
||||||
|
@ -970,7 +970,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
|
|
||||||
if let Some(impl_def_id) = relevant_impl {
|
if let Some(impl_def_id) = relevant_impl {
|
||||||
// Check that `impl Drop` is actually const, if there is a custom impl
|
// Check that `impl Drop` is actually const, if there is a custom impl
|
||||||
if self.tcx().impl_constness(impl_def_id) == hir::Constness::Const {
|
if self.tcx().constness(impl_def_id) == hir::Constness::Const {
|
||||||
candidates.vec.push(ConstDestructCandidate(Some(impl_def_id)));
|
candidates.vec.push(ConstDestructCandidate(Some(impl_def_id)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1119,8 +1119,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
if obligation.is_const() {
|
if obligation.is_const() {
|
||||||
match candidate {
|
match candidate {
|
||||||
// const impl
|
// const impl
|
||||||
ImplCandidate(def_id)
|
ImplCandidate(def_id) if tcx.constness(def_id) == hir::Constness::Const => {}
|
||||||
if tcx.impl_constness(def_id) == hir::Constness::Const => {}
|
|
||||||
// const param
|
// const param
|
||||||
ParamCandidate(trait_pred) if trait_pred.is_const_if_const() => {}
|
ParamCandidate(trait_pred) if trait_pred.is_const_if_const() => {}
|
||||||
// auto trait impl
|
// auto trait impl
|
||||||
|
@ -490,7 +490,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
|
|||||||
// The bounds we that we would require from `to_check`
|
// The bounds we that we would require from `to_check`
|
||||||
let mut bounds = FxHashSet::default();
|
let mut bounds = FxHashSet::default();
|
||||||
|
|
||||||
let (regions, types) = GATSubstCollector::visit(tcx, gat_def_id.to_def_id(), to_check);
|
let (regions, types) = GATSubstCollector::visit(gat_def_id.to_def_id(), to_check);
|
||||||
|
|
||||||
// If both regions and types are empty, then this GAT isn't in the
|
// If both regions and types are empty, then this GAT isn't in the
|
||||||
// set of types we are checking, and we shouldn't try to do clause analysis
|
// set of types we are checking, and we shouldn't try to do clause analysis
|
||||||
@ -664,7 +664,6 @@ fn resolve_regions_with_wf_tys<'tcx>(
|
|||||||
/// the two vectors, `regions` and `types` (depending on their kind). For each
|
/// the two vectors, `regions` and `types` (depending on their kind). For each
|
||||||
/// parameter `Pi` also track the index `i`.
|
/// parameter `Pi` also track the index `i`.
|
||||||
struct GATSubstCollector<'tcx> {
|
struct GATSubstCollector<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
gat: DefId,
|
gat: DefId,
|
||||||
// Which region appears and which parameter index its substituted for
|
// Which region appears and which parameter index its substituted for
|
||||||
regions: FxHashSet<(ty::Region<'tcx>, usize)>,
|
regions: FxHashSet<(ty::Region<'tcx>, usize)>,
|
||||||
@ -674,16 +673,11 @@ struct GATSubstCollector<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> GATSubstCollector<'tcx> {
|
impl<'tcx> GATSubstCollector<'tcx> {
|
||||||
fn visit<T: TypeFoldable<'tcx>>(
|
fn visit<T: TypeFoldable<'tcx>>(
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
gat: DefId,
|
gat: DefId,
|
||||||
t: T,
|
t: T,
|
||||||
) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) {
|
) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) {
|
||||||
let mut visitor = GATSubstCollector {
|
let mut visitor =
|
||||||
tcx,
|
GATSubstCollector { gat, regions: FxHashSet::default(), types: FxHashSet::default() };
|
||||||
gat,
|
|
||||||
regions: FxHashSet::default(),
|
|
||||||
types: FxHashSet::default(),
|
|
||||||
};
|
|
||||||
t.visit_with(&mut visitor);
|
t.visit_with(&mut visitor);
|
||||||
(visitor.regions, visitor.types)
|
(visitor.regions, visitor.types)
|
||||||
}
|
}
|
||||||
@ -692,19 +686,12 @@ impl<'tcx> GATSubstCollector<'tcx> {
|
|||||||
impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
|
||||||
type BreakTy = !;
|
type BreakTy = !;
|
||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
|
||||||
&mut self,
|
|
||||||
t: &ty::Binder<'tcx, T>,
|
|
||||||
) -> ControlFlow<Self::BreakTy> {
|
|
||||||
self.tcx.liberate_late_bound_regions(self.gat, t.clone()).visit_with(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
match t.kind() {
|
match t.kind() {
|
||||||
ty::Projection(p) if p.item_def_id == self.gat => {
|
ty::Projection(p) if p.item_def_id == self.gat => {
|
||||||
for (idx, subst) in p.substs.iter().enumerate() {
|
for (idx, subst) in p.substs.iter().enumerate() {
|
||||||
match subst.unpack() {
|
match subst.unpack() {
|
||||||
GenericArgKind::Lifetime(lt) => {
|
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => {
|
||||||
self.regions.insert((lt, idx));
|
self.regions.insert((lt, idx));
|
||||||
}
|
}
|
||||||
GenericArgKind::Type(t) => {
|
GenericArgKind::Type(t) => {
|
||||||
|
@ -1644,11 +1644,11 @@ impl<K, V, A: Allocator + Clone> IntoIter<K, V, A> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
|
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
|
||||||
if self.length == 0 {
|
if self.length == 0 {
|
||||||
self.range.deallocating_end(&self.alloc);
|
self.range.deallocating_end(self.alloc.clone());
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
Some(unsafe { self.range.deallocating_next_unchecked(&self.alloc) })
|
Some(unsafe { self.range.deallocating_next_unchecked(self.alloc.clone()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1658,11 +1658,11 @@ impl<K, V, A: Allocator + Clone> IntoIter<K, V, A> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
|
) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
|
||||||
if self.length == 0 {
|
if self.length == 0 {
|
||||||
self.range.deallocating_end(&self.alloc);
|
self.range.deallocating_end(self.alloc.clone());
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.length -= 1;
|
self.length -= 1;
|
||||||
Some(unsafe { self.range.deallocating_next_back_unchecked(&self.alloc) })
|
Some(unsafe { self.range.deallocating_next_back_unchecked(self.alloc.clone()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1849,7 +1849,7 @@ where
|
|||||||
type Item = (K, V);
|
type Item = (K, V);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<(K, V)> {
|
fn next(&mut self) -> Option<(K, V)> {
|
||||||
self.inner.next(&mut self.pred, &self.alloc)
|
self.inner.next(&mut self.pred, self.alloc.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
@ -1320,7 +1320,7 @@ where
|
|||||||
fn next(&mut self) -> Option<T> {
|
fn next(&mut self) -> Option<T> {
|
||||||
let pred = &mut self.pred;
|
let pred = &mut self.pred;
|
||||||
let mut mapped_pred = |k: &T, _v: &mut ()| pred(k);
|
let mut mapped_pred = |k: &T, _v: &mut ()| pred(k);
|
||||||
self.inner.next(&mut mapped_pred, &self.alloc).map(|(k, _)| k)
|
self.inner.next(&mut mapped_pred, self.alloc.clone()).map(|(k, _)| k)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
@ -187,7 +187,7 @@ impl System {
|
|||||||
old_size => unsafe {
|
old_size => unsafe {
|
||||||
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
|
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
|
||||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
|
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
|
||||||
Allocator::deallocate(&self, ptr, old_layout);
|
Allocator::deallocate(self, ptr, old_layout);
|
||||||
Ok(new_ptr)
|
Ok(new_ptr)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ unsafe impl Allocator for System {
|
|||||||
match new_layout.size() {
|
match new_layout.size() {
|
||||||
// SAFETY: conditions must be upheld by the caller
|
// SAFETY: conditions must be upheld by the caller
|
||||||
0 => unsafe {
|
0 => unsafe {
|
||||||
Allocator::deallocate(&self, ptr, old_layout);
|
Allocator::deallocate(self, ptr, old_layout);
|
||||||
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
|
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -274,9 +274,9 @@ unsafe impl Allocator for System {
|
|||||||
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
|
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
|
||||||
// for `dealloc` must be upheld by the caller.
|
// for `dealloc` must be upheld by the caller.
|
||||||
new_size => unsafe {
|
new_size => unsafe {
|
||||||
let new_ptr = Allocator::allocate(&self, new_layout)?;
|
let new_ptr = Allocator::allocate(self, new_layout)?;
|
||||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
|
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
|
||||||
Allocator::deallocate(&self, ptr, old_layout);
|
Allocator::deallocate(self, ptr, old_layout);
|
||||||
Ok(new_ptr)
|
Ok(new_ptr)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
|
|||||||
snapshot_path = '{}.{}.{}'.format(rust_test_path[:-3], snapshot_name, 'html')
|
snapshot_path = '{}.{}.{}'.format(rust_test_path[:-3], snapshot_name, 'html')
|
||||||
try:
|
try:
|
||||||
with open(snapshot_path, 'r') as snapshot_file:
|
with open(snapshot_path, 'r') as snapshot_file:
|
||||||
expected_str = snapshot_file.read()
|
expected_str = snapshot_file.read().replace("{{channel}}", channel)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
if bless:
|
if bless:
|
||||||
expected_str = None
|
expected_str = None
|
||||||
@ -429,8 +429,6 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
|
|||||||
else:
|
else:
|
||||||
actual_str = flatten(actual_tree)
|
actual_str = flatten(actual_tree)
|
||||||
|
|
||||||
expected_str = expected_str.replace("{{channel}}", channel)
|
|
||||||
|
|
||||||
# Conditions:
|
# Conditions:
|
||||||
# 1. Is --bless
|
# 1. Is --bless
|
||||||
# 2. Are actual and expected tree different
|
# 2. Are actual and expected tree different
|
||||||
|
@ -23,6 +23,8 @@ use rustc_span::symbol::kw;
|
|||||||
use rustc_span::{sym, Symbol};
|
use rustc_span::{sym, Symbol};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::clean::{
|
use crate::clean::{
|
||||||
self, types::ExternalLocation, utils::find_nearest_parent_module, ExternalCrate, ItemId,
|
self, types::ExternalLocation, utils::find_nearest_parent_module, ExternalCrate, ItemId,
|
||||||
PrimitiveType,
|
PrimitiveType,
|
||||||
@ -874,20 +876,42 @@ fn fmt_type<'cx>(
|
|||||||
match &typs[..] {
|
match &typs[..] {
|
||||||
&[] => primitive_link(f, PrimitiveType::Unit, "()", cx),
|
&[] => primitive_link(f, PrimitiveType::Unit, "()", cx),
|
||||||
&[ref one] => {
|
&[ref one] => {
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(", cx)?;
|
if let clean::Generic(name) = one {
|
||||||
// Carry `f.alternate()` into this display w/o branching manually.
|
primitive_link(f, PrimitiveType::Tuple, &format!("({name},)"), cx)
|
||||||
fmt::Display::fmt(&one.print(cx), f)?;
|
} else {
|
||||||
primitive_link(f, PrimitiveType::Tuple, ",)", cx)
|
write!(f, "(")?;
|
||||||
|
// Carry `f.alternate()` into this display w/o branching manually.
|
||||||
|
fmt::Display::fmt(&one.print(cx), f)?;
|
||||||
|
write!(f, ",)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
many => {
|
many => {
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(", cx)?;
|
let generic_names: Vec<Symbol> = many
|
||||||
for (i, item) in many.iter().enumerate() {
|
.iter()
|
||||||
if i != 0 {
|
.filter_map(|t| match t {
|
||||||
write!(f, ", ")?;
|
clean::Generic(name) => Some(*name),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let is_generic = generic_names.len() == many.len();
|
||||||
|
if is_generic {
|
||||||
|
primitive_link(
|
||||||
|
f,
|
||||||
|
PrimitiveType::Tuple,
|
||||||
|
&format!("({})", generic_names.iter().map(|s| s.as_str()).join(", ")),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
write!(f, "(")?;
|
||||||
|
for (i, item) in many.iter().enumerate() {
|
||||||
|
if i != 0 {
|
||||||
|
write!(f, ", ")?;
|
||||||
|
}
|
||||||
|
// Carry `f.alternate()` into this display w/o branching manually.
|
||||||
|
fmt::Display::fmt(&item.print(cx), f)?;
|
||||||
}
|
}
|
||||||
fmt::Display::fmt(&item.print(cx), f)?;
|
write!(f, ")")
|
||||||
}
|
}
|
||||||
primitive_link(f, PrimitiveType::Tuple, ")", cx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
src/test/rustdoc/tuples.link1_i32.html
Normal file
1
src/test/rustdoc/tuples.link1_i32.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple1(x: (<a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>,)) -> (<a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>,)</code>
|
1
src/test/rustdoc/tuples.link1_t.html
Normal file
1
src/test/rustdoc/tuples.link1_t.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple1_t<T>(x: <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T,)</a>) -> <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T,)</a></code>
|
1
src/test/rustdoc/tuples.link2_i32.html
Normal file
1
src/test/rustdoc/tuples.link2_i32.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple2(x: (<a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>, <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>)) -> (<a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>, <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a>)</code>
|
1
src/test/rustdoc/tuples.link2_t.html
Normal file
1
src/test/rustdoc/tuples.link2_t.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple2_t<T>(x: <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T, T)</a>) -> <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T, T)</a></code>
|
1
src/test/rustdoc/tuples.link2_tu.html
Normal file
1
src/test/rustdoc/tuples.link2_tu.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple2_tu<T, U>(x: <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T, U)</a>) -> <a class="primitive" href="{{channel}}/std/primitive.tuple.html">(T, U)</a></code>
|
1
src/test/rustdoc/tuples.link_unit.html
Normal file
1
src/test/rustdoc/tuples.link_unit.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<code>pub fn tuple0(x: <a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>)</code>
|
@ -1,8 +1,20 @@
|
|||||||
#![crate_name = "foo"]
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
// @has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())'
|
// @has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())'
|
||||||
|
// @snapshot link_unit - '//pre[@class="rust fn"]/code'
|
||||||
pub fn tuple0(x: ()) -> () { x }
|
pub fn tuple0(x: ()) -> () { x }
|
||||||
// @has foo/fn.tuple1.html //pre 'pub fn tuple1(x: (i32,)) -> (i32,)'
|
// @has foo/fn.tuple1.html //pre 'pub fn tuple1(x: (i32,)) -> (i32,)'
|
||||||
|
// @snapshot link1_i32 - '//pre[@class="rust fn"]/code'
|
||||||
pub fn tuple1(x: (i32,)) -> (i32,) { x }
|
pub fn tuple1(x: (i32,)) -> (i32,) { x }
|
||||||
// @has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)'
|
// @has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)'
|
||||||
|
// @snapshot link2_i32 - '//pre[@class="rust fn"]/code'
|
||||||
pub fn tuple2(x: (i32, i32)) -> (i32, i32) { x }
|
pub fn tuple2(x: (i32, i32)) -> (i32, i32) { x }
|
||||||
|
// @has foo/fn.tuple1_t.html //pre 'pub fn tuple1_t<T>(x: (T,)) -> (T,)'
|
||||||
|
// @snapshot link1_t - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn tuple1_t<T>(x: (T,)) -> (T,) { x }
|
||||||
|
// @has foo/fn.tuple2_t.html //pre 'pub fn tuple2_t<T>(x: (T, T)) -> (T, T)'
|
||||||
|
// @snapshot link2_t - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn tuple2_t<T>(x: (T, T)) -> (T, T) { x }
|
||||||
|
// @has foo/fn.tuple2_tu.html //pre 'pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U)'
|
||||||
|
// @snapshot link2_tu - '//pre[@class="rust fn"]/code'
|
||||||
|
pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U) { x }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user