Closed
Description
Code
Luckily I found this error in rust playground.
pub fn trimGood(line: String) -> String {
let mut fixed = String::new();
for i in 0..line.len() {
let last = line.chars().nth(if i == 0 { 0 } else {i - 1}); //I think this made the error
let current = line.chars().nth(i).unwrap();
let next = line.chars().nth(i);
if let Some(q) = last && i != 0 {
if q == ' ' && current == ' ' {
println!("Ignore; current: {:#?}, next: {:#?}", current, q);
fixed += "@";
} else {
fixed += ¤t.to_string();
}
} else {
fixed += ¤t.to_string();
}
}
return fixed;
}
fn main() {
let q = " trim this ";
println!("ptr: {:#?}", q.to_string());
println!("ptr: {:#?}", trimGood(q.to_string()));
}
Meta
Stable: 1.51.0
Error output
Compiling playground v0.0.1 (/playground)
error[E0658]: `let` expressions in this position are experimental
--> src/main.rs:9:12
|
9 | if let Some(q) = last && i != 0 {
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
NodeId(77),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: could not compile `playground`
To learn more, run the command again with --verbose.