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

Forbid recursive impl trait #56074

Merged
merged 2 commits into from
Jan 4, 2019

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented Nov 19, 2018

There is no type T, such that T = [T; 2], but impl Trait could sometimes
be to circumvented this.

This patch makes it a hard error for an opaque type to resolve to such a
"type". Before this can be merged it needs

  • A better error message - it's good enough for now.
  • A crater run (?) to see if this any real-world code

closes #47659

@rust-highfive
Copy link
Collaborator

r? @zackmdavis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 19, 2018
@cramertj
Copy link
Member

cc #47659

span: Span,
) {
if let Err(partially_expanded_type) = tcx.try_expand_impl_trait_type(def_id, substs) {
let mut err = tcx.sess.struct_span_err(span, "recursive opaque type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this deserves a dedicated E0XXX error code? (which would be defined in librustc_typeck/diagnostics.rs)

@zackmdavis
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Nov 22, 2018

⌛ Trying commit cdf5394 with merge db42d4d...

bors added a commit that referenced this pull request Nov 22, 2018
…try>

Forbid recursive impl trait

There is no type T, such that `T = [T; 2]`, but impl Trait could sometimes
be to circumvented this.

This patch makes it a hard error for an opaque type to resolve to such a
"type". Before this can be merged it needs

- [ ] A better error message
- [ ] A crater run (?) to see if this any real-world code
@bors
Copy link
Contributor

bors commented Nov 22, 2018

☀️ Test successful - status-travis
State: approved= try=True

@matthewjasper
Copy link
Contributor Author

Can I have a crater run @rust-lang/infra?

@pietroalbini
Copy link
Member

@craterbot run start=master#0b9f19dff1347e29bf4362ab5a8fab84b43023b5 end=try#db42d4dad33013eba11ef37342ad9f614e5652b8 mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-56074 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2018
@craterbot
Copy link
Collaborator

🚧 Experiment pr-56074 is now running on agent aws-1.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-56074 is completed!
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Nov 29, 2018
@pietroalbini
Copy link
Member

Only one regression, ThatsGobbles/taggu-rust:

Nov 28 10:49:30.564 INFO [stderr] error: recursive opaque type
Nov 28 10:49:30.564 INFO [stderr]    --> src/metadata/mod.rs:149:63
Nov 28 10:49:30.564 INFO [stderr]     |
Nov 28 10:49:30.564 INFO [stderr] 149 |     pub fn iter_over<'a>(&'a self, mis: MappingIterScheme) -> impl Iterator<Item = &'a String> {
Nov 28 10:49:30.564 INFO [stderr]     |                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ resolves to self-referential type
Nov 28 10:49:30.564 INFO [stderr]     |
Nov 28 10:49:30.564 INFO [stderr]     = note: resolved type is `generator::GenConverter::gen_to_iter::It<[generator@src/metadata/mod.rs:150:23: 184:10 self:&'a metadata::MetaValue, mis:metadata::MappingIterScheme for<'r, 's, 't0, 't1, 't2, 't3, 't4, 't5, 't6, 't7, 't8, 't9, 't10, 't11, 't12, 't13, 't14, 't15, 't16, 't17, 't18, 't19, 't20, 't21, 't22, 't23, 't24, 't25, 't26, 't27, 't28, 't29, 't30, 't31, 't32, 't33, 't34, 't35> {&'r metadata::MetaValue, metadata::MetaValue, &'s std::string::String, (), &'t0 std::vec::Vec<metadata::MetaValue>, fn(&'t1 std::vec::Vec<metadata::MetaValue>) -> <&'t1 std::vec::Vec<metadata::MetaValue> as std::iter::IntoIterator>::IntoIter {<&'t1 std::vec::Vec<metadata::MetaValue> as std::iter::IntoIterator>::into_iter}, std::slice::Iter<'t2, metadata::MetaValue>, std::slice::Iter<'t3, metadata::MetaValue>, &'t4 metadata::MetaValue, &'t5 metadata::MetaValue, fn(std::boxed::Box<impl std::iter::Iterator>) -> <std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::IntoIter {<std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::into_iter}, fn(impl std::iter::Iterator) -> std::boxed::Box<impl std::iter::Iterator> {<std::boxed::Box<T>><impl std::iter::Iterator>::new}, &'t8 metadata::MetaValue, metadata::MappingIterScheme, impl std::iter::Iterator, std::boxed::Box<impl std::iter::Iterator>, &'t11 std::string::String, &'t12 std::string::String, std::string::String, &'t13 std::string::String, &'t14 std::collections::BTreeMap<metadata::MetaKey, metadata::MetaValue>, fn(&'t15 std::collections::BTreeMap<metadata::MetaKey, metadata::MetaValue>) -> <&'t15 std::collections::BTreeMap<metadata::MetaKey, metadata::MetaValue> as std::iter::IntoIterator>::IntoIter {<&'t15 std::collections::BTreeMap<metadata::MetaKey, metadata::MetaValue> as std::iter::IntoIterator>::into_iter}, std::collections::btree_map::Iter<'t16, metadata::MetaKey, metadata::MetaValue>, std::collections::btree_map::Iter<'t17, metadata::MetaKey, metadata::MetaValue>, (&'t18 metadata::MetaKey, &'t19 metadata::MetaValue), &'t20 metadata::MetaKey, &'t21 metadata::MetaValue, fn(std::boxed::Box<impl std::iter::Iterator>) -> <std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::IntoIter {<std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::into_iter}, fn(impl std::iter::Iterator) -> std::boxed::Box<impl std::iter::Iterator> {<std::boxed::Box<T>><impl std::iter::Iterator>::new}, metadata::MetaKey, &'t24 metadata::MetaKey, impl std::iter::Iterator, std::boxed::Box<impl std::iter::Iterator>, &'t27 std::string::String, &'t28 std::string::String, fn(std::boxed::Box<impl std::iter::Iterator>) -> <std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::IntoIter {<std::boxed::Box<impl std::iter::Iterator> as std::iter::IntoIterator>::into_iter}, fn(impl std::iter::Iterator) -> std::boxed::Box<impl std::iter::Iterator> {<std::boxed::Box<T>><impl std::iter::Iterator>::new}, &'t31 metadata::MetaValue, impl std::iter::Iterator, std::boxed::Box<impl std::iter::Iterator>, &'t34 std::string::String, &'t35 std::string::String}]>`

@matthewjasper
Copy link
Contributor Author

matthewjasper commented Nov 29, 2018

Regression is due to this change. Code in question is:

impl MetaValue {
    pub fn iter_over<'a>(&'a self, mis: MappingIterScheme) -> impl Iterator<Item = &'a String> {
        let closure = move || {
            match *self {
                MetaValue::Nil => {},
                MetaValue::Str(ref s) => { yield s; },
                MetaValue::Seq(ref mvs) => {
                    for mv in mvs {
                        for i in Box::new(mv.iter_over(mis)) {
                            yield i;
                        }
                    }
                },
                MetaValue::Map(ref map) => {
                    for (mk, mv) in map {
                        match mis {
                            MappingIterScheme::Keys | MappingIterScheme::Both => {
                                // This outputs the value of the Nil key first, but only if a BTreeMap is used.
                                for s in Box::new(mk.iter_over()) {
                                    yield s;
                                }
                            },
                            MappingIterScheme::Vals => {},
                        };

                        match mis {
                            MappingIterScheme::Vals | MappingIterScheme::Both => {
                                for s in Box::new(mv.iter_over(mis)) {
                                    yield s;
                                }
                            },
                            MappingIterScheme::Keys => {},
                        };
                    }
                },
            }
        };

        GenConverter::gen_to_iter(closure)
    }
}

Replacing for s in Box::new(mv.iter_over(mis)) { with

let iter = Box::new(mv.iter_over(mis)) as Box<dyn Iterator<Item = &'a String>>;
for s in iter {

fixes this.
using an existential type with a wrapper struct should also work at some point.

So @rust-lang/lang, should this be a future compatibility lint (with what default level)?

@Centril Centril added T-lang Relevant to the language team, which will review and decide on the PR/issue. I-nominated labels Nov 29, 2018
@eddyb
Copy link
Member

eddyb commented Dec 2, 2018

r? @nikomatsakis

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code is r=me-- haven't looked or thought about crater run results yet

src/librustc/ty/util.rs Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Show resolved Hide resolved
@matthewjasper
Copy link
Contributor Author

@Centril was a decision reached on whether this should be a future compat lint?

@Centril
Copy link
Contributor

Centril commented Dec 16, 2018

I don't recall a decision on that but as there was a regression you might as well do it. An issue filed against the regressed repo would also be nice.

@bors
Copy link
Contributor

bors commented Jan 2, 2019

📌 Commit 671da3d47366a3f79162a8c0a77c3a58f567ced8 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2019
@bors
Copy link
Contributor

bors commented Jan 3, 2019

⌛ Testing commit 671da3d47366a3f79162a8c0a77c3a58f567ced8 with merge 357c9c1522caf3c1ab6c2f4380090650d491db56...

@bors
Copy link
Contributor

bors commented Jan 3, 2019

💔 Test failed - status-travis

@rust-highfive
Copy link
Collaborator

The job dist-i586-gnu-i586-i686-musl of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:48:39] 
[00:48:39] ---- [ui] ui/impl-trait/infinite-impl-trait-issue-38064.rs stdout ----
[00:48:39] diff of stderr:
[00:48:39] 
[00:48:39] 1 error[E0720]: opaque type expands to a recursive type
[00:48:39] +   --> $DIR/infinite-impl-trait-issue-38064.rs:8:13
[00:48:39] 3    |
[00:48:39] 3    |
[00:48:39] 4 LL | fn foo() -> impl Quux { //~ opaque type expands to a recursive type
[00:48:39] 5    |             ^^^^^^^^^ expands to self-referential type
[00:48:39] 
[00:48:39] 7    = note: expanded type is `foo::Foo<bar::Bar<impl Quux>>`
[00:48:39] 8 
[00:48:39] 9 error[E0720]: opaque type expands to a recursive type
[00:48:39] +   --> $DIR/infinite-impl-trait-issue-38064.rs:14:13
[00:48:39] 11    |
[00:48:39] 11    |
[00:48:39] 12 LL | fn bar() -> impl Quux { //~ opaque type expands to a recursive type
[00:48:39] 13    |             ^^^^^^^^^ expands to self-referential type
[00:48:39] 
[00:48:39] The actual stderr differed from the expected stderr.
[00:48:39] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/infinite-impl-trait-issue-38064/infinite-impl-trait-issue-38064.stderr
[00:48:39] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/infinite-impl-trait-issue-38064/infinite-impl-trait-issue-38064.stderr
[00:48:39] To update references, rerun the tests and pass the `--bless` flag
[00:48:39] To only update this specific test, also pass `--test-args impl-trait/infinite-impl-trait-issue-38064.rs`
[00:48:39] error: 1 errors occurred comparing output.
[00:48:39] status: exit code: 1
[00:48:39] status: exit code: 1
[00:48:39] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs" "--target=i586-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/infinite-impl-trait-issue-38064/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=cc" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/infinite-impl-trait-issue-38064/auxiliary" "-A" "unused"
[00:48:39] ------------------------------------------
[00:48:39] 
[00:48:39] ------------------------------------------
[00:48:39] stderr:
[00:48:39] stderr:
[00:48:39] ------------------------------------------
[00:48:39] {"message":"opaque type expands to a recursive type","code":{"code":"E0720","explanation":"\nAn `impl Trait` type expands to a recursive type.\n\nAn `impl Trait` type must be expandable to a concrete type that contains no\n`impl Trait` types. For example the following example tries to create an\n`impl Trait` type `T` that is equal to `[T, T]`:\n\n```compile_fail,E0720\nfn make_recursive_type() -> impl Sized {\n    [make_recursive_type(), make_recursive_type()]\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":154,"byte_end":163,"line_start":8,"line_end":8,"column_start":13,"column_end":22,"is_primary":true,"text":[{"text":"fn foo() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":"expands to self-referential type","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":154,"byte_end":163,"line_start":8,"line_end":8,"column_start":13,"column_end":22,"is_primary":false,"text":[{"text":"fn foo() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `existential type`","def_site_span":{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":154,"byte_end":163,"line_start":8,"line_end":8,"column_start":13,"column_end":22,"is_primary":false,"text":[{"text":"fn foo() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"expanded type is `foo::Foo<bar::Bar<impl Quux>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0720]: opaque type expands to a recursive type\n  --> /checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs:8:13\n   |\nLL | fn foo() -> impl Quux { //~ opaque type expands to a recursive type\n   |             ^^^^^^^^^ expands to self-referential type\n   |\n   = note: expanded type is `foo::Foo<bar::Bar<impl Quux>>`\n\n"}
[00:48:39] {"message":"opaque type expands to a recursive type","code":{"code":"E0720","explanation":"\nAn `impl Trait` type expands to a recursive type.\n\nAn `impl Trait` type must be expandable to a concrete type that contains no\n`impl Trait` types. For example the following example tries to create an\n`impl Trait` type `T` that is equal to `[T, T]`:\n\n```compile_fail,E0720\nfn make_recursive_type() -> impl Sized {\n    [make_recursive_type(), make_recursive_type()]\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":293,"byte_end":302,"line_start":14,"line_end":14,"column_start":13,"column_end":22,"is_primary":true,"text":[{"text":"fn bar() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":"expands to self-referential type","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":293,"byte_end":302,"line_start":14,"line_end":14,"column_start":13,"column_end":22,"is_primary":false,"text":[{"text":"fn bar() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `existential type`","def_site_span":{"file_name":"/checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs","byte_start":293,"byte_end":302,"line_start":14,"line_end":14,"column_start":13,"column_end":22,"is_primary":false,"text":[{"text":"fn bar() -> impl Quux { //~ opaque type expands to a recursive type","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"expanded type is `bar::Bar<foo::Foo<impl Quux>>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0720]: opaque type expands to a recursive type\n  --> /checkout/src/test/ui/impl-trait/infinite-impl-trait-issue-38064.rs:14:13\n   |\nLL | fn bar() -> impl Quux { //~ opaque type expands to a recursive type\n   |             ^^^^^^^^^ expands to self-referential type\n   |\n   = note: expanded type is `bar::Bar<foo::Foo<impl Quux>>`\n\n"}
[00:48:39] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:48:39] {"message":"For more information about this error, try `rustc --explain E0720`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0720`.\n"}
[00:48:39] ------------------------------------------
[00:48:39] 
[00:48:39] thread '[ui] ui/impl-trait/infinite-impl-trait-issue-38064.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3245:9
[00:48:39] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:48:39] 
[00:48:39] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:495:22
[00:48:39] 
[00:48:39] 
[00:48:39] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/i586-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-i586-unknown-linux-gnu" "--mode" "ui" "--target" "i586-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "cc" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/i586-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:48:39] 
[00:48:39] 
[00:48:39] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target i586-unknown-linux-gnu,i686-unknown-linux-musl
[00:48:39] Build completed unsuccessfully in 0:46:24
---
travis_time:end:371b0910:start=1546511344068181903,finish=1546511344074849411,duration=6667508
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0f702870
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0d5db000
travis_time:start:0d5db000
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a1dd79a
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 3, 2019
@nikomatsakis
Copy link
Contributor

@matthewjasper looks like this maybe needs a --bless run?

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2019
It used to display as just `impl`
@matthewjasper
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 3, 2019

📌 Commit 450c756996340e50a2ed2d385b6e9d2dd6c51f67 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 3, 2019
@rust-highfive

This comment has been minimized.

There is no type T, such that `T = [T; 2]`, we should not allow this
to be circumvented by impl Trait.
@matthewjasper
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 3, 2019

📌 Commit 65c1f54 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 4, 2019

⌛ Testing commit 65c1f54 with merge ae167c9...

bors added a commit that referenced this pull request Jan 4, 2019
…ikomatsakis

Forbid recursive impl trait

There is no type T, such that `T = [T; 2]`, but impl Trait could sometimes
be to circumvented this.

This patch makes it a hard error for an opaque type to resolve to such a
"type". Before this can be merged it needs

- [x] A better error message - it's good enough for now.
- [x] A crater run (?) to see if this any real-world code

closes #47659
@bors
Copy link
Contributor

bors commented Jan 4, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing ae167c9 to master...

@bors bors merged commit 65c1f54 into rust-lang:master Jan 4, 2019
@matthewjasper matthewjasper deleted the forbid-recursive-impl-trait branch January 5, 2019 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message for infinitely recursive impl Trait type