`extra_requirement_in_impl` future-compatibility warning #37166

Open
nikomatsakis opened this Issue Oct 14, 2016 · 2 comments

Projects

None yet

2 participants

@nikomatsakis
Contributor
nikomatsakis commented Oct 14, 2016 edited

This is the summary issue for the extra_requirement_in_impl future-compatibility warning and other related errors. The goal of this page is describe why this change was made and how you can fix code that is affected by it. It also provides a place to ask questions or register a complaint if you feel the change should not be made. For more information on the policy around future-compatibility warnings, see our breaking change policy guidelines.

What is the warning for?

There has been a longstanding bug in rustc (#18937) that sometimes allowed an impl
to place additional requirements on its methods above and beyond the requirements
that appear in the trait definition. For example:

trait Trait {
    fn foo<F>(&mut self, f: F)
        where F: Clone;
}

impl Trait for i32 {
    fn foo<F>(&mut self, f: F)
        where F: Clone + 'static
    {   //               ^^^^^^^ additional requirement
    }
}

This is unsound and can permit crashes and other arbitrary behavior.
The solution is usually to move the requirement into the trait definition:

trait Trait {
    fn foo<F>(&mut self, f: F)
        where F: Clone + 'static;
}

or else remove the requirement from the impl.

When will this warning become a hard error?

At the beginning of each 6-week release cycle, the Rust compiler team will review the set of outstanding future compatibility warnings and nominate some of them for Final Comment Period. Toward the end of the cycle, we will review any comments and make a final determination whether to convert the warning into a hard error or remove it entirely.

@nikomatsakis nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 14, 2016
@nikomatsakis nikomatsakis update `extra_requirement_in_impl` to #37166 68e87a3
@nikomatsakis nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 14, 2016
@nikomatsakis nikomatsakis update `extra_requirement_in_impl` to #37166 160dd14
@nikomatsakis nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 19, 2016
@nikomatsakis nikomatsakis update `extra_requirement_in_impl` to #37166 0d15904
@nikomatsakis nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 21, 2016
@nikomatsakis nikomatsakis update `extra_requirement_in_impl` to #37166 ab28cba
@nikomatsakis nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Nov 1, 2016
@nikomatsakis nikomatsakis update `extra_requirement_in_impl` to #37166 b659752
@keeperofdakeys keeperofdakeys added a commit to keeperofdakeys/rust that referenced this issue Nov 5, 2016
@nikomatsakis @keeperofdakeys nikomatsakis + keeperofdakeys update `extra_requirement_in_impl` to #37166 e09020b
@keeperofdakeys keeperofdakeys added a commit to keeperofdakeys/rust that referenced this issue Nov 6, 2016
@nikomatsakis @keeperofdakeys nikomatsakis + keeperofdakeys update `extra_requirement_in_impl` to #37166 98f50af
@nagisa
Contributor
nagisa commented Jan 19, 2017

There’s a desire to make this either a “lint-error” or “non-lint-warning” (can’t be disabled) for 1.16 and hard error for 1.17.

@nikomatsakis
Contributor

Discussed in compiler-team meeting and decided to move this to deny-by-default.

@nagisa nagisa added a commit to nagisa/rust that referenced this issue Jan 19, 2017
@nagisa nagisa Deny extra_requirement_in_impl forward-compat lint
Part of #37166
2c9c70f
@alexcrichton alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 19, 2017
@alexcrichton alexcrichton Rollup merge of #39195 - nagisa:deny-extra-requirement-in-impl, r=eddyb
Deny extra_requirement_in_impl forward-compat lint

Part of #37166
981e3d6
@J-F-Liu J-F-Liu added a commit to J-F-Liu/pom that referenced this issue Jan 20, 2017
@J-F-Liu J-F-Liu Fix extra_requirement_in_impl issue 50594bd
@alexcrichton alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 20, 2017
@alexcrichton alexcrichton Rollup merge of #39195 - nagisa:deny-extra-requirement-in-impl, r=eddyb
Deny extra_requirement_in_impl forward-compat lint

Part of #37166
5a4658d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment