Skip to content

'static bound not enforced in borrowed trait coercion #10751

Closed

Description

@mitsuhiko

Current bug report

I would not expect this program to compile:

trait A {}                 
impl<T: 'static> A for T {}

fn main() {                
    let a = 3;             
    let b = &a;            
    let c = &b as &A;      
}                          

Original Bug Report

fn main() {
    let x = 42;
    let ref_x = &x;

    let any_x : &Any = &ref_x as &Any;
    println!("{:?}", any_x);
}

Results in

error: internal compiler error: non-static region found when hashing a type
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
task 'rustc' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /Users/mitsuhiko/Development/rust/src/librustc/lib.rs:396

Activity

  1. alexcrichton commented on Dec 1, 2013

    @alexcrichton
    Member

    cc @nikomatsakis, this should have aborted much earlier in compilation. I've updated the title of the bug to be what the root cause is.

  2. dmski commented on Mar 25, 2014

    @dmski
    Contributor

    Not sure if related to this issue, but this also compiles (taken from irc):

    trait U {}
    trait T<X: U> {}
    trait S<Y> { fn m(x: ~T<Y>) {} }
    
    fn main() {}
    
  3. added a commit that references this issue on Apr 18, 2014
    e4b13cf
  4. alexcrichton commented on Jan 19, 2015

    @alexcrichton
    Member

    This issue has since been fixed, closing.

  5. added a commit that references this issue on May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemA-type-system

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions