Skip to content

Rollup of 8 pull requests #106386

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

Merged
merged 24 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
40916ef
Add notes and examples about non-intuitive `PathBuf::set_extension` b…
tbu- Dec 30, 2022
b7b252a
clean: Always store enum disriminant.
aDotInTheVoid Jan 1, 2023
cca5d21
Rustdoc-Json: Report discriminant on all kinds of enum variant.
aDotInTheVoid Jan 1, 2023
beefcf8
Cleanup `mingw-tidy` docker job
jyn514 Dec 31, 2022
3919b71
Fix rustdoc ICE on bad typedef with mismatching types
GuillaumeGomez Jan 2, 2023
e885356
Add regression test for #106226
GuillaumeGomez Jan 2, 2023
ed3c3d3
Add regression test for #105334
GuillaumeGomez Jan 2, 2023
1a94322
Add regression test for #105737
GuillaumeGomez Jan 2, 2023
a167435
Add regression test for #105742
GuillaumeGomez Jan 2, 2023
c156773
Add regression test for #96287
GuillaumeGomez Jan 2, 2023
693399f
Update books
rustbot Jan 2, 2023
fd59b62
Add PhantomData marker to Context to make Context !Send and !Sync
Apr 12, 2022
257e766
Remove test of static Context
dtolnay Jan 2, 2023
e1787f5
Reduce HIR debug output
Noratrieb Dec 11, 2022
3c7c694
Document rustc_ast::Extern variants
Manishearth Jan 2, 2023
157211f
Document rustc_ast::FnHeader fields
Manishearth Jan 2, 2023
722bc0c
Rollup merge of #95985 - jihiggins:issue-66481, r=dtolnay
compiler-errors Jan 2, 2023
da1ca5d
Rollup merge of #104298 - tbu-:pr_set_extension_caveats, r=m-ou-se
compiler-errors Jan 2, 2023
fbffaa9
Rollup merge of #105558 - Nilstrieb:less-spam-hir-tree, r=cjgillot
compiler-errors Jan 2, 2023
0670a61
Rollup merge of #106315 - jyn514:cleanup-mingw-tidy, r=fee1-dead
compiler-errors Jan 2, 2023
0d5c5fa
Rollup merge of #106354 - aDotInTheVoid:rdj-always-discr, r=Guillaume…
compiler-errors Jan 2, 2023
ea3c4d8
Rollup merge of #106366 - GuillaumeGomez:fix-rustdoc-ice-typedef-type…
compiler-errors Jan 2, 2023
d112cd9
Rollup merge of #106376 - rustbot:docs-update, r=ehuss
compiler-errors Jan 2, 2023
d4cf00f
Rollup merge of #106383 - Manishearth:ast-docs, r=compiler-errors
compiler-errors Jan 2, 2023
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
Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with
the alternate (`#`) flag. This commit reduces the amount of noisy
newlines by forcing a few small key types to stay on one line, which
makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
  • Loading branch information
Noratrieb committed Jan 2, 2023
commit e1787f557223245375571550000eb6441de17b6e
9 changes: 8 additions & 1 deletion compiler/rustc_data_structures/src/sorted_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::fmt::Debug;
use std::mem;
use std::ops::{Bound, Index, IndexMut, RangeBounds};

Expand All @@ -16,7 +17,7 @@ pub use index_map::SortedIndexMultiMap;
/// stores data in a more compact way. It also supports accessing contiguous
/// ranges of elements as a slice, and slices of already sorted elements can be
/// inserted efficiently.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
pub struct SortedMap<K, V> {
data: Vec<(K, V)>,
}
Expand Down Expand Up @@ -314,5 +315,11 @@ impl<K: HashStable<CTX> + StableOrd, V: HashStable<CTX>, CTX> HashStable<CTX> fo
}
}

impl<K: Debug, V: Debug> Debug for SortedMap<K, V> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_map().entries(self.data.iter().map(|(a, b)| (a, b))).finish()
}
}

#[cfg(test)]
mod tests;
16 changes: 15 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,11 @@ impl fmt::Debug for OwnerNodes<'_> {
&self
.nodes
.iter_enumerated()
.map(|(id, parented_node)| (id, parented_node.as_ref().map(|node| node.parent)))
.map(|(id, parented_node)| {
let parented_node = parented_node.as_ref().map(|node| node.parent);

debug_fn(move |f| write!(f, "({id:?}, {parented_node:?})"))
})
.collect::<Vec<_>>(),
)
.field("bodies", &self.bodies)
Expand Down Expand Up @@ -3615,3 +3619,13 @@ mod size_asserts {
static_assert_size!(TyKind<'_>, 32);
// tidy-alphabetical-end
}

fn debug_fn(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Debug {
struct DebugFn<F>(F);
impl<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result> fmt::Debug for DebugFn<F> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
(self.0)(fmt)
}
}
DebugFn(f)
}
21 changes: 18 additions & 3 deletions compiler/rustc_hir/src/hir_id.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
use rustc_span::{def_id::DefPathHash, HashStableContext};
use std::fmt;
use std::fmt::{self, Debug};

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Encodable, Decodable)]
pub struct OwnerId {
pub def_id: LocalDefId,
}

impl Debug for OwnerId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Example: DefId(0:1 ~ aa[7697]::{use#0})
Debug::fmt(&self.def_id, f)
}
}

impl From<OwnerId> for HirId {
fn from(owner: OwnerId) -> HirId {
HirId { owner, local_id: ItemLocalId::from_u32(0) }
Expand Down Expand Up @@ -60,14 +67,22 @@ impl<CTX: HashStableContext> ToStableHashKey<CTX> for OwnerId {
/// the `local_id` part of the `HirId` changing, which is a very useful property in
/// incremental compilation where we have to persist things through changes to
/// the code base.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Encodable, Decodable, HashStable_Generic)]
#[rustc_pass_by_value]
pub struct HirId {
pub owner: OwnerId,
pub local_id: ItemLocalId,
}

impl Debug for HirId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Example: HirId(DefId(0:1 ~ aa[7697]::{use#0}).10)
// Don't use debug_tuple to always keep this on one line.
write!(f, "HirId({:?}.{:?})", self.owner, self.local_id)
}
}

impl HirId {
/// Signal local id which should never be used.
pub const INVALID: HirId =
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui/thir-tree.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ Thir {
kind: Scope {
region_scope: Node(2),
lint_level: Explicit(
HirId {
owner: OwnerId {
def_id: DefId(0:3 ~ thir_tree[8f1d]::main),
},
local_id: 2,
},
HirId(DefId(0:3 ~ thir_tree[8f1d]::main).2),
),
value: e0,
},
Expand Down