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 const_fn ICE with non-const function pointer #56337

Merged
merged 2 commits into from Nov 30, 2018

Conversation

Projects
None yet
3 participants
@phansch
Contributor

phansch commented Nov 29, 2018

Fixes #56164

@phansch

This comment has been minimized.

Contributor

phansch commented Nov 29, 2018

assert!(!self.tcx.is_const_fn(def_id));
match &self.tcx.item_name(def_id).as_str()[..] {
| "size_of"
| "min_align_of"

This comment has been minimized.

@oli-obk

oli-obk Nov 29, 2018

Contributor

what happened to the indent here?

This comment has been minimized.

@phansch

phansch Nov 29, 2018

Contributor

vim messing up some indentation apparently ◀️ 🙁
I will add a separate commit to fix it.

}
},
_ => {
span_bug!(self.span, "this is not allowed in const fn");

This comment has been minimized.

@oli-obk

oli-obk Nov 29, 2018

Contributor

I think it would be strictly less ICEy if we just called not_const here and early returned

phansch added some commits Nov 30, 2018

@phansch phansch force-pushed the phansch:fix_const_ice branch from fb39f5a to 247ab49 Nov 30, 2018

@phansch

This comment has been minimized.

Contributor

phansch commented Nov 30, 2018

I had to rebase from master which was rather complicated, so I opted to re-do this because that was quicker. I added an additional test for const fn foo() { (||{})() } and it's now using self.not_const() instead of a custom message.

@oli-obk

This comment has been minimized.

Contributor

oli-obk commented Nov 30, 2018

@bors r+

thanks

@bors

This comment has been minimized.

Contributor

bors commented Nov 30, 2018

📌 Commit 247ab49 has been approved by oli-obk

kennytm added a commit to kennytm/rust that referenced this pull request Nov 30, 2018

Rollup merge of rust-lang#56337 - phansch:fix_const_ice, r=oli-obk
Fix const_fn ICE with non-const function pointer

Fixes rust-lang#56164

bors added a commit that referenced this pull request Nov 30, 2018

Auto merge of #56381 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests

Successful merges:

 - #55011 (Add libstd Cargo feature "panic_immediate_abort")
 - #55821 (Use sort_by_cached_key when the key function is not trivial/free)
 - #56014 (add test for issue #21335)
 - #56131 (Assorted tweaks)
 - #56214 (Implement chalk unification routines)
 - #56216 (Add TryFrom<&[T]> for [T; $N] where T: Copy)
 - #56268 (Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.)
 - #56324 (Use raw_entry for more efficient interning)
 - #56336 (Clean up and streamline the pretty-printer)
 - #56337 (Fix const_fn ICE with non-const function pointer)
 - #56339 (Remove not used option)
 - #56341 (Rename conversion util; remove duplicate util in librustc_codegen_llvm.)
 - #56349 (rustc 1.30.0's linker flavor inference is a non-backwards compat change to -Clinker)
 - #56355 (Add inline attributes and add unit to CommonTypes)
 - #56360 (Optimize local linkchecker program)
 - #56364 (Fix panic with outlives in existential type)
 - #56365 (Stabilize self_struct_ctor feature.)
 - #56367 (Moved some feature gate tests to correct location)
 - #56373 (Update books)

@bors bors merged commit 247ab49 into rust-lang:master Nov 30, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@phansch phansch deleted the phansch:fix_const_ice branch Dec 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment