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

Warn must_use in tuple #29815

Closed
wants to merge 2 commits into from

Conversation

Projects
None yet
9 participants
@sanxiyn
Copy link
Member

sanxiyn commented Nov 13, 2015

cc #26291.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Nov 13, 2015

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@sanxiyn

This comment has been minimized.

Copy link
Member Author

sanxiyn commented Nov 23, 2015

Ping.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 26, 2015

☔️ The latest upstream changes (presumably #30043) made this pull request unmergeable. Please resolve the merge conflicts.

@sanxiyn sanxiyn force-pushed the sanxiyn:tuple-must-use branch from f08ccec to b31cffe Nov 27, 2015

@sanxiyn

This comment has been minimized.

Copy link
Member Author

sanxiyn commented Dec 7, 2015

Another ping.

@arielb1

This comment has been minimized.

Copy link
Contributor

arielb1 commented Dec 8, 2015

I am not sure this is a bug.

@arielb1

This comment has been minimized.

Copy link
Contributor

arielb1 commented Dec 8, 2015

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned arielb1 Dec 8, 2015

@@ -45,4 +45,7 @@ fn main() {
let _ = foo::<isize>();
let _ = foo::<MustUse>();
let _ = foo::<MustUseMsg>();

foo::<(MustUse, ())>(); //~ ERROR: unused result which must be used
foo::<(MustUseMsg, ())>(); //~ ERROR: unused result which must be used: some message

This comment has been minimized.

@nrc

nrc Dec 8, 2015

Member

Can you add checks that when we do use the result, then it is not an error?

if attr.check_name("must_use") {
let s = match attr.value_str() {
None => "".to_string(),
Some(s) => s.to_string()

This comment has been minimized.

@nrc

nrc Dec 8, 2015

Member

prefer to_owned to to_string

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Dec 8, 2015

The code looks fine (other than the minor things mentioned). But this would be a breaking change, so I would like to check with other memebers of the tools team that this should land.

Whilst it seems like a good idea, the must use lint is a little bit questionable in this case - if a field on a struct was must_use, we wouldn't assume the whole struct is must_use, so it is not clear if a tuple should be either.

cc @rust-lang/tools

@sanxiyn

This comment has been minimized.

Copy link
Member Author

sanxiyn commented Dec 8, 2015

cc @nagisa who reported the original issue.

@sanxiyn

This comment has been minimized.

Copy link
Member Author

sanxiyn commented Dec 8, 2015

Does strengthening a lint count as a breaking change? I thought it specifically didn't count as one. I'd like a clarification since I have another PR(#30021) that strengthens a lint.

@nagisa

This comment has been minimized.

Copy link
Contributor

nagisa commented Dec 8, 2015

Since it is a warning, I wouldn’t count it a breaking change in any imaginable way. There was a lengthy discussion about users of #[deny(...)] in context of new warnings and we basically decided to just ignore they exist AFAIR.

if result.is_some() {
return result;
}
}

This comment has been minimized.

@frewsxcv

frewsxcv Jan 25, 2016

Member

Alternatively, something like this might work:

tys.iter()
   .filter_map(|ty| check_must_use(cx, ty))
   .next()

@nrc nrc added the I-nominated label Jan 25, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Mar 9, 2016

We discussed this during the tools triage meeting today (sorry for the delay!) and the conclusion was that we don't want to merge this at this time. This arguably isn't idiomatic to return a tuple of results (vs a result of tuples) and it also doesn't extend well to other type compositions like enums/structs (you can ignore a struct which contains a #[must_use]. Thanks for the PR though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.