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

Remove the trait selection impl in method::probe #43880

Merged
merged 5 commits into from
Aug 30, 2017

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Aug 15, 2017

This removes the hacky trait selection reimplementation in method::probe, which occasionally comes and causes problems.

There are 2 issues I've found with this approach:

  1. The older implementation sometimes had a "guess" type from an impl, which allowed subtyping to work. This is why I needed to make a change in libtest: there's an impl<A> Clone for fn(A) and we're calling <for<'a> fn(&'a T) as Clone>::clone. The older implementation would do a subtyping between the impl type and the trait type, so it would do the check for <fn(A) as Clone>::clone, and confirmation would continue with the subtyping. The newer implementation directly passes <for<'a> fn(&'a T) as Clone>::clone to selection, which fails. I'm not sure how big of a problem that would be in reality, especially after Generate builtin impls for Clone #43690 would remove the Clone problem, but I still want a crater run to avoid breaking the world.
  2. The older implementation "looked into" impls to display error messages. I'm not sure that's an advantage - it looked exactly 1 level deep.

r? @eddyb

@arielb1 arielb1 added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Aug 15, 2017
@arielb1 arielb1 changed the title [WIP] Remove the selection impl in method::probe [WIP] Remove the trait selection impl in method::probe Aug 15, 2017
@eddyb
Copy link
Member

eddyb commented Aug 15, 2017

LGTM (modulo how it fares in the wild, which is yet to be seen) r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Aug 15, 2017
@arielb1 arielb1 force-pushed the noninvasive-probe branch from 8a32f1b to 7aecbc3 Compare August 15, 2017 11:07
@eddyb
Copy link
Member

eddyb commented Aug 15, 2017

@bors try

@bors
Copy link
Contributor

bors commented Aug 15, 2017

⌛ Trying commit 7aecbc38c5c70f730eccb571290d02094cb9b6af with merge b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2...

@bors
Copy link
Contributor

bors commented Aug 15, 2017

☀️ Test successful - status-travis
State: approved= try=True

@eddyb
Copy link
Member

eddyb commented Aug 15, 2017

cc @rust-lang/infra Cargobomb requested.

@bors
Copy link
Contributor

bors commented Aug 16, 2017

