Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upWarn must_use in tuple #29815
Conversation
rust-highfive
assigned
arielb1
Nov 13, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Ping. |
This comment has been minimized.
This comment has been minimized.
|
|
sanxiyn
added some commits
Nov 13, 2015
sanxiyn
force-pushed the
sanxiyn:tuple-must-use
branch
from
f08ccec
to
b31cffe
Nov 27, 2015
This comment has been minimized.
This comment has been minimized.
|
Another ping. |
This comment has been minimized.
This comment has been minimized.
|
I am not sure this is a bug. |
arielb1
added
I-needs-decision
T-tools
labels
Dec 8, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @nrc |
rust-highfive
assigned
nrc
and unassigned
arielb1
Dec 8, 2015
nrc
reviewed
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.
This comment has been minimized.
nrc
reviewed
Dec 8, 2015
| 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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
cc @nagisa who reported the original issue. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 |
frewsxcv
reviewed
Jan 25, 2016
| if result.is_some() { | ||
| return result; | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
frewsxcv
Jan 25, 2016
Member
Alternatively, something like this might work:
tys.iter()
.filter_map(|ty| check_must_use(cx, ty))
.next()
nrc
added
the
I-nominated
label
Jan 25, 2016
This comment has been minimized.
This comment has been minimized.
|
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 |
sanxiyn commentedNov 13, 2015
cc #26291.