Skip to content

Commit a1a8164

Browse files
committed
Update Guide to reflect how nightlies are proposed
I forgot where I landed on how to handle them
1 parent cb8acba commit a1a8164

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

text/3857-cfg-version.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,20 @@ However, this would produce an `unexpected_cfgs` lint and you would need to add
171171
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rust,values(none()))'] }
172172
```
173173

174-
Say you were wanting to test out `#[must_use]` after it got stabilized on nightly to provide feedback and to be ready for when it hits stable, there would be no change to the examples above.
175-
Nightly compiler releases report themselves as the version they will be on hitting the stable channel.
174+
Say you were wanting to test out `#[must_use]` after it got stabilized on nightly to provide feedback and to be ready for when it hits stable,
175+
you would instead use `"1.27.0-0"` to match all pre-release versions of 1.27.0:
176+
```rust
177+
#[cfg_attr(since(rust, "1.27.0-0"), must_use)]
178+
fn double(x: i32) -> i32 {
179+
2 * x
180+
}
176181

177-
On the flip side, you might be bisecting nightlies or pinning to a 1.27 nightly before `#[must_use]` was stabilized.
178-
You would have the sad predicament of not being able to use `double` because you would get a feature-gate error.
179-
In that case, you can pass `-Z assume-incomplete-release` to the compiler so that 1.27 nightly reports itself as being 1.26 and `#[must_use]` won't be applied within `double`.
182+
fn main() {
183+
double(4);
184+
// warning: unused return value of `double` which must be used
185+
// ^--- This warning only happens if we are on Rust >= 1.27.
186+
}
187+
```
180188

181189
# Reference-level explanation
182190
[reference-level-explanation]: #reference-level-explanation

0 commit comments

Comments
 (0)