mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:41:12 +00:00
Update Rust crate rustc-hash to v2 (#12001)
This commit is contained in:
parent
446ad0ba44
commit
53a80a5c11
17 changed files with 78 additions and 105 deletions
|
@ -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": [],
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue