Skip to content
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

Recommend replacing ones with L's in functions like println!() #13677

Closed
mdinger opened this issue Apr 22, 2014 · 7 comments
Closed

Recommend replacing ones with L's in functions like println!() #13677

mdinger opened this issue Apr 22, 2014 · 7 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@mdinger
Copy link
Contributor

mdinger commented Apr 22, 2014

fn main()
{
    print1n!("{}", 3);
}

Give a helpful tip to point out the "one" should be an "L" in keywords like this. Pointing out zeros for O or o might also be good.

It was suggested I try to fix this which I may in a few days.

A better error message might be like:

# print1n!("{}", 3);
       ^
If you meant `println!()`, this is the wrong character.
@mcpherrinm
Copy link
Contributor

It's probably better to use the same "distance" code function name "did you mean" works, and not just focus on characters that look alike

@mdinger
Copy link
Contributor Author

mdinger commented Apr 22, 2014

What do you mean by distance? Number of characters in a keyword?

@jschaf
Copy link
Contributor

jschaf commented Apr 23, 2014

Probably edit distance, which tells how far apart two strings are using addition, deletion and substitution.

@mdinger
Copy link
Contributor Author

mdinger commented Apr 23, 2014

Okay, I think I can see how that could be done.

@mdinger mdinger closed this as completed Apr 23, 2014
@mdinger
Copy link
Contributor Author

mdinger commented Apr 23, 2014

Didn't mean to close that.

@mdinger mdinger reopened this Apr 23, 2014
@mdinger
Copy link
Contributor Author

mdinger commented May 5, 2014

Not gonna get around to trying to fix this any time soon.

@mdinger
Copy link
Contributor Author

mdinger commented May 21, 2014

If someone could add labels that would be good. I'm assuming this is E-easy. Otherwise this might get lost.

@steveklabnik steveklabnik added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Jan 23, 2015
bors added a commit that referenced this issue Nov 27, 2015
Fixes #13677
This does the same sort of suggestion for misspelt macros that we already do for misspelt identifiers.
Example. Compiling this program:

```rust
macro_rules! foo {
    ($e:expr) => ( $e )
}

fn main() {
    fob!("hello!");
}
```

gives the following error message:

```
/Users/mcp/temp/test.rs:7:5: 7:8 error: macro undefined: 'fob!'
/Users/mcp/temp/test.rs:7     fob!("hello!");
                              ^~~
/Users/mcp/temp/test.rs:7:5: 7:8 help: did you mean `foo`?
/Users/mcp/temp/test.rs:7     fob!("hello!");
```

I had to move the levenshtein distance function into libsyntax for this. Maybe this should live somewhere else (some utility crate?), but I couldn't find a crate to put it in that is imported by libsyntax and the other rustc crates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

4 participants