Skip to content

More 0.7 release notes #7165

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

Closed
wants to merge 1 commit into from
Closed

More 0.7 release notes #7165

wants to merge 1 commit into from

Conversation

brson
Copy link
Contributor

@brson brson commented Jun 15, 2013

No description provided.

* The `main` function is only detected at the topmost level of the crate.
The `#[main]` attribute is still valid anywhere.
* Struct fields may no longer be mutable. Use inherited mutability.
* Oh, but actually you can put `#[mutable]` on a field if you *really*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? I thought that this just turned on some bit about the type information in middle::ty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's required if you're going to use unsafe code to hack around the mutability rules. Perhaps it shouldn't be mentioned at all, since it's just an edge case feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this doesn't mean that this is valid code, right?

struct A {
  #[mutable]
  a: int
}

fn main() {
  let a = A{ a: 3 };
  a.a = 4;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur, don't even mention the attribute.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work. It can only be applied to the type (not a field or variant) and all it does is make it not classified as Const (soon to be Freeze). Making it safe is still entirely up to the user, it's just one tool required to make a type like RcMut safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #[mutable] and #[non_owned] both turn off traits perhaps we can name them similarly, #[non_send], #[non_freeze], etc?

Both of these are added in 0.7. It seems notable that we are providing this way to turn off a feature of the type system, so I'm inclined to mention it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brson: yeah, I think they should be renamed but @pcwalton's commits to rename the traits haven't landed yet.

It makes sense to mention them, but perhaps not as a replacement for mutable fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated to reflect this feedback. Thanks.

@bors bors closed this Jun 16, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 20, 2021
Fix needless_quesiton_mark false positive

changelog: Fix [`needless_question_mark`] false positive where the inner value is implicity dereferenced by the question mark.

Fixes rust-lang#7107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants