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

A few cleanups and minor improvements to rustc/infer #54641

Merged
merged 6 commits into from
Oct 1, 2018

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Sep 28, 2018

  • use unwrap_or(_else) where applicable
  • convert single-branch matches to if-let
  • use to_owned instead of to_string with string literals
  • improve vector allocations
  • readability improvements
  • miscellaneous minor code improvements

@rust-highfive
Copy link
Collaborator

r? @estebank

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2018
@rust-highfive

This comment has been minimized.

@ljedrz
Copy link
Contributor Author

ljedrz commented Sep 28, 2018

Whoops, looks like I overdid it somewhere; I'll look into the errors shortly.

Ok(()) => vec![],
Err(errors) => errors,
};
let true_errors = fulfill_cx.select_where_possible(self).err().unwrap_or(vec![]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minot nitpick: These are probably better served with .unwrap_or_else(Vec::new).

Ok(()) => vec![],
Err(errors) => errors,
};
let ambig_errors = fulfill_cx.select_all_or_error(self).err().unwrap_or(vec![]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@@ -100,7 +100,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let mut labels = vec![(
span,
if &name == "_" {
"cannot infer type".to_string()
"cannot infer type".to_owned()
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no preference nowadays between to_string and to_owned other than style as both now have the same performance impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean when #54613 is merged? At this moment to_string is not inlined.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ljedrz I was referring to #18404, which was fixed by #32586.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That change might still not be enough; see this clippy issue.


dot::Id::new(name()).unwrap_or_else(|_|
bug!("failed to create graphviz node identified by {}", name())
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tweak the formatting here, as it makes it look like the closing parenthesis is for the unwrap_or_else, while it is for Id::new.

@ljedrz
Copy link
Contributor Author

ljedrz commented Sep 29, 2018

@estebank thanks for the review! I addressed your comments and fixed the test errors.

@estebank
Copy link
Contributor

estebank commented Oct 1, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Oct 1, 2018

📌 Commit 52da886 has been approved by estebank

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

bors commented Oct 1, 2018

⌛ Testing commit 52da886 with merge 20bb18dff67fd960249cfdac52b987989b8c24ae...

@bors
Copy link
Contributor

bors commented Oct 1, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 1, 2018
@rust-highfive
Copy link
Collaborator

The job dist-various-1 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:00:18] test [run-make] run-make/thumb-none-cortex-m ... FAILED
[01:00:18] 
[01:00:18] failures:
[01:00:18] 
[01:00:18] ---- [run-make] run-make/thumb-none-cortex-m stdout ----
[01:00:18] error: make failed
[01:00:18] status: exit code: 2
[01:00:18] command: "make"
[01:00:18] stdout:
---
[01:00:18] CC_armebv7r_none_eabi=arm-none-eabi-gcc
[01:00:18] S=/checkout
[01:00:18] _=/bin/sh
[01:00:18] TOOLSTATE_REPO_ACCESS_TOKEN=[secure]
[01:00:18] TRAVIS=true
[01:00:18] RUST_RELEASE_CHANNEL=nightly
[01:00:18] PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[01:00:18] RUN_MAKE_TARGETS=thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf
[01:00:18] RUSTC=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc
[01:00:18] RUST_BUILD_STAGE=stage2-thumbv6m-none-eabi
[01:00:18] BOOTSTRAP_PYTHON=/usr/bin/python2.7
[01:00:18] SCRIPT=python2.7 ../x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf src/test/run-make &&       python2.7 ../x.py dist --target asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:00:18] AR=ar
[01:00:18] TRAVIS_BRANCH=auto
[01:00:18] RUSTC_BOOTSTRAP=1
[01:00:18] HOST_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:00:18] SCCACHE_BUCKET=rust-lang-ci-sccache2
[01:00:18] PWD=/checkout/obj
[01:00:18] CI_JOB_NAME=dist-various-1
[01:00:18] TARGET_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/thumbv6m-none-eabi/lib
[01:00:18] LD_LIB_PATH_ENVVAR=LD_LIBRARY_PATH
[01:00:18] PYTHON=/usr/bin/python2.7
[01:00:18] HOME=/home/user
[01:00:18] LD_LIBRARY_PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:00:18] HOSTNAME=2c49e2caafa0
[01:00:18] CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc
[01:00:18] SHLVL=2
[01:00:18] CC= 
[01:00:18] BUILD_DIR=/checkout/obj/build
[01:00:18] BUILD_DIR=/checkout/obj/build
[01:00:18] RUST_TEST_TMPDIR=/checkout/obj/build/tmp
[01:00:18] LLVM_CXXFLAGS=
[01:00:18] STAGING_DIR=/tmp
[01:00:18] TMPDIR=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m
[01:00:18] TARGETS=asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:00:18] RUST_CONFIGURE_ARGS=--musl-root-armv5te=/musl-armv5te       --musl-root-arm=/musl-arm       --musl-root-armhf=/musl-armhf       --musl-root-armv7=/musl-armv7       --musl-root-aarch64=/musl-aarch64       --musl-root-mips=/musl-mips       --musl-root-mipsel=/musl-mipsel       --enable-emscripten       --disable-docs --set build.print-step-timings --enable-verbose-tests --enable-sccache --disable-manage-submodules --enable-locked-deps --enable-cargo-openssl-static --disable-dist-src --release-channel=nightly --enable-llvm-static-stdcpp --set rust.remap-debuginfo
[01:00:18] MAKEFLAGS=
[01:00:18] MFLAGS=
[01:00:18] BOOTSTRAP_PARENT_ID=1044
[01:00:18] BOOTSTRAP_PARENT_ID=1044
[01:00:18] __COMPAT_LAYER=RunAsInvoker
[01:00:18] CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc
[01:00:18] BUILD=x86_64-unknown-linux-gnu
[01:00:18] CXX= 
[01:00:18] AWS_ACCESS_KEY_ID=AKIAJAMV3QAMMA6AXHFQ
[01:00:18] CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
[01:00:18] CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
[01:00:18] CARGO_HOME=/cargo
[01:00:18] RUSTC_LINKER=arm-none-eabi-gcc
[01:00:18] SCCACHE_REGION=us-west-1
[01:00:18] CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc
[01:00:18] LLVM_COMPONENTS=
[01:00:18] TERM=xterm
[01:00:18] MAKELEVEL=1
[01:00:18] mkdir -p /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m
[01:00:18] cd /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m && rm -rf cortex-m
[01:00:18] cd /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m && bash -x /checkout/src/test/run-make/thumb-none-cortex-m/../git_clone_sha1.sh cortex-m https://github.com/rust-embedded/cortex-m a448e9156e2cb1e556e5441fd65426952ef4b927 
[01:00:18] Makefile:29: recipe for target 'all' failed
[01:00:18] 
[01:00:18] ------------------------------------------
[01:00:18] stderr:
[01:00:18] stderr:
[01:00:18] ------------------------------------------
[01:00:18] + PROJECT_NAME=cortex-m
[01:00:18] + URL=https://github.com/rust-embedded/cortex-m
[01:00:18] + SHA1=a448e9156e2cb1e556e5441fd65426952ef4b927
[01:00:18] + git clone https://github.com/rust-embedded/cortex-m cortex-m
[01:00:18] Cloning into 'cortex-m'...
[01:00:18] fatal: unable to access 'https://github.com/rust-embedded/cortex-m/': Could not resolve host: github.com
[01:00:18] + err_exit
[01:00:18] + echo ERROR:
[01:00:18] + exit 1
[01:00:18] make: *** [all] Error 1
[01:00:18] ------------------------------------------
[01:00:18] 
[01:00:18] 
[01:00:18] thread '[run-make] run-make/thumb-none-cortex-m' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3267:9
[01:00:18] 
[01:00:18] 
[01:00:18] failures:
[01:00:18]     [run-make] run-make/thumb-none-cortex-m
[01:00:18]     [run-make] run-make/thumb-none-cortex-m
[01:00:18] 
[01:00:18] test result: FAILED. 6 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
[01:00:18] 
[01:00:18] 
[01:00:18] 
[01:00:18] 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/thumbv6m-none-eabi/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-make" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make" "--stage-id" "stage2-thumbv6m-none-eabi" "--mode" "run-make" "--target" "thumbv6m-none-eabi" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "arm-none-eabi-gcc" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/thumbv6m-none-eabi/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:00:18] 
[01:00:18] 
[01:00:18] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf src/test/run-make
[01:00:18] Build completed unsuccessfully in 0:54:55
---
travis_time:end:15b6c8d0:start=1538377197998959269,finish=1538377198007595750,duration=8636481
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:2762a6c8
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0fa549c2
travis_time:start:0fa549c2
$ 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:0e1cbb1a
$ 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)

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 1, 2018

