Skip to content

update for upstream changes to TyFnDef #226

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 2 commits into from
Jun 29, 2017
Merged

Conversation

dwrensha
Copy link
Contributor

Fixes breakage from rust-lang/rust#42417.

@dwrensha
Copy link
Contributor Author

The tests/run-pass/non_capture_closure_to_fn_ptr.rs test still fails:

$ cargo run --bin miri -- tests/run-pass/non_capture_closure_to_fn_ptr.rs 
   Compiling miri v0.1.0 (file:///home/david/src/miri)
    Finished dev [unoptimized + debuginfo] target(s) in 35.92 secs
     Running `target/debug/miri tests/run-pass/non_capture_closure_to_fn_ptr.rs`
error: tried to call a function with sig extern "rust-call" fn([closure@tests/run-pass/non_capture_closure_to_fn_ptr.rs:3:20: 3:45], ()) -> <[closure@tests/run-pass/non_capture_closure_to_fn_ptr.rs:3:20: 3:45] as std::ops::FnOnce<()>>::Output through a function pointer of type fn()
 --> tests/run-pass/non_capture_closure_to_fn_ptr.rs:8:5
  |
8 |     FOO();
  |     ^^^^^
  |
note: inside call to main
 --> tests/run-pass/non_capture_closure_to_fn_ptr.rs:7:1
  |
7 | / fn main() {
8 | |     FOO();
9 | |     BAR(44, 45);
10| |     let bar: unsafe fn(i32, i32) = BAR;
... |
13| |     boo(48, 49);
14| | }
  | |_^

error: aborting due to previous error(s)

thread 'main' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:512
note: Run with `RUST_BACKTRACE=1` for a backtrace.

@dwrensha
Copy link
Contributor Author

I think maybe we need to update the check_sig_compat() method?

eddyb
eddyb previously requested changes Jun 29, 2017
f.abi() == Abi::RustIntrinsic ||
f.abi() == Abi::PlatformIntrinsic =>
ty::TyFnDef(..) if {
let f = item_type.fn_sig(tcx);
Copy link
Member

Choose a reason for hiding this comment

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

Do not call this. tcx.fn_sig(def_id) is less work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is directly copied from librustc_trans. Should it also be changed there?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, just leave it alone then. Minor inefficiency but the DefId might not match.

@RalfJung
Copy link
Member

I think maybe we need to update the check_sig_compat() method?

To me this looks more like some form of normalization used to be performed, but is no longer performed... I never saw types like <[closure@tests/run-pass/non_capture_closure_to_fn_ptr.rs:3:20: 3:45] as std::ops::FnOnce<()>>::Output when I wrote check_sig_compat.

@eddyb
Copy link
Member

eddyb commented Jun 29, 2017

Ah yeah you need to normalize yourself when working on a signature, like you would a field.

@dwrensha
Copy link
Contributor Author

OK. Fixed by adding a call to self.tcx.normalize_associated_type().

@oli-obk oli-obk dismissed eddyb’s stale review June 29, 2017 12:13

The compiler does the same thing

@oli-obk oli-obk merged commit 4a56083 into rust-lang:master Jun 29, 2017
@dwrensha dwrensha deleted the rustup branch June 29, 2017 13:23
# 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.

4 participants