Commit graph

153613 commits

Author SHA1 Message Date
Frank Steffahn
90354c719a Make explanations of cross-references between make_mut and get_mut more accurate 2021-08-24 21:34:12 +02:00
Frank Steffahn
335bf7ca6b Clarifiy weak pointers being diassociated…
…noting the fact that `clone` is not called.

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2021-08-24 21:17:20 +02:00
Eduard-Mihai Burtescu
edb4b2d8c2 Morph layout_raw query into layout_of. 2021-08-24 22:04:27 +03:00
Andreas Liljeqvist
f17e384a43 use convention for with_* methods 2021-08-24 19:41:58 +02:00
bors
0599f34033 Auto merge of #87472 - inquisitivecrystal:stabilize-force-warn, r=Mark-Simulacrum
Stabilize and document `--force-warn`

This PR will stabilize and document the `--force-warn` command line option. It is currently a draft, pending an FCP.

I've taken the liberty of tidying up the lint level command line options a bit as part of this. The changes are quite minor and should only affect rustc's help output. I'm making them here because they're trivial and, in one case, necessary to unify the way `--force-warn` with the way the other options are displayed.

I also want to mention that `@rylev` has done a ton of work on moving this along and deserves most of the credit. I'm just the one who landed up writing this particular PR.

Resolves #86516.
2021-08-24 17:41:24 +00:00
Ian Jackson
db13636f03 Stabilise BufWriter::into_parts
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 18:26:18 +01:00
Eduard-Mihai Burtescu
b4fcf1b1dc tests: add v0 structural const value demangling test. 2021-08-24 20:11:49 +03:00
Eduard-Mihai Burtescu
af002c1524 tests: add v0 &str const value demangling test. 2021-08-24 20:11:49 +03:00
Eduard-Mihai Burtescu
f8810ee171 Update rustc-demangle to 0.1.21. 2021-08-24 19:53:20 +03:00
Ian Jackson
7b5c0ecb3d Fix tidy
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 17:45:53 +01:00
Eduard-Mihai Burtescu
755385cd4f tests: shorten symbol-names/const-generics-demangling output. 2021-08-24 19:07:51 +03:00
Eduard-Mihai Burtescu
f60d333aff tests: support -Zsymbol-mangling-version=v0 being the default. 2021-08-24 19:07:50 +03:00
Eduard-Mihai Burtescu
cb7890e791 rustc_symbol_mangling: support structural constants and &str in v0. 2021-08-24 19:07:50 +03:00
Eduard-Mihai Burtescu
948f19ea8f Fix typo (variant_id should've been variant_idx). 2021-08-24 19:07:50 +03:00
Eduard-Mihai Burtescu
eec84b31fb rustc_symbol_mangling: never cache placeholders in print_const. 2021-08-24 19:07:50 +03:00
Eduard-Mihai Burtescu
e291234f59 Pretty-print uninhabited const values more explicitly. 2021-08-24 19:07:50 +03:00
est31
8f7007991e Fix grammar 2021-08-24 17:56:39 +02:00
Ian Jackson
4c0203eb4b io::ErrorKind: rationalise ordering in main enum
It is useful to keep some coherent structure to this ordering.  In
particular, Other and Uncategorized should be next to each other, at
the end.

Also it seems to make sense to treat UnexpectedEof and OutOfMemory
specially, since they are not like the other errors (despite
OutOfMemory also being generatable by some OS errors).

So:
 * Move Other to the end, just before Uncategorized
 * Move Unsupported to between Interrupted and UnexpectedEof
 * Add some comments documenting where to add things

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 16:53:58 +01:00
Ian Jackson
54df693dd7 io::Error: alphabeticise the match in as_str()
There was no rationale for the previous ordering.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-08-24 16:51:58 +01:00
inquisitivecrystal
1f3170cf16 Update tests
This updates tests to reflect that `force-warn` is now stable.
2021-08-24 11:39:22 -04:00
inquisitivecrystal
228a5f4096 Document force-warn
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2021-08-24 11:21:49 -04:00
inquisitivecrystal
aee2c30f69 Stabilize force-warn 2021-08-24 11:19:55 -04:00
inquisitivecrystal
d89b4a705c Tidy up lint command line flags 2021-08-24 11:19:55 -04:00
bors
b5fe3bc065 Auto merge of #87900 - jackh726:issue-87429, r=nikomatsakis
Use bound vars for GAT params in param_env in check_type_bounds

Fixes #87429
2021-08-24 14:55:48 +00:00
asquared31415
0b81c2eb82 Move named_asm_labels to a HIR lint 2021-08-24 08:23:58 -04:00
Andy Wang
7ed9f2e6aa
Ignore test on Windows 2021-08-24 13:21:27 +01:00
bors
47ab5f7ce2 Auto merge of #87699 - ubamrein:use-iphone-deployment-target-for-llvm, r=petrochenkov
Allow specifying an deployment target version for all iOS llvm targets

Closes: https://github.com/rust-lang/rust/issues/79408

This pull requests adds the same procedure to define the iOS-version for the LLVM-target as was used for the simulator target and the desktop target.

This then closes the original problem mentioned in the above issue. The problem with incompatible bitcode remains, but is probably not easy fixable.

I realised that something is still not right. Try to fix that.

r? `@petrochenkov`
2021-08-24 12:13:37 +00:00
Tomasz Miąsko
9f6f8620e1 Improve liveness analysis for generators
Liveness analysis for generators assumes that execution always continues
normally after a yield point, not accounting for the fact that generator
could be dropped before completion.

If generators captures any variables by reference, those variables could
be used within a generator, or when the generator completes, but also
after each yield point in the case the generator is dropped.

Account for the case when generator is dropped after yielding, but
before running to the completion. This effectively considers all
variables captured by reference to be used after a yield point.
2021-08-24 13:31:11 +02:00
Andreas Liljeqvist
e3f07b2e30 Force inline: small functions and single call-site 2021-08-24 10:18:07 +02:00
Patrick Amrein
8f65d154c8 allow specifying an ios version for the llvm target 2021-08-24 08:23:05 +02:00
bors
f66e825f73 Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`

Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-24 03:58:22 +00:00
Eric Huss
2af3b20ad8 Update books 2021-08-23 19:42:31 -07:00
bors
5ca596f486 Auto merge of #85556 - FabianWolff:issue-85071, r=estebank,jackh726
Warn about unreachable code following an expression with an uninhabited type

This pull request fixes #85071. The issue is that liveness analysis currently is "smarter" than reachability analysis when it comes to detecting uninhabited types: Unreachable code is detected during type checking, where full type information is not yet available. Therefore, the check for type inhabitedness is quite crude:
fc81ad22c4/compiler/rustc_typeck/src/check/expr.rs (L202-L205)

i.e. it only checks for `!`, but not other, non-trivially uninhabited types, such as empty enums, structs containing an uninhabited type, etc. By contrast, liveness analysis, which runs after type checking, can benefit from the more sophisticated `tcx.is_ty_uninhabited_from()`:
fc81ad22c4/compiler/rustc_passes/src/liveness.rs (L981)
fc81ad22c4/compiler/rustc_passes/src/liveness.rs (L996)

This can lead to confusing warnings when a variable is reported as unused, but the use of the variable is not reported as unreachable. For instance:
```rust
enum Foo {}
fn f() -> Foo {todo!()}

fn main() {
    let x = f();
    let _ = x;
}
```
currently leads to
```
warning: unused variable: `x`
 --> t1.rs:5:9
  |
5 |     let x = f();
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted
```
which is confusing, because `x` _appears_ to be used in line 6. With my changes, I get:
```
warning: unreachable expression
 --> t1.rs:6:13
  |
5 |     let x = f();
  |             --- any code following this expression is unreachable
6 |     let _ = x;
  |             ^ unreachable expression
  |
  = note: `#[warn(unreachable_code)]` on by default
note: this expression has type `Foo`, which is uninhabited
 --> t1.rs:5:13
  |
5 |     let x = f();
  |             ^^^

warning: unused variable: `x`
 --> t1.rs:5:9
  |
5 |     let x = f();
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted
```
My implementation is slightly inelegant because unreachable code warnings can now be issued in two different places (during type checking and during liveness analysis), but I think it is the solution with the least amount of unnecessary code duplication, given that the new warning integrates nicely with liveness analysis, where unreachable code is already implicitly detected for the purpose of finding unused variables.
2021-08-24 01:36:09 +00:00
Frank Steffahn
6248dbcf70 Also fix “a OwningRef 2021-08-24 02:28:38 +02:00
Frank Steffahn
b823dc1bbd Also fix “a RwLock*” 2021-08-24 02:24:35 +02:00
Frank Steffahn
04fa1d81dd Fix typo “a Rc” → “an Rc” 2021-08-24 02:23:16 +02:00
Jacob Pratt
bc33861c22
Fix references to ControlFlow in docs 2021-08-23 20:02:17 -04:00
bors
de42550d0a Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay
Get piece unchecked in `write`

We already use specialized `zip`, but it seems like we can do a little better by not checking `pieces` length at all.

`Arguments` constructors are now unsafe. So the `format_args!` expansion now includes an `unsafe` block.

<details>
<summary>Local Bench Diff</summary>

```text
 name                        before ns/iter  after ns/iter  diff ns/iter   diff %  speedup
 fmt::write_str_macro1       22,967          19,718               -3,249  -14.15%   x 1.16
 fmt::write_str_macro2       35,527          32,654               -2,873   -8.09%   x 1.09
 fmt::write_str_macro_debug  571,953         575,973               4,020    0.70%   x 0.99
 fmt::write_str_ref          9,579           9,459                  -120   -1.25%   x 1.01
 fmt::write_str_value        9,573           9,572                    -1   -0.01%   x 1.00
 fmt::write_u128_max         176             173                      -3   -1.70%   x 1.02
 fmt::write_u128_min         138             134                      -4   -2.90%   x 1.03
 fmt::write_u64_max          139             136                      -3   -2.16%   x 1.02
 fmt::write_u64_min          129             135                       6    4.65%   x 0.96
 fmt::write_vec_macro1       24,401          22,273               -2,128   -8.72%   x 1.10
 fmt::write_vec_macro2       37,096          35,602               -1,494   -4.03%   x 1.04
 fmt::write_vec_macro_debug  588,291         589,575               1,284    0.22%   x 1.00
 fmt::write_vec_ref          9,568           9,732                   164    1.71%   x 0.98
 fmt::write_vec_value        9,516           9,625                   109    1.15%   x 0.99
```
</details>
2021-08-23 22:55:19 +00:00
Aman Arora
d7b4ee8a32 2229: Consider varaiables mentioned in closure as used 2021-08-23 18:47:38 -04:00
Niko Matsakis
ec9531bcb0 fix test 2021-08-23 22:25:55 +00:00
Niko Matsakis
ef2b9a4068 x.py fmt 2021-08-23 22:21:21 +00:00
Rémy Rakic
7b0e564e7c Update NLL HRTB type ascription blessed expectations
Some of these tests have reached parity with the migrate-mode output.
2021-08-24 00:00:56 +02:00
jackh726
b0170779f5 Add comment and extra test 2021-08-23 17:53:16 -04:00
jackh726
6df6eb8ae8 Add a couple more tests 2021-08-23 17:45:04 -04:00
jackh726
d9242ff0aa When checking associated type bounds, use bound vars for GAT params in param_env 2021-08-23 17:45:04 -04:00
Rémy Rakic
820e2680ec handle ascription type op in NLL HRTB diagnostics
Refactors the `type_op_ascribe_user_type` query into a version which
accepts a span, and uses it in the nicer NLL HRTB bound region errors.
2021-08-23 23:31:01 +02:00
Aman Arora
ed43e02e8c 2229: Update signature for truncate function 2021-08-23 17:15:52 -04:00
bors
a49e38e672 Auto merge of #88265 - m-ou-se:rollup-soymv20, r=m-ou-se
Rollup of 6 pull requests

Successful merges:

 - #87976 (Account for tabs when highlighting multiline code suggestions)
 - #88174 (Clarify some wording in Rust 2021 lint docs)
 - #88188 (Greatly improve limitation handling on parallel rustdoc GUI test run)
 - #88230 (Fix typos “a”→“an”)
 - #88232 (Add notes to macro-not-found diagnostics to point out how things with the same name were not a match.)
 - #88259 (Do not mark `-Z thir-unsafeck` as unsound anymore)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-23 20:10:29 +00:00
Niko Matsakis
e49323b07d add trailing newline 2021-08-23 19:53:18 +00:00
Niko Matsakis
754d51ebe4 useful debug printouts
The changes to dumping expressions seem particularly useful
2021-08-23 19:16:48 +00:00