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

Rollup of 22 pull requests #57727

Closed
wants to merge 57 commits into from
Closed

Rollup of 22 pull requests #57727

wants to merge 57 commits into from

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Jan 18, 2019

Successful merges:

Failed merges:

r? @ghost

sdroege and others added 30 commits December 13, 2018 11:07
Using `!` for `c_void` would have the problem that pointers and
potentially references to an uninhabited type would be created, and at
least for references this is UB.

Also document in addition that newtype wrappers around `c_void` are not
recommended for representing opaque types (as a workaround for `extern
type` not being stable) but instead refer to the Nomicon.
…rent implementation

We need at least two variants of the enum as otherwise the compiler
complains about the #[repr(u8)] attribute and we also need at least one
variant as otherwise the enum would be uninhabitated and dereferencing
pointers to it would be UB.

As such, mark the variants not unstable because they should not actually
exist but because they are temporary implementation details until
`extern type` is stable and can be used instead.
- Cleanup the `impl PartialEq<BookFormat> for Book` implementation
- Implement `impl PartialEq<Book> for BookFormat` so it’s symmetric
  - Fixes rust-lang#53844.
- Removes the last example since it appears to be redundant with the
  previous two examples.
This may be needed with some host compilers.
A few items were referenced, but did not have links.
It's simpler and makes some benchmark run up to 1% faster. It also makes
`hir::ExprKind` more like `ast::ExprKind` (which underwent the
equivalent change in rust-lang#55777).
It's identical to `ast::Label`.
Add signed num::NonZeroI* types

Multiple people have asked for them in rust-lang#49137. Given that the unsigned ones already exist, they are very easy to add and not an additional maintenance burden.
High priority resolutions for associated variants

In rust-lang#56225 variants were assigned lowest priority during name resolution to avoid crater run and potential breakage.

This PR changes the rules to give variants highest priority instead.
Some motivation:
- If variants (and their constructors) are treated as associated items, then they are obviously *inherent* associated items since they don't come from traits.
- Inherent associated items have higher priority during resolution than associated items from traits.
- The reason is that there is a way to disambiguate in favor of trait items (`<Type as Trait>::Ambiguous`), but there's no way to disambiguate in favor of inherent items, so they became unusable in case of ambiguities if they have low priority.
- It's technically problematic to fallback from associated types to anything until lazy normalization (?) is implemented.

Crater found some regressions from this change, but they are all in type positions, e.g.
```rust
fn f() -> Self::Ambiguos { ... } // Variant `Ambiguous` or associated type `Ambiguous`?
```
, so variants are not usable there right now, but they may become usable in the future if rust-lang/rfcs#2593 is accepted.
This PR keeps code like this successfully resolving, but introduces a future-compatibility lint `ambiguous_associated_items` that recommends rewriting it as `<Self as Trait>::Ambiguous`.
resolve: Add a test for issue rust-lang#57539

Add a test for the bugfix regression reported in rust-lang#57539

Closes rust-lang#57539
…enkov

Fix nested `?` matchers

fix rust-lang#57597

I'm not 100% if this works yet...

cc @alercah

When  this is ready (but perhaps not yet):
…avidtwco

Remove an unused function argument

The only use was a debug printing, which might help someone with debugging dataflow problems, but seems otherwise useless
…erister

use structured macro and path resolve suggestions
… r=QuietMisdreavus

Fix sources sidebar not showing up

Fixes rust-lang#57601.

The order of imports made it so that the sidebar creation was called before the sidebar sources were created. Like this, when the sources are loaded, they create the sidebar as expected.

r? @QuietMisdreavus
…reavus

Fixes text becoming invisible when element targetted

Fixes rust-lang#57628.

r? @QuietMisdreavus
privacy: Account for associated existential types

Turns out they *can* be associated (but only in impls, not traits).
Fixes rust-lang#53546 (comment)

r? @arielb1
librustc_metadata: Pass a default value when unwrapping a span

Fixes rust-lang#57323.

When compiling with `static-nobundle` a-la

`rustc -l static-nobundle=nonexistent main.rs`

we now get a neat output in the form of:

```
error[E0658]: kind="static-nobundle" is feature gated (see issue rust-lang#37403)
  |
  = help: add #![feature(static_nobundle)] to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
```
The build and tests completed successfully on my machine. Should I be adding a new test?
Add some links in std::fs.

A few items were referenced, but did not have links.
…woerister

Two HIR tweaks

Two HIR tweaks that make things slightly simpler and faster.
Document Unpin in std::prelude documentation
…-applicability, r=withoutboats

Enhance `Pin` impl applicability for `PartialEq` and `PartialOrd`.

This allows for comparing for equality or ordering a `Pin<P>` and a `Pin<Q>` as long as `P` and `Q` are correspondingly comparable themselves *even when `P` and `Q` are different types*.
An example might be comparing a `Pin<&mut OsString>` to a `Pin<&mut PathBuf>`, which might arise from pin projections from a pair of larger contexts that aren't `Unpin`.
Fix typo bug in DepGraph::try_mark_green().

r? @Zoxc

Fixes rust-lang#57692.
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: rust-lang#57521
@Centril
Copy link
Contributor Author

Centril commented Jan 18, 2019

@bors r+ p=22

@bors
Copy link
Contributor

bors commented Jan 18, 2019

📌 Commit ca72ad1 has been approved by Centril

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 18, 2019
@bors
Copy link
Contributor

bors commented Jan 18, 2019

⌛ Testing commit ca72ad1 with merge fd3f45b02699d0b74948edc199da7898ac331846...

@bors
Copy link
Contributor

bors commented Jan 18, 2019

💔 Test failed - checks-travis

@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 18, 2019
@rust-highfive
Copy link
Collaborator

The job armhf-gnu 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:04:01] 71  |                           Some(unsafe { $Ty(n) })
[00:04:01]     |                                ^^^^^^ unnecessary `unsafe` block
[00:04:01] ...
[00:04:01] 100 | / nonzero_integers! {
[00:04:01] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[00:04:01] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[00:04:01] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[00:04:01] ...   |
[00:04:01] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[00:04:01]     | |_- in this macro invocation
[00:04:01]     |
[00:04:01]     = note: #[warn(unused_unsafe)] on by default
[00:04:01] 
[00:04:01] 
[00:04:01] warning: unnecessary `unsafe` block
[00:04:01]    --> src/libcore/num/mod.rs:71:30
[00:04:01]     |
[00:04:01] 71  |                           Some(unsafe { $Ty(n) })
[00:04:01]     |                                ^^^^^^ unnecessary `unsafe` block
[00:04:01] ...
[00:04:01] 100 | / nonzero_integers! {
[00:04:01] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[00:04:01] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[00:04:01] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[00:04:01] ...   |
[00:04:01] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[00:04:01]     | |_- in this macro invocation
[00:04:01] 
[00:04:01] warning: unnecessary `unsafe` block
[00:04:01]     --> src/libcore/ptr.rs:2786:18
---
[00:04:01] 50  |                   #[rustc_layout_scalar_valid_range_start(1)]
[00:04:01]     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:04:01] ...
[00:04:01] 100 | / nonzero_integers! {
[00:04:01] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[00:04:01] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[00:04:01] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[00:04:01] ...   |
[00:04:01] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[00:04:01]     | |_- in this macro invocation
[00:04:01]     |
[00:04:01]     = note: #[warn(unused_attributes)] on by default
[00:04:01] 
[00:04:01] 
[00:04:01] warning: unused attribute
[00:04:01]    --> src/libcore/num/mod.rs:50:17
[00:04:01]     |
[00:04:01] 50  |                   #[rustc_layout_scalar_valid_range_start(1)]
[00:04:01]     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:04:01] ...
[00:04:01] 100 | / nonzero_integers! {
[00:04:01] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[00:04:01] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[00:04:01] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[00:04:01] ...   |
[00:04:01] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[00:04:01]     | |_- in this macro invocation
[00:04:01] 
[00:04:01] warning: unused attribute
[00:04:01]     --> src/libcore/ptr.rs:2721:1
---
[01:00:59] 71  |                           Some(unsafe { $Ty(n) })
[01:00:59]     |                                ^^^^^^ unnecessary `unsafe` block
[01:00:59] ...
[01:00:59] 100 | / nonzero_integers! {
[01:00:59] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[01:00:59] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[01:00:59] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[01:00:59] ...   |
[01:00:59] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[01:00:59]     | |_- in this macro invocation
[01:00:59]     |
[01:00:59]     = note: #[warn(unused_unsafe)] on by default
[01:00:59] 
[01:00:59] 
[01:00:59] warning: unnecessary `unsafe` block
[01:00:59]    --> src/libcore/num/mod.rs:71:30
[01:00:59]     |
[01:00:59] 71  |                           Some(unsafe { $Ty(n) })
[01:00:59]     |                                ^^^^^^ unnecessary `unsafe` block
[01:00:59] ...
[01:00:59] 100 | / nonzero_integers! {
[01:00:59] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[01:00:59] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[01:00:59] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[01:00:59] ...   |
[01:00:59] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[01:00:59]     | |_- in this macro invocation
[01:00:59] 
[01:00:59] warning: unnecessary `unsafe` block
[01:00:59]     --> src/libcore/ptr.rs:2786:18
---
[01:00:59] 50  |                   #[rustc_layout_scalar_valid_range_start(1)]
[01:00:59]     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:00:59] ...
[01:00:59] 100 | / nonzero_integers! {
[01:00:59] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[01:00:59] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[01:00:59] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[01:00:59] ...   |
[01:00:59] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[01:00:59]     | |_- in this macro invocation
[01:00:59]     |
[01:00:59]     = note: #[warn(unused_attributes)] on by default
[01:00:59] 
[01:00:59] 
[01:00:59] warning: unused attribute
[01:00:59]    --> src/libcore/num/mod.rs:50:17
[01:00:59]     |
[01:00:59] 50  |                   #[rustc_layout_scalar_valid_range_start(1)]
[01:00:59]     |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[01:00:59] ...
[01:00:59] 100 | / nonzero_integers! {
[01:00:59] 101 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8);
[01:00:59] 102 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16);
[01:00:59] 103 | |     #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32);
[01:00:59] ...   |
[01:00:59] 112 | |     #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize);
[01:00:59]     | |_- in this macro invocation
[01:00:59] 
[01:00:59] warning: unused attribute
[01:00:59]     --> src/libcore/ptr.rs:2721:1
---
[01:06:20] 
[01:06:20] ---- [ui] ui/try-block/try-block-bad-type.rs stdout ----
[01:06:20] diff of stderr:
[01:06:20] 
[01:06:20] 5    |         ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32`
[01:06:20] 7    = help: the following implementations were found:
[01:06:20] 7    = help: the following implementations were found:
[01:06:20] -              <i32 as std::convert::From<core::num::NonZeroI32>>
[01:06:20] +              <i32 as std::convert::From<bool>>
[01:06:20] 9              <i32 as std::convert::From<i16>>
[01:06:20] -              <i32 as std::convert::From<i8>>
[01:06:20] +              <i32 as std::convert::From<u16>>
[01:06:20] 11              <i32 as std::convert::From<u8>>
[01:06:20] 13    = note: required by `std::convert::From::from`
[01:06:20] 
[01:06:20] 
[01:06:20] The actual stderr differed from the expected stderr.
[01:06:20] The actual stderr differed from the expected stderr.
[01:06:20] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/try-block/try-block-bad-type/try-block-bad-type.stderr
[01:06:20] To update references, rerun the tests and pass the `--bless` flag
[01:06:20] To only update this specific test, also pass `--test-args try-block/try-block-bad-type.rs`
[01:06:20] error: 1 errors occurred comparing output.
[01:06:20] status: exit code: 1
[01:06:20] status: exit code: 1
[01:06:20] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/try-block/try-block-bad-type.rs" "--target=arm-unknown-linux-gnueabihf" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/try-block/try-block-bad-type/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/arm-unknown-linux-gnueabihf/native/rust-test-helpers" "-Clinker=arm-linux-gnueabihf-gcc" "--edition" "2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/try-block/try-block-bad-type/auxiliary" "-A" "unused"
[01:06:20] ------------------------------------------
[01:06:20] 
[01:06:20] ------------------------------------------
[01:06:20] stderr:
[01:06:20] stderr:
[01:06:20] ------------------------------------------
[01:06:20] {"message":"the trait bound `i32: std::convert::From<&str>` is not satisfied","code":{"code":"E0277","explanation":"\nYou tried to use a type which doesn't implement some trait in a place which\nexpected that trait. Erroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function: Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function: It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":121,"byte_end":129,"line_start":7,"line_end":7,"column_start":9,"column_end":17,"is_primary":true,"text":[{"text":"        Err(\"\")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied","highlight_start":9,"highlight_end":17}],"label":"the trait `std::convert::From<&str>` is not implemented for `i32`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the following implementations were found:\n  <i32 as std::convert::From<bool>>\n  <i32 as std::convert::From<i16>>\n  <i32 as std::convert::From<u16>>\n  <i32 as std::convert::From<u8>>\nand 2 others","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required by `std::convert::From::from`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied\n  --> /checkout/src/test/ui/try-block/try-block-bad-type.rs:7:9\n   |\nLL |         Err(\"\")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied\n   |         ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32`\n   |\n   = help: the following implementations were found:\n             <i32 as std::convert::From<bool>>\n             <i32 as std::convert::From<i16>>\n             <i32 as std::convert::From<u16>>\n             <i32 as std::convert::From<u8>>\n           and 2 others\n   = note: required by `std::convert::From::from`\n\n"}
[01:06:20] {"message":"type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == &str`","code":{"code":"E0271","explanation":"\nThis is because of a type mismatch between the associated type of some\ntrait (e.g., `T::Bar`, where `T` implements `trait Quux { type Bar; }`)\nand another type `U` that is required to be equal to `T::Bar`, but is not.\nExamples follow.\n\nHere is a basic example:\n\n```compile_fail,E0271\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType=u32> {\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n\nfoo(3_i8);\n```\n\nHere is that same example again, with some explanatory comments:\n\n```compile_fail,E0271\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType=u32> {\n//                    ~~~~~~~~ ~~~~~~~~~~~~~~~~~~\n//                        |            |\n//         This says `foo` can         |\n//           only be used with         |\n//              some type that         |\n//         implements `Trait`.         |\n//                                     |\n//                             This says not only must\n//                             `T` be an impl of `Trait`\n//                             but also that the impl\n//                             must assign the type `u32`\n//                             to the associated type.\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n//~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n//      |                             |\n// `i8` does have                     |\n// implementation                     |\n// of `Trait`...                      |\n//                     ... but it is an implementation\n//                     that assigns `&'static str` to\n//                     the associated type.\n\nfoo(3_i8);\n// Here, we invoke `foo` with an `i8`, which does not satisfy\n// the constraint `<i8 as Trait>::AssociatedType=u32`, and\n// therefore the type-checker complains with this error code.\n```\n\nTo avoid those issues, you have to make the types match correctly.\nSo we can fix the previous examples like this:\n\n```\n// Basic Example:\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType = &'static str> {\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n\nfoo(3_i8);\n\n// For-Loop Example:\nlet vs = vec![1, 2, 3, 4];\nfor v in &vs {\n    match v {\n        &1 => {}\n        _ => {}\n    }\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":270,"byte_end":272,"line_start":12,"line_end":12,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"        \"\" //~ ERROR type mismatch","highlight_start":9,"highlight_end":11}],"label":"expected i32, found &str","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `i32`\n   found type `&str`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == &str`\n  --> /checkout/src/test/ui/try-block/try-block-bad-type.rs:12:9\n   |\nLL |         \"\" //~ ERROR type mismatch\n   |         ^^ expected i32, found &str\n   |\n   = note: expected type `i32`\n              found type `&str`\n\n"}
[01:06:20] {"message":"type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`","code":{"code":"E0271","explanation":"\nThis is because of a type mismatch between the associated type of some\ntrait (e.g., `T::Bar`, where `T` implements `trait Quux { type Bar; }`)\nand another type `U` that is required to be equal to `T::Bar`, but is not.\nExamples follow.\n\nHere is a basic example:\n\n```compile_fail,E0271\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType=u32> {\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n\nfoo(3_i8);\n```\n\nHere is that same example again, with some explanatory comments:\n\n```compile_fail,E0271\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType=u32> {\n//                    ~~~~~~~~ ~~~~~~~~~~~~~~~~~~\n//                        |            |\n//         This says `foo` can         |\n//           only be used with         |\n//              some type that         |\n//         implements `Trait`.         |\n//                                     |\n//                             This says not only must\n//                             `T` be an impl of `Trait`\n//                             but also that the impl\n//                             must assign the type `u32`\n//                             to the associated type.\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n//~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n//      |                             |\n// `i8` does have                     |\n// implementation                     |\n// of `Trait`...                      |\n//                     ... but it is an implementation\n//                     that assigns `&'static str` to\n//                     the associated type.\n\nfoo(3_i8);\n// Here, we invoke `foo` with an `i8`, which does not satisfy\n// the constraint `<i8 as Trait>::AssociatedType=u32`, and\n// therefore the type-checker complains with this error code.\n```\n\nTo avoid those issues, you have to make the types match correctly.\nSo we can fix the previous examples like this:\n\n```\n// Basic Example:\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType = &'static str> {\n    println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &'static str; }\n\nfoo(3_i8);\n\n// For-Loop Example:\nlet vs = vec![1, 2, 3, 4];\nfor v in &vs {\n    match v {\n        &1 => {}\n        _ => {}\n    }\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":343,"byte_end":344,"line_start":15,"line_end":15,"column_start":39,"column_end":40,"is_primary":true,"text":[{"text":"    let res: Result<i32, i32> = try { }; //~ ERROR type mismatch","highlight_start":39,"highlight_end":40}],"label":"expected i32, found ()","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":341,"byte_end":344,"line_start":15,"line_end":15,"column_start":37,"column_end":40,"is_primary":false,"text":[{"text":"    let res: Result<i32, i32> = try { }; //~ ERROR type mismatch","highlight_start":37,"highlight_end":40}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `try block`","def_site_span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":341,"byte_end":344,"line_start":15,"line_end":15,"column_start":37,"column_end":40,"is_primary":false,"text":[{"text":"    let res: Result<i32, i32> = try { }; //~ ERROR type mismatch","highlight_start":37,"highlight_end":40}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"expected type `i32`\n   found type `()`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`\n  --> /checkout/src/test/ui/try-block/try-block-bad-type.rs:15:39\n   |\nLL |     let res: Result<i32, i32> = try { }; //~ ERROR type mismatch\n   |                                       ^ expected i32, found ()\n   |\n   = note: expected type `i32`\n              found type `()`\n\n"}
[01:06:20] {"message":"the trait bound `(): std::ops::Try` is not satisfied","code":{"code":"E0277","explanation":"\nYou tried to use a type which doesn't implement some trait in a place which\nexpected that trait. Erroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function: Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function: It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":393,"byte_end":396,"line_start":17,"line_end":17,"column_start":23,"column_end":26,"is_primary":true,"text":[{"text":"    let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied","highlight_start":23,"highlight_end":26}],"label":"the trait `std::ops::Try` is not implemented for `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":393,"byte_end":396,"line_start":17,"line_end":17,"column_start":23,"column_end":26,"is_primary":false,"text":[{"text":"    let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied","highlight_start":23,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `try block`","def_site_span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":393,"byte_end":396,"line_start":17,"line_end":17,"column_start":23,"column_end":26,"is_primary":false,"text":[{"text":"    let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied","highlight_start":23,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"required by `std::ops::Try::from_ok`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `(): std::ops::Try` is not satisfied\n  --> /checkout/src/test/ui/try-block/try-block-bad-type.rs:17:23\n   |\nLL |     let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied\n   |                       ^^^ the trait `std::ops::Try` is not implemented for `()`\n   |\n   = note: required by `std::ops::Try::from_ok`\n\n"}
[01:06:20] {"message":"the trait bound `i32: std::ops::Try` is not satisfied","code":{"code":"E0277","explanation":"\nYou tried to use a type which doesn't implement some trait in a place which\nexpected that trait. Erroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function: Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function: It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":479,"byte_end":484,"line_start":19,"line_end":19,"column_start":24,"column_end":29,"is_primary":true,"text":[{"text":"    let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied","highlight_start":24,"highlight_end":29}],"label":"the trait `std::ops::Try` is not implemented for `i32`","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":479,"byte_end":484,"line_start":19,"line_end":19,"column_start":24,"column_end":29,"is_primary":false,"text":[{"text":"    let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied","highlight_start":24,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"desugaring of `try block`","def_site_span":{"file_name":"/checkout/src/test/ui/try-block/try-block-bad-type.rs","byte_start":479,"byte_end":484,"line_start":19,"line_end":19,"column_start":24,"column_end":29,"is_primary":false,"text":[{"text":"    let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied","highlight_start":24,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"required by `std::ops::Try::from_ok`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `i32: std::ops::Try` is not satisfied\n  --> /checkout/src/test/ui/try-block/try-block-bad-type.rs:19:24\n   |\nLL |     let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied\n   |                        ^^^^^ the trait `std::ops::Try` is not implemented for `i32`\n   |\n   = note: required by `std::ops::Try::from_ok`\n\n"}
[01:06:20] {"message":"aborting due to 5 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 5 previous errors\n\n"}
[01:06:20] {"message":"Some errors occurred: E0271, E0277.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0271, E0277.\n"}
[01:06:20] 
[01:06:20] ------------------------------------------
[01:06:20] 
[01:06:20] thread '[ui] ui/try-block/try-block-bad-type.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3245:9
---
[01:06:20] 
[01:06:20] 
[01:06:20] 
[01:06:20] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:495:22
[01:06:20] 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/arm-unknown-linux-gnueabihf/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-arm-unknown-linux-gnueabihf" "--mode" "ui" "--target" "arm-unknown-linux-gnueabihf" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "arm-linux-gnueabihf-gcc" "--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/arm-unknown-linux-gnueabihf/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--remote-test-client" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/remote-test-client" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:06:20] 
[01:06:20] 
[01:06:20] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target arm-unknown-linux-gnueabihf
[01:06:20] Build completed unsuccessfully in 1:02:44
---
travis_time:end:264f3912:start=1547811150419271592,finish=1547811150430131735,duration=10860143
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:22fd2d80
$ 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:06a2d996
travis_time:start:06a2d996
$ 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:00cb4630
$ 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)

@Centril Centril closed this Jan 18, 2019
@Centril Centril deleted the rollup branch January 18, 2019 11:35
@Centril Centril added the rollup A PR which is a rollup label Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.