Skip to content

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented Oct 3, 2025

Example

Assist: make_raw_string

fn f() {
    let s = $0b"random\nstring";
}

->

fn f() {
    let s = br#"random
string"#;
}

Assist: make_raw_string

fn f() {
    let s = $0c"random\nstring";
}

->

fn f() {
    let s = cr#"random
string"#;
}

Assist: add_hash

fn f() {
    let s = $0cr"random string";
}

->

fn f() {
    let s = cr#"random string"#;
}

Assist: remove_hash

fn f() {
    let s = $0cr#"random string"#;
}

->

fn f() {
    let s = cr"random string";
}

Assist: make_usual_string

fn f() {
    let s = $0cr#"random string"#;
}

->

fn f() {
    let s = c"random string";
}

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2025
Copy link
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 But could this be migrated to use SyntaxEditor as well?

@A4-Tacks
Copy link
Contributor Author

The current implementation can replace quotation marks separately instead of string tokens

Using SyntaxEditor requires replacing the string token

@ShoyuVanilla
Copy link
Member

Yeah, but we should eventually get rid of mutable syntax tree usages. Though this PR achieves solid improvement without much changes but the added lines won't directly work with the new API so I think it would be better to migrate it as well

Example
---

Assist: `make_raw_string`

```rust
fn f() {
    let s = $0b"random\nstring";
}
```
->
```rust
fn f() {
    let s = br#"random
string"#;
}
```

---

Assist: `make_raw_string`

```rust
fn f() {
    let s = $0c"random\nstring";
}
```
->
```rust
fn f() {
    let s = cr#"random
string"#;
}
```

---

Assist: `add_hash`

```rust
fn f() {
    let s = $0cr"random string";
}
```
->
```rust
fn f() {
    let s = cr#"random string"#;
}
```

---

Assist: `remove_hash`

```rust
fn f() {
    let s = $0cr#"random string"#;
}
```
->
```rust
fn f() {
    let s = cr"random string";
}
```

---

Assist: `make_usual_string`

```rust
fn f() {
    let s = $0cr#"random string"#;
}
```
->
```rust
fn f() {
    let s = c"random string";
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants