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

Unnecessary parens could warn on let foo = (bar); #12350

Closed
alexcrichton opened this issue Feb 17, 2014 · 6 comments
Closed

Unnecessary parens could warn on let foo = (bar); #12350

alexcrichton opened this issue Feb 17, 2014 · 6 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@alexcrichton
Copy link
Member

Just another case that the unnecessary-parens lint could warn about. I don't think that the parens serve any use in that situation.

@milibopp
Copy link
Contributor

I'll give it a try. I think this could be extended to operator assignments, too:

let mut foo = 0;
let bar = 1;
foo += (bar); // here

@huonw
Copy link
Member

huonw commented Feb 18, 2014

@aepsil0n sounds good: it should be possible to extend the match in rustc::middle::lint::check_unnecessary_parens to include ExprAssign and ExprAssignOp.

@pnkfelix
Copy link
Member

I sometimes use "unnecessary" parens in order to compensate for my editor's (Emacs with rust-mode.el) auto-indent, e.g.:

    let a = if b { c }
        else { d };
    // versus
    let a = (if b { c }
             else { d });

Not sure whether I would just disable the unnecessary-parens lint in my projects, or if I would try to add an exception to the lint when the contained expression spans multiple lines in the source file.

@milibopp
Copy link
Contributor

@pnkfelix Since there is no significant whitespace in Rust (unlike e.g. Python, where this totally makes sense), I'd intuitively say, that's an editor issue and not a syntax issue. Anyway, how would you check the expression for whether it's multiline?

@pnkfelix
Copy link
Member

@aepsil0n You could check whether the expression crosses lines by using the expression's Span and CodeMap::lookup_char_pos , I think?

But as I tried to indicate, it could just be a matter of personal preference, and I can always disable the lint in my own projects.

@milibopp
Copy link
Contributor

Yeah, I'll leave it out for now. Just being curious. ^^

@bors bors closed this as completed in eb5ba4d Feb 22, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
Fix build on OpenBSD (and probably other BSDs too)

notify-5.0.0-pre.14 does not build on these systems; this was fixed in
notify-rs/notify@41a74f0 , which landed in pre.15.
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 26, 2024
…olors, r=xFrednet

style: sync GitHub Corner colors

fixes rust-lang#12349.

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: sync site GitHub Corner colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants