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

Tracking issue for nested_impl_trait compatibility lint #59014

Closed
1 of 3 tasks
pnkfelix opened this issue Mar 8, 2019 · 0 comments · Fixed by #65785
Closed
1 of 3 tasks

Tracking issue for nested_impl_trait compatibility lint #59014

pnkfelix opened this issue Mar 8, 2019 · 0 comments · Fixed by #65785
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-future-incompatibility Category: Future-incompatibility lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Mar 8, 2019

What is this lint about

Some occurrences of impl Trait that appear nested at certain points within the type structure of a larger impl Trait type are meant to be rejected by the compiler, because (at least in part) the assignment of concrete types to those nested impl Trait is fragile and fails to provide a path for the user to be more explicit should inference fail.

Due to implementation oversights, some occurrences were erroneously skipped by the nested impl Trait detection, and then those occurrences were sometimes successfully assigned to a type based on Rust type inference implementation details. These implementation oversights were long overlooked and thus became part of the stable Rust compiler.

PR #57730 fixed those aforementioned implementation details, and thus some instances of impl Trait are rejected as erroneous when they were previously accepted by the stable compiler. Since our policy is to provide a smooth transition when such errors are introduced (see RFC 1589), PR #58608 adapted those fixes to the implementation to downgrade those particular rejections of nested impl Trait to be linted as warnings rather than errors.

How to fix this warning/error

All cases where this code was known to successfully compile are instances of impl Trait in argument position (#44721). All such cases can be rewritten to instead use explicit generic type parameters. For example, this signature from #57979

pub fn collect(_: impl IntoIterator<Item = impl Borrow<Data<impl AsRef<[u8]>>>>)

can be rewritten as follows:

pub fn collect<T>(_: impl IntoIterator<Item = impl Borrow<Data<T>>>) where T: AsRef<[u8]>

Current status

@pnkfelix pnkfelix added C-future-incompatibility Category: Future-incompatibility lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 8, 2019
bors added a commit that referenced this issue Aug 3, 2019
Transition some C-future-compatibility lints to {ERROR, DENY}

Closes #40107 (ERROR).
Closes #39207 (ERROR).
Closes #37872 (ERROR).
Closes #36887 (ERROR).
Closes #36247 (ERROR.
Closes #42238 (ERROR).
Transitions #59014 (DENY).
Transitions #57571 (DENY).
Closes #60210 (ERROR).
Transitions #35203 (DENY).

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this issue Nov 8, 2019
Transition future compat lints to {ERROR, DENY} - Take 2

Follow up to rust-lang#63247 implementing rust-lang#63247 (comment).

- `legacy_ctor_visibility` (ERROR) -- closes rust-lang#39207
- `legacy_directory_ownership` (ERROR) -- closes rust-lang#37872
- `safe_extern_static` (ERROR) -- closes rust-lang#36247
- `parenthesized_params_in_types_and_modules` (ERROR) -- closes rust-lang#42238
- `duplicate_macro_exports` (ERROR)
- `nested_impl_trait` (ERROR) -- closes rust-lang#59014
- `ill_formed_attribute_input` (DENY) -- transitions rust-lang#57571
- `patterns_in_fns_without_body` (DENY) -- transitions rust-lang#35203

r? @varkor
cc @petrochenkov
@bors bors closed this as completed in 7ab50e4 Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-future-incompatibility Category: Future-incompatibility lints 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.

1 participant