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

Don't crash when checking types with only region parameters for destructor safety #15585

Merged
merged 7 commits into from
Jul 16, 2014

Conversation

bgamari
Copy link
Contributor

@bgamari bgamari commented Jul 10, 2014

This branch has a fix for #15557 (a2bcef9) as well as a variety of patches I found useful while debugging this issue. These include adding Show impls to a variety of types, including the majority of syntax::ast and some of middle::ty.

try!(write!(fmt, "}}"));
Ok(())
}
}
Copy link
Member

Choose a reason for hiding this comment

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

rust conventions are to use four-space tabs instead of 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh, sorry about that. I had my editor configured to work on Zinc while working this.

@alexcrichton
Copy link
Member

Can you add a test for the fixed issue as well?

@bgamari
Copy link
Contributor Author

bgamari commented Jul 10, 2014

Sure!

format!("Type parameter out of range \
when substituting in region {} (root type={})",
region_name.as_str(),
self.root_ty.repr(self.tcx())).as_slice());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alexcrichton is the two-space indentation here acceptable?

Copy link
Member

Choose a reason for hiding this comment

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

The formatting here would generally look like:

format!("foo bar baz \
         aligned after quote",
        aligned_with_quote);

@bgamari
Copy link
Contributor Author

bgamari commented Jul 10, 2014

@alexcrichton everything should be fixed other than the test. Where should the test go? src/test/auxiliary/?

@pnkfelix
Copy link
Member

@bgamari I think src/test/run-pass is a fine area for it, there are other tests involving dtors and/or lifetimes in there.

(FYI: I think src/test/auxiliary is only for support files that other tests refer to, when testing things like linking to other libraries.)

@pnkfelix
Copy link
Member

@bgamari also, when you are inevitably asked to squash your commtis together before they are finally merged, I would request that you try to keep the nice refactorings (e.g. the additions of deriving(Show) and the uses of {} instead of {:?}) separate from the core changes.

(The above may be an obvious thing to do, but not everyone takes the time to squash things into more than one commit, so that is why I'm explicitly asking.)

@huonw
Copy link
Member

huonw commented Jul 10, 2014

FWIW, deriving(Show) can cause significant additional code: #15548.

@bgamari
Copy link
Contributor Author

bgamari commented Jul 10, 2014

@pnkfelix of course! I intend on wrapping this up tonight.

@huonw I would like to characterize the difference in binary size and compile time. I hope it won't be terrible given the already long compile times of librustc.

@bgamari
Copy link
Contributor Author

bgamari commented Jul 12, 2014

@pnkfelix how does this patch structure look?

@bgamari
Copy link
Contributor Author

bgamari commented Jul 14, 2014

Pushed a rebased set. Seems to compile on my end and I believe the failing Travis build isn't my fault.

@pnkfelix
Copy link
Member

@bgamari please squash fca9dec into e149dc9

@bgamari
Copy link
Contributor Author

bgamari commented Jul 15, 2014

@pnkfelix oops, that had been on my todo list. Thanks for the reminder.

@bgamari
Copy link
Contributor Author

bgamari commented Jul 15, 2014

@pnkfelix this is ready, by the way.

@bgamari
Copy link
Contributor Author

bgamari commented Jul 15, 2014

Alright, here we go again.

And change some uses of the `{:?}` format string to `{}`.
Previously this was an Option::unwrap() which failed for me.
Unfortunately I've since inadvertently worked around the bug and have
been unable to reproduce it. With this patch hopefully the next person
to encounter this will be in a slightly better position to debug it.
To verify that a type can satisfy Send
`check_struct_safe_for_destructor` attempts to construct a new `ty::t`
an empty substitution list.

Previously the function would verify that the function has no type
parameters before attempting this. Unfortunately this check would not
catch functions with only regions parameters. In this case, the type
would eventually find its way to the substition engine which would
attempt to perform a substitution on the region parameters. As the
constructed substitution list is empty, this would fail, leading to a
compiler crash.

We fix this by verifying that types have both no type and region
parameters.
@bgamari
Copy link
Contributor Author

bgamari commented Jul 15, 2014

Updated and travis passed.

bors added a commit that referenced this pull request Jul 16, 2014
This branch has a fix for #15557 (a2bcef9) as well as a variety of patches I found useful while debugging this issue. These include adding `Show` impls to a variety of types, including the majority of `syntax::ast` and some of `middle::ty`.
@bors bors closed this Jul 16, 2014
@bors bors merged commit 446f937 into rust-lang:master Jul 16, 2014
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.

5 participants