Skip to content
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

libsyntax: Change ~[T] to Vec<T>. #12637

Merged
merged 6 commits into from
Mar 2, 2014
Merged

libsyntax: Change ~[T] to Vec<T>. #12637

merged 6 commits into from
Mar 2, 2014

Conversation

pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Mar 1, 2014

cx.cfg(),
tts.iter()
.map(|x| (*x).clone())
.collect());
Copy link
Member

Choose a reason for hiding this comment

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

This is a rather unfortunate pattern. Shouldn't there be something like tts.to_vec() or Vec::from_slice(tts)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just transitionary. I don't really want to add methods to Vec that will persist for only a week or so.

@alexcrichton
Copy link
Member

I'm curious, but what were some of the good/bad parts of this conversion? With future traits we plan on implementing, do you think that this is an adequate replacement for ~[T]?

I'm also curious if there are patterns that were concise previously but verbose now. There seem to be lots of spots in this diff which have gotten more verbose, but most of them look like they could be reduced.

I commented on a few places (obviously just spot checking), and I just wanted to make sure that there's a relatively nice way of expressing those. Otherwise, let's do this, r=me p=1

@pcwalton
Copy link
Contributor Author

pcwalton commented Mar 1, 2014

I think this will be an adequate replacement once we have Deref and the old vectors are gone. All the nastiness in this pull request is mostly just because of places where we have to convert from new to old or vice versa.

@alexcrichton
Copy link
Member

Sounds good to me, r=me whenever you please.

@bnoordhuis
Copy link
Contributor

May I suggest that the commit logs explain why this is being changed? As an outsider, I can only guess now.

@huonw
Copy link
Member

huonw commented Mar 2, 2014

#8981 is a big reason for wanting to switch to Vec; there's also some consideration with DST (dynamically sized types) where having a uniform representation of Ptr<[T]> is much nicer (under DST ~[T] just stores its length, without a capacity).)

(In any case, I agree that having a short sentence or two for the background of these changes in the commits is useful: very helpful for history diving in future when all contemporary context is lost.)

@bill-myers
Copy link
Contributor

Are these kinds of changes being done automatically or manually?

If the former, it would be nice to release the software, so that people with Rust codebases can run it too on their own codebase.

If the latter, maybe rustc should be enhanced with infrastructure to make writing such translators easy, and then it should be used.

Ideally there would be a tool that automatically applies all the changes that ever happened to old Rust code.

@pcwalton
Copy link
Contributor Author

pcwalton commented Mar 2, 2014

@bors: retry

@pcwalton
Copy link
Contributor Author

pcwalton commented Mar 2, 2014

The tool is far too primitive and hacky for public consumption, unfortunately.

@bors bors closed this Mar 2, 2014
@bors bors merged commit 3559324 into rust-lang:master Mar 2, 2014
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 2, 2024
…hable initializers

This commit introduces a check to ensure that the lint won't trigger when the initializer is
unreachable, such as:

```
thread_local! {
    static STATE: Cell<usize> = panic!();
}
```

This is achieved by looking at the unpeeled initializer expression and ensuring that the parent
macro is not `panic!()`, `todo!()`, `unreachable!()`, `unimplemented!()`.

fixes rust-lang#12637

changelog: [`threadlocal_initializer_can_be_made_const`] will no longer trigger on `unreachable` macros.
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 2, 2024
Threadlocal_initializer_can_be_made_const will not trigger for unreachable initializers

This commit introduces a check to ensure that the lint won't trigger when the initializer is unreachable, such as:

```
thread_local! {
    static STATE: Cell<usize> = panic!();
}
```

This is achieved by looking at the unpeeled initializer expression and ensuring that the parent macro is not `panic!()`, `todo!()`, `unreachable!()`, `unimplemented!()`.

fixes rust-lang#12637

changelog: [`threadlocal_initializer_can_be_made_const`] will no longer trigger on `unreachable` macros.
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.

7 participants