Skip to content

Remove owned string literal - #13548

Closed
richo wants to merge 1 commit into
rust-lang:masterfrom
richo:remove_owned_string_literal
Closed

Remove owned string literal#13548
richo wants to merge 1 commit into
rust-lang:masterfrom
richo:remove_owned_string_literal

Conversation

@richo

Copy link
Copy Markdown
Contributor

Had a quick stab at this with a sed macro.

Fixed a lot of strings, but there's a bunch of tidy errors because of the increased line lengths now, definitely some broken tests, and isn't complete.

Pushing purely so that there's state on this. /cc #13543

@richo

Copy link
Copy Markdown
ContributorAuthor

So having played with this a little.. should I be using the str! macro instead, purely for brevity?

This upsets a LOT of checking because of how much longer it makes lines that include more than one string.

@brson

Copy link
Copy Markdown
Contributor

@richo No, I think what you've done with to_owned is fine. Can you rebase so this can be merged? This looks a good start, and I think it's best to merge in pieces so to avoid clashing with @pcwalton.

@richo

Copy link
Copy Markdown
ContributorAuthor

I broke a bunch of tests while I was doing this, I think (based on my make check) run last night. I think mostly to do with the repr of strings.

Regardless I'll rebase and push now.

@richo

Copy link
Copy Markdown
ContributorAuthor

(FWIW rustc builds and does reasonable things with my stripe bindings after this patch)

@richo

Copy link
Copy Markdown
ContributorAuthor

Rebased.

@brson

Copy link
Copy Markdown
Contributor

@richo GitHub still says it can't merge. Maybe something landed that conflicted after you rebased (perhaps another good reason to do this type of change in small chunks).

@richo

Copy link
Copy Markdown
ContributorAuthor

Entirely valid. Should I split this into per-file commits maybe?

@richo

Copy link
Copy Markdown
ContributorAuthor

I just rebased again. Assuming noone pushes anything conflicting before you get a chance to look at it, this should be merge-able, but I'm open to the idea of splitting this up a bit.

My only real concern is the amount of merge bubbles I'll create by doing this one lib at a time. Totall appreciate you working with me on this though :)

@richoricho changed the title [WIP] Remove owned string literalRemove owned string literalApr 17, 2014
@richo

Copy link
Copy Markdown
ContributorAuthor

I'm getting this failure locally too:

/home/travis/build/mozilla/rust/src/libstd/tuple.rs:272:21: 272:35 error: type `&'static str` does not implement any method in scope named `to_owned`
/home/travis/build/mozilla/rust/src/libstd/tuple.rs:272 let a = (1, "2".to_owned());
^~~~~~~~~~~~~~

Is this a bootstrapping issue? eg, it's building a stage with a rustc too old to know about it?

@brson

Copy link
Copy Markdown
Contributor

@richo No, probably not. The to_owned fn is defined by the std::str::StrSlice trait, which is typically imported by the prelude, so available everywhere. std though does not import the prelude, so all imports must be explicit. This code is probably just missing the import.

@richo

Copy link
Copy Markdown
ContributorAuthor

Thanks, I was just about to push changes backing out of the change in those modules, but instead I'll fix it. I won't push again till the tests pass locally.

@richo

Copy link
Copy Markdown
ContributorAuthor

That unused import warning is a bug, since StrSlice is used in both a #[cfg(test)] and a #cfg(not(test))].

@richo

Copy link
Copy Markdown
ContributorAuthor

These test breakages are new to me (but consistent with my dev environment).

Any ideas @brson / @pcwalton ?

(Sorry for the delays in getting this in)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be written as:

Err(...);
//~^ ERROR: cannot determine a type for this expression: unconstrained type

The line with the error should go right next to the statement that should fail. If there's a tidy error, you can do what I've done in the example above. That is, put the expected error in the line below and use a ^ to specify that the expected error should be raised by the line above the comment.

@richo

Copy link
Copy Markdown
ContributorAuthor

Thanks for all the feedback! Updateing now.

@richo

Copy link
Copy Markdown
ContributorAuthor

I think the tests all pass locally (I'm waiting on make clean && make -j4 check now), and I've rebased on master.

@richo

Copy link
Copy Markdown
ContributorAuthor

And the tests pass!! \o/

/cc @brson

@brson

Copy link
Copy Markdown
Contributor

Since I never get to this before it goes stale, I've rebased and pushed to my own branch to land: #13607

It should land today. Thanks for your patience!

@brsonbrson closed this Apr 18, 2014
bors added a commit that referenced this pull request Apr 18, 2014
bors added a commit that referenced this pull request Apr 19, 2014
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2022
Fix `tt::Punct`'s spacing calculation
Fixesrust-lang#13499
We currently set a `tt::Punct`'s spacing to `Spacing::Joint` unless its next token is a trivia (i.e. whitespaces or comment). As I understand it, rustc only [sets `Spacing::Joint` if the next token is an operator](https://github.com/rust-lang/rust/blob/5b3e9090757da9a95b22f589fe39b6a4b5455b96/compiler/rustc_parse/src/lexer/tokentrees.rs#L77-L78) and we should follow it to guarantee the consistent behavior of proc macros.
Manishearth pushed a commit to Manishearth/rust that referenced this pull request Nov 23, 2022
internal: Update proc-macro-srv tests
Should have been included in rust-lang#13548, but I didn't notice as those tests aren't run in our CI.
cc rust-lang#104454
Sign up for freeto 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.

3 participants

@richo@brson@flaper87