Skip to content

Commit f3e4d34

Browse files
authored
Merge pull request #4962 from youknowone/fix-ast
Revert a few .as_str() calls by adding it to ast
2 parents b85e134 + a43a8c5 commit f3e4d34

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

Cargo.lock

Lines changed: 6 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ rustpython-pylib = { path = "pylib" }
2929
rustpython-stdlib = { path = "stdlib" }
3030
rustpython-doc = { git = "https://github.com/RustPython/__doc__", branch = "main" }
3131

32-
rustpython-literal = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "aa101e4f2693624eddabe35eaf3067bba65331df" }
33-
rustpython-parser-core = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "aa101e4f2693624eddabe35eaf3067bba65331df" }
34-
rustpython-parser = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "aa101e4f2693624eddabe35eaf3067bba65331df" }
35-
rustpython-ast = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "aa101e4f2693624eddabe35eaf3067bba65331df" }
32+
rustpython-literal = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "5b2af304a2baa53598e594097824165d4ac7a119" }
33+
rustpython-parser-core = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "5b2af304a2baa53598e594097824165d4ac7a119" }
34+
rustpython-parser = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "5b2af304a2baa53598e594097824165d4ac7a119" }
35+
rustpython-ast = { git = "https://github.com/youknowone/RustPython-parser.git", rev = "5b2af304a2baa53598e594097824165d4ac7a119" }
3636
# rustpython-literal = { path = "../RustPython-parser/literal" }
3737
# rustpython-parser-core = { path = "../RustPython-parser/core" }
3838
# rustpython-parser = { path = "../RustPython-parser/parser" }

compiler/codegen/src/compile.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,16 +582,16 @@ impl Compiler {
582582
value: num_traits::Zero::zero(),
583583
});
584584
self.emit_constant(ConstantData::None);
585-
let idx = self.name(name.name.as_str());
585+
let idx = self.name(&name.name);
586586
emit!(self, Instruction::ImportName { idx });
587587
if let Some(alias) = &name.asname {
588-
for part in name.name.as_str().split('.').skip(1) {
588+
for part in name.name.split('.').skip(1) {
589589
let idx = self.name(part);
590590
emit!(self, Instruction::LoadAttr { idx });
591591
}
592592
self.store_name(alias.as_str())?
593593
} else {
594-
self.store_name(name.name.as_str().split('.').next().unwrap())?
594+
self.store_name(name.name.split('.').next().unwrap())?
595595
}
596596
}
597597
}
@@ -600,7 +600,7 @@ impl Compiler {
600600
module,
601601
names,
602602
}) => {
603-
let import_star = names.iter().any(|n| n.node.name.as_str() == "*");
603+
let import_star = names.iter().any(|n| &n.node.name == "*");
604604

605605
let from_list = if import_star {
606606
if self.ctx.in_func() {

compiler/codegen/src/symboltable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl SymbolTableBuilder {
646646
if let ImportFrom(StmtImportFrom { module, names, .. }) = &statement.node {
647647
if module.as_ref().map(|id| id.as_str()) == Some("__future__") {
648648
for feature in names {
649-
if feature.node.name.as_str() == "annotations" {
649+
if &feature.node.name == "annotations" {
650650
self.future_annotations = true;
651651
}
652652
}
@@ -752,7 +752,7 @@ impl SymbolTableBuilder {
752752
} else {
753753
// `import module`
754754
self.register_name(
755-
name.node.name.as_str().split('.').next().unwrap(),
755+
name.node.name.split('.').next().unwrap(),
756756
SymbolUsage::Imported,
757757
location,
758758
)?;

0 commit comments

Comments
 (0)