about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2020-09-21Add cfg(target_has_atomic_equal_alignment).Mara Bos-4/+15
This is needed for Atomic::from_mut.
2020-09-21Pacify tidyOliver Scherer-0/+4
2020-09-21Document future incompat lintsOliver Scherer-0/+17
2020-09-20Use precise errors during const to pat conversion instead of a catch-all on ↵Oliver Scherer-18/+52
the main constant
2020-09-20Lint on function pointers used in patternsOliver Scherer-0/+27
2020-09-20Rollup merge of #76832 - khyperia:backend_target_override, r=eddybRalf Jung-5/+7
Let backends define custom targets Add a target_override hook that takes priority over builtin targets.
2020-09-17Let backends define custom targetskhyperia-5/+7
Add a target_override hook that takes priority over builtin targets.
2020-09-17use strip_prefix over starts_with and manual slicing based on pattern length ↵Matthias Krüger-10/+10
(clippy::manual_strip)
2020-09-16Rollup merge of #76794 - richkadel:graphviz-font, r=ecstatic-morseTyler Mandry-0/+7
Make graphviz font configurable Alternative to PR #76776. To change the graphviz output to use an alternative `fontname` value, add a command line option like: `rustc --graphviz-font=monospace`. r? @ecstatic-morse
2020-09-16Added RUSTC_GRAPHVIZ_FONT environment variableRich Kadel-1/+6
Overrides the debugging_opts.graphviz_font setting.
2020-09-16Make graphviz font configurableRich Kadel-0/+2
Alternative to PR ##76776. To change the graphviz output to use an alternative `fontname` value, add a command line option like: `rustc --graphviz-font=monospace`.
2020-09-13Make const_evaluatable_unchecked lint example not depend on the architecture ↵Eric Huss-1/+1
pointer size.
2020-09-13Support `ignore` for lint examples.Eric Huss-6/+20
2020-09-13Link rustdoc lint docs to the rustdoc book.Eric Huss-125/+13
2020-09-13Auto-generate lint documentation.Eric Huss-4/+2170
2020-09-12Auto merge of #76538 - ↵bors-1/+8
fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr Warn for #[unstable] on trait impls when it has no effect. Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: https://github.com/rust-lang/rust/pull/76525#issuecomment-689678895, issue: https://github.com/rust-lang/rust/issues/55436) This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning: ``` warning: An `#[unstable]` annotation here has no effect. See issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information. --> library/std/src/panic.rs:235:1 | 235 | #[unstable(feature = "integer_atomics", issue = "32976")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` --- It detects three problems in the existing code: 1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/panic.rs#L235-L236 2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/error.rs#L392-L397 3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example: https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/alloc/src/task.rs#L36-L37 Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.
2020-09-11Turn unstable trait impl error into a lint, so it can be disabled.Mara Bos-1/+8
2020-09-10use push(char) instead of push_str(&str) to add single chars to stringsMatthias Krüger-2/+2
clippy::single-char-push-str
2020-09-10Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obkbors-0/+7
Add CONST_ITEM_MUTATION lint Fixes #74053 Fixes #55721 This PR adds a new lint `CONST_ITEM_MUTATION`. Given an item `const FOO: SomeType = ..`, this lint fires on: * Attempting to write directly to a field (`FOO.field = some_val`) or array entry (`FOO.array_field[0] = val`) * Taking a mutable reference to the `const` item (`&mut FOO`), including through an autoderef `FOO.some_mut_self_method()` The lint message explains that since each use of a constant creates a new temporary, the original `const` item will not be modified.
2020-09-09Rollup merge of #76500 - richkadel:mir-graphviz-dark, r=tmandryTyler Mandry-0/+2
Add -Zgraphviz_dark_mode and monospace font fix Many developers use a dark theme with editors and IDEs, but this typically doesn't extend to graphviz output. When I bring up a MIR graphviz document, the white background is strikingly bright. This new option changes the colors used for graphviz output to work better in dark-themed UIs. <img width="1305" alt="Screen Shot 2020-09-09 at 3 00 31 PM" src="https://user-images.githubusercontent.com/3827298/92659478-4b9bff00-f2ad-11ea-8894-b40d3a873cb9.png"> Also fixed the monospace font for common graphviz renders (e.g., VS Code extensions), as described in https://github.com/rust-lang/rust/pull/76500#issuecomment-689837948 **Before:** <img width="943" alt="Screen Shot 2020-09-09 at 2 48 44 PM" src="https://user-images.githubusercontent.com/3827298/92658939-47231680-f2ac-11ea-97ac-96727e4dd622.png"> **Now with fix:** <img width="943" alt="Screen Shot 2020-09-09 at 2 49 02 PM" src="https://user-images.githubusercontent.com/3827298/92658959-51451500-f2ac-11ea-9aae-de982d466d6a.png">
2020-09-09Rollup merge of #75094 - 0dvictor:cgu, r=oli-obkTyler Mandry-0/+2
Add `-Z combine_cgu` flag Introduce a compiler option to let rustc combines all regular CGUs into a single one at the end of compilation. Part of Issue #64191
2020-09-09Add `-Z combine_cgu` flagVictor Ding-0/+2
Introduce a compiler option to let rustc combines all regular CGUs into a single one at the end of compilation. Part of Issue #64191
2020-09-08Add -Zgraphviz_dark_modeRich Kadel-0/+2
Many developers use a dark theme with editors and IDEs, but this typically doesn't extend to graphviz output. When I bring up a MIR graphviz document, the white background is strikingly bright. This new option changes the colors used for graphviz output to work better in dark-themed UIs.
2020-09-08add tracking issue, fix rebaseBastian Kauschke-1/+1
2020-09-08convert to future compat lintBastian Kauschke-0/+11
2020-09-08Auto merge of #75138 - jumbatm:session-diagnostic-derive, r=oli-obkbors-0/+11
Add derive macro for specifying diagnostics using attributes. Introduces `#[derive(SessionDiagnostic)]`, a derive macro for specifying structs that can be converted to Diagnostics using directions given by attributes on the struct and its fields. Currently, the following attributes have been implemented: - `#[code = "..."]` -- this sets the Diagnostic's error code, and must be provided on the struct iself (ie, not on a field). Equivalent to calling `code`. - `#[message = "..."]` -- this sets the Diagnostic's primary error message. - `#[label = "..."]` -- this must be applied to fields of type `Span`, and is equivalent to `span_label` - `#[suggestion(..)]` -- this allows a suggestion message to be supplied. This attribute must be applied to a field of type `Span` or `(Span, Applicability)`, and is equivalent to calling `span_suggestion`. Valid arguments are: - `message = "..."` -- this sets the suggestion message. - (Optional) `code = "..."` -- this suggests code for the suggestion. Defaults to empty. `suggestion`also comes with other variants: `#[suggestion_short(..)]`, `#[suggestion_hidden(..)]` and `#[suggestion_verbose(..)]` which all take the same keys. Within the strings passed to each attribute, fields can be referenced without needing to be passed explicitly into the format string -- eg, `#[error = "{ident} already declared"] ` will set the error message to `format!("{} already declared", &self.ident)`. Any fields on the struct can be referenced in this way. Additionally, for any of these attributes, Option fields can be used to only optionally apply the decoration -- for example: ```rust #[derive(SessionDiagnostic)] #[code = "E0123"] struct SomeKindOfError { ... #[suggestion(message = "informative error message")] opt_sugg: Option<(Span, Applicability)> ... } ``` will not emit a suggestion if `opt_sugg` is `None`. We plan on iterating on this macro further; this PR is a start. Closes #61132. r? `@oli-obk`
2020-09-07Add CONST_ITEM_MUTATION lintAaron Hill-0/+7
Fixes #74053 Fixes #55721 This PR adds a new lint `CONST_ITEM_MUTATION`. Given an item `const FOO: SomeType = ..`, this lint fires on: * Attempting to write directly to a field (`FOO.field = some_val`) or array entry (`FOO.array_field[0] = val`) * Taking a mutable reference to the `const` item (`&mut FOO`), including through an autoderef `FOO.some_mut_self_method()` The lint message explains that since each use of a constant creates a new temporary, the original `const` item will not be modified.
2020-09-04Auto merge of #76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandrybors-0/+9
Tools, tests, and experimenting with MIR-derived coverage counters Leverages the new mir_dump output file in HTML+CSS (from #76074) to visualize coverage code regions and the MIR features that they came from (including overlapping spans). See example below. The `run-make-fulldeps/instrument-coverage` test has been refactored to maximize test coverage and reduce code duplication. The new tests support testing with and without `-Clink-dead-code`, so Rust coverage can be tested on MSVC (which, currently, only works with `link-dead-code` _disabled_). New tests validate coverage region generation and coverage reports with multiple counters per function. Starting with a simple `if-else` branch tests, coverage tests for each additional syntax type can be added by simply dropping in a new Rust sample program. Includes a basic, MIR-block-based implementation of coverage injection, available via `-Zexperimental-coverage`. This implementation has known flaws and omissions, but is simple enough to validate the new tools and tests. The existing `-Zinstrument-coverage` option currently enables function-level coverage only, which at least appears to generate accurate coverage reports at that level. Experimental coverage is not accurate at this time. When branch coverage works as intended, the `-Zexperimental-coverage` option should be removed. This PR replaces the bulk of PR #75828, with the remaining parts of that PR distributed among other separate and indentpent PRs. This PR depends on two of those other PRs: #76002, #76003 and #76074 Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation ![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif) r? @tmandry FYI: @wesleywiser
2020-09-03Tools, tests, and experimenting with MIR-derived coverage countersRich Kadel-0/+9
Adds a new mir_dump output file in HTML/CSS to visualize code regions and the MIR features that they came from (including overlapping spans). See example below: Includes a basic, MIR-block-based implementation of coverage injection, available via `-Zexperimental-coverage`. This implementation has known flaws and omissions, but is simple enough to validate the new tools and tests. The existing `-Zinstrument-coverage` option currently enables function-level coverage only, which at least appears to generate accurate coverage reports at that level. Experimental coverage is not accurate at this time. When branch coverage works as intended, the `-Zexperimental-coverage` option should be removed. This PR replaces the bulk of PR #75828, with the remaining parts of that PR distributed among other separate and indentpent PRs. This PR depends on three of those other PRs: #76000, #76002, and Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation ![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-09-02pretty: trim paths of unique symbolsDan Aloni-1/+26
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-09-02rustc_{errors,session}: add `delay_good_path_bug`Dan Aloni-0/+18
The first use case of this detection of regression for trimmed paths computation, that is in the case of rustc, which should be computed only in case of errors or warnings. Our current user of this method is deeply nested, being a side effect from `Display` formatting on lots of rustc types. So taking only the caller to the error message is not enough - we should collect the traceback instead.
2020-09-01Rollup merge of #76158 - mati865:self-contained-option, r=petrochenkovTyler Mandry-3/+3
Stabilise link-self-contained option MCP has been accepted: https://github.com/rust-lang/compiler-team/issues/343 I'll add improved heuristic in next PR.
2020-09-01Add SessionDiagnostic derive macro.jumbatm-0/+11
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-08-31Add new `-Z dump-mir-spanview` optionRich Kadel-0/+51
Similar to `-Z dump-mir-graphviz`, this adds the option to write HTML+CSS files that allow users to analyze the spans associated with MIR elements (by individual statement, just terminator, or overall basic block). This PR was split out from PR #76004, and exposes an API for spanview HTML+CSS files that is also used to analyze code regions chosen for coverage instrumentation (in a follow-on PR). Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-08-31Rollup merge of #76002 - richkadel:llvm-coverage-map-gen-6b.3, r=tmandryTyler Mandry-30/+41
Fix `-Z instrument-coverage` on MSVC Found that `-C link-dead-code` (which was enabled automatically under `-Z instrument-coverage`) was causing the linking error that resulted in segmentation faults in coverage instrumented binaries. Link dead code is now disabled under MSVC, allowing `-Z instrument-coverage` to be enabled under MSVC for the first time. More details are included in Issue #76038 . Note this PR makes it possible to support `Z instrument-coverage` but does not enable instrument coverage for MSVC in existing tests. It will be enabled in another PR to follow this one (both PRs coming from original PR #75828). r? @tmandry FYI: @wesleywiser
2020-08-31Fix `-Z instrument-coverage` on MSVCRich Kadel-30/+41
Found that -C link-dead-code (which was enabled automatically under -Z instrument-coverage) was causing the linking error that resulted in segmentation faults in coverage instrumented binaries. Link dead code is now disabled under MSVC, allowing `-Z instrument-coverage` to be enabled under MSVC for the first time. More details are included in Issue #76038. (This PR was broken out from PR #75828)
2020-09-01Auto merge of #75931 - estebank:suggest-if-let, r=petrochenkovbors-0/+4
Suggest `if let x = y` when encountering `if x = y` Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-08-31Rollup merge of #76075 - marmeladema:remove-once-cell-crate, r=matkladAleksey Kladov-0/+1
datastructures: replace `once_cell` crate with an impl from std Fixes #75700 r? @matklad We might need a perf run for this change.
2020-08-31Stabilise link-self-contained optionMateusz Mikuła-3/+3
2020-08-30Add `-Z proc-macro-backtrace` to allow showing proc-macro panicsAaron Hill-0/+2
Fixes #75050 Previously, we would unconditionally suppress the panic hook during proc-macro execution. This commit adds a new flag -Z proc-macro-backtrace, which allows running the panic hook for easier debugging.
2020-08-30Suggest `if let x = y` when encountering `if x = y`Esteban Küber-0/+4
Detect potential cases where `if let` was meant but `let` was left out. Fix #44990.
2020-08-30datastructures: replace `once_cell` crate with an impl from stdmarmeladema-0/+1
2020-08-30mv compiler to compiler/mark-0/+6946