Skip to content

Regression in interaction between lifetime parameter and defaulted type parameter #49344

Closed
@bsteinb

Description

@bsteinb

The mpi crate contains (approximately) the following code that used to work before nightly-2018-03-02:

use std::cell::Cell;
use std::marker::PhantomData;

pub struct Request<'a, S: Scope<'a> = StaticScope> {
    scope: S,
    phantom: PhantomData<Cell<&'a ()>>,
}

pub unsafe trait Scope<'a> {
    /// Registers a request with the scope.
    fn register(&self);

    /// Unregisters a request from the scope.
    unsafe fn unregister(&self);
}

pub struct StaticScope;

unsafe impl Scope<'static> for StaticScope {
    fn register(&self) {}

    unsafe fn unregister(&self) {}
}

The newest nightly compiler that successfully compiles this is:

rustc 1.26.0-nightly (0ff9872b2 2018-02-28)
binary: rustc
commit-hash: 0ff9872b2280009f094af0df3dcdc542cc46a5fd
commit-date: 2018-02-28
host: x86_64-apple-darwin
release: 1.26.0-nightly
LLVM version: 6.0

It no longer compiles on:

rustc 1.26.0-nightly (3eeb5a665 2018-03-01)
binary: rustc
commit-hash: 3eeb5a665e313c5b281820099e04d4c6c8188b46
commit-date: 2018-03-01
host: x86_64-apple-darwin
release: 1.26.0-nightly
LLVM version: 6.0

Was this not supposed to ever work or is this a regression?

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions