Update Rust crate rustc-hash to v2 (#12001)
This commit is contained in:
@@ -55,7 +55,11 @@ impl Debug for DebugComments<'_> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let mut map = f.debug_map();
|
||||
|
||||
for node in self.comments.keys().sorted_by_key(|key| key.node().start()) {
|
||||
for node in self
|
||||
.comments
|
||||
.keys()
|
||||
.sorted_by_key(|key| (key.node().start(), key.node().end()))
|
||||
{
|
||||
map.entry(
|
||||
&NodeKindWithSource {
|
||||
key: *node,
|
||||
@@ -191,11 +195,11 @@ mod tests {
|
||||
#[test]
|
||||
fn debug() {
|
||||
let continue_statement = AnyNode::from(StmtContinue {
|
||||
range: TextRange::default(),
|
||||
range: TextRange::new(TextSize::new(18), TextSize::new(26)),
|
||||
});
|
||||
|
||||
let break_statement = AnyNode::from(StmtBreak {
|
||||
range: TextRange::default(),
|
||||
range: TextRange::new(TextSize::new(55), TextSize::new(60)),
|
||||
});
|
||||
|
||||
let source = r"# leading comment
|
||||
|
||||
@@ -5,8 +5,8 @@ expression: comments.debug(source_code)
|
||||
{
|
||||
Node {
|
||||
kind: StmtContinue,
|
||||
range: 0..0,
|
||||
source: ``,
|
||||
range: 18..26,
|
||||
source: `continue`,
|
||||
}: {
|
||||
"leading": [
|
||||
SourceComment {
|
||||
@@ -26,8 +26,8 @@ expression: comments.debug(source_code)
|
||||
},
|
||||
Node {
|
||||
kind: StmtBreak,
|
||||
range: 0..0,
|
||||
source: ``,
|
||||
range: 55..60,
|
||||
source: `break`,
|
||||
}: {
|
||||
"leading": [
|
||||
SourceComment {
|
||||
|
||||
@@ -3,21 +3,6 @@ source: crates/ruff_python_formatter/src/comments/mod.rs
|
||||
expression: comments.debug(test_case.source_code)
|
||||
---
|
||||
{
|
||||
Node {
|
||||
kind: ExprBinOp,
|
||||
range: 30..57,
|
||||
source: `10 + # More comments⏎`,
|
||||
}: {
|
||||
"leading": [
|
||||
SourceComment {
|
||||
text: "# Trailing comment",
|
||||
position: EndOfLine,
|
||||
formatted: false,
|
||||
},
|
||||
],
|
||||
"dangling": [],
|
||||
"trailing": [],
|
||||
},
|
||||
Node {
|
||||
kind: ExprNumberLiteral,
|
||||
range: 30..32,
|
||||
@@ -33,4 +18,19 @@ expression: comments.debug(test_case.source_code)
|
||||
},
|
||||
],
|
||||
},
|
||||
Node {
|
||||
kind: ExprBinOp,
|
||||
range: 30..57,
|
||||
source: `10 + # More comments⏎`,
|
||||
}: {
|
||||
"leading": [
|
||||
SourceComment {
|
||||
text: "# Trailing comment",
|
||||
position: EndOfLine,
|
||||
formatted: false,
|
||||
},
|
||||
],
|
||||
"dangling": [],
|
||||
"trailing": [],
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user