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

beta ICE: new iron: &mut iron::Request<'_, '_> was a subtype of &mut _ but now is not? #45801

Closed
FauxFaux opened this issue Nov 6, 2017 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@FauxFaux
Copy link

FauxFaux commented Nov 6, 2017

Upgrading iron in my project causes an ICE. This is possibly the same as #36701, but this must be new as I only see the ICE on beta/nightly, not on the current stable channel, which is way newer than the bug report.

Test repo: https://github.com/FauxFaux/quad-image/blob/ice/src/main.rs
git clone -b ice https://github.com/FauxFaux/quad-image.git

Relevant code:

fn handle(req: &mut Request) -> IronResult<Response> {
    req.get_ref::<Params>();
    unimplemented!()
}
error: internal compiler error: /checkout/src/librustc_typeck/check/method/confirm.rs:330: &mut iron::Request<'_, '_> was a subtype of &mut _ but now is not?
 --> src/main.rs:8:9
  |
8 |     req.get_ref::<Params>();
  |         ^^^^^^^

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (3b82e4c74 2017-11-05) running on x86_64-unknown-linux-gnu
rustc 1.23.0-nightly (3b82e4c74 2017-11-05)
binary: rustc
commit-hash: 3b82e4c74d43fc1273244532c3a90bf9912061cf
commit-date: 2017-11-05
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0

On stable:

error[E0277]: the trait bound `params::Params: plugin::Plugin<iron::Request<'_, '_>>` is not satisfied
 --> src/main.rs:8:9
  |
8 |     req.get_ref::<Params>();
  |         ^^^^^^^ the trait `plugin::Plugin<iron::Request<'_, '_>>` is not implemented for `params::Params`
  |
  = help: the following implementations were found:
            <params::Params as plugin::Plugin<iron::request::Request<'a, 'b>>>

error: aborting due to previous error

I note that (on all releases), cargo decides to download two different versions of iron? This doesn't seem right.

   Compiling iron v0.5.1
   Compiling iron v0.6.0

Cargo.toml:

[dependencies]
iron = "0.6.0"
params = "0.7.1"
% cargo tree  | fgrep -B2 iron
boom v0.1.0 (file:///home/faux/code/quad-image)
├── iron v0.6.0
--
└── params v0.7.1
    ├── bodyparser v0.6.0
    │   ├── iron v0.5.1
...
@kennytm kennytm added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Nov 6, 2017
@arielb1
Copy link
Contributor

arielb1 commented Nov 7, 2017

Minified:

struct Params;

pub trait Plugin<E: ?Sized> {
    type Error;
}

pub trait Pluggable {
    fn get_ref<P: Plugin<Self>>(&mut self) -> Option<P::Error> {
        None
    }
}

impl Plugin<()> for Params {
    type Error = ();
}

impl Pluggable for i32 {}

fn handle(req: &mut i32) {
    req.get_ref::<Params>();
}

fn main() {}

@arielb1
Copy link
Contributor

arielb1 commented Nov 7, 2017

So the main question here is how did this ever work, but given #36701 I suppose the answer is "entirely by accident".

arielb1 added a commit to arielb1/rust that referenced this issue Nov 9, 2017
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.
bors added a commit that referenced this issue 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 issue 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
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

3 participants