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

support ascription for patterns in NLL #53873

Merged

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Aug 31, 2018

This implements the strategy outlined in this comment:

  • We first extend the NLL subtyping code so it can handle inference variables and subtyping.
  • Then we extend HAIR patterns with type ascription.
  • Then we treat the type T in let pat: T = ... as an ascription.

Before landing, a few things:

r? @pnkfelix

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2018
@nikomatsakis nikomatsakis force-pushed the nll-universe-subtyping-and-pattern-ascription branch from 9bff8b5 to 93cd6a5 Compare September 1, 2018 01:04
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/d7/d2/04d4fb0da66c7a8850477ff1fb8f9e80597147286e118e111f7d548cf1d7/awscli-1.16.6-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 19.2MB/s eta 0:00:01
    1% |▌                               | 20kB 2.0MB/s eta 0:00:01
    2% |▊                               | 30kB 2.3MB/s eta 0:00:01
    3% |█                               | 40kB 2.1MB/s eta 0:00:01
---

[00:04:44] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:45] tidy error: /checkout/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs:550: line longer than 100 chars
[00:04:45] tidy error: /checkout/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs:632: line longer than 100 chars
[00:04:45] tidy error: /checkout/src/librustc_mir/hair/pattern/_match.rs:1238: line longer than 100 chars
[00:04:46] some tidy checks failed
[00:04:46] 
[00:04:46] 
[00:04:46] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:46] 
[00:04:46] 
[00:04:46] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:46] Build completed unsuccessfully in 0:00:51
[00:04:46] Build completed unsuccessfully in 0:00:51
[00:04:46] Makefile:79: recipe for target 'tidy' failed
[00:04:46] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:282c617d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:0687f43a:start=1535764279707614206,finish=1535764279717440833,duration=9826627
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:02c91f90
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:220b578c
travis_time:start:220b578c
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1ec6bfd6
$ dmesg | grep -i kill

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

@memoryruins memoryruins added the A-NLL Area: Non-lexical lifetimes (NLL) label Sep 1, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 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:13:25]    Compiling rustc_metadata_utils v0.0.0 (file:///checkout/src/librustc_metadata_utils)
[00:13:25]    Compiling rustc_mir v0.0.0 (file:///checkout/src/librustc_mir)
[00:13:25]    Compiling rustc_typeck v0.0.0 (file:///checkout/src/librustc_typeck)
[00:13:26]    Compiling rustc_traits v0.0.0 (file:///checkout/src/librustc_traits)
[00:13:34] error[E0599]: no variant named `UserAssertTy` found for type `rustc::mir::StatementKind<'_>` in the current scope
[00:13:34]    --> librustc_mir/transform/qualify_min_const_fn.rs:233:11
[00:13:34]     |
[00:13:34] 233 |         | StatementKind::UserAssertTy(..)
[00:13:34] 
[00:13:37] error: aborting due to previous error
[00:13:37] 
[00:13:37] For more information about this error, try `rustc --explain E0599`.
[00:13:37] For more information about this error, try `rustc --explain E0599`.
[00:13:37] error: Could not compile `rustc_mir`.
[00:13:37] 
[00:13:37] Caused by:
[00:13:37]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_mir librustc_mir/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=7952c237ec0d4952 -C extra-filename=-7952c237ec0d4952 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-4ee92b74dcb65ca6.so --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbitflags-5a39798fe03e47f4.rlib --extern byteorder=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbyteorder-8246be02936c9b1b.rlib --extern either=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libeither-0a515e87c8afea9e.rlib --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-45ae4394366d07fd.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-c55d6c95192e4906.rlib --extern log_settings=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog_settings-87ec950697a15ed0.rlib --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-218f3033f29f5493.rlib --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-cfbc17aa3c766576.so --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_apfloat-4a211d9e23f5aeb5.rlib --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-61336079186baa43.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-f882aab6100635ab.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-51fd1bd0441a9815.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-8d84add221c0f710.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-8d84add221c0f710.rlib --extern smallvec=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsmallvec-cb741677cd0e0351.rlib --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-26b6009735d1b07c.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-ef45b71e578357b1.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-ee16f6821aef40e9/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-52504d5ed57fefc2/out` (exit code: 1)
3652692 .
1401844 ./obj
1401808 ./obj/build
1185132 ./.git
---
151200 ./src/tools/clang
149128 ./src/llvm-emscripten/test
148964 ./obj/build/bootstrap/debug/incremental
134532 ./obj/build/bootstrap/debug/incremental/bootstrap-11nz4fw202v9g
134528 ./obj/build/bootstrap/debug/incremental/bootstrap-11nz4fw202v9g/s-f4goosyi8j-ffgrad-29k09wkatlb53
111072 ./src/llvm/test/CodeGen
103868 ./src/tools/lldb
98952 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
93756 ./src/tools/clang/test

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)

@nikomatsakis nikomatsakis force-pushed the nll-universe-subtyping-and-pattern-ascription branch from a70eb79 to c543e2c Compare September 4, 2018 20:10
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 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:47:21] .................................................................i...i................ii............
[00:47:24] ...................................................................................iii..............
[00:47:27] ......................................................................i..........i..................
[00:47:30] ........i...........................................................................................
[00:47:35] ............................F...F...................................................................
[00:47:41] ...........................ii.iii...................................................................
[00:47:44] ....................................................................................................
[00:47:46] ....................................................................................................
[00:47:48] ....................................................................................................
---
[00:48:07] ....................................................................................................
[00:48:10] ....................................................................................................
[00:48:13] ...........................i........................................................................
[00:48:16] ....................................................................................................
[00:48:18] ............................................................................iiiiiiiii...............
[00:48:24] ....................................................................................................
[00:48:27] ....................................................................................................
[00:48:30] .........................................................i..........................................
[00:48:33] ....................................................................................................
---
[00:49:05] ....................................................................................................
[00:49:09] ....................................................................................................
[00:49:11] ................................................................................................i.ii
..
[00:49:13] 25 LL | }
[00:49:13] 26    | - temporary value only lives until here
[00:49:13] 
[00:49:13] 
[00:49:13] The actual stderr differed from the expected stderr.
[00:49:13] The actual stderr differed from the expected stderr.
[00:49:13] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll/dont_promote_unstable_const_fn.nll.stderr
[00:49:13] To update references, rerun the tests and pass the `--bless` flag
[00:49:13] To only update this specific test, also pass `--test-args consts/const-eval/dont_promote_unstable_const_fn.rs`
[00:49:13] error: 1 errors occurred comparing output.
[00:49:13] status: exit code: 1
[00:49:13] status: exit code: 1
[00:49:13] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.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/consts/const-eval/dont_promote_unstable_const_fn.nll/a" "-Zborrowck=mir" "-Ztwo-phase-borrows" "-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/consts/const-eval/dont_promote_unstable_const_fn.nll/auxiliary" "-A" "unused"
[00:49:13] ------------------------------------------
[00:49:13] 
[00:49:13] ------------------------------------------
[00:49:13] stderr:
[00:49:13] stderr:
[00:49:13] ------------------------------------------
[00:49:13] {"message":"`foo` is not yet stable as a const fn","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":867,"byte_end":872,"line_start":25,"line_end":25,"column_start":25,"column_end":30,"is_primary":true,"text":[{"text":"const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn","highlight_start":25,"highlight_end":30}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"in Nightly builds, add `#![feature(foo)]` to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `foo` is not yet stable as a const fn\n  --> /checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs:25:25\n   |\nLL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn\n   |                         ^^^^^\n   |\n   = help: in Nightly builds, add `#![feature(foo)]` to the crate attributes to enable\n\n"}
[00:49:13] {"message":"borrowed value does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":960,"byte_end":965,"line_start":28,"line_end":28,"column_start":28,"column_end":33,"is_primary":true,"text":[{"text":"    let _: &'static u32 = &foo(); //~ ERROR does not live long enough","highlight_start":28,"highlight_end":33}],"label":"temporary value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":1003,"byte_end":1004,"line_start":29,"line_end":29,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough\n  --> /checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs:28:28\n   |\nLL |     let _: &'static u32 = &foo(); //~ ERROR does not live long enough\n   |                            ^^^^^ temporary value does not live long enough\nLL | }\n   | - temporary value only lives until here\n   |\n   = note: borrowed value must be valid for the static lifetime...\n\n"}
[00:49:13] {"message":"borrowed value does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":1045,"byte_end":1050,"line_start":32,"line_end":32,"column_start":28,"column_end":33,"is_primary":true,"text":[{"text":"    let _: &'static u32 = &meh(); //~ ERROR does not live long enough","highlight_start":28,"highlight_end":33}],"label":"temporary value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":1202,"byte_end":1203,"line_start":35,"line_end":35,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough\n  --> /checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs:32:28\n   |\nLL |     let _: &'static u32 = &meh(); //~ ERROR does not live long enough\n   |                            ^^^^^ temporary value does not live long enough\n...\nLL | }\n   | - temporary value only lives until here\n   |\n   = note: borrowed value must be valid for the static lifetime...\n\n"}
[00:49:13] {"message":"borrowed value does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":1113,"byte_end":1165,"line_start":33,"line_end":33,"column_start":26,"column_end":78,"is_primary":true,"text":[{"text":"    let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();","highlight_start":26,"highlight_end":78}],"label":"temporary value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs","byte_start":1202,"byte_end":1203,"line_start":35,"line_end":35,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough\n  --> /checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs:33:26\n   |\nLL |     let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();\n   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough\nLL |     //~^ does not live long enough\nLL | }\n   | - temporary value only lives until here\n   |\n   = note: borrowed value must be valid for the static lifetime...\n\n"}
[00:49:13] {"message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors\n\n"}
[00:49:13] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,value only lives until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"borrowed value must be valid for the static lifetime...","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0597]: borrowed value does not live long enough\n  --> /checkout/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs:18:28\n   |\nLL |     let _: &'static u32 = &foo(); //~ ERROR does not live long enough\n   |                            ^^^^^ temporary value does not live long enough\nLL |     let _x: &'static u32 = &foo(); //~ ERROR does not live long enough\nLL | }\n   | - temporary value only lives until here\n   |\n   = note: borrowed value must be valid for the static lifetime...\n\n"}
[00:49:13] {"message":"borrowed value does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"error","spans":[{"file_name":"/c:
udev            7.4G  4.0K  7.4G   1% /dev
tmpfs           1.5G  284K  1.5G   1% /run
/dev/sda1        30G   11G   18G  37% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup

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)

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
[00:48:14] ....................................................................................................
[00:48:17] ....................................................................................................
[00:48:20] ................................i...................................................................
[00:48:23] ....................................................................................................
[00:48:25] .................................................................................iiiiiiiii..........
[00:48:31] ...ii...............................................................................................
[00:48:34] ....................................................................................................
[00:48:37] ..............................................................i.....................................
[00:48:40] ....................................................................................................
---
[00:50:22] ....................................................................................................
[00:50:30] ....................................................................................................
[00:50:39] ....................................................................................................
[00:50:52] ....................................................................................................
[00:51:01] ...................................F................................................................
[00:51:18] ....................................................................................................
[00:51:25] ....................................................................................................
[00:51:33] ....................................................................................................
[00:51:44] .................................................................................i..................
---
[00:54:54] 
[00:54:54] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:497:22
[00:54:54] 
[00:54:54] 
[00:54:54] 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/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/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" "5.0.0\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:54:54] 
[00:54:54] 
[00:54:54] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:54:54] Build completed unsuccessfully in 0:10:42
[00:54:54] Build completed unsuccessfully in 0:10:42
[00:54:54] Makefile:58: recipe for target 'check' failed
[00:54:54] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0cd29820
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:092063f2:start=1536164053546578483,finish=1536164053554604888,duration=8026405
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:133bb5d3
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:start:crashlog
obj/cores/core.29561.!checkout!obj!build!x86_64-unknown-linux-gnu!test!run-pass!intrinsic-move-val!a
Source directories searched: /home/travis/build/rust-lang/rust/src:$cdir:$cwd
Reading symbols from obj/build/x86_64-unknown-linux-gnu/test/run-pass/intrinsic-move-val/a...(no debugging symbols found)...done.
[New LWP 29561]
warning: Could not load shared library symbols for 6 libraries, e.g. /lib/x86_64-linux-gnu/libgcc_s.so.1.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/intrinsic-move-val/a'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x000055ac94e770ba in intrinsic_move_val::main::he550cac715749cad ()
#0  0x000055ac94e770ba in intrinsic_move_val::main::he550cac715749cad ()
#1  0x000055ac94e772f3 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h98cbeff320c1f187 ()
#2  0x00007fdace5ebfe3 in std::panicking::try::do_call::haac499133cc3b53f ()
   from ./checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d36e1a231adc37cd.so
#3  0x00007fdace62df3a in __rust_maybe_catch_panic ()
   from ./checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d36e1a231adc37cd.so
#4  0x00007fdace5ebed8 i
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0d30553e
$ dmesg | grep -i kill

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

@nikomatsakis
Copy link
Contributor Author

Hmm, I also see this intrinsic-move-val failure locally. Very curious. It seems to only crash when -O is given, as well.

@nikomatsakis
Copy link
Contributor Author

Changing the code from

        let mut y: Box<D> = rusti::init();

to

        let mut y = rusti::init::<Box<D>>();

averts the crash. The problem seems to be that we are adding a

AscribeUserType(_73, Canonical { variables: [], value: std::boxed::Box<D> });

instruction, where _73 is the result of init (which is indeed an invalid value). I'm not sure yet why this is problematic, though. The statement seems to be optimized away later.

@nikomatsakis
Copy link
Contributor Author

Presumably this has something to do with this special case:

// optimize the case of `let x = ...`
match *irrefutable_pat.kind {
PatternKind::Binding { mode: BindingMode::ByValue,
var,
subpattern: None, .. } => {
let place = self.storage_live_binding(block, var, irrefutable_pat.span,
OutsideGuard);
if let Some(ty) = ty {
self.user_assert_ty(block, ty, var, irrefutable_pat.span);
}
unpack!(block = self.into(&place, block, initializer));
self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
block.unit()
}
_ => {
let place = unpack!(block = self.as_place(block, initializer));
self.place_into_pattern(block, irrefutable_pat, &place, true)
}

@nikomatsakis
Copy link
Contributor Author

This is basically the only way that the final code differs:

    bb9: {
        StorageDead(_46);                // bb9[0]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:35:37: 35:38
        StorageLive(_48);                // bb9[1]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:29: 37:42
        _48 = const rusti::::init() -> [return: bb10, unwind: bb3]; // bb9[2]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:29: 37:42
                                         // ty::Const
                                         // + ty: unsafe extern "rust-intrinsic" fn() -> std::boxed::Box<D> {rusti::::init::<std::boxed::Box<D>>}
                                         // + val: Scalar(Bits { size: 0, bits: 0 })
                                         // mir::Constant
                                         // + span: /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:29: 37:40
                                         // + ty: unsafe extern "rust-intrinsic" fn() -> std::boxed::Box<D> {rusti::::init::<std::boxed::Box<D>>}
                                         // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> std::boxed::Box<D> {rusti::::init::<std::boxed::Box<D>>}, val: Scalar(Bits { size: 0, bits: 0 }) \
}
    }

    bb10: {
        StorageLive(_47);                // bb10[0]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:13: 37:18
        _47 = move _48;                  // bb10[1]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:13: 37:18
        StorageDead(_48);                // bb10[2]: scope 2 at /home/nmatsakis/versioned/rust-6/src/test/run-pass/intrinsic-move-val.rs:37:42: 37:43

presumably something here is illegal -- I guess the _47 = move _48.

@nikomatsakis
Copy link
Contributor Author

I just realized while working through this bug that we also have to make sure that NLL enforces ref mut binding type ascription correctly. In particular:

let ref mut x: T = <expr>

We historically had some soundness issues there, because we only enforced that typeof(expr) <: T and that wasn't enough when <expr> is a place.

That said, I don't think that would affect NLL, but perhaps for a sort of confusing reason. Under this PR anyway, we will enforce that typeof(expr) <: T -- but this doesn't actually say anything about the type of x!

Perhaps that is OK, though. That is, we still have to handle cases like let x: T;, which obviously relates the type of x to T. Perhaps we just need to do that all the time. In that case, we will "push the type down" into the type of x as desired.

@rust-highfive

This comment has been minimized.

@nikomatsakis nikomatsakis force-pushed the nll-universe-subtyping-and-pattern-ascription branch from 836855e to 4a4099c Compare September 6, 2018 09:48
@bors
Copy link
Contributor

bors commented Sep 6, 2018

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

assert!(!k.has_escaping_regions());

k
// These always correspond to an `_` or `'_` written by
Copy link
Member

Choose a reason for hiding this comment

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

I just want to make sure I'm understanding this comment: You are drawing this conclusion that the type (or region) is always either _ or '_ ... because that is the only scenario where canonical_var_values[var] is allowed to return None?

// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test that the NLL `relate_tys` code correctly deduces that a
Copy link
Member

Choose a reason for hiding this comment

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

This comment appears to be a cut-and-paste mistake left over from hr-fn-aba-as-aaa.rs

let b = 44;

// Here we get an error because `DoubleCell<_>` requires the same type
// on both parts of the `Cell`, and we can't have that.
Copy link
Member

Choose a reason for hiding this comment

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

it probably wouldn't hurt, if you get the chance, to add a parenthetical reminding the reader that the type Cell<X> is invariant with respect to X (which is why, IIUC, the return type of make_cell here cannot be "simply upcast" from Cell(&'static _, &'b _) up to Cell(&'b _, &'b _).

Copy link
Member

@pnkfelix pnkfelix Sep 7, 2018

Choose a reason for hiding this comment

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

(basically I stopped for a beat when I read "... and we can't have that", because I needed to reason through the steps of why the two parts could not be unified to one type.)

// Reset the ambient variance to covariant. This is needed
// to correctly handle cases like
//
// for<'a> fn(&'a u32, &'a u3) == for<'b, 'c> fn(&'b u32, &'c u32)
Copy link
Member

Choose a reason for hiding this comment

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

uber-nit: &'a u3 has a typo.

@@ -16,9 +16,7 @@
// another -- effectively, the single lifetime `'a` is just inferred
Copy link
Member

Choose a reason for hiding this comment

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

Github will not let me leave a comment directly on the relevant line, because it is not part of the diff here, but starting on line 11 there is a parenthetical that says "(though the current code actually gets it wrong, see below)"; you should remove that parenthetical as part of this commit.

|
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
...
LL | let z: I::A = if cond { x } else { y };
| ^ assignment requires that `'a` must outlive `'b`
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b`
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Copy link
Member

Choose a reason for hiding this comment

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

oops apparently that 🎉 was premature. 😄 Luckily this change was not the point per se of the PR; I just (subjectively) thought it might have been a happy accident.

@@ -35,7 +35,7 @@ error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` poin
--> $DIR/borrowck-access-permissions.rs:56:23
|
LL | let ptr_x : *const _ = &x;
| -- help: consider changing this to be a mutable pointer: `&mut x`
| ----- help: consider changing this to be a mutable pointer: `*mut i32`
Copy link
Member

Choose a reason for hiding this comment

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

this is interesting; hypothetically we probably would prefer, if possible to highlight the ascribed type*const _ here, right?

error[E0597]: borrowed value does not live long enough
--> $DIR/dont_promote_unstable_const_fn.rs:28:28
|
LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough
Copy link
Member

Choose a reason for hiding this comment

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

🎉

LL | let x: Box<Foo + 'static> = Box::new(v);
| ^^^^^^^^^^^ lifetime `'static` required
...
LL | x
Copy link
Member

Choose a reason for hiding this comment

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

This change in diagnostic seems unfortunate.

After all, the user wrote down the type they wanted x to have, and that type exactly matches the return type of the function, so having the diagnostic blame the point to where x is returned, rather than the point where x was initialized (i.e. the prior behavior), seems subpar to me.

Let me try to guess: Is it something where we do not use the ascribed type from let x: Box<Foo + 'static> as the type for x itself (and instead are using the lifetime that resulted from region inference in our internal type for x), and thus we subsequently error when we try to return x as the result in a context expecting Box<Foo + 'static>?

Or is there something else going on?


In any case, I won't block landing this PR based on this issue. But we may want to file a follow-up issue about it, since it seems like something we should try to address eventually, if possible.

@@ -2,7 +2,7 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
--> $DIR/slice-mut-2.rs:17:18
|
LL | let x: &[isize] = &[1, 2, 3, 4, 5];
| ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]`
| - help: consider changing this to be a mutable reference: `&mut [isize]`
Copy link
Member

Choose a reason for hiding this comment

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

hmm, I'm again surprised that we highlight x here, and not the ascribed type. I thought we had code in place that tried to select the span of the explicitly provided type in scenarios like this.

@pnkfelix
Copy link
Member

pnkfelix commented Sep 7, 2018

Do you have a unit test illustrating the effect of the commit "generalize AscribeUserType to handle sub or super type" ?

@pnkfelix
Copy link
Member

pnkfelix commented Sep 7, 2018

Very interesting that the commit "optimize let x: T = .. to avoid a temporary" seems to undo a number of the changes that I noted and/or was concerned about in the diagnostics...

The big one I still want an answer about is this one: #53873 (review)

Just to elaborate on that linked comment, here is the test code:

https://github.com/rust-lang/rust/blob/cde014b9d37acad41fa8fe09fef47eca86075bef/src/test/ui/regions/region-object-lifetime-in-coercion.rs#L17-L21

The oddity: The NLL diagnostics, at least temporarily, were highlighting the return of x as the error, acting as if x (which is ascribed as having type Box<Foo + 'static>) is not an appropriate return value for a function which returns Box<Foo + 'static>...

In particular, I want to know if there are other potential scenarios where we produce a diagnostic that is similarly "bad", in the sense that it may frustrate a user who thinks intuitively that if they wrote let x: MyFunctionsReturnType = ... then a subsequent return x; should probably not produce a type error highlighting the x in return x;...

@pnkfelix
Copy link
Member

pnkfelix commented Sep 7, 2018

This seems fine. I have nits, and there are known bugs in the PR. But its an improvement on our current status, which may mean we might want to land this PR even in its current state...

Having said that, I'll not issue any bors commands until niko gets a chance to finish resolving the remaining issues on this PR, or at least weigh in on whether to land it as is.

INDENT,
indent,
mut_str,
local,
var.ty
);
if let Some(user_ty) = var.user_ty {
write!(indented_var, " as {:?}", user_ty).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

hmm. I'd have to think about this syntax and whether it makes sense. (But I won't let that block landing this PR; the printed MIR output format is unstable, afterall...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it...probably doesn't make sense =)

let x = 22;
let y: &'static u32;
y = &x; //~ ERROR
Copy link
Member

Choose a reason for hiding this comment

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

🎉

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 10, 2018

📌 Commit 2b6f966 has been approved by pnkfelix

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

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.

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)

@nikomatsakis
Copy link
Contributor Author

@bors r-

Travis failure. I think I know what the problem is, I thought that interaction seemed suspicious. (ref bindings, in particular)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 10, 2018
@nikomatsakis nikomatsakis force-pushed the nll-universe-subtyping-and-pattern-ascription branch from 30c5572 to df37678 Compare September 10, 2018 18:12
@nikomatsakis
Copy link
Contributor Author

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Sep 10, 2018

📌 Commit df37678 has been approved by pnkfelix

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

The job x86_64-gnu-llvm-5.0 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.
travis_fold:end:step_upload_script
travis_fold:start:worker_info
Worker information
hostname: 600c5fbe-4d35-42a4-b1b0-8b0da6048aff@1.production-2-worker-org-b-1-gce
version: v4.1.0-17-gbb60707 https://github.com/travis-ci/worker/tree/bb607075d490bc4e77c266194569bdd17ae6b7a6
startup: 6.438663479s
travis_fold:end:worker_info
travis_fold:start:system_info
Build system information
---
travis_time:start:test_incremental
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:00:37] 
[01:00:37] running 90 tests
[01:00:50] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:497:22
[01:00:50] ...............................F..........................................................
[01:00:50] 
[01:00:50] ---- [incremental] incremental/hashes/let_expressions.rs stdout ----
[01:00:50] 
[01:00:50] 
[01:00:50] error in revision `cfail2`: test compilation failed although it shouldn't!
[01:00:50] status: exit code: 1
[01:00:50] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/incremental/hashes/let_expressions.rs" "--target=x86_64-unknown-linux-gnu" "--cfg" "cfail2" "-C" "incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/let_expressions/let_expressions.inc" "-Z" "incremental-verify-ich" "-Z" "incremental-queries" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/let_expressions/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "query-dep-graph" "-Zincremental-ignore-spans" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental/hashes/let_expressions/auxiliary"
[01:00:50] ------------------------------------------
[01:00:50] 
[01:00:50] ------------------------------------------
[01:00:50] stderr:
[01:00:50] stderr:
[01:00:50] ------------------------------------------
[01:00:50] {"message":"`MirOptimized(add_type)` should be clean but is not","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/incremental/hashes/let_expressions.rs","byte_start":1549,"byte_end":1594,"line_start":54,"line_end":56,"column_start":1,"column_end":2,"is_primary":true,"text":[{"text":"pub fn add_type() {","highlight_start":1,"highlight_end":20},{"text":"    let _x: u32 = 2u32;","highlight_start":1,"highlight_end":24},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: `MirOptimized(add_type)` should be clean but is not\n  --> /checkout/src/test/incremental/hashes/let_expressions.rs:54:1\n   |\nLL | / pub fn add_type() {\nLL | |     let _x: u32 = 2u32;\nLL | | }\n   | |_^\n\n"}
[01:00:50] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[01:00:50] ------------------------------------------
[01:00:50] 
[01:00:50] thread '[incremental] incremental/hashes/let_expressions.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3196:9
[01:00:50] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:00:50] test result: FAILED. 89 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:00:50] 
[01:00:50] 
[01:00:50] 
[01:00:50] 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/incremental" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/incremental" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "incremental" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/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" "5.0.0\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:00:50] 
[01:00:50] 
[01:00:50] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:00:50] Build completed unsuccessfully in 0:15:58
[01:00:50] Build completed unsuccessfully in 0:15:58
[01:00:50] Makefile:58: recipe for target 'check' failed
[01:00:50] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:3bc5ff58
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:0b9d37c0:start=1536612375682292453,finish=1536612375688791404,duration=6498951
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:29b1268c
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0b301410
travis_time:start:0b301410
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a2bc804
$ dmesg | grep -i kill

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

We are now carrying the user-given type through MIR, so it makes sense
that this would change the hash.
@nikomatsakis
Copy link
Contributor Author

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Sep 10, 2018

📌 Commit f95f23f has been approved by pnkfelix

@nikomatsakis
Copy link
Contributor Author

@bors p=1

Edition blocker

@bors
Copy link
Contributor

bors commented Sep 11, 2018

⌛ Testing commit f95f23f with merge 2f1547c...

bors added a commit that referenced this pull request Sep 11, 2018
…n-ascription, r=pnkfelix

support ascription for patterns in NLL

This implements the strategy outlined in [this comment](#47184 (comment)):

- We first extend the NLL subtyping code so it can handle inference variables and subtyping.
- Then we extend HAIR patterns with type ascription.
- Then we treat the type `T` in `let pat: T = ...` as an ascription.

Before landing, a few things:

- [x] Fix the WF rule bug (filed a FIXME #54105)
- [x] Fix an ICE I encountered locally around bound regions, or else file a follow-up
- [x] More tests probably =)

r? @pnkfelix
@bors
Copy link
Contributor

bors commented Sep 11, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: pnkfelix
Pushing 2f1547c to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants