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

builtin bounds specified on impls are not checked #15860

Closed
nikomatsakis opened this issue Jul 21, 2014 · 2 comments · Fixed by #15957
Closed

builtin bounds specified on impls are not checked #15860

nikomatsakis opened this issue Jul 21, 2014 · 2 comments · Fixed by #15957
Labels
A-traits Area: Trait system A-typesystem Area: The type system
Milestone

Comments

@nikomatsakis
Copy link
Contributor

Example:

// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test that Copy bounds implied indirectly by the impl are checked.

use std::any::Any;
use std::any::AnyRefExt;

trait Foo {
}

impl<T:Copy> Foo for T {
}

fn take_param<T:Foo>(foo: &T) { }

fn main() {
    let x = box 3i;
    take_param(&x);
}

This should be fixed by code in #5527.

@pcwalton
Copy link
Contributor

Nominating for 1.0, P-backcompat-lang.

@pnkfelix
Copy link
Member

Assigning 1.0, P-backcompat-lang

@pnkfelix pnkfelix added this to the 1.0 milestone Jul 24, 2014
pcwalton added a commit to pcwalton/rust that referenced this issue Jul 25, 2014
method calls are involved.

This breaks code like:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = box 3i; // note no `Copy` bound
        take_param(&x);
    }

Change this code to not contain a type error. For example:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = 3i; // satisfies `Copy` bound
        take_param(&x);
    }

Closes rust-lang#15860.

[breaking-change]
bors added a commit that referenced this issue Jul 25, 2014
…uonw,pnkfelix

method calls are involved.

This breaks code like:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = box 3i; // note no `Copy` bound
        take_param(&x);
    }

Change this code to not contain a type error. For example:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = 3i; // satisfies `Copy` bound
        take_param(&x);
    }

Closes #15860.

[breaking-change]

r? @alexcrichton
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system A-typesystem Area: The type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants