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 10 pull requests #75683

Closed
wants to merge 43 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift click to select a range
e720f42
See also X-Link mem::{swap, take, replace}
Havvy Aug 2, 2020
7835c8c
docs(marker/copy): clarify that `&T` is also `Copy`
janriemer Aug 2, 2020
9b0f3d1
Fix documentation error
jack-champagne Aug 13, 2020
a876b3d
docs(marker/copy): provide example for `&T` being `Copy`
janriemer Aug 16, 2020
43dec0e
rephrase: struct -> type
janriemer Aug 16, 2020
dce8644
add back emojis that have been removed accidentally
janriemer Aug 16, 2020
9061da2
add empty line above code block
janriemer Aug 16, 2020
56daf63
docs: add `derive` for struct
janriemer Aug 16, 2020
3b2c0a9
Minor changes to Ipv4Addr
tesuji Aug 14, 2020
b0eb55a
Add test demonstrating the issue.
jumbatm Aug 15, 2020
db75313
Fix stack overflow for recursive types.
jumbatm Aug 15, 2020
154b74e
Actually introduce a cycle in Reffy test.
jumbatm Aug 16, 2020
a1fa4e0
Remove unnecessary rebinding of def ids.
jumbatm Aug 16, 2020
80c2c80
Remove structural equiv check for Array const.
jumbatm Aug 16, 2020
bca48ad
Reduce indentation by replacing match arm w/ early return.
jumbatm Aug 16, 2020
6c57de1
Don't memoize seen types.
jumbatm Aug 16, 2020
7708abb
Avoid double hashset lookup.
jumbatm Aug 16, 2020
1321a2d
Also accept Refs for is_primitive_or_pointer
jumbatm Aug 16, 2020
bc15dd6
Wrap recursion in `ensure_sufficient_stack`.
jumbatm Aug 17, 2020
431a465
Move to intra doc links for keyword documentation
poliorcetics Aug 17, 2020
a4995fc
Refactor `impl_for_type` into a separate function
jyn514 Aug 17, 2020
833bbb1
Say `tcx.lang_items()` less
jyn514 Aug 17, 2020
dae3a4f
Return all impls, not just the primary one
jyn514 Aug 17, 2020
c6ac860
impl_for_type -> PrimitiveType::impls
jyn514 Aug 17, 2020
3b1d2e3
Allow reusing the code in `collect_trait_impls`
jyn514 Aug 17, 2020
1b74f04
Use `impls` for intra doc links as well
jyn514 Aug 17, 2020
2858074
xpy fmt
jyn514 Aug 17, 2020
7be824e
Add a test
jyn514 Aug 17, 2020
38b920d
Capture output from threads spawned in tests
tmandry Aug 5, 2020
8c4641b
BTreeMap: check some invariants, avoid recursion in depth first search
ssomers Aug 18, 2020
d9d84dc
Add doc examples count for --show-coverage
GuillaumeGomez Aug 18, 2020
f957bae
Update rustdoc-ui tests
GuillaumeGomez Aug 18, 2020
522d177
docs: add another `derive` for `Copy`able struct
Aug 18, 2020
9a8e3d8
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
tmandry Aug 18, 2020
7b4ff26
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
tmandry Aug 18, 2020
81f62a9
Rollup merge of #75110 - lzutao:ip-endianness, r=Mark-Simulacrum
tmandry Aug 18, 2020
ad4610d
Rollup merge of #75172 - tmandry:test-thread-capture, r=dtolnay
tmandry Aug 18, 2020
816e701
Rollup merge of #75480 - ssomers:btree_check_invariant, r=Mark-Simula…
tmandry Aug 18, 2020
bc4b517
Rollup merge of #75499 - jack-champagne:jack-champagne/issue-75412, r…
tmandry Aug 18, 2020
7e283e9
Rollup merge of #75554 - jumbatm:fix-clashing-extern-decl-overflow, r…
tmandry Aug 18, 2020
7e09c7e
Rollup merge of #75646 - poliorcetics:intra-links-keywords, r=jyn514
tmandry Aug 18, 2020
9360e87
Rollup merge of #75649 - jyn514:inherent-lang-impls, r=GuillaumeGomez
tmandry Aug 18, 2020
2a5b4b2
Rollup merge of #75665 - GuillaumeGomez:doc-examples-coverage, r=jyn514
tmandry Aug 18, 2020
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
Prev Previous commit
Next Next commit
Don't memoize seen types.
That cache is unlikely to be particularly useful within a single
invocation of structurally_same_type, especially compared to memoizing
results across _all_ invocations of that function.
  • Loading branch information
jumbatm committed Aug 17, 2020
commit 6c57de1166d36725a689cef17e0dab8b9abcd00b
60 changes: 9 additions & 51 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,62 2153,22 @@ impl ClashingExternDeclarations {
b: Ty<'tcx>,
ckind: CItemKind,
) -> bool {
// In order to avoid endlessly recursing on recursive types, we maintain a "seen" set.
// We'll need to store every combination of types we encounter anyway, so we also memoize
// the result.
struct SeenSet<'tcx>(FxHashMap<(Ty<'tcx>, Ty<'tcx>), Option<bool>>);

enum SeenSetResult {
/// We've never seen this combination of types.
Unseen,
/// We've seen this combination of types, but are still computing the result.
Computing,
/// We've seen this combination of types, and have already computed the result.
Computed(bool),
}

impl<'tcx> SeenSet<'tcx> {
fn new() -> Self {
SeenSet(FxHashMap::default())
}
/// Mark (a, b) as `Computing`.
fn mark_computing(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
self.0.insert((a, b), None);
}
/// Mark (a, b) as `Computed(result)`.
fn mark_computed(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, result: bool) {
*self.0.get_mut(&(a, b)).expect("Missing prior call to mark_computing") =
Some(result);
}
fn get(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> SeenSetResult {
match self.0.get(&(a, b)) {
None => SeenSetResult::Unseen,
Some(None) => SeenSetResult::Computing,
Some(Some(b)) => SeenSetResult::Computed(*b),
}
}
}
fn structurally_same_type_impl<'tcx>(
seen_types: &mut SeenSet<'tcx>,
seen_types: &mut FxHashSet<(Ty<'tcx>, Ty<'tcx>)>,
cx: &LateContext<'tcx>,
a: Ty<'tcx>,
b: Ty<'tcx>,
ckind: CItemKind,
) -> bool {
debug!("structurally_same_type_impl(cx, a = {:?}, b = {:?})", a, b);
match seen_types.get(a, b) {
// If we've already computed the result, just return the memoized result.
SeenSetResult::Computed(result) => return result,
// We are already in the process of computing structural sameness for this type,
// meaning we've found a cycle. The types are structurally same, then.
SeenSetResult::Computing => return true,
// We haven't seen this combination of types at all -- continue on to computing
// their sameness.
SeenSetResult::Unseen => (),
if seen_types.contains(&(a, b)) {
// We've encountered a cycle. There's no point going any further -- the types are
// structurally the same.
return true;
}
seen_types.mark_computing(a, b);
seen_types.insert((a, b));
let tcx = cx.tcx;
let result = if a == b || rustc_middle::ty::TyS::same_type(a, b) {
if a == b || rustc_middle::ty::TyS::same_type(a, b) {
// All nominally-same types are structurally same, too.
true
} else {
Expand Down Expand Up @@ -2333,11 2293,9 @@ impl ClashingExternDeclarations {
// uninitialised memory.
_ => compare_layouts(a, b),
}
};
seen_types.mark_computed(a, b, result);
result
}
}
let mut seen_types = SeenSet::new();
let mut seen_types = FxHashSet::default();
structurally_same_type_impl(&mut seen_types, cx, a, b, ckind)
}
}
Expand Down