Commit Graph

283 Commits

Author SHA1 Message Date
Alex Crichton
255cc1aed3 rustc: Request ansi colors if stderr isn't a tty
Currently Cargo will always capture the output of rustc meaning that
rustc is never hooked up to a tty. To retain colors Cargo uses the
`fwdansi` crate to ensure that ansi color codes are translated to
windows terminal methods (and ansi codes otherwise just go their natural
route on Unix).

Cargo passes `--color always` to rustc to ensure that using a pipe
doesn't trick it into not emitting colors at all. It turns out, however,
that `--color always` ends up still accidentally using the native shell
api on native windows shells.

The fix here is to instead pass `AlwaysAnsi` to `termcolor` instead of
`Always`, ensuring that when `--color always` is passed to rustc and its
output isn't a terminal, we're always generating ansi colors regardless
of the platform.

Closes #55769
2018-11-08 07:53:03 -08:00
ljedrz
9ff0f33748 Pass suggestions as impl Iterator instead of Vec 2018-10-31 13:56:20 +01:00
David Lavati
6c9f6a1afd Rename other occs of (Code/File)Map to Source(Map/File) #51574 2018-10-29 21:26:13 +01:00
bors
ca2639e82e Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasper
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations

The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`.

An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
2018-10-20 11:22:48 +00:00
Oliver Scherer
ab3f37ec43 Free some memory instead of just dropping elements 2018-10-19 14:34:44 +02:00
Oliver Scherer
3c9258e604 Prefer Default::default over FxHash*::default in struct constructors 2018-10-19 14:34:44 +02:00
Oliver Scherer
ee81739dc1 Deprecate the FxHashMap() and FxHashSet() constructor function hack 2018-10-19 14:34:44 +02:00
ljedrz
d28aed6dc4 Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
ljedrz
a01a994231 A handful of random string-related improvements 2018-10-10 10:39:18 +02:00
Josh Stone
ce034951fb Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
bors
992d1e4d3d Auto merge of #54241 - vi:suggest_with_applicability, r=estebank
Remove usages of span_suggestion without Applicability

Use `Applicability::Unspecified` for all of them instead.

Shall deprecations for the non-`_with_applicability` functions be added?

Shall clippy be addressed somehow?

r? @estebank
2018-09-20 06:34:22 +00:00
David Wood
874e08bdd8
Log when buffering a diagnostic.
This is useful in debugging when and where errors are emitted in
logs.
2018-09-18 13:45:24 +02:00
Vitaly _Vi Shukela
d0790c490a
Whitespace fix again. 2018-09-17 20:26:05 +03:00
Vitaly _Vi Shukela
15982fe369
Better trick for allowing trailing comma at forward! 2018-09-17 16:33:37 +03:00
Felix S. Klock II
82e1750414 Add -Z dont-buffer-diagnostics, a way to force NLL to immediately emit its diagnostics.
This is mainly intended for `rustc` developers who want to see a
diagnostic in its original context in the control flow.  Two uses
cases for that are:

 * `-Z treat-err-as-bug` which then allows extraction of a stack-trace to the origin of the error
   (a case that is so important that we make that flag imply this one, effectively).

 * `RUST_LOG=... rustc`, in which case it is often useful to see the logging statements that
   occurred immediately prior to the point where the diagnostic was signalled.

Drive-by: Added some documentation pointing future devs at
HandlerFlags, and documented the fields of `HandlerFlags` itself.
2018-09-17 14:30:01 +02:00
Vitaly _Vi Shukela
0ad1c0e369
Change diagnostic_builder's forward! macro to enforce trailing argument comma 2018-09-17 02:50:00 +03:00
Vitaly _Vi Shukela
6ebb9161ea
Fix style according to review comments. 2018-09-17 02:49:27 +03:00
Vitaly _Vi Shukela
3be24c6647
trailing whitespace fix 2018-09-16 21:43:07 +03:00
Vitaly _Vi Shukela
959fc6116a
Deprecate *_suggestion* that are without explicit applicability 2018-09-16 21:43:06 +03:00
Vitaly _Vi Shukela
2f5cb6dbdc
Add multipart_suggestion_with_applicability 2018-09-16 21:43:06 +03:00
kennytm
33bc6c3dae
Rollup merge of #54024 - alexcrichton:compile-to-wasm, r=petrochenkov
Fix compiling some rustc crates to wasm

I was dabbling recently seeing what it would take to compile `rustfmt` to the
`wasm32-unknown-unknown` target and it turns out not much effort is needed!
Currently `rustfmt` depends on a few rustc crates published to crates.io, so
this commit touches up those crates to compile for wasm themselves. Notably:

* The `rustc_data_structures` crate's `flock` implementation is stubbed out to
  unconditionally return errors on unsupported platforms.
* The `rustc_errors` crate is extended to not do any locking for all non-windows
  platforms.

In both of these cases if we port the compiler to new platforms the
functionality isn't critical but will be discovered over time as it comes up, so
this hopefully doesn't make it too too hard to compile to new platforms!
2018-09-14 14:50:10 +08:00
toidiu
731f4efae5 stabalize infer outlives requirements (RFC 2093).
Co-authored-by: nikomatsakis
2018-09-11 11:40:04 -04:00
Alex Crichton
0c89243fd3 Fix compiling some rustc crates to wasm
I was dabbling recently seeing what it would take to compile `rustfmt` to the
`wasm32-unknown-unknown` target and it turns out not much effort is needed!
Currently `rustfmt` depends on a few rustc crates published to crates.io, so
this commit touches up those crates to compile for wasm themselves. Notably:

* The `rustc_data_structures` crate's `flock` implementation is stubbed out to
  unconditionally return errors on unsupported platforms.
* The `rustc_errors` crate is extended to not do any locking for all non-windows
  platforms.

In both of these cases if we port the compiler to new platforms the
functionality isn't critical but will be discovered over time as it comes up, so
this hopefully doesn't make it too too hard to compile to new platforms!
2018-09-07 08:17:02 -07:00
Mark Rousskov
9ec5ef541a Breaking change upgrades 2018-09-04 13:22:08 -06:00
Pietro Albini
78d5509625
Rollup merge of #53786 - frewsxcv:frewsxcv-bad-style, r=Manishearth
Replace usages of 'bad_style' with 'nonstandard_style'.

`bad_style` is being deprecated in favor of `nonstandard_style`:

- https://github.com/rust-lang/rust/issues/41646
2018-08-30 20:15:47 +02:00
Corey Farwell
e477a13d63 Replace usages of 'bad_style' with 'nonstandard_style'.
`bad_style` is being deprecated in favor of `nonstandard_style`:

- https://github.com/rust-lang/rust/issues/41646
2018-08-29 09:01:35 -05:00
Eduard-Mihai Burtescu
93f3f5b155 Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. 2018-08-28 17:04:04 +03:00
bors
70a21e89f1 Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis
fix for late-bound regions

Fix for https://github.com/rust-lang/rust/issues/53419

r? @nikomatsakis
2018-08-27 17:42:45 +00:00
Niko Matsakis
73fb1622b3 check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
Matthias Krüger
ede1f7d2a5 use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() 2018-08-23 10:14:52 +02:00
Donato Sciarra
6138c82803 fix tidy errors 2018-08-19 23:01:01 +02:00
Donato Sciarra
cbd0595710 mv filemap source_file 2018-08-19 23:00:59 +02:00
Donato Sciarra
d6dcbcd4e1 mv FileMap SourceFile 2018-08-19 23:00:59 +02:00
Donato Sciarra
c655473378 mv CodeMap SourceMap 2018-08-19 23:00:59 +02:00
kennytm
62d70c9d47
Rollup merge of #53214 - memoryruins:nll_bootstrap_2, r=nikomatsakis
[nll] enable feature(nll) on various crates for bootstrap: part 2

#53172
2018-08-10 01:01:31 +08:00
memoryruins
80e8e97d93 [nll] librustc_errors: enable feature(nll) for bootstrap 2018-08-09 04:08:45 -04:00
ljedrz
44d32d4413 Avoid unnecessary pattern matching against Option and Result 2018-08-07 10:24:27 +02:00
Alex Crichton
ca762ba954 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-30 07:48:59 -07:00
bors
a5c2d0fffa Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakis
Misc cleanups
2018-07-29 06:32:24 +00:00
kennytm
59f8422a17
Rollup merge of #52781 - ljedrz:avoid_vec_arguments, r=nikomatsakis
Use a slice where a vector is not necessary
2018-07-28 16:25:07 +08:00
bors
4f1e235744 Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrum
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-27 20:27:40 +00:00
ljedrz
1cca420435 Use slices where a vector is not necessary 2018-07-27 16:50:28 +02:00
Shotaro Yamada
8296699fae Remove unnecessary .collect() 2018-07-27 23:26:36 +09:00
Shotaro Yamada
3525368a56 Use str::repeat 2018-07-27 23:26:36 +09:00
bors
b18b9edf00 Auto merge of #52681 - pnkfelix:z-borrowck-migrate, r=nikomatsakis
Add `-Z borrowck=migrate`

This adds `-Z borrowck=migrate`, which represents the way we want to migrate to NLL under Rust versions to come. It also hooks this new mode into `--edition 2018`, which means we're officially turning NLL on in the 2018 edition.

The basic idea of `-Z borrowck=migrate` that there are cases where NLL is fixing old soundness bugs in the borrow-checker, but in order to avoid just breaking code by immediately rejecting the programs that hit those soundness bugs, we instead use the following strategy:

If your code is accepted by NLL, then we accept it.
If your code is rejected by both NLL and the old AST-borrowck, then we reject it.
If your code is rejected by NLL but accepted by the old AST-borrowck, then we emit the new NLL errors as **warnings**.

These warnings will be turned into hard errors in the future, and they say so in these diagnostics.

Fix #46908
2018-07-27 09:10:07 +00:00
Felix S. Klock II
a23e8a726c Add -Z borrowck=migrate flag, use it to link NLL up to AST-borrowck. 2018-07-26 13:17:55 +02:00
ljedrz
f653bf4fba Improve readability in a few sorts 2018-07-25 12:13:02 +02:00
Tatsuyuki Ishi
e098985939 Deny bare_trait_objects globally 2018-07-25 10:25:29 +09:00
Santiago Pastorino
3d3e0aa571 Buffer errors in MIR borrow check
(pnkfelix updated to address tidy, and to change the buffer from
`Vec<DiagnosticBuilder<'errs>>` to a `Vec<Diagnostic>` in order to
avoid painful lifetime maintenance.)
2018-07-23 14:20:12 +02:00
bors
02b0479c26 Auto merge of #52568 - oli-obk:span_bug_error, r=varkor
Fix loop label resolution around constants

And make `delay_span_bug` a little more helpful

r? @varkor

fixes #52442
fixes #52443
2018-07-23 01:02:32 +00:00