-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: expected one of {
or an operator, found }
#36611
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Fixing the errors reported by the compiler reveals why this parses that far: fn main() {
for i in in 1..2 {
println!("{}", i);
}
{ } }
|
steveklabnik
added
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
and removed
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Mar 9, 2017
Mark-Simulacrum
added
the
A-parser
Area: The parsing of Rust source code to an AST
label
Jun 4, 2017
Mark-Simulacrum
added
the
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
label
Jul 26, 2017
Current output points at the char immediately after the closing of the for scope, still needs some improvement:
|
This was referenced Feb 12, 2018
Closed by #48333:
That PR was reverted :( |
This was referenced Sep 19, 2018
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Sep 22, 2018
Detect `for _ in in bar {}` typo Fix rust-lang#36611, rust-lang#52964, without modifying the parsing of emplacement `in` to avoid further problems like rust-lang#50832.
use std::collections::HashMap;
fn main() {
let vec:Vec<i32> = vec![2,2,1];
single_number(vec);
}
fn single_number(nums: Vec<i32>) -> i32 {
let mut result = HashMap::new();
for v in vec! {
// 类型转换
let str_key = v.to_string();
//插入之前先判断,当前的key对应的value有值则加1,没值初始化为1
if result.get(&str_key) == None {
result.insert(str_key,1);
}else{
let str_key1 = v.to_string();
let _strValue = result.get(&str_key1);
let value = _strValue.unwrap();
result.insert(str_key,value + 1);
}
}
// 遍历result
let mut resultK = 0;
for (k,v) in &result {
println!("{},{}",k,v);
let value = *v as i32;
if value == 1
{
resultK = k.parse::<i32>().unwrap();;
}
}
resultK
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I did a stupid typo in a program, where I typed
in
twice in afor
statement:The compiler pointed the error on the closing brace, which, in the real code, with much more things happening in the loop (plus nested loops) was completely unhelpful.
The text was updated successfully, but these errors were encountered: