Skip to content

Trying to concatenate strings with operator += results in an Internal Compiler Error #11344

Closed
@Matthias247

Description

@Matthias247

The following code produces an internal compiler error:

fn main() {
    let mut mystr = ~"";
    mystr += ~"abc";
    println(mystr);
}

Compiler output:

$ rustc.exe main.rs
main.rs:7:5: 7:20 error: binary operation + cannot be applied to type `~str`
main.rs:7     mystr += ~"abc";
              ^~~~~~~~~~~~~~~
error: internal compiler error: no type for node 48: expr "abc" (id=48) in fcx 0
x65041c0
This message reflects a bug in the Rust compiler.
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
task 'rustc' failed at 'explicit failure', C:\Rust\rust\src\libsyntax\diagnostic.rs:75
task '<main>' failed at 'explicit failure', C:\Rust\rust\src\librustc\lib.rs:440

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions