Auto merge of #128689 - matthiaskrgr:rollup-ukyn8wq, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #128385 (rustdoc-json: discard non-local inherent impls for primitives) - #128559 (Don't re-elaborated already elaborated caller bounds in method probe) - #128631 (handle crates when they are not specified for std docs) - #128664 (Add `Debug` impls to API types in `rustc_codegen_ssa`) - #128686 (fix the invalid argument type) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
f7eefec4e0
@ -8,7 +8,7 @@
|
||||
|
||||
use crate::traits::*;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum IntPredicate {
|
||||
IntEQ,
|
||||
IntNE,
|
||||
@ -22,7 +22,7 @@ pub enum IntPredicate {
|
||||
IntSLE,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum RealPredicate {
|
||||
RealPredicateFalse,
|
||||
RealOEQ,
|
||||
@ -42,7 +42,7 @@ pub enum RealPredicate {
|
||||
RealPredicateTrue,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum AtomicRmwBinOp {
|
||||
AtomicXchg,
|
||||
AtomicAdd,
|
||||
@ -57,7 +57,7 @@ pub enum AtomicRmwBinOp {
|
||||
AtomicUMin,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum AtomicOrdering {
|
||||
Unordered,
|
||||
Relaxed,
|
||||
@ -67,7 +67,7 @@ pub enum AtomicOrdering {
|
||||
SequentiallyConsistent,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum SynchronizationScope {
|
||||
SingleThread,
|
||||
CrossThread,
|
||||
|
@ -23,7 +23,7 @@
|
||||
use crate::mir::place::{PlaceRef, PlaceValue};
|
||||
use crate::MemFlags;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum OverflowOp {
|
||||
Add,
|
||||
Sub,
|
||||
|
@ -774,18 +774,23 @@ fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) {
|
||||
// instantiation that replaces `Self` with the object type itself. Hence,
|
||||
// a `&self` method will wind up with an argument type like `&dyn Trait`.
|
||||
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
|
||||
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
|
||||
this.push_candidate(
|
||||
Candidate { item, kind: ObjectCandidate(new_trait_ref), import_ids: smallvec![] },
|
||||
true,
|
||||
);
|
||||
});
|
||||
self.assemble_candidates_for_bounds(
|
||||
traits::supertraits(self.tcx, trait_ref),
|
||||
|this, new_trait_ref, item| {
|
||||
this.push_candidate(
|
||||
Candidate {
|
||||
item,
|
||||
kind: ObjectCandidate(new_trait_ref),
|
||||
import_ids: smallvec![],
|
||||
},
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
|
||||
// FIXME: do we want to commit to this behavior for param bounds?
|
||||
|
||||
let bounds = self.param_env.caller_bounds().iter().filter_map(|predicate| {
|
||||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
@ -806,7 +811,7 @@ fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
|
||||
}
|
||||
});
|
||||
|
||||
self.elaborate_bounds(bounds, |this, poly_trait_ref, item| {
|
||||
self.assemble_candidates_for_bounds(bounds, |this, poly_trait_ref, item| {
|
||||
this.push_candidate(
|
||||
Candidate {
|
||||
item,
|
||||
@ -820,15 +825,14 @@ fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
|
||||
|
||||
// Do a search through a list of bounds, using a callback to actually
|
||||
// create the candidates.
|
||||
fn elaborate_bounds<F>(
|
||||
fn assemble_candidates_for_bounds<F>(
|
||||
&mut self,
|
||||
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||
mut mk_cand: F,
|
||||
) where
|
||||
F: for<'b> FnMut(&mut ProbeContext<'b, 'tcx>, ty::PolyTraitRef<'tcx>, ty::AssocItem),
|
||||
{
|
||||
let tcx = self.tcx;
|
||||
for bound_trait_ref in traits::transitive_bounds(tcx, bounds) {
|
||||
for bound_trait_ref in bounds {
|
||||
debug!("elaborate_bounds(bound_trait_ref={:?})", bound_trait_ref);
|
||||
for item in self.impl_or_trait_item(bound_trait_ref.def_id()) {
|
||||
if !self.has_applicable_self(&item) {
|
||||
|
@ -62,7 +62,7 @@
|
||||
};
|
||||
pub use self::structural_normalize::StructurallyNormalizeExt;
|
||||
pub use self::util::{
|
||||
elaborate, expand_trait_aliases, impl_item_is_final, supertraits, transitive_bounds,
|
||||
elaborate, expand_trait_aliases, impl_item_is_final, supertraits,
|
||||
transitive_bounds_that_define_assoc_item, upcast_choices, with_replaced_escaping_bound_vars,
|
||||
BoundVarReplacer, PlaceholderReplacer, TraitAliasExpander, TraitAliasExpansionInfo,
|
||||
};
|
||||
|
@ -264,15 +264,6 @@ pub fn supertraits<I: Interner>(
|
||||
elaborate(cx, [trait_ref.upcast(cx)]).filter_only_self().filter_to_traits()
|
||||
}
|
||||
|
||||
pub fn transitive_bounds<I: Interner>(
|
||||
cx: I,
|
||||
trait_refs: impl Iterator<Item = ty::Binder<I, ty::TraitRef<I>>>,
|
||||
) -> FilterToTraits<I, Elaborator<I, I::Clause>> {
|
||||
elaborate(cx, trait_refs.map(|trait_ref| trait_ref.upcast(cx)))
|
||||
.filter_only_self()
|
||||
.filter_to_traits()
|
||||
}
|
||||
|
||||
impl<I: Interner> Elaborator<I, I::Clause> {
|
||||
fn filter_to_traits(self) -> FilterToTraits<I, Self> {
|
||||
FilterToTraits { _cx: PhantomData, base_iterator: self }
|
||||
|
@ -599,6 +599,16 @@ fn make_run(run: RunConfig<'_>) {
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let stage = self.stage;
|
||||
let target = self.target;
|
||||
let crates = if self.crates.is_empty() {
|
||||
builder
|
||||
.in_tree_crates("sysroot", Some(target))
|
||||
.iter()
|
||||
.map(|c| c.name.to_string())
|
||||
.collect()
|
||||
} else {
|
||||
self.crates
|
||||
};
|
||||
|
||||
let out = match self.format {
|
||||
DocumentationFormat::Html => builder.doc_out(target),
|
||||
DocumentationFormat::Json => builder.json_doc_out(target),
|
||||
@ -627,7 +637,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
extra_args.push("--disable-minification");
|
||||
}
|
||||
|
||||
doc_std(builder, self.format, stage, target, &out, &extra_args, &self.crates);
|
||||
doc_std(builder, self.format, stage, target, &out, &extra_args, &crates);
|
||||
|
||||
// Don't open if the format is json
|
||||
if let DocumentationFormat::Json = self.format {
|
||||
@ -639,7 +649,7 @@ fn run(self, builder: &Builder<'_>) {
|
||||
let index = out.join("std").join("index.html");
|
||||
builder.open_in_browser(index);
|
||||
} else {
|
||||
for requested_crate in &*self.crates {
|
||||
for requested_crate in crates {
|
||||
if STD_PUBLIC_CRATES.iter().any(|&k| k == requested_crate) {
|
||||
let index = out.join(requested_crate).join("index.html");
|
||||
builder.open_in_browser(index);
|
||||
|
@ -536,8 +536,7 @@ pub fn get_closest_merge_base_commit(
|
||||
|
||||
let merge_base = get_git_merge_base(config, source_dir).unwrap_or_else(|_| "HEAD".into());
|
||||
|
||||
git.arg(Path::new("rev-list"));
|
||||
git.args([&format!("--author={author}"), "-n1", "--first-parent", &merge_base]);
|
||||
git.args(["rev-list", &format!("--author={author}"), "-n1", "--first-parent", &merge_base]);
|
||||
|
||||
if !target_paths.is_empty() {
|
||||
git.arg("--").args(target_paths);
|
||||
|
@ -310,16 +310,16 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
||||
// `public_items` map, so we can skip inserting into the
|
||||
// paths map if there was already an entry present and we're
|
||||
// not a public item.
|
||||
if !self.cache.paths.contains_key(&item.item_id.expect_def_id())
|
||||
let item_def_id = item.item_id.expect_def_id();
|
||||
if !self.cache.paths.contains_key(&item_def_id)
|
||||
|| self
|
||||
.cache
|
||||
.effective_visibilities
|
||||
.is_directly_public(self.tcx, item.item_id.expect_def_id())
|
||||
.is_directly_public(self.tcx, item_def_id)
|
||||
{
|
||||
self.cache.paths.insert(
|
||||
item.item_id.expect_def_id(),
|
||||
(self.cache.stack.clone(), item.type_()),
|
||||
);
|
||||
self.cache
|
||||
.paths
|
||||
.insert(item_def_id, (self.cache.stack.clone(), item.type_()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -381,9 +381,7 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
||||
&& adt.is_fundamental()
|
||||
{
|
||||
for ty in generics {
|
||||
if let Some(did) = ty.def_id(self.cache) {
|
||||
dids.insert(did);
|
||||
}
|
||||
dids.extend(ty.def_id(self.cache));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -396,32 +394,26 @@ fn is_from_private_dep(tcx: TyCtxt<'_>, cache: &Cache, def_id: DefId) -> bool {
|
||||
.primitive_type()
|
||||
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
|
||||
|
||||
if let Some(did) = did {
|
||||
dids.insert(did);
|
||||
}
|
||||
dids.extend(did);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
|
||||
for bound in generics {
|
||||
if let Some(did) = bound.def_id(self.cache) {
|
||||
dids.insert(did);
|
||||
}
|
||||
dids.extend(bound.def_id(self.cache));
|
||||
}
|
||||
}
|
||||
let impl_item = Impl { impl_item: item };
|
||||
if impl_item.trait_did().map_or(true, |d| self.cache.traits.contains_key(&d)) {
|
||||
let impl_did = impl_item.def_id();
|
||||
let trait_did = impl_item.trait_did();
|
||||
if trait_did.map_or(true, |d| self.cache.traits.contains_key(&d)) {
|
||||
for did in dids {
|
||||
if self.impl_ids.entry(did).or_default().insert(impl_item.def_id()) {
|
||||
self.cache
|
||||
.impls
|
||||
.entry(did)
|
||||
.or_insert_with(Vec::new)
|
||||
.push(impl_item.clone());
|
||||
if self.impl_ids.entry(did).or_default().insert(impl_did) {
|
||||
self.cache.impls.entry(did).or_default().push(impl_item.clone());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let trait_did = impl_item.trait_did().expect("no trait did");
|
||||
let trait_did = trait_did.expect("no trait did");
|
||||
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
|
||||
}
|
||||
None
|
||||
|
@ -216,13 +216,7 @@ fn mod_item_in(&mut self, _item: &clean::Item) -> Result<(), Error> {
|
||||
fn after_krate(&mut self) -> Result<(), Error> {
|
||||
debug!("Done with crate");
|
||||
|
||||
debug!("Adding Primitive impls");
|
||||
for primitive in Rc::clone(&self.cache).primitive_locations.values() {
|
||||
self.get_impls(*primitive);
|
||||
}
|
||||
|
||||
let e = ExternalCrate { crate_num: LOCAL_CRATE };
|
||||
|
||||
let index = (*self.index).clone().into_inner();
|
||||
|
||||
debug!("Constructing Output");
|
||||
|
5
tests/rustdoc-json/the_smallest.rs
Normal file
5
tests/rustdoc-json/the_smallest.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// This test asserts that `index` is not polluted with unrelated items.
|
||||
// See https://github.com/rust-lang/rust/issues/114039
|
||||
|
||||
//@ count "$.index[*]" 1
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user