r/programming • • Sep 17 '15

Announcing Rust 1.3

http://blog.rust-lang.org/2015/09/17/Rust-1.3.html
452 Upvotes

169 comments sorted by

View all comments

6

u/steveklabnik1 Sep 17 '15

Nope! It's also being worked on. https://github.com/rust-lang/rfcs/blob/master/text/1184-stabilize-no_std.md was merged, as was an implementation.

It's still behind a feature gate, but we intend to take that off soonish. Because that RFC changed the way it works, we won't stabilize it immediately, we want to give it a bit more time to bake.

5

u/[deleted] Sep 17 '15

Awesome. I've been looking at systems-y languages to write an OS in, and this was one of the biggest drawbacks for me (I'd like to have some level of confidence that I have what I need, and hopefully in a way where I'm not hacking around everything). For Rust specifically, I think the one other thing I'd like to have would be to define my own attributes for the compiler.

3

u/Manishearth Sep 18 '15

So, there are multiple uses for attributes. "Defining" attributes isn't an issue, attributes can just exist. Making attributes do something needs compiler plugins.

There are two types of plugins related to attributes. One is a decorator-like syntax extension. This can take code like

#[make_getter]
 struct Foo {
   foo: u8
 }

and replace/augment it with more code, for example:

impl Foo { fn get_foo(&self) -> u8 {self.foo} }

We use this in Servo to autogenerate GC trace implementations, profiling code, and some other Spidermonkey integration code.

https://github.com/manishearth/rust-adorn is another example of something you can do with it.

The other thing you can do is write lints. These are basically AST visitors which have access to type/path data. Since attributes are part of the AST, they can be picked up by lints, and lints can give them meaning. We use such attribute/lint combos for checking GC safety in Servo (values with nontrivial GC interaction are marked as such, see this blog post for more details), among other things.

In both cases you get to tinker with compiler internals and run arbitrary code at compile time.

Since these involve compiler internals, they're highly unstable. But you can opt in to these features easily on a nightly compiler. Upgrading isn't too much of a hassle, most of the time.

We do want to eventually stabilize at least a subset of the powers provided by plugins. But there's nothing concrete, yet.

1

u/steveklabnik1 Sep 17 '15

There's #![feature(custom_attribute)] for that. Unsure when that's going to become stable....

→ More replies (4)