Skip to content

Static method returning 'self with generics fails cross crate #7178

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

Closed
huonw opened this issue Jun 16, 2013 · 5 comments
Closed

Static method returning 'self with generics fails cross crate #7178

huonw opened this issue Jun 16, 2013 · 5 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@huonw
Copy link
Member

huonw commented Jun 16, 2013

// cross_crate_self.rs
pub struct Foo<'self, A>(&'self A);

impl<'self, A> Foo<'self, A> {
    pub fn new(a: &'self A) -> Foo<'self, A> {
        Foo(a)
    }
}
#[test]
fn test_foo() {
    let _ = Foo::new(&1i);
}
// other.rs
extern mod cross_crate_self;

#[test]
fn test_foo() {
    let _ = cross_crate_self::Foo::new(&1i);
}
$ rustc --test cross_crate_self.rs
$ ./cross_crate_self 

running 1 test
test test_foo ... ok

result: ok. 1 passed; 0 failed; 0 ignored

$ rustc --lib cross_crate_self.rs         
warning: missing crate link meta `name`, using `cross_crate_self` as default
warning: missing crate link meta `vers`, using `0.0` as default
$ rustc --test -L . other.rs
error: internal compiler error: ty::Region#subst(): Reference to self region when given substs with no self region: substs(self_r=None, self_ty=None, tps=[<V1>])

Having a generic A seems to be necessary to exhibit the bug. (Caused #7177.)

@catamorphism
Copy link
Contributor

Reproduced with 2ab4a6f . Nominating.

@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2013

cc me

@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2013

declining; just-a-bug

@nikomatsakis
Copy link
Contributor

cc me; possibly addressed by patch to #4846

@alexcrichton
Copy link
Member

This has been fixed, adding a test for it soon.

alexcrichton added a commit that referenced this issue Dec 19, 2013
Closes #5806
Closes #5950
Closes #7178
Closes #8259
Closes #8578
Closes #8851
Closes #9129
Closes #10412
flip1995 pushed a commit to flip1995/rust that referenced this issue May 6, 2021
Rustup

r? `@ghost`

changelog: none
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants