-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Rearchitect the attribute-usage lint #3
Conversation
I like this, but being able to modify |
It seems like it'd be a pain to properly link things in the side table. A |
This sounds like a great idea to me, but I agree with @huonw that a side table may be the way to go for now (it's what almost everything else uses). Things like unused-unsafe, unused-mut, etc, could also all use |
That seems reasonable to me. I think this will require a bit more infrastructure than |
The parallelism was my concern too, although I guess (Doesn't TLD go against parallelism too? I guess the ident interner needs to change for parallelism, anyway.) |
Why not? (We can either give attributes nodeids, or have a special attribute id doing a similar thing.)
I don't think it has to be the side table: just each stage has to have access to a side table, and then the lint has to look at all of them (or just merge all the tables before doing any look-ups). |
|
Oh, of course. it doesn't have to be task-local at all: the parser can just keep track of it... (Although then we hit the problems that caused us to reassign nodeids like we do now: macro expansion has to be careful reassign everything or things end up with duplicated ids.) |
Well... actually maybe that's not so much of a problem for attributes. In fact, maybe duplicated IDs is exactly what we want, so that we don't get "spurious" warnings, where one expansion of a macro legitimately uses some attribute but another doesn't. |
I would want to minimize the amount of anti-"spurious" warning logic because it won't work in all cases. It seems to me that it's a macro's responsibility to mark all the attributes it's okay with as used even if it isn't using them at that point. There are cases I can imagine like "don't use this attribute unless you've already used this attribute on the struct" or something that should still get attribute usage warnings. |
Some thoughts:
|
I'd like to avoid the whitelist approach entirely since it won't be able (I don't think) warn in cases like this, where the attribute is valid but ignored since it's missing the attribute on the Item that actually does the work: #[feature(phase)];
#[phase(syntax, link)]
extern crate some_orm;
// #[ormify]
pub struct Foo {
#[column(foo_)]
#[primary_key]
foo: int
} I think the Java-style approach would also run into this. How does this sound: pub type AttrId = uint; // u32?
pub struct Attribute_ {
id: AttrId,
style: AttrStyle,
value: @MetaItem,
is_sugared_doc: bool,
} We can adjust the Do people have preferences on the storage location of the side table? A task-local store would be the most convenient, and allow for the |
I've updated the RFC to describe the side table approach. |
Can we make You are correct that any Java-style scheme is going to be more limited than what we can achieve with custom coding. Talking it over in the meeting I actually kind of came around -- an imperative scheme is more flexible, and we could probably layer a more declarative scheme on top if desired. |
Making |
Updated with |
I do think that a Java-style scheme would be worth thinking about as well, as this proposal won't handle something I've run into recently: #[deriving(Ord(a, c))]
pub struct Foo {
a: int,
b: int,
c: int
} I thought the We could potentially handle that with this proposal by pushing the IDs out from |
@sfackler isn't that the fault of |
It is, but in the same way that it's also the fault of |
Right. In this case, it's scanning the argument list anyway, I think it's the job of deriving to validate its format. |
It sounds like we're all in general agreement that this is the right direction to go in. Details may change along the way, but that's expected from an RFC. I'm going to merge this. |
Committed in 1245e64 |
Add Cursor, remove MemWriter/MemReader
Explanations about the buffer contents
include explicit examples of parametric aliases.
Rewrite to include abstract type syntax.
Dump my notes on arbitrary self types
Clarify language on affiliation
No description provided.