☔ The latest upstream changes (presumably #43710) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1 arielb1 force-pushed the noninvasive-probe branch from 4c09b45 to 9b54410 Compare August 16, 2017 11:55
@arielb1
Copy link
Contributor Author

arielb1 commented Aug 16, 2017

I think I'm comfortable with landing this refactor the way it is, provided crater agrees.

@aidanhs
Copy link
Member

aidanhs commented Aug 17, 2017

Cargobomb run has started.

@nikomatsakis
Copy link
Contributor

I read over the changes and r=me once we see the cargobomb results.

@arielb1 arielb1 changed the title [WIP] Remove the trait selection impl in method::probe Remove the trait selection impl in method::probe Aug 20, 2017
@aidanhs
Copy link
Member

aidanhs commented Aug 21, 2017

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 21, 2017

ai-0.1.0 test-pass test-fail - flaky
ceramic-0.3.0 test-pass test-fail - looks dubious?
hashconsing-0.3.0 test-pass test-fail - flaky
idna-0.1.4 test-pass test-fail - clone of libtest
ldap3-0.5.0 test-fail build-fail - interesting
nss-sys-0.1.9 test-pass test-fail - "error: An unknown error occurred"?
parking_lot_mpsc-0.1.5-alpha.1 test-pass test-fail - looks flaky?
rustc-test-0.1.5 test-pass build-fail - clone of libtest
rustc-test-0.2.0 test-pass build-fail - clone of libtest
yggie.mach.b1c15026e0f31117d0d54ee6eeaeadd3e94a3d92 test-pass test-fail
   - [quickcheck] TEST FAILED (runtime error). Arguments: (UnitVec3D(Vec3D { x: -0.08164979, y: 0.41588578, z: -0.905744 }), UnitQuat(Quat { r: -0.9998616, i: 0.00013082517, j: -0.012743562, k: 0.010695696 }))
    - looks spurious

I think this has to depend on #43690 because that should fix the (benchfn.clone()) problem.

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 21, 2017

LDAP report:

Aug 19 09:54:47.599 INFO testing ldap3-0.5.0 against try#b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2 for pr-43880
Aug 19 09:54:47.599 INFO running: cargo +b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2 build --frozen
Aug 19 09:54:47.599 INFO creating container for: cargo +b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2 build --frozen
Aug 19 09:54:47.599 INFO running `"docker" "create" "-v" "/home/ec2-user/cargobomb/./work/local/test-source/pr-43880/try#b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2:/source:ro,Z" "-v" "/home/ec2-user/cargobomb/./work/local/target-dirs/pr-43880/try#b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2:/target:rw,Z" "-v" "/home/ec2-user/cargobomb/./work/local/cargo-home:/cargo-home:ro,Z" "-v" "/home/ec2-user/cargobomb/./work/local/rustup-home:/rustup-home:ro,Z" "-e" "USER_ID=500" "-e" "CMD=cargo +b96d5eea76e758bdd82fd4169eb4d5f7e3ce4fe2 build --frozen" "cargobomb"`
Aug 19 09:54:47.673 INFO blam! 9fc7035ce68cfa6644c99cbc35ad850fd22cb7666409104c55eb40cfa186023c
Aug 19 09:54:47.674 INFO running `"docker" "start" "-a" "9fc7035ce68cfa6644c99cbc35ad850fd22cb7666409104c55eb40cfa186023c"`
Aug 19 09:54:48.186 INFO kablam!    Compiling ldap3 v0.5.0 (file:///source)
Aug 19 09:54:49.482 INFO kablam! error[E0308]: mismatched types
Aug 19 09:54:49.482 INFO kablam!    --> src/ldap.rs:235:42
Aug 19 09:54:49.482 INFO kablam!     |
Aug 19 09:54:49.482 INFO kablam! 235 |             let result = self.inner.call((req, Box::new(move |msgid| *closure_assigned_msgid.borrow_mut() = msgid))).select2(timeout).then(move |res| {
Aug 19 09:54:49.482 INFO kablam!     |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure
Aug 19 09:54:49.482 INFO kablam!     |
Aug 19 09:54:49.482 INFO kablam!     = note: expected type `(ldap::LdapOp, std::boxed::Box<std::ops::Fn(i32) + 'static>)`
Aug 19 09:54:49.483 INFO kablam!                found type `(ldap::LdapOp, std::boxed::Box<[closure@src/ldap.rs:235:57: 235:114 closure_assigned_msgid:_]>)`
Aug 19 09:54:49.483 INFO kablam! 
Aug 19 09:54:49.489 INFO kablam! error[E0308]: mismatched types
Aug 19 09:54:49.489 INFO kablam!    --> src/ldap.rs:259:38
Aug 19 09:54:49.489 INFO kablam!     |
Aug 19 09:54:49.489 INFO kablam! 259 |             Box::new(self.inner.call((req, Box::new(|_msgid| ()))).and_then(|(tag, vec)| Ok(LdapResponse(tag, vec))))
Aug 19 09:54:49.489 INFO kablam!     |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure
Aug 19 09:54:49.489 INFO kablam!     |
Aug 19 09:54:49.489 INFO kablam!     = note: expected type `(ldap::LdapOp, std::boxed::Box<std::ops::Fn(i32) + 'static>)`
Aug 19 09:54:49.489 INFO kablam!                found type `(ldap::LdapOp, std::boxed::Box<[closure@src/ldap.rs:259:53: 259:64]>)`
Aug 19 09:54:49.489 INFO kablam! 
Aug 19 09:54:49.770 INFO kablam! error: aborting due to 2 previous errors
Aug 19 09:54:49.770 INFO kablam! 
Aug 19 09:54:49.793 INFO kablam! error: Could not compile `ldap3`.
Aug 19 09:54:49.793 INFO kablam! 
Aug 19 09:54:49.793 INFO kablam! To learn more, run the command again with --verbose.
Aug 19 09:54:49.796 INFO kablam! su: No module specific data is present
Aug 19 09:54:50.119 INFO running `"docker" "rm" "-f" "9fc7035ce68cfa6644c99cbc35ad850fd22cb7666409104c55eb40cfa186023c"`
Aug 19 09:54:50.136 INFO blam! 9fc7035ce68cfa6644c99cbc35ad850fd22cb7666409104c55eb40cfa186023c

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 21, 2017

I think I fixed the LDAP problem with the new commit.

@arielb1 arielb1 force-pushed the noninvasive-probe branch from f378da6 to e77247c Compare August 21, 2017 14:37
@bors
Copy link
Contributor

bors commented Aug 22, 2017

☔ The latest upstream changes (presumably #43690) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1 arielb1 force-pushed the noninvasive-probe branch from e77247c to e37c087 Compare August 22, 2017 12:32
@arielb1
Copy link
Contributor Author

arielb1 commented Aug 22, 2017

Now that the Clone issue is fixed, I think we can land this.

@arielb1 arielb1 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Aug 22, 2017
@bors
Copy link
Contributor

bors commented Aug 28, 2017

☔ The latest upstream changes (presumably #43076) made this pull request unmergeable. Please resolve the merge conflicts.

the data serves no purpose - it can be recovered from the obligation -
and I think may leak stale inference variables into global caches.
This fixes a few cases of inference misses, some of them regressions
caused by the impl selected for a method not being immediately evaluated.
@arielb1 arielb1 force-pushed the noninvasive-probe branch from e37c087 to 15f6540 Compare August 29, 2017 16:45
@arielb1
Copy link
Contributor Author

arielb1 commented Aug 29, 2017

Ready for review, assuming higher-ranked function pointers will still impl Clone this release.

@nikomatsakis
Copy link
Contributor

@bors r+

assuming higher-ranked function pointers will still impl Clone this release.

That part in particular doesn't seem to be controversial, I think...?

@bors
Copy link
Contributor

bors commented Aug 29, 2017

📌 Commit 15f6540 has been approved by nikomatsakis

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 29, 2017

That part in particular doesn't seem to be controversial, I think...?

It can't be, given that they are already Copy

@arielb1 arielb1 added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 29, 2017
@bors
Copy link
Contributor

bors commented Aug 30, 2017

⌛ Testing commit 15f6540 with merge b58e31a...

bors added a commit that referenced this pull request Aug 30, 2017
Remove the trait selection impl in method::probe

This removes the hacky trait selection reimplementation in `method::probe`, which occasionally comes and causes problems.

There are 2 issues I've found with this approach:
1. The older implementation sometimes had a "guess" type from an impl, which allowed subtyping to work. This is why I needed to make a change in `libtest`: there's an `impl<A> Clone for fn(A)` and we're calling `<for<'a> fn(&'a T) as Clone>::clone`. The older implementation would do a subtyping between the impl type and the trait type, so it would do the check for `<fn(A) as Clone>::clone`, and confirmation would continue with the subtyping. The newer implementation directly passes `<for<'a> fn(&'a T) as Clone>::clone` to selection, which fails. I'm not sure how big of a problem that would be in reality, especially after #43690 would remove the `Clone` problem, but I still want a crater run to avoid breaking the world.
2. The older implementation "looked into" impls to display error messages. I'm not sure that's an advantage - it looked exactly 1 level deep.

r? @eddyb
@bors
Copy link
Contributor

bors commented Aug 30, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing b58e31a to master...

@bors bors merged commit 15f6540 into rust-lang:master Aug 30, 2017
@SimonSapin
Copy link
Contributor

This broke Servo. With have a fix (servo/servo#18327), but this does reject real code that was previously accepted. This should at least be noted in release notes.

@alexcrichton alexcrichton added the relnotes Marks issues that should be documented in the release notes of the next release. label Aug 31, 2017
@nikomatsakis
Copy link
Contributor

@SimonSapin Indeed -- I'm trying to figure out what is going on in that PR. Can you dump the struct definition on which the traceable derive was failing?

@nikomatsakis
Copy link
Contributor

@SimonSapin I opened #44224 to discuss and decide on a resolution. Thanks for the regression report!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 3, 2017
Changelog:
Version 1.21.0 (2017-10-12)
==========================

Language
--------
- [You can now use static references for literals.][43838]
  Example:
  ```rust
  fn main() {
      let x: &'static u32 = &0;
  }
  ```
- [Relaxed path syntax. Optional `::` before `<` is now allowed in all contexts.][43540]
  Example:
  ```rust
  my_macro!(Vec<i32>::new); // Always worked
  my_macro!(Vec::<i32>::new); // Now works
  ```

Compiler
--------
- [Upgraded jemalloc to 4.5.0][43911]
- [Enabled unwinding panics on Redox][43917]
- [Now runs LLVM in parallel during translation phase.][43506]
  This should reduce peak memory usage.

Libraries
---------
- [Generate builtin impls for `Clone` for all arrays and tuples that
  are `T: Clone`][43690]
- [`Stdin`, `Stdout`, and `Stderr` now implement `AsRawFd`.][43459]
- [`Rc` and `Arc` now implement `From<&[T]> where T: Clone`, `From<str>`,
  `From<String>`, `From<Box<T>> where T: ?Sized`, and `From<Vec<T>>`.][42565]

Stabilized APIs
---------------

[`std::mem::discriminant`]

Cargo
-----
- [You can now call `cargo install` with multiple package names][cargo/4216]
- [Cargo commands inside a virtual workspace will now implicitly
  pass `--all`][cargo/4335]
- [Added a `[patch]` section to `Cargo.toml` to handle
  prepublication dependencies][cargo/4123] [RFC 1969]
- [`include` & `exclude` fields in `Cargo.toml` now accept gitignore
  like patterns][cargo/4270]
- [Added the `--all-targets` option][cargo/4400]
- [Using required dependencies as a feature is now deprecated and emits
  a warning][cargo/4364]


Misc
----
- [Cargo docs are moving][43916]
  to [doc.rust-lang.org/cargo](https://doc.rust-lang.org/cargo)
- [The rustdoc book is now available][43863]
  at [doc.rust-lang.org/rustdoc](https://doc.rust-lang.org/rustdoc)
- [Added a preview of RLS has been made available through rustup][44204]
  Install with `rustup component add rls-preview`
- [`std::os` documentation for Unix, Linux, and Windows now appears on doc.rust-lang.org][43348]
  Previously only showed `std::os::unix`.

Compatibility Notes
-------------------
- [Changes in method matching against higher-ranked types][43880] This may cause
  breakage in subtyping corner cases. [A more in-depth explanation is available.][info/43880]
- [rustc's JSON error output's byte position start at top of file.][42973]
  Was previously relative to the rustc's internal `CodeMap` struct which
  required the unstable library `libsyntax` to correctly use.
- [`unused_results` lint no longer ignores booleans][43728]

[42565]: rust-lang/rust#42565
[42973]: rust-lang/rust#42973
[43348]: rust-lang/rust#43348
[43459]: rust-lang/rust#43459
[43506]: rust-lang/rust#43506
[43540]: rust-lang/rust#43540
[43690]: rust-lang/rust#43690
[43728]: rust-lang/rust#43728
[43838]: rust-lang/rust#43838
[43863]: rust-lang/rust#43863
[43880]: rust-lang/rust#43880
[43911]: rust-lang/rust#43911
[43916]: rust-lang/rust#43916
[43917]: rust-lang/rust#43917
[44204]: rust-lang/rust#44204
[cargo/4123]: rust-lang/cargo#4123
[cargo/4216]: rust-lang/cargo#4216
[cargo/4270]: rust-lang/cargo#4270
[cargo/4335]: rust-lang/cargo#4335
[cargo/4364]: rust-lang/cargo#4364
[cargo/4400]: rust-lang/cargo#4400
[RFC 1969]: rust-lang/rfcs#1969
[info/43880]: rust-lang/rust#44224 (comment)
[`std::mem::discriminant`]: https://doc.rust-lang.org/std/mem/fn.discriminant.html
bors added a commit that referenced this pull request Nov 13, 2017
check::method - unify receivers before normalizing method signatures

Normalizing method signatures can unify inference variables, which can
cause receiver unification to fail. Unify the receivers first to avoid
that.

Fixes #36701.
Fixes #45801.
Fixes #45855.

r? @eddyb

beta-nominating because #43880 made this ICE happen in more cases (the code in that issue ICEs post-#43880 only, but the unit test here ICEs on all versions).
arielb1 pushed a commit to arielb1/rust that referenced this pull request Nov 14, 2017
check::method - unify receivers before normalizing method signatures

Normalizing method signatures can unify inference variables, which can
cause receiver unification to fail. Unify the receivers first to avoid
that.

Fixes rust-lang#36701.
Fixes rust-lang#45801.
Fixes rust-lang#45855.

r? @eddyb

beta-nominating because rust-lang#43880 made this ICE happen in more cases (the code in that issue ICEs post-rust-lang#43880 only, but the unit test here ICEs on all versions).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants