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

Associate an allocator to boxes #50882

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
@glandium
Copy link
Contributor

glandium commented May 19, 2018

This turns Box<T> into Box<T, A: Alloc = Global>. This is a
minimalist change to achieve this, not touching anything that could have
backwards incompatible consequences like requiring type annotations in
places where they currently aren't required,
per #50822 (comment)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented May 19, 2018

r? @bluss

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

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented May 19, 2018

Note this has trivial conflicts with PR #50880, so whichever goes in first will need the other to be rebased on top of it.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 19, 2018

The job x86_64-gnu-llvm-3.9 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.
Check compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:44:26] 
[00:44:26] running 1436 tests
[00:44:31] .......................................................................................i............
[00:44:36] ......................................i.......................................................F.....
[00:44:44] ....................................................................................................
[00:44:47] ....................................................................................................
[00:44:50] ....................................................................................................
[00:44:50] ....................................................................................................
[00:44:55] .....................................................................F.............................F
[00:45:04] ....................................................................................................
[00:45:04] ....................................................................................................
[00:45:09] ............................................................iF......................................
[00:45:14] .........................F.....F.....i..............................................................
[00:45:24] ....................................................................................................
[00:45:30] ..........................................................i.........................................
[00:45:30] ..........................................................i.........................................
[00:45:32] .............F......................
[00:45:32] 
[00:45:32] ---- [ui] ui/e0119/conflict-with-std.rs stdout ----
[00:45:32] diff of stderr:
[00:45:32] 
[00:45:32] 
[00:45:32] 5    | ^^^^^^^^^^^^^^^^^^^^^^^^
[00:45:32] 6    |
[00:45:32] 7    = note: conflicting implementation in crate `alloc`:
[00:45:32] -            - impl<T> std::convert::AsRef<T> for std::boxed::Box<T>
[00:45:32] -              where T: ?Sized;
[00:45:32] +            - impl<T, A> std::convert::AsRef<T> for std::boxed::Box<T, A>
[00:45:32] +              where A: std::heap::Alloc, T: ?Sized;
[00:45:32] 10 
[00:45:32] 11 error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
[00:45:32] 
[00:45:32] 
[00:45:32] The actual stderr differed from the expected stderr.
[00:45:32] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/e0119/conflict-with-std/conflict-with-std.stderr
[00:45:32] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/e0119/conflict-with-std/conflict-with-std.stderr
[00:45:32] To update references, rerun the tests and pass the `--bless` flag
[00:45:32] To only update this specific test, also pass `--test-args e0119/conflict-with-std.rs`
[00:45:32] error: 1 errors occurred comparing output.
[00:45:32] error: 1 errors occurred comparing output.
[00:45:32] stat MyTrait {\n    fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n    fn get(&self) -> usize { 0 }\n}\n```\n\nThis makes the trait implemented on all types in the scope. So if you\ntry to implement it on another one after that, the implementations will\nconflict. Example:\n\n```\ntrait MyTrait {\n    fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n    fn get(&self) -> usize { 0 }\n}\n\nstruct Foo;\n\nfn main() {\n    let f = Foo;\n\n    f.get(); // the trait is implemented so we can use it\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/e0119/conflict-with-std.rs","byte_start":567,"byte_end":591,"line_start":17,"line_end":17,"column_start":1,"column_end":25,"is_primary":true,"text":[{"text":"impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations","highlight_start":1,"highlight_end":25}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"conflicting implementation in crate `alloc`:\n- impl<T, A> std::convert::AsRef<T> for std::boxed::Box<T, A>\n  where A: std::heap::Alloc, T: ?Sized;","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:\n  --> /checkout/src/test/ui/e0119/conflict-with-std.rs:17:1\n   |\nLL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations\n   | ^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: conflicting implementation in crate `alloc`:\n           - impl<T, A> std::convert::AsRef<T> for std::boxed::Box<T, A>\n             where A: std::heap::Alloc, T: ?Sized;\n\n"}
[00:45:32] {"messa"highlight_end":19}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"conflicting implementation in crate `core`:\n- impl<T> std::convert::From<T> for T;","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:\n  --> /checkout/src/test/ui/e0119/conflict-with-std.rs:24:1\n   |\nLL | impl From<S> for S { //~ ERROR conflicting implementations\n   | ^^^^^^^^^^^^^^^^^^\n   |\n   = note: conflicting implementation in crate `core`:\n           - impl<T> std::convert::From<T> for T;\n\n"}
[00:45:32] {"message":"conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:","code":{"code":"E0119","explanation":"\nThere are conflicting trait implementations for the same type.\nExample of erroneous code:\n\n```compile_fail,E0119\ntrait MyTrait {\n    fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n    fn get(&self) -> usize { 0 }\n}\n\nstruct Foo {\n    value: usize\n}\n\nimpl MyTrait for Foo { // error: conflicting implementations of trait\n                       //        `MyTrait` for type `Foo`\n    fn get(&self) -> usize { self.value }\n}\n```\n\nWhen looking for the implementation for the trait, the compiler finds\nboth the `impl<T> MyTrait for T` where T is all types and the `impl\nMyTrait for Foo`. Since a trait cannot be implemented multiple times,\nthis is an error. So, when you write:\n\n```\ntrait MyTrait {\n    fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n    fn get(&self) -> usize { 0 }\n}\n```\n\nThis makes the trait implemented on all types in the scope. So if you\ntry to implement it on another one after that, the implementations will\nconflict. Example:\n\n```\ntrait MyTrait {\n    fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n    fn get(&self) -> usize { 0 }\n}\n\nstruct Foo;\n\nfn main() {\n    let f = Foo;\n\n    f.get(); // the trait is implemented so we can use it\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/e0119/conflict-with-std.rs","byte_start":809,"byte_end":830,"line_start":31,"line_end":31,"column_start":1,"column_end":22,"is_primary":true,"text":[{"text":"impl TryFrom<X> for X { //~ ERROR conflicting implementations","highlight_start":1,"highlight_end":22}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"conflicting implementation in crate `core`:\n- impl<T, U> std::convert::TryFrom<U> for T\n  where T: std::convert::From<U>;","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:\n  --> /checkout/src/test/ui/e0119/conflict-with-std.rs:31:1\n   |\nLL | impl TryFrom<X> for X { //~ ERROR conflicting implementations\n   | ^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: conflicting implementation in crate `core`:\n           - impl<T, U> std::convert::TryFrom<U> for T\n             where T: std::convert::From<U>;\n\n"}
[00:45:32] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[00:45:32] {"message":"For more information about this error, try `rustc --explad":964,"line_start":31,"line_end":31,"column_start":1,"column_end":53,"is_primary":true,"text":[{"text":"fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {","highlight_start":1,"highlight_end":53}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so that the expression is assignable:\nexpected std::boxed::Box<std::fmt::Debug, _>\n   found std::boxed::Box<std::fmt::Debug + 'a, _>","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"but, the lifetime must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"...so that the types are compatible:\nexpected StaticTrait\n   found StaticTrait","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements\n  --> /checkout/src/test/ui/in-band-lifetimes/impl/dyn-trait.rs:32:16\n   |\nLL |     static_val(x); //~ ERROR cannot infer\n   |                ^\n   |\nnote: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:1...\n  --> /checkout/src/test/ui/in-band-lifetimes/impl/dyn-trait.rs:31:1\n   |\nLL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   = note: ...so that the expression is assignable:\n           expected std::boxed::Box<std::fmt::Debug, _>\n              found std::boxed::Box<std::fmt::Debug + 'a, _>\n   = note: but, the lifetime must be valid for the static lifetime...\n   = note: ...so that the types are compatible:\n           expected StaticTrait\n              found StaticTrait\n\n"}
[00:45:32] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:45:32] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] thread '[ui] ui/in-band-lifetimes/impl/dyn-trait.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:32] 
[00:45:32] 
[00:45:32] ---- [ui] ui/issue-14092.rs stdout ----
[00:45:32] diff of stderr:
[00:45:32] 
[00:45:32] - error[E0243]: wrong number of type arguments: expected 1, found 0
[00:45:32] + error[E0243]: wrong number of type arguments: expected at least 1, found 0
[00:45:32] 2   --> $DIR/issue-14092.rs:11:11
[00:45:32] 3    |
[00:45:32] 4 LL | fn fn1(0: Box) {}
[00:45:32] -    |           ^^^ expected 1 type argument
[00:45:32] -    |           ^^^ expected 1 type argument
[00:45:32] +    |           ^^^ expected at least 1 type argument
[00:45:32] 7 error: aborting due to previous error
[00:45:32] 8 
[00:45:32] 
[00:45:32] 
[00:45:32] 
[00:45:32] The actual stderr differed from the expected stderr.
[00:45:32] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-14092/issue-14092.stderr
[00:45:32] To update references, rerun the tests and pass the `--bless` flag
[00:45:32] To only update this specific test, also pass `--test-args issue-14092.rs`
[00:45:32] error: 1 errors occurred comparing output.
[00:45:32] status: exit code: 101
[00:45:32] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:45:32] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:45:32] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-14092.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-14092/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-14092/auxiliary" "-A" "unused"
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] ------------------------------------------
[00:45:32] stderr:
[00:45:32] stderr:
[00:45:32] ------------------------------------------
[00:45:32] {"message":"wrong number of type arguments: expected at least 1, found 0","code":{"code":"E0243","explanation":"\nThis error indicates that not enough type parameters were found in a type or\ntrait.\n\nFor example, the `Foo` struct below is defined to be generic in `T`, but the\ntype parameter is missing in the definition of `Bar`:\n\n```compile_fail,E0243\nstruct Foo<T> { x: T }\n\nstruct Bar { x: Foo }\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issue-14092.rs","byte_start":477,"byte_end":480,"line_start":11,"line_end":11,"column_start":11,"column_end":14,"is_primary":true,"text":[{"text":"fn fn1(0: Box) {}","highlight_start":11,"highlight_end":14}],"label":"expected at least 1 t actual stderr differed from the expected stderr.
[00:45:32] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mismatched_types/trait-bounds-cant-coerce/trait-bounds-cant-coerce.stderr
[00:45:32] To update references, rerun the tests and pass the `--bless` flag
[00:45:32] To only update this specific test, also pass `--test-args mismatched_types/trait-bounds-cant-coerce.rs`
[00:45:32] error: 1 errors occurred comparing output.
[00:45:32] status: exit code: 101
[00:45:32] status: exit code: 101
[00:45:32] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mismatched_types/trait-bounds-cant-coerce/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mismatched_types/trait-bounds-cant-coerce/auxiliary" "-A" "unused"
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] ------------------------------------------
[00:45:32] stderr:
[00:45:32] stderr:
[00:45:32] ------------------------------------------
[00:45:32] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expre-explain E0308`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.\n"}
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] thread '[ui] ui/mismatched_types/trait-bounds-cant-coerce.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:32] 
[00:45:32] 
[00:45:32] ---- [ui] ui/nll/ty-outlives/projection-no-regions-closure.rs stdout ----
[00:45:32] diff of stderr:
[00:45:32] 
[00:45:32] 20                '_#1r,
[00:45:32] 21                T,
[00:45:32] 22                i32,
[00:45:32] -                extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
[00:45:32] +                extern "rust-call" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#2r, std::heap::Global>
[00:45:32] 24            ]
[00:45:32] 25    = note: number of external vids: 3
[00:45:32] 26    = note: where <T as std::iter::Iterator>::Item: '_#2r
[00:45:32] 60                '_#1r,
[00:45:32] 61                T,
[00:45:32] 62                i32,
[00:45:32] 62                i32,
[00:45:32] -                extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#2r>
[00:45:32] +                extern "rust-call" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#2r, std::heap::Global>
[00:45:32] 64            ]
[00:45:32] 65    = note: number of external vids: 3
[00:45:32] 66    = note: where <T as std::iter::Iterator>::Item: '_#2r
[00:45:32] 92                '_#2r,
[00:45:32] 93                T,
[00:45:32] 93                T,
[00:4/ty-outlives/projection-no-regions-closure.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/ty-outlives/projection-no-regions-closure/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=mir" "-Zverbose" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/ty-outlives/projection-no-regions-closure/auxiliary" "-A" "unused"
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] ------------------------------------------
[00:45:32] stderr:
[00:45:32] stderr:
[00:45:32] ------------------------------------------
[00:45:32] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1046,"byte_end":1064,"line_start":35,"line_end":35,"column_start":31,"column_end":49,"is_primary":true,"text":[{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":31,"highlight_end":49}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:35:31\n   |\nLL |     with_signature(x, |mut y| Box::new(y.next()))\n   |                               ^^^^^^^^^^^^^^^^^^\n\n"}
[00:45:32] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outliverendered":null}],"rendered":"note: External requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:35:23\n   |\nLL |     with_signature(x, |mut y| Box::new(y.next()))\n   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: defining type: DefId(0/1:15 ~ projection_no_regions_closure[317d]::no_region[0]::{{closure}}[0]) with closure substs [\n               '_#1r,\n               T,\n               i32,\n               extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#2r, std::heap::Global>\n           ]\n   = note: number of external vids: 3\n   = note: where <T as std::iter::Iterator>::Item: '_#2r\n\n"}
[00:45:32] {"message":"the associated type `<T as std::iter::Iterator>::Item` may not live long enough","code":{"code":"E0309","explanation":"\nTypes in type definitions have lifetimes associated with them that represent\nhow long the data stored within them is guaranteed to be live. This lifetime\nmust be as long as the data needs to be alive, and missing the constraint that\ndenotes this will cause this error.\n\n```compile_fail,E0309\n// This won't compile because T is not constrained, meaning the data\n// stored in it is not guaranteed to last as long as the reference\nstruct Foo<'a, T> {\n    foo: &'a T\n}\n```\n\nThis will compile, because it has the constraint on the type parameter:\n\n```\nstruct Foo<'a, T: 'a> {\n    foo: &'a T\n}\n```\n\nTo see why this is important, consider the case where `T` is itself a reference\n(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the\nfollowing code would be phighlight_end":57},{"text":"where","highlight_start":1,"highlight_end":6},{"text":"    T: Iterator,","highlight_start":1,"highlight_end":17},{"text":"{","highlight_start":1,"highlight_end":2},{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":1,"highlight_end":50},{"text":"    //~^ WARNING not reporting region error due to nll","highlight_start":1,"highlight_end":55},{"text":"    //~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough","highlight_start":1,"highlight_end":95},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/0:6 ~ projection_no_regions_closure[317d]::no_region[0]) with substs [\n    '_#1r,\n    T\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:31:1\n   |\nLL | / fn no_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>\nLL | | where\nLL | |     T: Iterator,\nLL | | {\n...  |\nLL | |     //~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough\nLL | | }\n   | |_^\n   |\n   = note: defining type: DefId(0/0:6 ~ projection_no_regions_closure[317d]::no_region[0]) with substs [\n               '_#1r,\n               T\n           ]\n\n"}
[00:45:32] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1350,"byte_end":1376,"line_start":45,"line_end":45,"column_start":23,"column_end":49,"is_primary":true,"text":[{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":23,"highlight_end":49}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/1:18 ~ projection_no_regions_closure[317d]::correct_region[0]::{{closure}}[0]) with closure substs [\n    '_#1r,\n    T,\n    i32,\n    extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#2r, std::heap::Global>\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"number of external vids: 3","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"where <T as std::iter::Iterator>::Item: '_#2r","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: External requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:45:23\n   |\nLL |     with_signature(x, |mut y| Box::new(y.next()))\n   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: defining type: DefId(0/1:18 ~ projection_no_regions_closure[317d]::correct_region[0]::{{closure}}[0]) with closure substs [\n               '_#1r,\n               T,\n               i32,\n               extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#2r, std::heap::Global>\n           ]\n   = note: number of external vids: 3\n   = note: where <T as std::iter::Iterator>::Item: '_#2r\n\n"}
[00:45:32] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1236,"byte_end":1379,"line_start":41,"line_end":46,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn correct_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>","highlight_start":1,"highlight_end":62},{"text":"where","highlight_start":1,"highlight_end":6},{"text":"    T: 'a + Iterator,","highlight_start":1,"highlight_end":22},{"text":"{","highlight_start":1,"highlight_end":2},{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":1,"highlight_end":50},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/0:7 ~ projection_no_regions_closure[317d]::correct_region[0]) with substs [\n    '_#1r,\n    T\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:41:1\n   |\nLL | / fn correct_region<'a, T>(x: Box<T>) -> Box<dyn Anything + 'a>\nLL | | where\nLL | |     T: 'a + Iterator,\nLL | | {\nLL | |     with_signature(x, |mut y| Box::new(y.next()))\nLL | | }\n   | |_^\n   |\n   = note: defining type: DefId(0/0:7 ~ projection_no_regions_closure[317d]::correct_region[0]) with substs [\n               '_#1r,\n               T\n           ]\n\n"}
[00:45:32] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1514,"byte_end":1540,"line_start":53,"line_end":53,"column_star_#2r,\n    T\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:49:1\n   |\nLL | / fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>\nLL | | where\nLL | |     T: 'b + Iterator,\nLL | | {\n...  |\nLL | |     //~| ERROR the associated type `<T as std::iter::Iterator>::Item` may not live long enough\nLL | | }\n   | |_^\n   |\n   = note: defining type: DefId(0/0:8 ~ projection_no_regions_closure[317d]::wrong_region[0]) with substs [\n               '_#1r,\n               '_#2r,\n               T\n           ]\n\n"}
[00:45:32] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1843,"byte_end":1869,"line_start":64,"line_end":64,"column_start":23,"column_end":49,"is_primary":true,"text":[{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":23,"highlight_end":49}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [\n    '_#1r,\n    '_#2r,\n    T,\n    i32,\n    extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"number of external vids: 4","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"where <T as std::iter::Iterator>::Item: '_#3r","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: External requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:64:23\n   |\nLL |     with_signature(x, |mut y| Box::new(y.next()))\n   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [\n               '_#1r,\n               '_#2r,\n               T,\n               i32,\n               extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>\n           ]\n   = note: number of external vids: 4\n   = note: where <T as std::iter::Iterator>::Item: '_#3r\n\n"}
[00:45:32] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1712,"byte_end":1872,"line_start":59,"line_end":65,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>","highlight_start":1,"highlight_end":67},{"text":"where","highlight_start":1,"highlight_end":6},{"text":"    T: 'b + Iterator,","highlight_start":1,"highlight_end":22},{"text":"    'b: 'a,","highlight_start":1,"highlight_end":12},{"text":"{","highlight_start":1,"highlight_end":2},{"text":"    with_signature(x, |mut y| Box::new(y.next()))","highlight_start":1,"highlight_end":50},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/0:9 ~ projection_no_regions_closure[317d]::outlives_region[0]) with substs [\n    '_#1r,\n    '_#2r,\n    T\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:59:1\n   |\nLL | / fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<dyn Anything + 'a>\nLL | | where\nLL | |     T: 'b + Iterator,\nLL | |     'b: 'a,\nLL | | {\nLL | |     with_signature(x, |mut y| Box::new(y.next()))\nLL | | }\n   | |_^\n   |\n   = note: defining type: DefId(0/0:9 ~ projection_no_regions_closure[317d]::outlives_region[0]) with substs [\n               '_#1r,\n               '_#2r,\n               T\n           ]\n\n"}
[00:45:32] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:45:32] {"message":"For more information about this error, try `rustc --explain E0309`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0309`.\n"}
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] thread '[ui] ui/nll/ty-outlives/projection-no-regions-closure.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:32] 
[00:45:32] 
[00:45:32] ---- [ui] ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs stdout ----
[00:45:32] diff of stderr:
[00:45:32] 
[00:45:32] 20                '_#1r,
[00:i/nll/ty-outlives/ty-param-closure-outlives-from-return-type/auxiliary" "-A" "unused"
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] ------------------------------------------
[00:45:32] stderr:
[00:45:32] stderr:
[00:45:32] ------------------------------------------
[00:45:32] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs","byte_start":1225,"byte_end":1226,"line_start":36,"line_end":36,"column_start":27,"column_end":28,"is_primary":true,"text":[{"text":"    with_signature(x, |y| y)","highlight_start":27,"highlight_end":28}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs:36:27\n   |\nLL |     with_signature(x, |y| y)\n   |                           ^\n\n"}
[00:45:32] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs","byte_start":1528,"byte_end":1529,"line_start":52,"line_end":52,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x","highlight_start":5,"highlight_end":6}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs:52:5\n   |\nLL |     x\n   ote: number of external vids: 3\n   = note: where T: '_#2r\n\n"}
[00:45:32] {"message":"the parameter type `T` may not live long enough","code":{"code":"E0309","explanation":"\nTypes in type definitions have lifetimes associated with them that represent\nhow long the data stored within them is guaranteed to be live. This lifetime\nmust be as long as the data needs to be alive, and missing the constraint that\ndenotes this will cause this error.\n\n```compile_fail,E0309\n// This won't compile because T is not constrained, meaning the data\n// stored in it is not guaranteed to last as long as the reference\nstruct Foo<'a, T> {\n    foo: &'a T\n}\n```\n\nThis will compile, because it has the constraint on the type parameter:\n\n```\nstruct Foo<'a, T: 'a> {\n    foo: &'a T\n}\n```\n\nTo see why this is important, consider the case where `T` is itself a reference\n(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the\nfollowing code would be perfectly legal:\n\n```compile_fail,E0309\nstruct Foo<'a, T> {\n    foo: &'a T\n}\n\nfn main() {\n    let v = \"42\".to_string();\n    let f = Foo{foo: &v};\n    drop(v);\n    println!(\"{}\", f.foo); // but we've already dropped v!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs","byte_start":1221,"byte_end":1226,"line_start":36,"line_end":36,"column_start":23,"column_end":28,"is_primary":true,"text":[{"text":"    with_signature(x, |y| y)","highlight_start":23,"highlight_end":28}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0309]: the parameter type `T` may not live long enough\n  --> /checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs:36:23\n   |\nLL |     with_signature(x, |y| y)\n   |                       ^^^^^\n   |\n   = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...\n\n"}
[00:45:32] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs","byte_start":730,"byte_end":1347,"line_start":25,"line_end":39,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a>","highlight_start":1,"highlight_end":54},{"text":"where","highlight_start":1,"highlight_end":6},{"text":"    T: Debug,","highlight_start":1,"highlight_end":14},{"text":"{","highlight_start":1,"highlight_end":2},{"text":"    // Here, the closure winds up being required to prove that `T:","highlight_start":1,"highlight_end":67},{"text":"    // 'a`.  In principle, it could know that, except that it is","highlight_start":1,"highlight_end":65},{"text":"    // type-checked in a fully generic way, and hence it winds up with","highlight_start":1,"highlight_end":71},{"text":"    // a propagated requirement that `T: '_#2`, where `'_#2` appears","highlight_start":1,"highlight_end":69},{"text":"    // in the return type. The caller makes the mapping from `'_#2` to","highlight_start":1,"highlight_end":71},{"text":"    // `'a` (and subsequently reports an error).","highlight_start":1,"highlight_end":49},{"text":"","highlight_start":1,"highlight_end":1},{"text":"    with_signature(x, |y| y)","highlight_start":1,"highlight_end":29},{"text":"    //~^ WARNING not reporting region error due to nll","highlight_start":1,"highlight_end":55},{"text":"    //~| ERROR the parameter type `T` may not live long enough","highlight_start":1,"highlight_end":63},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"defining type: DefId(0/0:5 ~ ty_param_closure_outlives_from_return_type[317d]::no_region[0]) with substs [\n    '_#1r,\n    T\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: No external requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs:25:1\n   |\nLL | / fn no_region<'a, T>(x: Box<T>) -> Box<dyn Debug + 'a>\nLL | | where\nLL | |     T: Debug,\nLL | | {\n...  |\nLL | |     //~| ERROR the parameter type `T` may not live long enough\nLL | | }\n   | |_^\n   |\n   = note: defining type: DefId(0/0:5 ~ ty_param_closure_outlives_from_return_type[317d]::no_region[0]) with substs [\n               '_#1r,\n               T\n           ]\n\n"}
[00:45:32] {"message":"the parameter type `T` may not live long enough","code":{"code":"E0309","explanation":"\nTypes in type definitions have lifetimes associated with them that represent\nhow long the data stored within them is guaranteed to be live. This lifetime\nmust be as long as the data needs to be alive, and missing the constraint that\ndenotes this will cause this error.\n\n```compile_fail,E0309\n// This won't compile because T is not constrained, meaning the data\n// stored in it is not guaranteed to last as long as the reference\nstruct Foo<'a, T> {\n    foo: &'a T\n}\n```\n\nThis will compile, because it has the constraint on the type parameter:\n\n```\nstruct Foo<'a, T: 'a> {\n    foo: &'a T\n}\n```\n\nTo see why this is important, consider the case where `T` is itself a reference\n(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the\nfollowing code would be perfectly legal:\n\n```compile_fail,E0309\nstruct Foo<'a, T> {\n    foo: &'a T\n}\n\nfn main() {\n    let v = \"42\".to_string();\n    let f = Foo{foo: &v};\n    drop(v);\n    println!(\"{}\", f.foo); // but we've already dropped v!\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs","byte_start":1528,"byte_end":1529,"line_start":52,"line_end":52,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x","highlight_start":5,"highlight_end":6}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0309]: the parameter type `T` may not live long enough\n  --> /checkout/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-return-type.rs:52:5\n   |\nLL |     x\n   |     ^\n   |\n   = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`...\n\n"}
[00:45:32] {"message":"aborage":"first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 16:1...","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs","byte_start":599,"byte_end":812,"line_start":16,"line_end":19,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {","highlight_start":1,"highlight_end":53},{"text":"    //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`","highlight_start":1,"highlight_end":85},{"text":"    Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime","highlight_start":1,"highlight_end":74},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"...so that reference does not outlive borrowed content","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs","byte_start":750,"byte_end":755,"line_start":18,"line_end":18,"column_start":14,"column_end":19,"is_primary":true,"text":[{"text":"    Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime","highlight_start":14,"highlight_end":19}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"but, the lifetime must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"...so that the expression is assignable:\nexpected std::boxed::Box<std::iter::Iterator<Item=&T> + 'static, _>\n   found std::boxed::Box<std::iter::Iterator<Item=&T>, _>","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements\n  --> /checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs:18:20\n   |\nLL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime\n   |                    ^^^^\n   |\nnote: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 16:1...\n  --> /checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs:16:1\n   |\nLL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {\nLL | |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`\nLL | |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime\nLL | | }\n   | |_^\nnote: ...so that reference does not outlive borrowed content\n  --> /checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs:18:14\n   |\nLL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime\n   |              ^^^^^\n   = note: but, the lifetime must be valid for the static lifetime...\n   = note: ...so that the expression is assignable:\n           expected std::boxed::Box<std::iter::Iterator<Item=&T> + 'static, _>\n              found std::boxed::Box<std::iter::Iterator<Item=&T>, _>\n\n"}
[00:45:32] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:45:32] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[00:45:32] ------------------------------------------
[00:45:32] 
[00:45:32] thread '[ui] ui/underscore-lifetime/dyn-trait-underscore.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:32] 
---
[00:45:32] test result: FAILED. 1422 passed; 7 failed; 7 ignored; 0 measured; 0 filtered out
[00:45:32] 
[00:45:32] 
[00:45:32] 
[00:45:32] 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/x86_64-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-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu"[00:45:32] make: *** [check] Error 1
[00:45:32] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:19b1ce88
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@glandium glandium force-pushed the glandium:box branch from 096f701 to e726409 May 19, 2018

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 19, 2018

The job x86_64-gnu-llvm-3.9 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:44:30] ....................................................................................................
[00:44:33] ....................................................................................................
[00:44:36] ....................................................................................................
[00:44:40] ....................................................................................................
[00:44:44] .....................................................................F.............................F
[00:44:53] ....................................................................................................
[00:44:53] ....................................................................................................
[00:44:58] ............................................................iF......................................
[00:45:03] .........................F.....F.....i..............................................................
[00:45:12] ....................................................................................................
[00:45:19] ..........................................................i.........................................
this error, try `rustc --explain E0308`.\n"}
[00:45:20] 
[00:45:20] 
[00:45:20] ------------------------------------------
[00:45:20] 
[00:45:20] thread '[ui] ui/mismatched_types/trait-bounds-cant-coerce.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:20] 
[00:45:20] ---- [ui] ui/nll/ty-outlives/projection-no-regions-closure.rs stdout ----
[00:45:20] diff of stderr:
[00:45:20] 
[00:45:20] 92                '_#2r,
[00:45:20] 93                T,
[00:45:20] 94                i32,
[00:45:20] -                extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
[00:45:20] +                extern "rust-call" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>
[00:45:20] 96            ]
[00:45:20] 97    = note: number of external vids: 4
[00:45:20] 98    = note: where <T as std::iter::Iterator>::Item: '_#3r
[00:45:20] 134                '_#2r,
[00:45:20] 135                T,
[00:45:20] 136                i32,
[00:45:20] 136                i32,
[00:45:20] -                extern "rust-call" fn((std::boxed::Box<T>,)) -> std::boxed::Box<Anything + '_#3r>
[00:45:20] +                extern "rust-call" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>
[00:45:20] 138            ]
[00:45:20] 139    = note: number of external vids: 4
[00:45:20] 140    = note: where <T as std::iter::Iterator>::Item: '_#3r
[00:45:20] 
[00:45:20] The actual stderr differed from the expected stderr.
[00:45:20] The actual stderr differed from the expected stderr.
[00:45:20] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/ty-oue: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [\n    '_#1r,\n    '_#2r,\n    T,\n    i32,\n    extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>\n]","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"number of external vids: 4","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"where <T as std::iter::Iterator>::Item: '_#3r","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"note: External requirements\n  --> /checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs:64:23\n   |\nLL |     with_signature(x, |mut y| Box::new(y.next()))\n   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: defining type: DefId(0/1:26 ~ projection_no_regions_closure[317d]::outlives_region[0]::{{closure}}[0]) with closure substs [\n               '_#1r,\n               '_#2r,\n               T,\n               i32,\n               extern \"rust-call\" fn((std::boxed::Box<T, std::heap::Global>,)) -> std::boxed::Box<Anything + '_#3r, std::heap::Global>\n           ]\n   = note: number of external vids: 4\n   = note: where <T as std::iter::Iterator>::Item: '_#3r\n\n"}
[00:45:20] {"message":"No external requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/ty-outlives/projection-no-regions-closure.rs","byte_start":1712,"byte_end":1872,"line_start":59,"line_end":65,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"fn outlives_region<'a, 'b, T>(x:Iterator<Item=&T> + 'static, _>
[00:45:20] +               found std::boxed::Box<std::iter::Iterator<Item=&T>, _>
[00:45:20] 25 error: aborting due to previous error
[00:45:20] 26 
[00:45:20] 
[00:45:20] 
[00:45:20] 
[00:45:20] The actual stderr differed from the expected stderr.
[00:45:20] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/underscore-lifetime/dyn-trait-underscore/dyn-trait-underscore.stderr
[00:45:20] To update references, rerun the tests and pass the `--bless` flag
[00:45:20] To only update this specific test, also pass `--test-args underscore-lifetime/dyn-trait-underscore.rs`
[00:45:20] error: 1 errors occurred comparing output.
[00:45:20] status: exit code: 101
[00:45:20] status: exit code: 101
[00:45:20] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/underscore-lifetime/dyn-trait-underscore.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/underscore-lifetime/dyn-trait-underscore/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/underscore-lifetime/dyn-trait-underscore/auxiliary" "-A" "unused"
[00:45:20] ------------------------------------------
[00:45:20] 
[00:45:20] ------------------------------------------
[00:45:20] stderr:
[00:45:20] stderr:
[00:45:20] ------------------------------------------
[00:45:20] {"message":"cannot infer an appropriate lifetime for autoref due to conflicting requ for the static lifetime...\n   = note: ...so that the expression is assignable:\n           expected std::boxed::Box<std::iter::Iterator<Item=&T> + 'static, _>\n              found std::boxed::Box<std::iter::Iterator<Item=&T>, _>\n\n"}
[00:45:20] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:45:20] {"message":"For more information about this error, try `rustc --explain E0495`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0495`.\n"}
[00:45:20] ------------------------------------------
[00:45:20] 
[00:45:20] thread '[ui] ui/underscore-lifetime/dyn-trait-underscore.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3042:9
[00:45:20] 

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)

@glandium glandium force-pushed the glandium:box branch from e726409 to ddfbc0a May 19, 2018

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented May 19, 2018

The various UI test changes raise the interesting question whether the compiler should "hide" default generic params in error messages.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 19, 2018

The job x86_64-gnu-llvm-3.9 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:56:09] ....................................................................................................
[00:56:15] .i..................................................................................................
[00:56:21] i..ii...............................................................................................
[00:56:28] ....................................................................................................
[00:56:33] ............................................................................................F.......
[00:56:42] ......................i.............................................................................
[00:56:42] ......................i.............................................................................
[00:56:47] .................F..........................................................................F.......
[00:56:55] ....................................................................................................
[00:56:55] ..................
[00:56:55] failures:
[00:56:55] 
[00:56:55] 
[00:56:55] ---- [compile-fail] compile-fail/regions-infer-paramd-indirect.rs stdout ----
[00:56:55] 
[00:56:55] error: /checkout/src/test/compile-fail/regions-infer-paramd-indirect.rs:33: expected message not found: expected type `std::boxed::Box<std::boxed::Box<&'a isize>>`
[00:56:55] 
[00:56:55] error: /checkout/src/test/compile-fail/regions-infer-paramd-indirect.rs:33: expected message not found: found type `std::boxed::Box<std::boxed::Box<&isize>>`
[00:56:55] 
[00:56:55] error: 0 unexpected errors found, 2 expected errors not found
[00:56:55] status: exit code: 101
[00:56:55] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail/regions-infer-paramd-indirect.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/regions-infer-paramd-indirect/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/regions-infer-paramd-indirect/auxiliary" "-A" "unused"
[00:56:55] not found errors (from test file): [
[00:56:55]     Error {
[00:56:55]         line_num: 33,
[00:56:55]         kind: None,
[00:56:55]         msg: "expected type `std::boxed::Box<std::boxed::Box<&\'a isize>>`"
[00:56:55]     Error {
[00:56:55]         line_num: 33,
[00:56:55]         kind: None,
[00:56:55]         kind: None,
[00:56:55]         msg: "found type `std::boxed::Box<std::boxed::Box<&isize>>`"
[00:56:55] ]
[00:56:55] 
[00:56:55] thread '[compile-fail] compile-fail/regions-infer-paramd-indirect.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1283:13
[00:56:55] 
[00:56:55] 
[00:56:55] ---- [compile-fail] compile-fail/terr-sorts.rs stdout ----
[00:56:55] 
[00:56:55] error: /checkout/src/test/compile-fail/terr-sorts.rs:21: expected message not found: found type `std::boxed::Box<foo>`
[00:56:55] 
[00:56:55] error: 0 unexpected errors found, 1 expected errors not found
[00:56:55] status: exit code: 101
[00:56:55] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail/terr-sorts.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/terr-sorts/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/terr-sorts/auxiliary" "-A" "unused"
[00:56:55] not found errors (from test file): [
[00:56:55]     Error {
[00:56:55]         line_num: 21,
[00:56:55]         kind: None,
[00:56:55]         msg: "found type `std::boxed::Box<foo>`"
[00:56:55] ]
[00:56:55] 
[00:56:55] thread '[compile-fail] compile-fail/terr-sorts.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1283:13
[00:56:55] 
[00:56:55] 
[00:56:55] ---- [compile-fail] compile-fail/type-mismatch-same-crate-name.rs stdout ----
[00:56:55] 
[00:56:55] error: /checkout/src/test/compile-fail/type-mismatch-same-crate-name.rs:32: expected message not found: expected type `std::boxed::Box<main::a::Bar + 'static>`
[00:56:55] 
[00:56:55] error: /checkout/src/test/compile-fail/type-mismatch-same-crate-name.rs:32: expected message not found: found type `std::boxed::Box<main::a::Bar>`
[00:56:55] 
[00:56:55] error: 0 unexpected errors found, 2 expected errors not found
[00:56:55] status: exit code: 101
[00:56:55] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail/type-mismatch-same-crate-name.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/type-mismatch-same-crate-name/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail/type-mismatch-same-crate-name/auxiliary" "-A" "unused"
[00:56:55] not found errors (from test file): [
[00:56:55]     Error {
[00:56:55]         line_num: 32,
[00:56:55]         kind: None,
[00:56:55]         msg: "expected type `std::boxed::Box<main::a::Bar + \'static>`"
[00:56:55]     Error {
[00:56:55]         line_num: 32,
[00:56:55]         kind: None,
[00:56:55]         kind: None,
[00:56:55]         msg: "found type `std::boxed::Box<main::a::Bar>`"
[00:56:55] ]
[00:56:55] 
[00:56:55] thread '[compile-fail] compile-fail/type-mismatch-same-crate-name.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1283:13
[00:56:55] 
---
[00:56:55] 
[00:56:55] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:56:55] 
[00:56:55] 
[00:56:55] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/compile-fail" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "compile-fail" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:56:55] 
[00:56:55] 
[00:56:55] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:55] Build completed unsuccessfully in 0:13:24
[00:56:55] Build completed unsuccessfully in 0:13:24
[00:56:55] Makefile:58: recipe for target 'check' failed
[00:56:55] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0ff5ad58
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@glandium glandium force-pushed the glandium:box branch from ddfbc0a to 3359246 May 19, 2018

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 19, 2018

The job x86_64-gnu-llvm-3.9 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:55:25] ............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:55:31] ........................
[00:55:45] ....................................................................................................
[00:56:29] ......ii..............................................................i.............................
[00:56:51] .......................i.ii....................................................test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:57:28] ...............................iiiiiii..............................................................
[00:57:47] ....................................................................................................
[00:58:01] ....................................................................................................
[00:58:19] ....................................................................................................
---
travis_time:start:test_mir-opt
Check compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:00:49] 
[01:00:49] running 50 tests
[01:01:06] ERROR 2018-05-19T11:13:39Z: compiletest::runtest: None
[01:01:11] ...........................................F......
[01:01:11] 
[01:01:11] ---- [mir-opt] mir-opt/validate_2.rs stdout ----
[01:01:11] ---- [mir-opt] mir-opt/validate_2.rs stdout ----
[01:01:11] thread '[mir-opt] mir-opt/validate_2.rs' panicked at 'Did not find expected line, error: Mismatch in lines
[01:01:11] Current block: None
[01:01:11] Actual Line: "        Validate(Acquire, [_2: std::boxed::Box<[i32; 3], std::heap::Global>]);"
[01:01:11] Expected Line: "        Validate(Acquire, [_2: std::boxed::Box<[i32; 3]>]);"
[01:01:11] Test Name: rustc.main.EraseRegions.after.mir
[01:01:11] Expected:
[01:01:11] ... (elided)
[01:01:11] fn main() -> () {
[01:01:11] ... (elided)
[01:01:11]     bb1: {
[01:01:11]         Validate(Acquire, [_2: std::boxed::Box<[i32; 3]>]);
[01:01:11]         Validate(Release, [_2: std::boxed::Box<[i32; 3]>]);
[01:01:11]         _1 = move _2 as std::boxed::Box<[i32]> (Unsize);
[01:01:11]         Validate(Acquire, [_1: std::boxed::Box<[i32]>]);
[01:01:11]         StorageDead(_2);
[01:01:11]         StorageDead(_3);
[01:01:11]         _0 = ();
[01:01:11]         Validate(Release, [_1: std::boxed::Box<[i32]>]);
[01:01:11]         drop(_1) -> [return: bb2, unwind: bb3];
[01:01:11]     }
[01:01:11] ... (elided)
[01:01:11] }
[01:01:11] Actual:
[01:01:11] fn main() -> (){
[01:01:11]     let mut _0: ();
[01:01:11]     scope 1 {
[01:01:11]         let _1: std::boxed::Box<[i32], std::heap::Global>;
[01:01:11]     scope 2 {
[01:01:11]     }
[01:01:11]     }
[01:01:11]     let mut _2: std::boxed::Box<[i32; 3], std::heap::Global>;
[01:01:11]     let mut _3: [i32; 3];
[01:01:11]     bb0: {                              
[01:01:11]         StorageLive(_1);
[01:01:11]         StorageLive(_2);
[01:01:11]         StorageLive(_3);
[01:01:11]         _3 = [const 1i32, const 2i32, const 3i32];
[01:01:11]         Validate(Release, [_2: std::boxed::Box<[i32; 3], std::heap::Global>, _3: [i32; 3]]);
[01:01:11]         _2 = const <std::boxed::Box<T, std::heap::Global>>::new(move _3) -> bb1;
[01:01:11]     }
[01:01:11]     bb1: {                              
[01:01:11]         Validate(Acquire, [_2: std::boxed::Box<[i32; 3], std::heap::Global>]);
[01:01:11]         Validate(Release, [_2: std::boxed::Box<[i32; 3], std::heap::Global>]);
[01:01:11]         _1 = move _2 as std::boxed::Box<[i32], std::heap::Global> (Unsize);
[01:01:11]         Validate(Acquire, [_1: std::boxed::Box<[i32], std::heap::Global>]);
[01:01:11]         StorageDead(_2);
[01:01:11]         StorageDead(_3);
[01:01:11]         _0 = ();
[01:01:11]         Validate(Release, [_1: std::boxed::Box<[i32], std::heap::Global>]);
[01:01:11]         drop(_1) -> [return: bb2, unwind: bb3];
[01:01:11]     }
[01:01:11]     bb2: {                              
[01:01:11]         StorageDead(_1);
[01:01:11]         return;
[01:01:11]     bb3: {
[01:01:11]         resume;
[01:01:11]     }
[01:01:11] }', tools/compiletest/src/runtest.rs:2776:13
---
[01:01:11] 
[01:01:11] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[01:01:11] 
[01:01:11] 
[01:01:11] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/mir-opt" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:01:11] 
[01:01:11] 
[01:01:11] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:01:11] Build completed unsuccessfully in 0:15:04
[01:01:11] Build completed unsuccessfully in 0:15:04
[01:01:11] Makefile:58: recipe for target 'check' failed
[01:01:11] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:3146d628
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@glandium glandium force-pushed the glandium:box branch from 3359246 to 62020b2 May 19, 2018

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 19, 2018

The job x86_64-gnu-llvm-3.9 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.
Testing alloc stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:05:08]    Compiling libc v0.2.40
[01:05:09]    Compiling rand v0.4.2
[01:05:11]    Compiling alloc v0.0.0 (file:///checkout/src/liballoc)
[01:05:14] error[E0624]: method `into_raw_and_alloc` is private
[01:05:14]     |
[01:05:14]     |
[01:05:14] 195 |             let (ptr, a) = Box::into_raw_and_alloc(slice);
[01:05:14] 
[01:05:14] error[E0308]: mismatched types
[01:05:14]    --> liballoc/vec.rs:645:13
[01:05:14]     |
[01:05:14]     |
[01:05:14] 640 |     pub fn into_boxed_slice(mut self) -> Box<[T]> {
[01:05:14]     |                                          -------- expected `std::boxed::Box<[T]>` because of return type
[01:05:14] ...
[01:05:14] 645 |             buf.into_box()
[01:05:14]     |             ^^^^^^^^^^^^^^ expected struct `std::heap::Global`, found struct `alloc::Global`
[01:05:14]     |
[01:05:14]     = note: expected type `std::boxed::Box<_, std::heap::Global>`
[01:05:14]                found type `std::boxed::Box<_, alloc::Global>`
[01:05:16] error: aborting due to 2 previous errors
[01:05:16] 
[01:05:16] Some errors occurred: E0308, E0624.
[01:05:16] For more information about an error, try `rustc --explain E0308`.
---
103868 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu
103864 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release
103604 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
103220 ./obj/build/bootstrap/debug/incremental/bootstrap-c730863262pt
103216 ./obj/build/bootstrap/debug/incremental/bootstrap-c730863262pt/s-f16j5w4jts-1guxjqd-1fl9pp8y1eh0p
91808 ./obj/build/x86_64-unknown-linux-gnu/stage1
91784 ./obj/build/x86_64-unknown-linux-gnu/stage1/lib
89792 ./src/llvm/test/CodeGen
89200 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps

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)

@glandium glandium force-pushed the glandium:box branch from 62020b2 to 59d5866 May 20, 2018

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented May 20, 2018

The job x86_64-gnu-llvm-3.9 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.
[01:14:14] error: no #[default_lib_allocator] found but one is required; is libstd not linked?
[01:14:14] 
[01:14:14] 
[01:14:14] running 397 tests
[01:14:35] .............................................................F....F.................................
[01:15:17] ....................................................................................................
te attributes to enable
[01:15:39] 
[01:15:39] 
[01:15:39] error[E0658]: use of unstable library feature 'allocator_api' (see issue #32838)
[01:15:39]  --> boxed.rs:175:18
[01:15:39]   |
[01:15:39] 6 | let x = unsafe { Box::from_raw_in(ptr, Global) };
[01:15:39]   |
[01:15:39]   |
[01:15:39]   = help: add #![feature(allocator_api)] to the crate attributes to enable
[01:15:39] 
[01:15:39] thread 'boxed.rs - boxed::Box<T, A>::from_raw_in (line 172)' panicked at 'couldn't compile the test', librustdoc/test.rs:325:17
[01:15:39] 
[01:15:39] 
[01:15:39] ---- boxed.rs - boxed::Box<T, A>::new_in (line 106) stdout ----
[01:15:39] error[E0425]: cannot find value `Global` in this scope
[01:15:39]  --> boxed.rs:107:27
[01:15:39]   |
[01:15:39] 4 | let five = Box::new_in(5, Global);
[01:15:39]   |                           ^^^^^^ not found in this scope
[01:15:39] help: possible candidates are found in other modules, you can import them into scope
[01:15:39] 3 | use std::alloc::Global;
[01:15:39]   |
[01:15:39] 3 | use std::heap::Global;
[01:15:39]   |
[01:15:39]   |
[01:15:39] 3 | use std::net::Ipv6MulticastScope::Global;
[01:15:39] 
[01:15:39] 
[01:15:39] error[E0658]: use of unstable library feature 'allocator_api' (see issue #32838)
[01:15:39]  --> boxed.rs:107:12
[01:15:39]   |
[01:15:39] 4 | let five = Box::new_in(5, Global);
[01:15:39]   |
[01:15:39]   |
[01:15:39]   = help: add #![feature(allocator_api)] to the crate attributes to enable
[01:15:39] 
[01:15:39] thread 'boxed.rs - boxed::Box<T, A>::necom | grep ^Date: | sed 's/Date: //g' || true)
travis_fold:start:after_failure.1
travis_time:start:02ea71d4

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)

@glandium glandium force-pushed the glandium:box branch from 59d5866 to 1e5328e May 20, 2018

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented May 20, 2018

A few comments now that this is passing tests:

  • Since it's now burried in the test reports noise, I'll link to this previous comment, which still applies: #50882 (comment)
  • I didn't intend for into_raw_and_alloc to be public, but I couldn't find a way to make tests work with it being pub(crate) because the boxed module comes from std in that case.
  • into_raw_and_alloc kind of sucks as a name, so please feel free to bikeshed. I was wondering if into_raw should return a (*mut T, A) when A is not Global and *mut T if it is, but I'm not sure it's worth the extra complexity.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 24, 2018

☔️ The latest upstream changes (presumably #50984) made this pull request unmergeable. Please resolve the merge conflicts.

@glandium glandium force-pushed the glandium:box branch from 1e5328e to 9aaeb4f May 24, 2018

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented May 29, 2018

Triage ping, @bluss / @rust-lang/libs: This PR needs you review, and, I assume, a crater run & FCP.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 29, 2018

We've long wanted to do something like this but we've been hesitant to do so historically due to various compiler bugs (which indeed aren't well tracked!). From the looks of the diff here it seems that error messages related to Box may be getting worse? Since I don't think we get a lot of benefit from landing this as-is (as opposed to having a crates.io crate that does this) that to me at least is fairly serious

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented May 29, 2018

There is a crates.io crate that does this, but it can't replace Box. It's only by implementing things in liballoc that we end up figuring out what's good and what's bad about it. See #50882 (comment).

@bors

This comment has been minimized.

Copy link
Contributor

bors commented May 30, 2018

☔️ The latest upstream changes (presumably #50880) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 30, 2018

Sure yeah makes sense, but as a PR to rust is this expected to be merged? I'd personally still be wary of the error message segregation

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented May 30, 2018

Re, degredation*

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented May 30, 2018

As a PR to rust, it allows tests to run. A crater run could be useful, for instance. There are some implementation details that still need to be figured out. For example, the current patch doesn't remove the use of the box keyword, so only Box has fn new, while Box<T, A: Alloc + Default> theoretically could have it.

@glandium glandium force-pushed the glandium:box branch from 9aaeb4f to d568c8c May 30, 2018

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Jun 4, 2018

Ping from triage! How should we move forward with this?

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jun 6, 2018

☔️ The latest upstream changes (presumably #51263) made this pull request unmergeable. Please resolve the merge conflicts.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jul 24, 2018

Ok. There has to be something wrong with either the compiler or the test.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 24, 2018

Sorry for the delay in posing this! As I mentioned before we've long wanted to do this but since Box (and other collections) are such prominent types in the standard library we've been hesitant to take the leap just yet. There's a number of longstanding questions which unfortunately haven't been well articulated up to now which has prevented work on these new type parameters from progressing.

A number of members on @rust-lang/libs have expressed concern about moving forward in this direction (adding allocator parameters everywhere). We don't have the time to work through these concerns, though, before the 2018 edition release. As a result this will likely need to be delayed at least until after the 2018 edition release.

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jul 24, 2018

@alexcrichton I'm perfectly find with mine being tabled for now, but this one by @glandium is much smaller, more targeted, and more researched. You mention the list of compiler issues isn't even written down. If anyone knows them, it's @glandium; they've been diligently chasing down issues in commits like 43b24c6, dfa6111, 6614fa0, 64f5233, bd8c177, and b5c2b79 as part of working towards this PR.

IMO if we're ever going to prioritize this, and gather relevant data so the lang team does less work overall, we should merge this on an experimental basis with the understanding that it will be reverted at the first sign of trouble. Either we raise the bus factor, or I fear nothing will happen ever.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 24, 2018

Indeed gathering data is good! My point is that we can't amongst the libs team have a serious discussion about landing this until after the edition.

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jul 24, 2018

I'm just still disappointed that unstable methods in an unstable create (std's Box has no alloc param, even on nightly) needs any "serious discussion" at all. The Placer API, for example, affected core APIs, sat unstable for a while, and then was reverted, without harming anyone, right?

I'm reminded of the vision best described by @gnzlbg in rust-lang/rfcs#2480 (comment) on making std a facade over rust-lang-nursery, as it relates to enabling more decentralized library experimentation while still giving the core libs team absolute control over what gets stabilized. Hopefully that gets us the best of both worlds by still keeping experiments out of rust-lang/rust while achieving that goal, but until that happens it would be nice to be more liberal about libraries in this repo provided everything is unstable.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jul 24, 2018

I'll note that it is possible to experiment with crates today, to some extent, and I've done so with the allocator_api crate, that implements Box<T, A> (could implement more, but I didn't need it, contributions welcome).

BUT "to some extent" is key. Because the liballoc exposes types rather than traits, one can't use an hypothetical my_crate::Vec<T, A> in place of a std::vec::Vec<T>. BTW, this is going to be something to figure out long term, even for std::vec::Vec<T, A>, and even for std::box::Box<T, A>, even if this PR was merged.

That being said, this PR is a relatively small step to start experimenting with these things, and, like @Ericson2314, I don't see why this would need to wait.

Well, except for the fact that, at the moment, I'm concerned that it breaks some compiler assumptions and that that would be the reason for the test failure.

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jul 24, 2018

Yeah, it's precisely because this experiment will take so long that that it's important to unlock the parallelism of not hogging tons of lib team time.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 26, 2018

Yes the libs team understands the value in experimentation and doesn't want to unnecessarily block efforts, but this PR is touching the Box type, which is a change we cannot take lightly. As a result, we need to postpone this until after the 2018 edition to ensure that other features ship.

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Aug 7, 2018

Ping from triage! If I understand correctly, this PR is blocked until after the 2018 edition ships, which is still quite some time to go. As such I'm closing this PR as blocked, following our triage procedure. Please add a comment or re-open if I missunderstood.

@phil-opp

This comment has been minimized.

Copy link
Contributor

phil-opp commented Jan 15, 2019

@glandium Do you have plans to reopen this PR now that the 2018 edition has shipped? This would be really great to have.

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jan 15, 2019

Yes please! Happy to assist in any way once it is, too.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jan 15, 2019

As long as #52694 is a problem (and it is because travis uses a system llvm that is affected), I can't make progress on this.

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jan 16, 2019

Can we cfg that dealloc call and do a static assert with old LLVM that the Alloc parameter is always the global allocator?

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jan 16, 2019

Can we?

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jan 24, 2019

So...

I tried to gave a quick try to the idea, but I hit two snags:

  • This happens:
error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, `PhantomData` fields, and nothing else
   --> src/liballoc/boxed.rs:794:1
    |
794 | impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Alloc> DispatchFromDyn<Box<U, A>> for Box<T, A> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: extra field `1` of type `A` is not allowed

which I don't know what to do about.

  • I picked an older rust tree, and tested making box_free Global-only, to possibly put that behind some cfg. Unfortunately, it seems type checking is not happening (I was hoping it would).

With:

pub(crate) unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, mut a: Global)

I can still compile code that uses Box::new_in(value, SomeAllocator), which calls SomeAllocator.alloc for allocations as expected, but Global.dealloc for deallocations, which is not going to do any good at runtime.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jan 24, 2019

error[E0378]: the trait DispatchFromDynmay only be implemented for structs containing the field being coerced,PhantomData fields, and nothing else

That apparently comes from #54383. @mikeyhew, @nikomatsakis, @eddyb, any idea how to get around this?

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jan 24, 2019

Thanks does trying! And sorry I didn't respond earlier. I think we can make an A: Is<Global> bound to allow the parameter in all cases, but constrain it to be useless with old LLVM. Maybe that helps with the second point?

Also did you push this experiment yet? I'd love to try it.

@mikeyhew

This comment has been minimized.

Copy link
Contributor

mikeyhew commented Jan 24, 2019

@glandium

That apparently comes from #54383. @mikeyhew, @nikomatsakis, @eddyb, any idea how to get around this?

In this PR, you update the definition of Box:

pub struct Box<T: ?Sized, A: Alloc = Global>(Unique<T>, A);

The problem is A isn't necessarily zero-sized. Right now, dynamic dispatch is only implemented for receiver types that have the same ABI as a *const T pointer (Scalar when T is Sized, ScalarPair when T is dyn Trait). If A wasn't zero-sized, this would change the ABI of Box<T, A>, and that's why DispatchFromDyn can only be implemented for newtyped pointers. PhantomData fields are allowed as an exception because the compiler knows that they are zero-sized and do not affect the ABI.

You need to edit this code here: https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/coherence/builtin.rs#L226. There are a couple options:

  • A quick and dirty solution: change the if statement to ignore std::alloc::Global in addition to PhantomData fields, and then implement DispatchFromDyn<Box<U, Global>> for Box<T, Global>. This would mean that Box<T, A> where A is not the global allocator would not be object-safe
  • Alternatively, you could introduces a new unsafe trait ZeroSized, add an A: ZeroSized bound to Box<T, A>, and update the if statement to ignore anything that implements ZeroSized. The trait could be safe if there were checks to make sure Self is actually zero-sized and doesn't have #[repr(C)]. (And whatever else is required to avoid affecting the ABI. @eddyb can comment on that.)

The real fix will be to support dynamic dispatch for method receivers with arbitrary ABIs, but that's pretty far off. For now it's probably best to use the ZeroSized trait.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Jan 25, 2019

Also did you push this experiment yet? I'd love to try it.

I haven't fully rebased, because I was only trying to see if box_free could be made to type-error. Considering the DispatchFromDyn part requires compiler changes anyways, that means there's going to be a need to #[cfg] away the whole thing anyways, for stage0, so it's not going to be more burdensome to add another condition for old-LLVM. The one problem that I have, though, is that currently, only the librustc_llvm crate knows anything about the llvm version...

@Ericson2314

This comment has been minimized.

Copy link
Contributor

Ericson2314 commented Jan 25, 2019

Ah, what a mess! The one good thing is hopefully Sized<size=0> is approaching possible so a ZeroSized isn't totally a temporary hack.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Jan 30, 2019

At this point it might be easier to support extra fields in DispatchFromDyn, than use some new traits to limit it to size_of::<T>() == 0.

I believe such support could work if built on top of the chalk-oriented "bounded/universe" types, e.g. computing the layout of exists T: Sized. Rc<T, FooAlloc> should be possible, the same way it can work for struct Foo<T>(Rc<T, FooAlloc>), but the compiler could do it without needing a nominal T parameter from anywhere.

This could also be used to represent the type of the data pointer field of DSTs, without overloading the meaning of a *mut dyn Trait TyLayout with a Scalar(Ptr) ABI.

cc @nikomatsakis

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Feb 14, 2019

So the good news is that #52694 is now "magically" gone. I'm currently in the process of reviving this patch in a different form, working around the DispatchFromDyn issue entirely. I'll open a new PR when I'm done, hopefully in a few hours.

@glandium

This comment has been minimized.

Copy link
Contributor Author

glandium commented Feb 14, 2019

Opened #58457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.