-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix generic Drop impls with trait bounds. #12403
Conversation
👍 |
if has_trait_bounds(*type_param_defs) { | ||
let vcx = VtableContext { | ||
infcx: &infer::new_infer_ctxt(tcx), | ||
param_env: &ty::construct_parameter_environment(tcx, None, [], [], [], id) |
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 are you passing all empty vectors here? That doesn't seem right to me. Themethod_type_params
and method_region_params
should be empty, yes, but not the item ones, those should be drawn from generics
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.
For normal type checking, those are taken from the enclosing function, which in this case isn't the callee, but the caller, a monomorphized function that is being translated. Possibly even a drop glue (maybe only drop glues?).
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.
Yeah, right. Sounds good.
Hurray! |
@@ -20,17 +20,17 @@ use syntax::codemap::Span; | |||
|
|||
// Requires that the two types unify, and prints an error message if they | |||
// don't. | |||
pub fn suptype(fcx: @FnCtxt, sp: Span, expected: ty::t, actual: ty::t) { | |||
pub fn suptype(fcx: &FnCtxt, sp: Span, expected: ty::t, actual: ty::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.
It'd be really nice to keep these in separate commits/PRs ;)
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've already split this into 3 commits, I have to take it one step at a time :).
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.
+1 @huonw
let tsubsts = ty::substs { | ||
regions: ty::ErasedRegions, | ||
self_ty: None, | ||
tps: /*bad*/ substs.to_owned() |
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.
Nit: Please remove this /* bad */
. No need to flagellate ourselves for every copy.
This looks good (modulo nits) -- but there is something very questionable about supporting type parameter bounds in drop to begin with. I guess any such def'n requires
and now I have It only makes sense if we can guarantee that all instances of Long story short: r+ with nits addressed. |
I think there's another interpretation that's equally reasonable. If you have
without a Following similar logic, if you have
you could say that for Along the same lines, you could also write things such as
in which case the destructors for The basic insight is that while they run together, the programmer-defined As in that other issue, while I believe all of this checks out on a logical/theoretical level, a big question is how it squares with the code humans might actually want to write, and their expectations. But even under the above semantics, if the programmer wants to rule out any |
On Thu, Feb 20, 2014 at 02:21:36AM -0800, Gábor Lehel wrote:
Yes, I considered this interpretation and rejected it, though it does |
…tsakis Fix generic Drop impls with trait bounds. Fixes #4252.
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but rust-lang#12403 should have just fixed that.
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
Pointers cannot be converted to integers at compile time Fix rust-lang#12402 changelog: [`transmutes_expressible_as_ptr_casts`]: do not suggest invalid const casts
Fix generic Drop impls with trait bounds.
Fixes #4252.