about summary refs log tree commit diff
path: root/src/librustc
AgeCommit message (Collapse)AuthorLines
2018-08-03Auto merge of #51657 - wesleywiser:wip_profiling, r=eddybbors-1/+306
Implement a self profiler This is a work in progress implementation of #50780. I'd love feedback on the overall structure and code as well as some specific things: - [The query categorization mechanism](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-19e0a69c10eff31eb2d16805e79f3437R101). This works but looks kind of ugly to me. Perhaps there's a better way? - [The profiler assumes only one activity can run at a time](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-f8a403b2d88d873e4b27c097c614a236R177). This is obviously incompatible with the ongoing parallel queries. - [The output code is just a bunch of `format!()`s](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-f8a403b2d88d873e4b27c097c614a236R91). Is there a better way to generate markdown or json in the compiler? - [The query categorizations are likely wrong](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-19e0a69c10eff31eb2d16805e79f3437R101). I've marked what seemed obvious to me but I'm sure I got a lot of them wrong. The overhead currently seems very low. Running `perf` on a sample compilation with profiling enabled reveals: ![image](https://user-images.githubusercontent.com/831192/41657821-9775efec-7462-11e8-9e5e-47ec94105d9d.png)
2018-08-02Generate self-profiler types with macrosWesley Wiser-130/+91
2018-08-02Fix tidyWesley Wiser-12/+25
2018-08-02Remove some dead codeWesley Wiser-17/+1
2018-08-02Include additional data in the json outputWesley Wiser-3/+12
2018-08-02Include query hits/totalsWesley Wiser-3/+10
2018-08-02Refactor json printingWesley Wiser-35/+21
2018-08-02First pass at json outputWesley Wiser-0/+52
2018-08-02Fix more missed query dataWesley Wiser-0/+9
2018-08-02Remove redundant s in outputWesley Wiser-1/+1
2018-08-02Fix some missed query dataWesley Wiser-4/+3
2018-08-02Switch to markdown outputWesley Wiser-12/+15
2018-08-02Add units to timesWesley Wiser-1/+1
2018-08-02Basic incremental statsWesley Wiser-9/+55
2018-08-02Basic profilingWesley Wiser-1/+237
2018-08-02Auto merge of #52841 - petrochenkov:premacro, r=alexcrichtonbors-0/+8
resolve: Implement prelude search for macro paths, implement tool attributes When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details. "Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude. This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope. The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order. If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway). Fixes https://github.com/rust-lang/rust/issues/52576 Fixes https://github.com/rust-lang/rust/issues/52512 Fixes https://github.com/rust-lang/rust/issues/51277 cc https://github.com/rust-lang/rust/issues/52269
2018-08-02Auto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichtonbors-14/+7
Switch to bootstrapping from 1.29 beta r? @alexcrichton
2018-08-02When we turn on NLL migration in the 2018 edition, we need two-phase borrows ↵Felix S. Klock II-3/+11
too! Fix #52967.
2018-08-01Switch to bootstrapping from 1.29 betaMark Rousskov-14/+7
2018-08-01Split out growth functionality into BitVector typeMark Rousskov-7/+7
2018-08-01resolve: Implement prelude search for macro pathsVadim Petrochenkov-0/+8
resolve/expansion: Implement tool attributes
2018-08-01Auto merge of #52937 - pietroalbini:rollup, r=pietroalbinibors-29/+92
Rollup of 30 pull requests Successful merges: - #52340 (Document From trait implementations for OsStr, OsString, CString, and CStr) - #52628 (Cleanup some rustdoc code) - #52732 (Remove unstable and deprecated APIs) - #52745 (Update clippy to latest master) - #52771 (Clarify thread::park semantics) - #52778 (Improve readability of serialize.rs) - #52810 ([NLL] Don't make "fake" match variables mutable) - #52821 (pretty print for std::collections::vecdeque) - #52822 (Fix From<LocalWaker>) - #52824 (Fix -Wpessimizing-move warnings in rustllvm/PassWrapper) - #52825 (Make sure #47772 does not regress) - #52831 (remove references to AUTHORS.txt file) - #52842 (update comment) - #52846 (Add timeout to use of `curl` in bootstrap.py.) - #52851 (Make the tool_lints actually usable) - #52853 (Improve bootstrap help on stages) - #52859 (Use Vec::extend in SmallVec::extend when applicable) - #52861 (Add targets for HermitCore (https://hermitcore.org) to the Rust compiler and port libstd to it.) - #52867 (releases.md: fix 2 typos) - #52870 (Implement Unpin for FutureObj and LocalFutureObj) - #52876 (run-pass/const-endianness: negate before to_le()) - #52878 (Fix wrong issue number in the test name) - #52883 (Include lifetime in mutability suggestion in NLL messages) - #52888 (Use suggestions for shell format arguments) - #52904 (NLL: sort diagnostics by span) - #52905 (Fix a typo in unsize.rs) - #52907 (NLL: On "cannot move out of type" error, print original before rewrite) - #52914 (Only run the sparc-abi test on sparc) - #52918 (Backport 1.27.2 release notes) - #52929 (Update compatibility note for 1.28.0 to be correct) Failed merges: r? @ghost
2018-08-01Rollup merge of #52851 - flip1995:tool_lints, r=oli-obkPietro Albini-29/+92
Make the tool_lints actually usable cc #44690 Necessary for rust-lang-nursery/rust-clippy#2955 and rust-lang-nursery/rust-clippy#2977 This PR makes it possible for lint tools (at the moment only for Clippy) to implement the `tool_lints`, like it was documented in #52018. Because the `declare_lint` macro is pretty cluttered right now, there was not really a good way to add the `tool_name` as an additional argument of the macro. That's why I chose to introduce the new `declare_tool_lint` macro. The switch from `&str` to `String` in the `lint_groups` `FxHashMap` is because I got weird error messages in the `check_lint_name` method. And the `by_name` field of the `LintStore` also uses `String`. ### What comes with this PR: If this PR lands and Clippy switches to the `tool_lints`, the currently used methods ```rust #[cfg_attr(feature = "cargo-clippy", allow(clippy_lint))] #[allow(unknown_lints, clippy_lint)] ``` to `allow`/`warn`/`deny`/`forbid` Clippy lints, won't have any effects anymore, but also won't produce a warning. That is because the name of `clippy_lint` will then be `clippy::clippy_lint`. (Maybe we can add a clippy lint to search for `cfg_attr` appearances with the `cargo-clippy` feature?) r? @oli-obk
2018-08-01Auto merge of #52756 - alexcrichton:cap-applicable, r=oli-obkbors-14/+16
rustc: Disallow machine applicability in foreign macros Recent changes to lints disallowed lints from being emitted against code located in foreign macros, except for future-incompatible lints. For a future incompatible lint, however, the automatic suggestions may not be applicable! This commit updates this code path to force all applicability suggestions made to foreign macros to never be `MachineApplicable`. This should avoid rustfix actually attempting fixing these suggestions, causing non-compiling code to be produced. Closes rust-lang/cargo#5799
2018-07-31assert no region obligations on entering custom type opNiko Matsakis-0/+13
Fixes #51649
2018-07-30rustc: Disallow machine applicability in foreign macrosAlex Crichton-14/+16
Recent changes to lints disallowed lints from being emitted against code located in foreign macros, except for future-incompatible lints. For a future incompatible lint, however, the automatic suggestions may not be applicable! This commit updates this code path to force all applicability suggestions made to foreign macros to never be `MachineApplicable`. This should avoid rustfix actually attempting fixing these suggestions, causing non-compiling code to be produced. Closes rust-lang/cargo#5799
2018-07-30Explain that the tool is responsible for unknown tool_lintsflip1995-3/+4
2018-07-30Check if the lint_name is from a tool and if the tool_lint existsflip1995-29/+71
2018-07-30Auto merge of #52830 - matthewjasper:bootstrap-prep, r=matthewjasperbors-3/+3
[NLL] Fix some things for bootstrap Some changes that are required when bootstrapping rustc with NLL enabled. * Remove a bunch of unused `mut`s that aren't needed, but the existing lint doesn't catch. * Rewrite a function call to satisfy NLL borrowck. Note that the borrow is two-phase, but gets activated immediately by an unsizing coercion. cc #51823
2018-07-30Introduce the declare_tool_lint macroflip1995-0/+20
2018-07-30Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkovbors-90/+85
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-26/+17
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Sanity-check all constantsOliver Schneider-6/+22
2018-07-29Remove unused `mut`sMatthew Jasper-3/+3
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-26/+17
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-28/+28
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-29Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakisbors-10/+11
Misc cleanups
2018-07-28Auto merge of #52355 - pietroalbini:zfeature, r=eddybbors-0/+3
Add the -Zcrate-attr=foo unstable rustc option This PR adds a new unstable option to `rustc`: `-Zcrate-attr=foo`. The option can be used to inject crate-level attributes from the CLI, and it's meant to be used by tools like Crater that needs to add their own attributes to a crate without changing the source code. The exact reason I need this is to implement "edition runs" in Crater: we need to add the preview feature flag to every crate, and editing the crates' source code on the fly might produce unexpected results, while a compiler flag is more reliable. cc https://github.com/rust-lang-nursery/crater/issues/282 @Mark-Simulacrum
2018-07-28Auto merge of #52546 - nikomatsakis:issue-52050, r=pnkfelixbors-22/+79
do not overwrite child def-id in place but rather remove/insert When inserting a node N into the tree of impls, we sometimes find than an existing node C should be replaced with N. We used to overwrite C in place with the new def-id N -- but since the lists of def-ids are separated by simplified type, that could lead to N being inserted in the wrong place. This meant we might miss conflicts. We are now not trying to be so smart -- we remove C and then add N later. Fixes #52050 r? @aturon -- do you still remember this code at all? :)
2018-07-28Don't format!() string literalsljedrz-90/+85
2018-07-28Auto merge of #52711 - eddyb:unsized-manuallydrop, r=nikomatsakisbors-2/+11
Change ManuallyDrop<T> to a lang item. This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`). A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`. r? @nikomatsakis
2018-07-28Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakiskennytm-5/+5
Use a slice where a vector is not necessary
2018-07-28Rollup merge of #52765 - sinkuu:remove_nonzeroing_move_opt, r=pnkfelixkennytm-9/+0
Remove unused "-Zenable_nonzeroing_move_hints" flag Removing a dead option which seems to be a remnant of the old drop-flag system.
2018-07-28Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakiskennytm-14/+7
Improve a few vectors - calculate capacity or build from iterators Collecting from iterators improves readability and tailoring vector capacities should be beneficial in terms of performance.
2018-07-27Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrumbors-2/+0
Rollup of bare_trait_objects PRs All deny attributes were moved into bootstrap so they can be disabled with a line of config. Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free. r? @Mark-Simulacrum cc @ljedrz @kennytm
2018-07-27Add the -Zcrate-attr=foo nightly rustc flag to inject crate attributesPietro Albini-0/+3
2018-07-27Use slices where a vector is not necessaryljedrz-5/+5
2018-07-27Better Option handlingShotaro Yamada-7/+9
2018-07-27Remove unnecessary `.collect()`Shotaro Yamada-1/+1
2018-07-27Use str::repeatShotaro Yamada-2/+1