fatal: unable to access 'https://github.com/rust-embedded/cortex-m/': Could not resolve host: github.com

Et tu, homu?

@kennytm
Copy link
Member

kennytm commented Oct 1, 2018

@bors retry travis-ci/travis-ci#9696

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Oct 1, 2018
A few cleanups and minor improvements to rustc/infer

- use unwrap_or(_else) where applicable
- convert single-branch matches to if-let
- use to_owned instead of to_string with string literals
- improve vector allocations
- readability improvements
- miscellaneous minor code improvements
@bors
Copy link
Contributor

bors commented Oct 1, 2018

⌛ Testing commit 52da886 with merge 64ce874ff293ab4336b9b5ae6355596fcd08ced2...

@bors
Copy link
Contributor

bors commented Oct 1, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 1, 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)

@kennytm
Copy link
Member

kennytm commented Oct 1, 2018

@bors retry

An error occurred while generating the build script.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2018
bors added a commit that referenced this pull request Oct 1, 2018
Rollup of 13 pull requests

Successful merges:

 - #53784 (Document that slices cannot be larger than `isize::MAX` bytes)
 - #54308 (Better user experience when attempting to call associated functions with dot notation)
 - #54488 (in which we include attributes in unused `extern crate` suggestion spans)
 - #54544 (Indicate how to move value out of Box in docs.)
 - #54623 (Added help message for `impl_trait_in_bindings` feature gate)
 - #54641 (A few cleanups and minor improvements to rustc/infer)
 - #54656 (Correct doc for WorkQueue<T>::pop().)
 - #54674 (update miri)
 - #54676 (Remove `-Z disable_ast_check_for_mutation_in_guard`)
 - #54679 (Improve bug! message for impossible case in Relate)
 - #54681 (Rename sanitizer runtime libraries on OSX)
 - #54708 (Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own)
 - #54713 (Add nightly check for tool_lints warning)
@bors bors merged commit 52da886 into rust-lang:master Oct 1, 2018
@ljedrz ljedrz deleted the cleanup_rustc_infer branch October 1, 2018 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants