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

Trait object coercion regression #16861

Closed
sfackler opened this issue Aug 29, 2014 · 4 comments
Closed

Trait object coercion regression #16861

sfackler opened this issue Aug 29, 2014 · 4 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-trait-system Area: Trait system

Comments

@sfackler
Copy link
Member

This code has stopped compiling some time in the last week:

trait Foo {}

impl Foo for i32 {}

fn test(_: &[&Foo]) {}

fn main() {
    test([&1i32]);
}
test.rs:8:10: 8:17 error: mismatched types: expected `&[&Foo]`, found `[&i32, .. 1]` (expected &-ptr, found vector)
test.rs:8     test([&1i32]);
                   ^~~~~~~
error: aborting due to previous error
@sfackler
Copy link
Member Author

cc @luqmana

@luqmana
Copy link
Member

luqmana commented Aug 29, 2014

I'm guessing this is fallout from DST? @nick29581

@huonw huonw added the A-dst label Aug 30, 2014
@huonw
Copy link
Member

huonw commented Aug 30, 2014

Works with test(&[&1i32]); (i.e. a pointer to a [&i32, .. 1] coercing to a &[&i32]), which is the long term solution, I believe.

sfackler added a commit to sfackler/rust-postgres that referenced this issue Aug 30, 2014
I'm temporarily diabling arrays until I have a chance to look over and
make sure the API is sound.

This also works around a trait object coercion regression:
rust-lang/rust#16861
@nrc
Copy link
Member

nrc commented Aug 31, 2014

Apparently we used to coerce [T, ..n] to &[T]. Since Rust is meant to never coerce a value type to a pointer type, I regard that as a bug that has been fixed. &[T, ..n] will still coerce to &[T]. And we even seem to do the nested coercion to trait objects (I'm not sure if we should....).

@nrc nrc closed this as completed Aug 31, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 31, 2024
fix: Ignore some warnings if they originate from within macro expansions

These tend to be annoying noise as we can't handle `allow`s for them properly for the time being.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants