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 upTracking issue for stmt_expr_attributes: Add attributes to expressions, etc. #15701
Comments
brson
added
the
B-RFC-approved
label
Jul 15, 2014
This comment has been minimized.
This comment has been minimized.
|
cc @huonw |
huonw
referenced this issue
Jul 23, 2014
Closed
RFC: Allow safe access to some `static mut` vars #177
huonw
added
the
A-grammar
label
Jul 23, 2014
This comment has been minimized.
This comment has been minimized.
|
ping. will this be implemented before 1.0? |
This comment has been minimized.
This comment has been minimized.
|
The RFC suggests
which inspired me to make a plugin for cryptographically signing |
alexcrichton
added
the
T-lang
label
Aug 11, 2015
This comment has been minimized.
This comment has been minimized.
|
The RFC says:
Does this mean that And what happens if an attribute is applied to a syntax sugar construct that is later expanded, for example |
This comment has been minimized.
This comment has been minimized.
|
Just a heads up that I'm currently in the process of implementing this RFC. |
This comment has been minimized.
This comment has been minimized.
|
I think the obvious choice is to give attributes the same operator precedence as unary operators. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, thats how I'm doing it in my WIP branch right now. |
Kimundi
referenced this issue
Nov 16, 2015
Merged
Implements RFC 16, attributes on statements and expressions. #29850
bors
added a commit
that referenced
this issue
Dec 3, 2015
bors
added a commit
that referenced
this issue
Dec 4, 2015
alexcrichton
referenced this issue
Dec 11, 2015
Closed
Liveness lints should consider statement attributes #30326
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Not as far as I can rember, probably just forgot about it. :) |
Kimundi
closed this
Jan 7, 2016
This comment has been minimized.
This comment has been minimized.
|
FYI, the |
pnkfelix
referenced this issue
Apr 8, 2016
Closed
is `#[cfg]` applicable to *some* non-stmt expressions? #32796
pnkfelix
added
the
B-unstable
label
Apr 8, 2016
pnkfelix
referenced this issue
Apr 8, 2016
Closed
meta: unclear stability state of tracking issues for RFCs #32826
This comment has been minimized.
This comment has been minimized.
|
Tracking issues are open until the feature is stable, aren't they? |
bluss
reopened this
Apr 10, 2016
matklad
added a commit
to intellij-rust/intellij-rust
that referenced
this issue
Apr 18, 2016
This comment has been minimized.
This comment has been minimized.
msjyoo
commented
Jul 10, 2016
•
|
By what Rust version will this feature gate be allowed on the stable channel? I couldn't find any chart / matrix with the list of them. |
msjyoo
referenced this issue
Jul 10, 2016
Closed
Return partial RSS feeds, rss_loose feature, resolves #22 #23
nrc
added
the
I-nominated
label
Aug 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Relevant issue #43494 I still think it is a good idea to work on stabilising different groups of expressions, starting with the most trivial and useful of all -- blocks, so e.g. We can then think how and if we want to stabilise the other sort of statement/expression attributes. @liigo that’s just a
|
This comment has been minimized.
This comment has been minimized.
This form is already stable: We can also already use |
This comment has been minimized.
This comment has been minimized.
|
@solson It is only stable for blocks in statement position. |
This comment has been minimized.
This comment has been minimized.
|
Ah, fair point. In that case, I would think it an odd decision to stabilize just blocks in expression position next, instead of all expressions. I think we already came up with reasonable rules for parsing above, and we should have an FCP about implementing and stabilizing for all expressions if there are no major objections. |
zackmdavis
referenced this issue
Oct 30, 2017
Closed
--print option to list available feature gates #45223
This comment has been minimized.
This comment has been minimized.
|
To make this easier to find for others, this issue (afaict) is why we can't have cfg attributes on #[cfg(test)]
if true {
println!("testing");
}fails to compile with
Perhaps it'd be useful to make that error include a reference to this issue? |
This comment has been minimized.
This comment has been minimized.
xftroxgpx
commented
Feb 27, 2018
|
This seems to be the proper place to raise this: (if not, let me know) Why is the and I'm generalizing that based on only this one example using the #![feature(plugin)]
#![plugin(clippy)]
#![deny(print_stdout)]
fn main() {
#[allow(print_stdout)] {
println!("Hello, world!"); // all good now
}
{
#![allow(print_stdout)]
println!("Hello, world!"); // all good
}
#[allow(print_stdout)]
println!("Hello, world!"); //error: use of `println!`
}It feels like there's a multi-line behind-the-scenes expansion of What is actually happening and will this be supported when this issue is closed?
[dependencies]
clippy = "*"
error: use of `println!`
--> /tmp/proj1/src/main.rs:18:5
|
18 | println!("Hello, world!"); //error: use of `println!`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> /tmp/proj1/src/main.rs:4:9
|
4 | #![deny(print_stdout)]
| ^^^^^^^^^^^^
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.187/index.html#print_stdout
error: aborting due to previous error
error: Could not compile `proj1`.
To learn more, run the command again with --verbose.
|
This comment has been minimized.
This comment has been minimized.
|
Your first two examples are identical, the second one uses |
This comment has been minimized.
This comment has been minimized.
xftroxgpx
commented
Feb 28, 2018
|
@eddyb sorry :D I didn't mean to include that one initially, but the first I've seen of it was here in this thread, in these two comments from above: and I thought it was kinda clever and wanted to have it added, for completion(so to have all known ways to add attrs to macro calls - in my case), though I initially wanted to include only first and third examples only |
This comment has been minimized.
This comment has been minimized.
|
Well, neither of the first two examples attach an attribute to the macro invocation, but to a block surrounding it - maybe macro expansion just discards the attribute in the third example? |
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Mar 11, 2018
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Apr 26, 2018
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Apr 28, 2018
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Apr 28, 2018
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Apr 29, 2018
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this issue
May 3, 2018
This comment has been minimized.
This comment has been minimized.
|
Is it expected that attributes on function arguments are allowed?
edit: never mind, I see it was mentioned in #15701 (comment) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Same with |
This comment has been minimized.
This comment has been minimized.
liuchong
commented
Dec 21, 2018
•
|
I would like a rust conditional compile block, seems like:
say, one "cfg" multiple lines, is this possiable? |
This comment has been minimized.
This comment has been minimized.
|
There's a separate issue for applying attributes to multiple items. |
This comment has been minimized.
This comment has been minimized.
|
It's worth noting that in many cases you can work around the lack of expression attribute support by simply wrapping the expression in a block, turning it into a statement. |
This comment has been minimized.
This comment has been minimized.
|
Currently, in the following example, rustc parses the attribute as it belongs to #![feature(stmt_expr_attributes)]
fn main() {
let foo;
#[must_use]
foo = false;
}Is this expected? I think the behavior is inconsistent with how rustc parsed the attribute on |
brson commentedJul 15, 2014
Tracking RFC 40: rust-lang/rfcs#16