Created
May 29, 2018 17:43
-
-
Save nikomatsakis/b2ff6bd75da58c34a5582c9f55655a68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- [ui] ui/error-codes/E0275.rs stdout ---- | |
error: ui test compiled successfully! | |
status: exit code: 0 | |
command: "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/home/nmatsakis/versioned/rust-9/src/test/ui/error-codes/E0275.rs" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0275.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/error-codes/E0275.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused" | |
stdout: | |
------------------------------------------ | |
------------------------------------------ | |
stderr: | |
------------------------------------------ | |
------------------------------------------ | |
thread '[ui] ui/error-codes/E0275.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2963:9 | |
note: Run with `RUST_BACKTRACE=1` for a backtrace. | |
---- [ui] ui/issue-24424.rs stdout ---- | |
error: ui test compiled successfully! | |
status: exit code: 0 | |
command: "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/home/nmatsakis/versioned/rust-9/src/test/ui/issue-24424.rs" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/issue-24424.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/issue-24424.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused" | |
stdout: | |
------------------------------------------ | |
------------------------------------------ | |
stderr: | |
------------------------------------------ | |
------------------------------------------ | |
thread '[ui] ui/issue-24424.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2963:9 | |
---- [ui] ui/type-check-defaults.rs stdout ---- | |
diff of stderr: | |
24 LL | struct Foo<T, U: FromIterator<T>>(T, U); | |
25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
26 | |
- error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | |
- --> $DIR/type-check-defaults.rs:21:1 | |
- | | |
- LL | struct Bounds<T:Copy=String>(T); | |
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | |
- | | |
- = note: required by `std::marker::Copy` | |
- | |
- error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | |
- --> $DIR/type-check-defaults.rs:24:1 | |
- | | |
- LL | struct WhereClause<T=String>(T) where T: Copy; | |
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | |
- | | |
- = note: required by `std::marker::Copy` | |
- | |
- error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied | |
- --> $DIR/type-check-defaults.rs:27:1 | |
- | | |
- LL | trait TraitBound<T:Copy=String> {} | |
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` | |
- | | |
- = note: required by `std::marker::Copy` | |
- | |
51 error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied | |
52 --> $DIR/type-check-defaults.rs:31:1 | |
53 | | |
68 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u8` | |
69 | | |
70 = help: the trait `std::ops::Add<u8>` is not implemented for `i32` | |
- = note: required by `std::ops::Add` | |
72 | |
- error: aborting due to 7 previous errors | |
+ error: aborting due to 4 previous errors | |
74 | |
75 For more information about this error, try `rustc --explain E0277`. | |
76 | |
The actual stderr differed from the expected stderr. | |
Actual stderr saved to /home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check-defaults.stderr | |
To update references, run this command from build directory: | |
/home/nmatsakis/versioned/rust-9/src/test/ui/update-references.sh '/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui' 'type-check-defaults.rs' | |
error: 1 errors occurred comparing output. | |
status: exit code: 101 | |
command: "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check-defaults.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check-defaults.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused" | |
stdout: | |
------------------------------------------ | |
------------------------------------------ | |
stderr: | |
------------------------------------------ | |
{"message":"the trait bound `i32: std::iter::FromIterator<i32>` 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":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":599,"byte_end":600,"line_start":16,"line_end":16,"column_start":19,"column_end":20,"is_primary":true,"text":[{"text":"struct WellFormed<Z = Foo<i32, i32>>(Z);","highlight_start":19,"highlight_end":20}],"label":"a collection of type `i32` cannot be built from an iterator over elements of type `i32`","suggested_replacement":null,"expansion":null}],"children":[{"message":"the trait `std::iter::FromIterator<i32>` is not implemented for `i32`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required by `Foo`","code":null,"level":"note","spans":[{"file_name":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":540,"byte_end":580,"line_start":15,"line_end":15,"column_start":1,"column_end":41,"is_primary":true,"text":[{"text":"struct Foo<T, U: FromIterator<T>>(T, U);","highlight_start":1,"highlight_end":41}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `i32: std::iter::FromIterator<i32>` is not satisfied\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:16:19\n |\nLL | struct WellFormed<Z = Foo<i32, i32>>(Z);\n | ^ a collection of type `i32` cannot be built from an iterator over elements of type `i32`\n |\n = help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`\nnote: required by `Foo`\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:15:1\n |\nLL | struct Foo<T, U: FromIterator<T>>(T, U);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"} | |
{"message":"the trait bound `i32: std::iter::FromIterator<i32>` 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":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":737,"byte_end":738,"line_start":18,"line_end":18,"column_start":27,"column_end":28,"is_primary":true,"text":[{"text":"struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);","highlight_start":27,"highlight_end":28}],"label":"a collection of type `i32` cannot be built from an iterator over elements of type `i32`","suggested_replacement":null,"expansion":null}],"children":[{"message":"the trait `std::iter::FromIterator<i32>` is not implemented for `i32`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required by `Foo`","code":null,"level":"note","spans":[{"file_name":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":540,"byte_end":580,"line_start":15,"line_end":15,"column_start":1,"column_end":41,"is_primary":true,"text":[{"text":"struct Foo<T, U: FromIterator<T>>(T, U);","highlight_start":1,"highlight_end":41}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `i32: std::iter::FromIterator<i32>` is not satisfied\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:18:27\n |\nLL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);\n | ^ a collection of type `i32` cannot be built from an iterator over elements of type `i32`\n |\n = help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`\nnote: required by `Foo`\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:15:1\n |\nLL | struct Foo<T, U: FromIterator<T>>(T, U);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"} | |
{"message":"the trait bound `T: std::marker::Copy` 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":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":1282,"byte_end":1318,"line_start":31,"line_end":31,"column_start":1,"column_end":37,"is_primary":true,"text":[{"text":"trait Base<T = String>: Super<T> { }","highlight_start":1,"highlight_end":37}],"label":"the trait `std::marker::Copy` is not implemented for `T`","suggested_replacement":null,"expansion":null}],"children":[{"message":"consider adding a `where T: std::marker::Copy` bound","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"required by `Super`","code":null,"level":"note","spans":[{"file_name":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":1257,"byte_end":1277,"line_start":30,"line_end":30,"column_start":1,"column_end":21,"is_primary":true,"text":[{"text":"trait Super<T: Copy> { }","highlight_start":1,"highlight_end":21}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:31:1\n |\nLL | trait Base<T = String>: Super<T> { }\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T`\n |\n = help: consider adding a `where T: std::marker::Copy` bound\nnote: required by `Super`\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:30:1\n |\nLL | trait Super<T: Copy> { }\n | ^^^^^^^^^^^^^^^^^^^^\n\n"} | |
{"message":"cannot add `u8` to `i32`","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":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs","byte_start":1396,"byte_end":1471,"line_start":34,"line_end":34,"column_start":1,"column_end":76,"is_primary":true,"text":[{"text":"trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {}","highlight_start":1,"highlight_end":76}],"label":"no implementation for `i32 + u8`","suggested_replacement":null,"expansion":null}],"children":[{"message":"the trait `std::ops::Add<u8>` is not implemented for `i32`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: cannot add `u8` to `i32`\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check-defaults.rs:34:1\n |\nLL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {}\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u8`\n |\n = help: the trait `std::ops::Add<u8>` is not implemented for `i32`\n\n"} | |
{"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"} | |
{"message":"For more information about this error, try `rustc --explain E0277`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0277`.\n"} | |
------------------------------------------ | |
thread '[ui] ui/type-check-defaults.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2963:9 | |
---- [ui] ui/type-check/issue-40294.rs stdout ---- | |
diff of stderr: | |
- error[E0283]: type annotations required: cannot resolve `&'a T: Foo` | |
+ error[E0282]: type annotations needed | |
2 --> $DIR/issue-40294.rs:15:1 | |
3 | | |
4 LL | / fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations required | |
8 LL | | x.foo(); | |
9 LL | | y.foo(); | |
10 LL | | } | |
- | |_^ | |
- | | |
- note: required by `Foo` | |
- --> $DIR/issue-40294.rs:11:1 | |
- | | |
- LL | trait Foo: Sized { | |
- | ^^^^^^^^^^^^^^^^ | |
+ | |_^ cannot infer type for `&'a T` | |
18 | |
19 error: aborting due to previous error | |
20 | |
- For more information about this error, try `rustc --explain E0283`. | |
+ For more information about this error, try `rustc --explain E0282`. | |
22 | |
The actual stderr differed from the expected stderr. | |
Actual stderr saved to /home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check/issue-40294.stderr | |
To update references, run this command from build directory: | |
/home/nmatsakis/versioned/rust-9/src/test/ui/update-references.sh '/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui' 'type-check/issue-40294.rs' | |
error: 1 errors occurred comparing output. | |
status: exit code: 101 | |
command: "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/home/nmatsakis/versioned/rust-9/src/test/ui/type-check/issue-40294.rs" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check/issue-40294.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/nmatsakis/versioned/rust-9/build/x86_64-unknown-linux-gnu/test/ui/type-check/issue-40294.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused" | |
stdout: | |
------------------------------------------ | |
------------------------------------------ | |
stderr: | |
------------------------------------------ | |
{"message":"type annotations needed","code":{"code":"E0282","explanation":"\nThis error indicates that type inference did not result in one unique possible\ntype, and extra information is required. In most cases this can be provided\nby adding a type annotation. Sometimes you need to specify a generic type\nparameter manually.\n\nA common example is the `collect` method on `Iterator`. It has a generic type\nparameter with a `FromIterator` bound, which for a `char` iterator is\nimplemented by `Vec` and `String` among others. Consider the following snippet\nthat reverses the characters of a string:\n\n```compile_fail,E0282\nlet x = \"hello\".chars().rev().collect();\n```\n\nIn this case, the compiler cannot infer what the type of `x` should be:\n`Vec<char>` and `String` are both suitable candidates. To specify which type to\nuse, you can use a type annotation on `x`:\n\n```\nlet x: Vec<char> = \"hello\".chars().rev().collect();\n```\n\nIt is not necessary to annotate the full type. Once the ambiguity is resolved,\nthe compiler can infer the rest:\n\n```\nlet x: Vec<_> = \"hello\".chars().rev().collect();\n```\n\nAnother way to provide the compiler with enough information, is to specify the\ngeneric type parameter:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<char>>();\n```\n\nAgain, you need not specify the full type if the compiler can infer it:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<_>>();\n```\n\nApart from a method or function with a generic type parameter, this error can\noccur when a type parameter of a struct or trait cannot be inferred. In that\ncase it is not always possible to use a type annotation, because all candidates\nhave the same return type. For instance:\n\n```compile_fail,E0282\nstruct Foo<T> {\n num: T,\n}\n\nimpl<T> Foo<T> {\n fn bar() -> i32 {\n 0\n }\n\n fn baz() {\n let number = Foo::bar();\n }\n}\n```\n\nThis will fail because the compiler does not know which instance of `Foo` to\ncall `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.\n"},"level":"error","spans":[{"file_name":"/home/nmatsakis/versioned/rust-9/src/test/ui/type-check/issue-40294.rs","byte_start":507,"byte_end":653,"line_start":15,"line_end":21,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations required","highlight_start":1,"highlight_end":72},{"text":" where &'a T : Foo,","highlight_start":1,"highlight_end":23},{"text":" &'b T : Foo","highlight_start":1,"highlight_end":22},{"text":"{","highlight_start":1,"highlight_end":2},{"text":" x.foo();","highlight_start":1,"highlight_end":13},{"text":" y.foo();","highlight_start":1,"highlight_end":13},{"text":"}","highlight_start":1,"highlight_end":2}],"label":"cannot infer type for `&'a T`","suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0282]: type annotations needed\n --> /home/nmatsakis/versioned/rust-9/src/test/ui/type-check/issue-40294.rs:15:1\n |\nLL | / fn foo<'a,'b,T>(x: &'a T, y: &'b T) //~ ERROR type annotations required\nLL | | where &'a T : Foo,\nLL | | &'b T : Foo\nLL | | {\nLL | | x.foo();\nLL | | y.foo();\nLL | | }\n | |_^ cannot infer type for `&'a T`\n\n"} | |
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"} | |
{"message":"For more information about this error, try `rustc --explain E0282`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0282`.\n"} | |
------------------------------------------ | |
thread '[ui] ui/type-check/issue-40294.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2963:9 | |
failures: | |
[ui] ui/error-codes/E0275.rs | |
[ui] ui/issue-24424.rs | |
[ui] ui/type-check-defaults.rs | |
[ui] ui/type-check/issue-40294.rs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment