Skip to content

implementing RFC 1623. This fixes #35897. #35915

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 8 commits into from
Sep 2, 2016
Merged

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented Aug 23, 2016

This is a work in progress. In particular, I want to add more tests,
especially the compile-fail test is very bare-bones.

This is a work in progress. In particular, I want to add more tests,
especially the compile-fail test is very bare-bones.
@rust-highfive
Copy link
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@llogiq
Copy link
Contributor Author

llogiq commented Aug 23, 2016

r? @nikomatsakis

@llogiq
Copy link
Contributor Author

llogiq commented Aug 23, 2016

Now the tests pass for me. That was too easy. 😄

I still want to add more tests to check for possible interference with custom types (structs/enums) and aliases, but @nikomatsakis if you want to merge this, I'm fine with adding those tests in a later PR.

@@ -1554,7 +1554,7 @@ fn type_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
NodeItem(item) => {
match item.node {
ItemStatic(ref t, _, _) | ItemConst(ref t, _) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget, did the RFC cover both constants and statics? Presumably yes.

@nikomatsakis
Copy link
Contributor

I still want to add more tests to check for possible interference with custom types (structs/enums) and aliases, but @nikomatsakis if you want to merge this, I'm fine with adding those tests in a later PR.

Looks good to me thus far -- why not add the tests now though.

llogiq added 2 commits August 23, 2016 21:38
...there is still one confusing thing – see the _BAZ functions, which
appear to be elided in the `compile-fail` test and defaulted in the
´run-pass` test (if you uncomment line 73).
@llogiq
Copy link
Contributor Author

llogiq commented Aug 24, 2016

Note there's still a strange mismatch between the run-pass and the compile-fail test.

@llogiq llogiq changed the title first attempt at implementing RFC 1623. This fixes #35897. implementing RFC 1623. This fixes #35897. Aug 24, 2016

let y = &[1u8, 2, 3];
STATIC_BAZ(BYTES);
//CONST_BAZ(y); // strangely enough, this fails
Copy link
Contributor

Choose a reason for hiding this comment

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

can you elaborate? how does it fail?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I created a play version: https://is.gd/RBg85e and I see now what you mean. This is, I think, expected! The type of Baz would be &'static fn(&'static [u8]) -> Option<u8>, and yet when you supply y it only has a lifetime confined to the current stack frame. If you change to CONST_BAZ(BYTES) it should work, I think.

@llogiq
Copy link
Contributor Author

llogiq commented Aug 29, 2016

cc @chriskrycho This will also need some documentation. I vaguely remember you wanted to be notified in such an event. I'm not sure, but perhaps a paragraph in the relevant book chapter?

@llogiq
Copy link
Contributor Author

llogiq commented Aug 29, 2016

Error appears to be LLVM related.

@TimNN
Copy link
Contributor

TimNN commented Aug 29, 2016

The LLVM error is #36077, to be fixed by #36080.

@llogiq
Copy link
Contributor Author

llogiq commented Aug 29, 2016

Thanks, @TimNN

@chriskrycho
Copy link
Contributor

👍 @llogiq – I'll review the RFC and see if I can submit a PR to the book in the next two weeks. (That's a long time because lots of travel and other commitments in the meantime, but it's on my radar now.)

@llogiq
Copy link
Contributor Author

llogiq commented Aug 29, 2016

@chriskrycho Great, one thing I don't need to do. To save you time, the RFC basically boils down to "elide lifetimes with a 'static default in statics and consts as per the usual elision rules. The contained tests show corner cases.

@llogiq
Copy link
Contributor Author

llogiq commented Aug 31, 2016

@nikomatsakis now that #36080 has landed, can we bump travis? Should I make a "bump" commit?

@nikomatsakis
Copy link
Contributor

@llogiq I don't know much about how travis works in that respect.

@nikomatsakis
Copy link
Contributor

Er, do you just want to re-run travis results?

@nikomatsakis
Copy link
Contributor

@bors r+

The travis failures look to be unrelated to this patch.

@bors
Copy link
Collaborator

bors commented Aug 31, 2016

📌 Commit a87b4d8 has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Sep 2, 2016

⌛ Testing commit a87b4d8 with merge 022cb6d...

bors added a commit that referenced this pull request Sep 2, 2016
implementing RFC 1623. This fixes #35897.

This is a work in progress. In particular, I want to add more tests,
especially the compile-fail test is very bare-bones.
@bors bors merged commit a87b4d8 into rust-lang:master Sep 2, 2016
@llogiq llogiq deleted the rfc-1623 branch September 2, 2016 09:11
@petrochenkov
Copy link
Contributor

@nikomatsakis
Is it stated explicitly anywhere that this change should be insta-stable and not feature gated?
This seems reasonable and the feature gate seems to be hard to enforce, but I haven't seen this discussed at all.

@@ -0,0 +1,98 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
Copy link
Contributor

Choose a reason for hiding this comment

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

Umm this seems to be a rustfmt-generated "backup" file, surely that shouldn't have been committed?

@nikomatsakis
Copy link
Contributor

@petrochenkov argh you are correct -- that was utterly wrong on my part. We should totally feature gate this. @llogiq, can I walk you through landing that change?

@nikomatsakis
Copy link
Contributor

And, yes, the .bk files ought to be removed.

/me embarassed

@nikomatsakis
Copy link
Contributor

(Adding the feature-gate itself is probably harder, of course, than the rest of this change, but not overly hard. The easiest way I think is to configure the rscope (or make a new one) that checks the feature gate and, when return 'static, also issues an error. We may need to thread a span through, I have to check the signature.)

@llogiq
Copy link
Contributor Author

llogiq commented Sep 2, 2016

/me=embarrassed, too.

@nikomatsakis
Copy link
Contributor

Nah, no big thing. :) Sharp eyes though, @petrochenkov.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants