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

type_id is not crate-independent with object associated types #35144

Open
arielb1 opened this issue Jul 31, 2016 · 6 comments
Open

type_id is not crate-independent with object associated types #35144

arielb1 opened this issue Jul 31, 2016 · 6 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@arielb1
Copy link
Contributor

arielb1 commented Jul 31, 2016

Meta

$ rustc -V
rustc 1.12.0-dev (5556554e2 2016-07-31)

STR

#![feature(core_intrinsics, rustc_private)]

#[cfg(arena_first)]
extern crate arena;
extern crate term;
#[cfg(not(arena_first))]
extern crate arena;

use std::intrinsics::type_id;

fn main() { unsafe {
    println!("same={:?} different={:?}",
        type_id::<arena::TypedArena<()>>(),
        type_id::<Iterator<Item=arena::TypedArena<()>>>()
    );
}}  

Any pair of crates, one of them with a struct, can be used instead of arena/term.

Expected Result

The Type ID of Iterator<Item=arena::TypedArena<()>> should be the same when the cfg is toggled.

Actual Result

The Type ID of Iterator<Item=arena::TypedArena<()>> differs when the cfg is toggled, but the id of arena::TypedArena<()> does not

@arielb1 arielb1 added the A-trait-system Area: Trait system label Jul 31, 2016
@michaelwoerister
Copy link
Member

michaelwoerister commented Aug 1, 2016

This is probably the same underlying issue that has been solved for tyencode in #34805.
Projection bounds should be hashed in deterministic order.

@arielb1
Copy link
Contributor Author

arielb1 commented Dec 25, 2016

This should be fixed - projections are now sorted by their DefPath.

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 25, 2016
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 25, 2017
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 18, 2020
@TornaxO7
Copy link

Is this issue still up to date?

@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 11, 2023
@apiraino
Copy link
Contributor

I've tested this with some more modern Rust code:

#![feature(core_intrinsics, rustc_private)]                                                                                   

use term;
#[cfg(arena_first)]
use typed_arena;
#[cfg(not(arena_first))]
use typed_arena;

use std::intrinsics::type_id;
 
 fn main() {
     println!(
         "same={:?} different={:?}",
         type_id::<typed_arena::Arena<()>>(),
         type_id::<dyn Iterator<Item = typed_arena::Arena<()>>>()
     );
 }

the Type IDs are now the same compiling with or without --features arena_first, ex:

$ cargo run --features arena_first
same=183576685912587470318627960423020482748 different=30593087131907206016297065634067928062
$ cargo run
same=183576685912587470318627960423020482748 different=30593087131907206016297065634067928062

@apiraino
Copy link
Contributor

apiraino commented Jul 25, 2023

reopen as it needs a test, possibly reducing to no external dependencies

@apiraino apiraino reopened this Jul 25, 2023
apiraino added a commit to apiraino/rust that referenced this issue Jul 31, 2023
@jackh726
Copy link
Member

This has an MCVE, just needs test (and there is an open PR).

@jackh726 jackh726 removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 25, 2023
@fmease fmease added A-trait-system Area: Trait system and removed A-trait-system Area: Trait system labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants