Skip to content

Commit 1ebe397

Browse files
committed
Rename procmacro2_unstable to procmacro2_semver_exempt
1 parent d66ecf6 commit 1ebe397

File tree

7 files changed

+71
-63
lines changed

7 files changed

+71
-63
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ matrix:
1212
script:
1313
- cargo test
1414
- cargo build --features nightly
15-
- RUSTFLAGS='--cfg procmacro2_unstable' cargo test
16-
- RUSTFLAGS='--cfg procmacro2_unstable' cargo build --features nightly
17-
- RUSTFLAGS='--cfg procmacro2_unstable' cargo doc --no-deps
15+
- RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test
16+
- RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build --features nightly
17+
- RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo doc --no-deps
1818
after_success:
1919
- travis-cargo --only nightly doc-upload
2020

2121
script:
2222
- cargo test
23-
- RUSTFLAGS='--cfg procmacro2_unstable' cargo test
23+
- RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo test
2424
env:
2525
global:
2626
- TRAVIS_CARGO_NIGHTLY_FEATURE=""

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@ proc-macro2 = { version = "0.1", features = ["nightly"] }
6565

6666
`proc-macro2` supports exporting some methods from `proc_macro` which are
6767
currently highly unstable, and may not be stabilized in the first pass of
68-
`proc_macro` stabilizations. These features are not exported by default.
68+
`proc_macro` stabilizations. These features are not exported by default. Minor
69+
versions of `proc-macro2` may make breaking changes to them at any time.
6970

70-
To export these features, the `procmacro2_unstable` config flag must be passed
71-
to rustc. To pass this flag, run `cargo` with
72-
`RUSTFLAGS='--cfg procmacro2_unstable' cargo build`.
71+
To enable these features, the `procmacro2_semver_exempt` config flag must be
72+
passed to rustc.
73+
74+
```
75+
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
76+
```
77+
78+
Note that this must not only be done for your crate, but for any crate that
79+
depends on your crate. This infectious nature is intentional, as it serves as a
80+
reminder that you are outside of the normal semver guarantees.
7381

7482

7583
# License

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ impl TokenStream {
104104
}
105105

106106
// Returned by reference, so we can't easily wrap it.
107-
#[cfg(procmacro2_unstable)]
107+
#[cfg(procmacro2_semver_exempt)]
108108
pub use imp::FileName;
109109

110-
#[cfg(procmacro2_unstable)]
110+
#[cfg(procmacro2_semver_exempt)]
111111
#[derive(Clone, PartialEq, Eq)]
112112
pub struct SourceFile(imp::SourceFile);
113113

114-
#[cfg(procmacro2_unstable)]
114+
#[cfg(procmacro2_semver_exempt)]
115115
impl SourceFile {
116116
/// Get the path to this source file as a string.
117117
pub fn path(&self) -> &FileName {
@@ -123,21 +123,21 @@ impl SourceFile {
123123
}
124124
}
125125

126-
#[cfg(procmacro2_unstable)]
126+
#[cfg(procmacro2_semver_exempt)]
127127
impl AsRef<FileName> for SourceFile {
128128
fn as_ref(&self) -> &FileName {
129129
self.0.path()
130130
}
131131
}
132132

133-
#[cfg(procmacro2_unstable)]
133+
#[cfg(procmacro2_semver_exempt)]
134134
impl fmt::Debug for SourceFile {
135135
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
136136
self.0.fmt(f)
137137
}
138138
}
139139

140-
#[cfg(procmacro2_unstable)]
140+
#[cfg(procmacro2_semver_exempt)]
141141
pub struct LineColumn {
142142
pub line: usize,
143143
pub column: usize,
@@ -168,24 +168,24 @@ impl Span {
168168
self.0.unstable()
169169
}
170170

171-
#[cfg(procmacro2_unstable)]
171+
#[cfg(procmacro2_semver_exempt)]
172172
pub fn source_file(&self) -> SourceFile {
173173
SourceFile(self.0.source_file())
174174
}
175175

176-
#[cfg(procmacro2_unstable)]
176+
#[cfg(procmacro2_semver_exempt)]
177177
pub fn start(&self) -> LineColumn {
178178
let imp::LineColumn{ line, column } = self.0.start();
179179
LineColumn { line: line, column: column }
180180
}
181181

182-
#[cfg(procmacro2_unstable)]
182+
#[cfg(procmacro2_semver_exempt)]
183183
pub fn end(&self) -> LineColumn {
184184
let imp::LineColumn{ line, column } = self.0.end();
185185
LineColumn { line: line, column: column }
186186
}
187187

188-
#[cfg(procmacro2_unstable)]
188+
#[cfg(procmacro2_semver_exempt)]
189189
pub fn join(&self, other: Span) -> Option<Span> {
190190
self.0.join(other.0).map(Span)
191191
}

src/stable.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::ascii;
22
use std::borrow::Borrow;
33
use std::cell::RefCell;
4-
#[cfg(procmacro2_unstable)]
4+
#[cfg(procmacro2_semver_exempt)]
55
use std::cmp;
66
use std::collections::HashMap;
77
use std::fmt;
@@ -36,7 +36,7 @@ impl TokenStream {
3636
}
3737
}
3838

39-
#[cfg(procmacro2_unstable)]
39+
#[cfg(procmacro2_semver_exempt)]
4040
fn get_cursor(src: &str) -> Cursor {
4141
// Create a dummy file & add it to the codemap
4242
CODEMAP.with(|cm| {
@@ -50,7 +50,7 @@ fn get_cursor(src: &str) -> Cursor {
5050
})
5151
}
5252

53-
#[cfg(not(procmacro2_unstable))]
53+
#[cfg(not(procmacro2_semver_exempt))]
5454
fn get_cursor(src: &str) -> Cursor {
5555
Cursor {
5656
rest: src,
@@ -163,24 +163,24 @@ impl IntoIterator for TokenStream {
163163
}
164164
}
165165

166-
#[cfg(procmacro2_unstable)]
166+
#[cfg(procmacro2_semver_exempt)]
167167
#[derive(Clone, PartialEq, Eq, Debug)]
168168
pub struct FileName(String);
169169

170-
#[cfg(procmacro2_unstable)]
170+
#[cfg(procmacro2_semver_exempt)]
171171
impl fmt::Display for FileName {
172172
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
173173
self.0.fmt(f)
174174
}
175175
}
176176

177-
#[cfg(procmacro2_unstable)]
177+
#[cfg(procmacro2_semver_exempt)]
178178
#[derive(Clone, PartialEq, Eq)]
179179
pub struct SourceFile {
180180
name: FileName,
181181
}
182182

183-
#[cfg(procmacro2_unstable)]
183+
#[cfg(procmacro2_semver_exempt)]
184184
impl SourceFile {
185185
/// Get the path to this source file as a string.
186186
pub fn path(&self) -> &FileName {
@@ -193,14 +193,14 @@ impl SourceFile {
193193
}
194194
}
195195

196-
#[cfg(procmacro2_unstable)]
196+
#[cfg(procmacro2_semver_exempt)]
197197
impl AsRef<FileName> for SourceFile {
198198
fn as_ref(&self) -> &FileName {
199199
self.path()
200200
}
201201
}
202202

203-
#[cfg(procmacro2_unstable)]
203+
#[cfg(procmacro2_semver_exempt)]
204204
impl fmt::Debug for SourceFile {
205205
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
206206
f.debug_struct("SourceFile")
@@ -210,14 +210,14 @@ impl fmt::Debug for SourceFile {
210210
}
211211
}
212212

213-
#[cfg(procmacro2_unstable)]
213+
#[cfg(procmacro2_semver_exempt)]
214214
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
215215
pub struct LineColumn {
216216
pub line: usize,
217217
pub column: usize,
218218
}
219219

220-
#[cfg(procmacro2_unstable)]
220+
#[cfg(procmacro2_semver_exempt)]
221221
thread_local! {
222222
static CODEMAP: RefCell<Codemap> = RefCell::new(Codemap {
223223
// NOTE: We start with a single dummy file which all call_site() and
@@ -230,14 +230,14 @@ thread_local! {
230230
});
231231
}
232232

233-
#[cfg(procmacro2_unstable)]
233+
#[cfg(procmacro2_semver_exempt)]
234234
struct FileInfo {
235235
name: String,
236236
span: Span,
237237
lines: Vec<usize>,
238238
}
239239

240-
#[cfg(procmacro2_unstable)]
240+
#[cfg(procmacro2_semver_exempt)]
241241
impl FileInfo {
242242
fn offset_line_column(&self, offset: usize) -> LineColumn {
243243
assert!(self.span_within(Span { lo: offset as u32, hi: offset as u32 }));
@@ -260,7 +260,7 @@ impl FileInfo {
260260
}
261261

262262
/// Computes the offsets of each line in the given source string.
263-
#[cfg(procmacro2_unstable)]
263+
#[cfg(procmacro2_semver_exempt)]
264264
fn lines_offsets(s: &str) -> Vec<usize> {
265265
let mut lines = vec![0];
266266
let mut prev = 0;
@@ -271,12 +271,12 @@ fn lines_offsets(s: &str) -> Vec<usize> {
271271
lines
272272
}
273273

274-
#[cfg(procmacro2_unstable)]
274+
#[cfg(procmacro2_semver_exempt)]
275275
struct Codemap {
276276
files: Vec<FileInfo>,
277277
}
278278

279-
#[cfg(procmacro2_unstable)]
279+
#[cfg(procmacro2_semver_exempt)]
280280
impl Codemap {
281281
fn next_start_pos(&self) -> u32 {
282282
// Add 1 so there's always space between files.
@@ -313,19 +313,19 @@ impl Codemap {
313313

314314
#[derive(Clone, Copy, Debug)]
315315
pub struct Span {
316-
#[cfg(procmacro2_unstable)]
316+
#[cfg(procmacro2_semver_exempt)]
317317
lo: u32,
318-
#[cfg(procmacro2_unstable)]
318+
#[cfg(procmacro2_semver_exempt)]
319319
hi: u32,
320320
}
321321

322322
impl Span {
323-
#[cfg(not(procmacro2_unstable))]
323+
#[cfg(not(procmacro2_semver_exempt))]
324324
pub fn call_site() -> Span {
325325
Span {}
326326
}
327327

328-
#[cfg(procmacro2_unstable)]
328+
#[cfg(procmacro2_semver_exempt)]
329329
pub fn call_site() -> Span {
330330
Span { lo: 0, hi: 0 }
331331
}
@@ -334,7 +334,7 @@ impl Span {
334334
Span::call_site()
335335
}
336336

337-
#[cfg(procmacro2_unstable)]
337+
#[cfg(procmacro2_semver_exempt)]
338338
pub fn source_file(&self) -> SourceFile {
339339
CODEMAP.with(|cm| {
340340
let cm = cm.borrow();
@@ -345,7 +345,7 @@ impl Span {
345345
})
346346
}
347347

348-
#[cfg(procmacro2_unstable)]
348+
#[cfg(procmacro2_semver_exempt)]
349349
pub fn start(&self) -> LineColumn {
350350
CODEMAP.with(|cm| {
351351
let cm = cm.borrow();
@@ -354,7 +354,7 @@ impl Span {
354354
})
355355
}
356356

357-
#[cfg(procmacro2_unstable)]
357+
#[cfg(procmacro2_semver_exempt)]
358358
pub fn end(&self) -> LineColumn {
359359
CODEMAP.with(|cm| {
360360
let cm = cm.borrow();
@@ -363,7 +363,7 @@ impl Span {
363363
})
364364
}
365365

366-
#[cfg(procmacro2_unstable)]
366+
#[cfg(procmacro2_semver_exempt)]
367367
pub fn join(&self, other: Span) -> Option<Span> {
368368
CODEMAP.with(|cm| {
369369
let cm = cm.borrow();
@@ -578,7 +578,7 @@ named!(token_stream -> ::TokenStream, map!(
578578
|trees| ::TokenStream(TokenStream { inner: trees })
579579
));
580580

581-
#[cfg(not(procmacro2_unstable))]
581+
#[cfg(not(procmacro2_semver_exempt))]
582582
fn token_tree(input: Cursor) -> PResult<TokenTree> {
583583
let (input, kind) = token_kind(input)?;
584584
Ok((input, TokenTree {
@@ -587,7 +587,7 @@ fn token_tree(input: Cursor) -> PResult<TokenTree> {
587587
}))
588588
}
589589

590-
#[cfg(procmacro2_unstable)]
590+
#[cfg(procmacro2_semver_exempt)]
591591
fn token_tree(input: Cursor) -> PResult<TokenTree> {
592592
let input = skip_whitespace(input);
593593
let lo = input.off;

src/strnom.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use imp::LexError;
99
#[derive(Copy, Clone, Eq, PartialEq)]
1010
pub struct Cursor<'a> {
1111
pub rest: &'a str,
12-
#[cfg(procmacro2_unstable)]
12+
#[cfg(procmacro2_semver_exempt)]
1313
pub off: u32,
1414
}
1515

1616
impl<'a> Cursor<'a> {
17-
#[cfg(not(procmacro2_unstable))]
17+
#[cfg(not(procmacro2_semver_exempt))]
1818
pub fn advance(&self, amt: usize) -> Cursor<'a> {
1919
Cursor {
2020
rest: &self.rest[amt..],
2121
}
2222
}
23-
#[cfg(procmacro2_unstable)]
23+
#[cfg(procmacro2_semver_exempt)]
2424
pub fn advance(&self, amt: usize) -> Cursor<'a> {
2525
Cursor {
2626
rest: &self.rest[amt..],

0 commit comments

Comments
 (0)