Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #128689

Merged
merged 11 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_ssa/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_span::Span;

use crate::traits::*;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum IntPredicate {
IntEQ,
IntNE,
Expand All @@ -22,7 +22,7 @@ pub enum IntPredicate {
IntSLE,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum RealPredicate {
RealPredicateFalse,
RealOEQ,
Expand All @@ -42,7 +42,7 @@ pub enum RealPredicate {
RealPredicateTrue,
}

#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum AtomicRmwBinOp {
AtomicXchg,
AtomicAdd,
Expand All @@ -57,7 +57,7 @@ pub enum AtomicRmwBinOp {
AtomicUMin,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum AtomicOrdering {
Unordered,
Relaxed,
Expand All @@ -67,7 +67,7 @@ pub enum AtomicOrdering {
SequentiallyConsistent,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum SynchronizationScope {
SingleThread,
CrossThread,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::mir::operand::{OperandRef, OperandValue};
use crate::mir::place::{PlaceRef, PlaceValue};
use crate::MemFlags;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub enum OverflowOp {
Add,
Sub,
Expand Down
28 changes: 16 additions & 12 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,18 +774,23 @@ impl<'a, 'tcx> ProbeContext<'a, '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() {
Expand All @@ -806,7 +811,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
}
});

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,
Expand All @@ -820,15 +825,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {

// 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) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub use self::specialize::{
};
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,
};
Expand Down
9 changes: 0 additions & 9 deletions compiler/rustc_type_ir/src/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
14 changes: 12 additions & 2 deletions src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,16 @@ impl Step for Std {
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),
Expand Down Expand Up @@ -627,7 +637,7 @@ impl Step for Std {
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 {
Expand All @@ -639,7 +649,7 @@ impl Step for Std {
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);
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 15 additions & 23 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
// `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_()));
}
}
}
Expand Down Expand Up @@ -381,9 +381,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
&& 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));
}
}
}
Expand All @@ -396,32 +394,26 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
.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
Expand Down
6 changes: 0 additions & 6 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
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");
Expand Down
5 changes: 5 additions & 0 deletions tests/rustdoc-json/the_smallest.rs
Original file line number Diff line number Diff line change
@@ -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