-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Reimplement public interface for stability #71
Conversation
src/lib.rs
Outdated
pub fn def_site() -> Span { | ||
Span(imp::Span::def_site()) | ||
Span::_new(imp::Span::def_site()) | ||
} | ||
|
||
/// Creates a new span with the same line/column information as `self` but | ||
/// that resolves symbols as though it were at `other`. | ||
pub fn resolved_at(&self, other: Span) -> Span { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this and located_at be procmacro2_semver_exempt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially had that yeah but this was used by serde_derive
, but I can remove the usage from serde_derive
@@ -1,3 +1,5 @@ | |||
#![allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to clean this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps yeah, I personally find the soup of #[cfg]
on imports somewhat unappealing and am generally ok with dead code otherwise, so I might personally lean towards leaving this
src/stable.rs
Outdated
TokenNode::Group(delim, ref stream) => { | ||
let (start, end) = match delim { | ||
match *tt { | ||
TokenTree::Group(ref g) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use the Syn match naming convention here, https://docs.rs/syn/0.12.15/syn/enum.Expr.html#syntax-tree-enums. For example TokenTree::Op(ref tt) => ... tt.op() ...
to avoid op.op()
.
@@ -158,11 +162,9 @@ impl fmt::Debug for TokenTreeIter { | |||
} | |||
} | |||
|
|||
#[cfg(procmacro2_semver_exempt)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is the same as the #[cfg]
soup above
src/lib.rs
Outdated
} | ||
} | ||
|
||
pub struct TokenTreeIter(imp::TokenTreeIter); | ||
pub struct TokenTreeIter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want a different name here because if we ever implement IntoIterator for &TokenStream then we will want this name.
src/lib.rs
Outdated
} | ||
|
||
pub fn as_str(&self) -> &str { | ||
self.0.as_str() | ||
pub fn stream(&self) -> &TokenStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sort of an unfortunate signature because you can't do anything with &TokenStream except clone or check if empty. Would it work to implement IntoIterator for &TokenStream? Or is there a cheap way to return TokenStream here?
} | ||
} | ||
|
||
pub fn set_span(&mut self, span: Span) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to clarify that this is a shallow set_span. Same for Group::set_span. Is that going to be confusing?
.travis.yml
Outdated
@@ -3,7 +3,7 @@ sudo: false | |||
|
|||
matrix: | |||
include: | |||
- rust: 1.15.0 | |||
- rust: 1.23.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore support for 1.15.0.
5993cd2
to
1f0e797
Compare
More information to come later about this, but this is a result of the work week discussions we've had about stabilizing procedural macros
Literal(f.into()) | ||
pub fn f32_unsuffixed(f: f32) -> Literal { | ||
assert!(f.is_finite()); | ||
Literal::_new(imp::Literal::float(f as f64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit scary, don't we want to stringify the exact f32
value? Not sure if this specific case is a problem but the compiler tried really hard (before APFloat, mostly) to avoid casting between f32
and f64
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this'll get fixed one we update upstream to match this api
Aside from #71 (comment) (and a broader question of "what do we even want literals to be?"), I'm curious what the plans for bringing the built-in Specifically, this design is much nicer for the decoupling being done in rust-lang/rust#49219, so I would prefer if we could first land this new API on Should it be done in lockstep, just to avoid friction for people who are using |
@eddyb I plan to land this here and then land referenced prs shortly after. Once that's done I'll send a PR to Rust nightly and we can update proc-macro2 once that lands That's the current plan at least! |
Ok! After lots of discussion at the work week I think we've settled on this API as the best way forward for stabilizing the |
More information to come later about this, but this is a result of the
work week discussions we've had about stabilizing procedural macros