-
Notifications
You must be signed in to change notification settings - Fork 13k
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
stabilize outlives requirements #53793
Conversation
src/test/ui/lint/lint-ctypes.rs
Outdated
@@ -10,7 +10,7 @@ | |||
|
|||
#![deny(improper_ctypes)] | |||
#![feature(libc)] | |||
|
|||
#![allow(private_in_public)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure why the error changed and why i needed this. Also is there is a better way to handle this?
I forgot to update the documentation. So will be pushing another commit. |
This comment has been minimized.
This comment has been minimized.
s/stabalize/stabilize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the main thing is that I think we should make a bigger effort to preserve some of the existing tests rather than deleting them. In particular, they were testing aspects of the WF definition and they just happened to be doing so as part of enum/struct fields. There are other ways to test that same code so we ought to port.
src/librustc_mir/lib.rs
Outdated
@@ -15,7 +15,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! | |||
*/ | |||
|
|||
#![cfg_attr(not(stage0), feature(nll))] | |||
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] | |||
#![cfg_attr(stage0, feature(infer_outlives_requirements))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this, really? It seems like we can't be relying on it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although https://forge.rust-lang.org/stabilization-guide.html says that we want to leave it to compile the stage0 compiler.
src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
Outdated
Show resolved
Hide resolved
src/test/ui/issues/issue-37323.rs
Outdated
// except according to those terms. | ||
|
||
#![feature(rustc_attrs)] | ||
#![allow(warnings)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add a // compile-pass
comment instead of deleting these tests
|
||
enum Ref1<'a, T> { | ||
Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure about deleting these tests. Maybe we should change them (for now) to use 'static
instead of 'a
? Seems like it would preserve the original intention of the test .. more or less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could add this to the test:
trait Dummy<'a> {
type Out;
}
impl<'a, T> Dummy<'a> for T
where T: 'a
{
type Out = ();
}
type RequireOutlives<'a, T> = <T as Dummy<'a>>::Out;
and then replace &'a T
with RequireOutlives<'a, T>
.
This just exploits a weakness in the inference. Kind of horrible though. Maybe move that code over into rfc-2093-infer-outlives
directory, too? (e.g., to test the cases where inference is expected to fail)
I suppose in principle we could keep the original test too and make it // compile-pass
but...presumably... we added equivalent tests for infer-outlives? Yeah, I see things like src/test/ui/rfc-2093-infer-outlives/enum.rs
, which seem pretty similar.
x: T | ||
} | ||
enum Bar<'a,'b> { | ||
F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could .. I think .. test this like so:
trait Trait<'a, 'b> {
type Out;
}
impl<'a, 'b> Trait<'a, 'b> {
type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime
}
trait Trait<T> { } | ||
|
||
struct Foo<'a,T> { | ||
f: &'a fn(T), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can rewrite this using the trait/impl trick like
trait Dummy<'a> {
type Out;
}
impl<'a, T> Dummy<'a> for T {
type Out = &'a fn(T); //~ ERROR E0389
|
||
struct Bar<'a,T> { | ||
f: &'a Trait<T>, | ||
//~^ ERROR E0309 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
|
||
// Test that an appearance of `T` in fn args or in a trait object must | ||
// still meet the outlives bounds. Since this is a new requirement, | ||
// this is currently only a warning, not a hard error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is out of date, I guess, though not your fault :)
This comment has been minimized.
This comment has been minimized.
@nikomatsakis believe i addressed all your comments. I added There are some cases where we have now have redundant tests but I am not certain if that is a bad thing. Docs: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@toidiu It may be worth coordinating this with #53013 (a lint for soon-to-be-unnecessary outlives-bounds), the current version of which introduces a new check for the |
This comment has been minimized.
This comment has been minimized.
@zackmdavis I ran into some trouble testing and reproducing the errors locally. Its a short week but I would like to get this ready for merge by end of week. If however your PR is ready then please go ahead (dont want this to be a blocker) and I can easily rebase. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@nikomatsakis I am getting a cryptic error and dont know how to approach it/reproduce it locally or what exactly is causing the error :(
|
to be more specific, on master, the definition for E0309 includes this: rust/src/librustc/diagnostics.rs Lines 1240 to 1246 in d8af8b6
this code no longer generates the error, so we have to rework the example. In fact, I think we should rework the whole section for E0309. In particular, I think that this error can only really arise due to associated types in the structure definition, so maybe we can specialize the text: The type definition contains some field whose type
Here, the where clause
|
For E0491, we'll need to make a similar adjustment to the example. A reference has a longer lifetime than the data it references. Erroneous code example:
Here, the problem is that a reference type like
|
I took the liberty of pasting those descriptions in. |
@@ -11,6 +11,8 @@ | |||
#![deny(improper_ctypes)] | |||
#![feature(libc)] | |||
|
|||
#![allow(private_in_public)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was failing for me locally until I added this. Although I am wondering if it was simply a bad local setup (same with a few other tests).
I would like to try and get to a passing state and then try to undo this change to see if things still pass.
@@ -15,10 +15,12 @@ | |||
#![feature(lang_items, box_syntax)] | |||
#![no_std] | |||
|
|||
use core::panic::PanicInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite know why this one changed, but I'm .. less concerned about it. Probably worth figuring out but might have to do with code executing in a somewhat different order than before owing to the new queries.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looks like a passing PR. Going to remove |
stabilize outlives requirements #44493 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
This hurt compile speed for @toidui: any thoughts? |
It also hurt max-rss on incremental builds by up to 10%: |
@nnethercote this was the first large PR i committed to rust so please excuse my lack of knowledge and procedure. What steps can I take to rectify the degraded performance? I am also available on rustlang discord and zulip (username: toidiu) is some of this is better for offline discussion. |
@toidiu: if you are on Linux, the best way would be to do Cachegrind runs on two revisions -- the one before your change landed, and the following revision -- and then do a diff. Instructions on how to do a Cachegrind run are here: https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/README.md |
@nikomatsakis or @arielb1 could also look at this - they already have things set up for profiling. |
They could, but I want to encourage more people to become familiar with profiling the compiler. It's not too hard now, if you're on Linux. And if there are ideas on how to make it easier, I'd love to hear them. |
So from what I understand
I am wondering if its possible to download the pre-compiled versions of the two branches from somewhere rather than building them locally (takes a long time)? |
Correct!
Not that I know of. |
@nnethercote Btw will this work on a mac? I got the error
|
Benchmarking (with |
I am getting the following errors on my mac:
error:
|
I have fixed that in rust-lang/rustc-perf#288. Unfortunately, it's not enough to get it working, at least on my MacOS 10.12 laptop. Cachegrind starts up ok but doesn't produce an output file, for reasons I haven't yet determined. |
Yes ran it locally and also still getting an error. Here is the full output: https://pastebin.com/xhjEKKr5 |
This means you don't have Valgrind installed. |
I installed Valgrind ran the @nnethercote I am wondering if there is a path forward where I dont have to rely on my local machine which is not a Linux. |
No path I can see, unfortunately. |
You can rent an AWS and work ssh-ed into it (tip: use |
I haz procured a Linux. I started running the collector and it seems to be taking a very long time.. been running for multiple hours. Any idea how long it will take to complete? @nnethercote since you asked before; making it easier to get see and analyze the results might an area for improvement. I imagine that someone somewhere already ran these results to conclude that this PR caused a regression. I wonder if it would be possible to reuse those outputs rather then having to rerun them locally? |
#44493
r? @nikomatsakis