Commit graph

3906 commits

Author SHA1 Message Date
Camille GILLOT
ac8961fc04 Add assertions on HIR enum sizes. 2021-02-15 19:24:57 +01:00
Camille GILLOT
21b0cdc9c0 Remove useless Named trait. 2021-02-15 19:24:57 +01:00
Jesus Rubio
8192793d50 Add long explanation for E0545 2021-02-15 19:16:39 +01:00
mark
aee1e59e6f Simplify pattern grammar by allowing nested leading vert
Along the way, we also implement a handful of diagnostics improvements
and fixes, particularly with respect to the special handling of `||` in
place of `|` and when there are leading verts in function params, which
don't allow top-level or-patterns anyway.
2021-02-15 12:07:54 -06:00
pierwill
f2f7ffecd7
Fix typo in rustc_infer::infer::UndoLog
Also use double quotes.
2021-02-15 10:02:03 -08:00
Gus Wynn
c28d86c53b name async generators something more human friendly in type error diagnostics 2021-02-15 08:51:08 -08:00
Jonas Schievink
1a2675fe26
Rollup merge of #82141 - jrvanwhy:issue-82052, r=sanxiyn
32-bit ARM: Emit `lr` instead of `r14` when specified as an `asm!` output register.

On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.

closes #82052

r? ``@nagisa``
2021-02-15 16:07:11 +01:00
Jonas Schievink
1c75dfbce7
Rollup merge of #82129 - est31:master, r=jyn514
Remove redundant bool_to_option feature gate
2021-02-15 16:07:09 +01:00
Jonas Schievink
285ea2f80d
Rollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011
expand: Some cleanup

See individual commits for details.

r? ``@Aaron1011``
2021-02-15 16:07:04 +01:00
Jonas Schievink
493c6c9f25
Rollup merge of #82077 - pierwill:edit-droparena, r=lcnr
Edit `rustc_arena::DropArena` docs

- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments
2021-02-15 16:07:00 +01:00
Jonas Schievink
665bf9e35f
Rollup merge of #82067 - BoxyUwU:hahaicantthinkofabadpun, r=oli-obk
const_generics: Fix incorrect ty::ParamEnv::empty() usage

Fixes #80561

Not sure if I should keep the `debug!(..)`s or not but its the second time I've needed them so they sure seem useful lol

cc ``@lcnr``
r? ``@oli-obk``
2021-02-15 16:06:59 +01:00
Jonas Schievink
5e8435abe0
Rollup merge of #82061 - RalfJung:ctfe-read-pointer-as-bytes, r=oli-obk
CTFE validation: catch ReadPointerAsBytes and better error

r? ``@oli-obk``
Fixes https://github.com/rust-lang/rust/issues/79690
Cc https://github.com/rust-lang/miri/issues/1706
2021-02-15 16:06:57 +01:00
Jonas Schievink
6fde3c5438
Rollup merge of #82009 - BoxyUwU:idontknooow, r=varkor
const_generics: Dont evaluate array length const when handling errors

Fixes #79518
Fixes #78246

cc ````@lcnr````

This was ICE'ing because we dont pass in the correct ``ParamEnv`` which meant that there was no ``Self: Foo`` predicate to make ``Self::Assoc`` well formed which caused an ICE when trying to normalize ``Self::Assoc`` in the mir interpreter

r? ````@varkor````
2021-02-15 16:06:55 +01:00
Jonas Schievink
f02f7b05b2
Rollup merge of #81503 - henryboisdequin:fix-const-fn-arr-err-msg, r=estebank
Suggest to create a new `const` item if the `fn` in the array is a `const fn`

Fixes #73734. If the `fn` in the array repeat expression is a `const fn`, suggest creating a new `const` item. On nightly, suggest creating an inline `const` block. This PR also removes the `suggest_const_in_array_repeat_expressions` as it is no longer necessary.

Example:

```rust
fn main() {
    // Should not compile but hint to create a new const item (stable) or an inline const block (nightly)
    let strings: [String; 5] = [String::new(); 5];
    println!("{:?}", strings);
}

```

Gives this error:

```
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
 --> $DIR/const-fn-in-vec.rs:3:32
  |
2 |     let strings: [String; 5] = [String::new(); 5];
  |                             ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `String`
  |
  = note: the `Copy` trait is required because the repeated element will be copied
```

With this change, this is the error message:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/const-fn-in-vec.rs:3:32
   |
LL |     let strings: [String; 5] = [String::new(); 5];
   |                                ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
   |
   = help: moving the function call to a new `const` item will resolve the error
```
2021-02-15 16:06:47 +01:00
Simon Sapin
b1e15fa8a2 Parameterize DynMetadata over its dyn SomeTrait type 2021-02-15 14:27:16 +01:00
Simon Sapin
696b239f72 Add ptr::Pointee trait (for all types) and ptr::metadata function
RFC: https://github.com/rust-lang/rfcs/pull/2580
2021-02-15 14:27:12 +01:00
bors
d1206f950f Auto merge of #81855 - cjgillot:ensure-cache, r=oli-obk
Check the result cache before the DepGraph when ensuring queries

Split out of https://github.com/rust-lang/rust/pull/70951

Calling `ensure` on already forced queries is a common operation.
Looking at the results cache first is faster than checking the DepGraph for a green node.
2021-02-15 12:11:59 +00:00
Ellen
7e368e57f2 the environment round here is awfully empty
capitalism
2021-02-15 11:38:20 +00:00
Johnathan Van Why
fd21eb18e9 32-bit ARM: Emit lr instead of r14 when specified as an asm! output register.
On 32-bit ARM platforms, the register `r14` has the alias `lr`. When used as an output register in `asm!`, rustc canonicalizes the name to `r14`. LLVM only knows the register by the name `lr`, and rejects it. This changes rustc's LLVM code generation to output `lr` instead.
2021-02-14 23:41:10 -08:00
Edward Shen
a4b2fafcc1
Revise HIR lowering comment 2021-02-15 00:28:58 -05:00
Edward Shen
a491f51218
Use delay_span_bug for mismatched subst/hir arg 2021-02-14 23:59:45 -05:00
est31
63806cc919 Remove redundant bool_to_option feature gate 2021-02-15 04:27:57 +01:00
Tomasz Miąsko
64b5b75e65 Use !Sync std::lazy::OnceCell in usefulness checking
The `rustc_data_structures::sync::OnceCell` is thread-safe when building
a parallel compiler. This is unnecessary for the purposes of pattern
usefulness checking. Use `!Sync` `std::lazy::OnceCell` instead.
2021-02-15 00:00:00 +00:00
bors
9503ea19ed Auto merge of #82103 - Dylan-DPC:rollup-5wv8rid, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #80523 (#[doc(inline)] sym_generated)
 - #80920 (Visit more targets when validating attributes)
 - #81720 (Updated smallvec version due to RUSTSEC-2021-0003)
 - #81891 ([rustdoc-json] Make `header` a vec of modifiers, and FunctionPointer consistent)
 - #81912 (Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`)
 - #81914 (Fixing bad suggestion for `_` in `const` type when a function #81885)
 - #81919 (BTreeMap: fix internal comments)
 - #81927 (Add a regression test for #32498)
 - #81965 (Fix MIR pretty printer for non-local DefIds)
 - #82029 (Use debug log level for developer oriented logs)
 - #82056 (fix ice (#82032))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-14 22:26:21 +00:00
Vadim Petrochenkov
6e11a8b66a expand: Remove redundant calls to configure
Starting from https://github.com/rust-lang/rust/pull/63468 cfg attributes on variants, fields, fn params etc. are processed together with other attributes (via `configure!`).
2021-02-14 19:47:00 +03:00
Vadim Petrochenkov
18c94b3edd expand: Remove obsolete ExpansionConfig::keep_macs
Maybe it was used before the introduction of placeholders, but now it has no effect.
2021-02-14 19:43:54 +03:00
Vadim Petrochenkov
0038eaee6b rustc_span: Remove obsolete allow_internal_unstable_backcompat_hack 2021-02-14 19:42:55 +03:00
Simonas Kazlauskas
fa3621b468 Don't fail to remove files if they are missing
In the backend we may want to remove certain temporary files, but in
certain other situations these files might not be produced in the first
place. We don't exactly care about that, and the intent is really that
these files are gone after a certain point in the backend.

Here we unify the backend file removing calls to use `ensure_removed`
which will attempt to delete a file, but will not fail if it does not
exist (anymore).

The tradeoff to this approach is, of course, that we may miss instances
were we are attempting to remove files at wrong paths due to some bug –
compilation would silently succeed but the temporary files would remain
there somewhere.
2021-02-14 18:31:57 +02:00
Dylan DPC
bcb14035e9
Rollup merge of #82056 - b-naber:mut_for_loop_bug, r=oli-obk
fix ice (#82032)

Fixes https://github.com/rust-lang/rust/issues/82032
2021-02-14 16:54:53 +01:00
Dylan DPC
c8dacf95ae
Rollup merge of #82029 - tmiasko:debug, r=matthewjasper
Use debug log level for developer oriented logs

The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-14 16:54:52 +01:00
Dylan DPC
2efde8c795
Rollup merge of #81965 - osa1:issue81200, r=oli-obk
Fix MIR pretty printer for non-local DefIds

Tries to fix #81200 -- the reproducer in the issue is not fixed yet.
Submitting PR to get feedback.

r? oli-obk
2021-02-14 16:54:51 +01:00
Dylan DPC
a6809d00ae
Rollup merge of #81914 - kper:fixing-81885, r=estebank
Fixing bad suggestion for `_` in `const` type when a function #81885

Closes #81885

```
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> $DIR/typeck_type_placeholder_item_help.rs:13:22
   |
LL | const TEST4: fn() -> _ = 42;
   |                      ^
   |                      |
   |                      not allowed in type signatures
   |                      help: use type parameters instead: `T`
```

Do not show the suggestion `help: use type parameters instead: T` when `fn`
2021-02-14 16:54:47 +01:00
Dylan DPC
25315635ef
Rollup merge of #81912 - sexxi-goose:Migrations2_review, r=nikomatsakis
Implement the precise analysis pass for lint `disjoint_capture_drop_reorder`

The precision pass for the lint prevents the lint from triggering for a variable (that was previously entirely captured by the closure) if all paths that need Drop starting at root variable have been captured by the closure.

r? `@nikomatsakis`
2021-02-14 16:54:46 +01:00
Dylan DPC
e3b2655c3a
Rollup merge of #81720 - klensy:smallvec-update, r=Mark-Simulacrum
Updated smallvec version due to RUSTSEC-2021-0003

Hi.

Updated Cargo.toml's for smallvec due to RUSTSEC-2021-0003 and Cargo.toml in separate commit.

Affected function `SmallVec::insert_many` looks like don't was used directly in rust, but can be somewhere in deps.

There should be some mechanism to not to do this kind of things manually, like dependabot. Actually, dependabot supports rust and can check security articles (at least that noted in description).
2021-02-14 16:54:44 +01:00
Dylan DPC
ac1d26bcd3
Rollup merge of #80920 - rylev:check_attr-refactor, r=davidtwco
Visit more targets when validating attributes

This begins to address #80048, allowing for additional validation of attributes.

There are more refactorings that can be done, though I think they should be tackled in additional PRs:
* ICE when a builtin attribute is encountered that is not checked
* Move some of the attr checking done `ast_validation` into `rustc_passes`
  * note that this requires a bit of additional refactoring, especially of extern items which currently parse attributes (and thus are a part of the AST) but do not possess attributes in their HIR representation.
* Rename `Target` to `AttributeTarget`
* Refactor attribute validation completely to go through `Visitor::visit_attribute`.
  * This would require at a minimum passing `Target` into this method which might be too big of a refactoring to be worth it.
  * It's also likely not possible to do all the validation this way as some validation requires knowing what other attributes a target has.

r? `@davidtwco`
2021-02-14 16:54:42 +01:00
Dylan DPC
29ed864dc3
Rollup merge of #80523 - LeSeulArtichaut:inline-sym, r=jyn514
#[doc(inline)] sym_generated

Manually doc-inlines `rustc_span::sym_generated` into `sym`.
Previously the docs would not get inlined, causing the symbols to be undocumented as `sym_generated` is private.

r? `@jyn514`
2021-02-14 16:54:35 +01:00
klensy
93c8ebe022 bumped smallvec deps 2021-02-14 18:03:11 +03:00
Ellen
7bd71262f8 param_env debugs are instrumental to rustc's success 2021-02-14 11:18:40 +00:00
Camelid
a9b16c6d71 Improve error and help messages 2021-02-13 21:42:32 -08:00
Henry Boisdequin
64fe2c183d update message 2021-02-14 10:08:37 +05:30
pierwill
1c3841ebf2 Edit rustc_arena::DropArena docs
- Add a "Safety" section, edit formatting for clarity
- Add missing punctuation in code comments
2021-02-13 16:04:18 -08:00
kadmin
be1ed00712 Add additional type info to mismatch err 2021-02-13 20:37:38 +00:00
Camille GILLOT
3fc8ed68e9 Check query cache before calling into the query engine. 2021-02-13 21:14:58 +01:00
Camille GILLOT
280a2866d5 Drop the cache lock earlier. 2021-02-13 21:14:58 +01:00
Camille GILLOT
15b0bc6b83 Separate the query cache from the query state. 2021-02-13 21:14:58 +01:00
Camille GILLOT
9f46259a75 Return a Result for query cache. 2021-02-13 21:14:58 +01:00
Camille GILLOT
f8ab649dfd Introduce query_storage. 2021-02-13 21:14:58 +01:00
Camille GILLOT
4b42a6d90b Introduce query_stored module. 2021-02-13 21:14:57 +01:00
Camille GILLOT
8684e9e47d Merge {get,ensure}_query. 2021-02-13 21:14:57 +01:00
Matthew Jasper
d785c8c447 Remove unnecessary function parameters project.rs 2021-02-13 19:30:07 +00:00
Matthew Jasper
dfee89f755 Make ProjectionTy::trait_ref truncate substs again
Also make sure that type arguments of associated types are printed in
some error messages.
2021-02-13 19:30:07 +00:00
Matthew Jasper
79f6f11816 Remove some unnecessary trait_ref calls 2021-02-13 19:30:07 +00:00
Matthew Jasper
9526c0c6e8 Avoid trait_ref when lowering ExistentialProjections 2021-02-13 19:30:07 +00:00
Matthew Jasper
0bf1d73d22 Don't go through TraitRef to relate projections 2021-02-13 19:30:07 +00:00
Matthew Jasper
9bbd3e0f8e Remove ProjectionTy::from_ref_and_name 2021-02-13 19:29:55 +00:00
Matthew Jasper
dfa581ff87 Fix pretty printing of generic associated type constraints 2021-02-13 19:29:55 +00:00
Ellen
b6144e7a20 yeet ya fixme into the void 2021-02-13 19:10:08 +00:00
Ellen
68405fdc2e debug!("paramenv={}paramenv={}paramenv={}paramenv={}") 2021-02-13 19:10:08 +00:00
Aaron Hill
3321d70161
Address review comments 2021-02-13 13:04:54 -05:00
Ömer Sinan Ağacan
fe82365630 Fix MIR pretty printer for non-local DefIds 2021-02-13 20:23:27 +03:00
Aaron Hill
0b411f56e1
Require passing an AttrWrapper to collect_tokens_trailing_token
This is a pure refactoring split out from #80689.
It represents the most invasive part of that PR, requiring changes in
every caller of `parse_outer_attributes`

In order to eagerly expand `#[cfg]` attributes while preserving the
original `TokenStream`, we need to know the range of tokens that
corresponds to every attribute target. This is accomplished by making
`parse_outer_attributes` return an opaque `AttrWrapper` struct. An
`AttrWrapper` must be converted to a plain `AttrVec` by passing it to
`collect_tokens_trailing_token`. This makes it difficult to accidentally
construct an AST node with attributes without calling `collect_tokens_trailing_token`,
since AST nodes store an `AttrVec`, not an `AttrWrapper`.

As a result, we now call `collect_tokens_trailing_token` for attribute
targets which only support inert attributes, such as generic arguments
and struct fields. Currently, the constructed `LazyTokenStream` is
simply discarded. Future PRs will record the token range corresponding
to the attribute target, allowing those tokens to be removed from an
enclosing `collect_tokens_trailing_token` call if necessary.
2021-02-13 12:07:15 -05:00
Ellen
a3e079534d Heat up the ICE-y error reporting
rest in peace match bool <3
2021-02-13 14:42:30 +00:00
Ralf Jung
d6dcb3de54 CTFE validation: catch ReadPointerAsBytes and better error 2021-02-13 14:58:31 +01:00
b-naber
77dfd71b95 fix 82032 2021-02-13 11:47:44 +01:00
Yuki Okushi
f6677b0f52
Rollup merge of #82031 - LingMan:unneeded_var, r=varkor
Drop an unnecessary intermediate variable

Neither does it shorten the code nor does it provide a helpful name.

`@rustbot` modify labels +C-cleanup +T-compiler

r? `@varkor`
2021-02-13 16:36:47 +09:00
Yuki Okushi
14b217c43e
Rollup merge of #81995 - 0yoyoyo:fix-issue-81650-explicit-lifetime-error, r=estebank
Fix suggestion to introduce explicit lifetime

Addresses #81650

Error message after fix:

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime #2 defined on the function body at 24:1...
  --> src/main.rs:24:1
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```
2021-02-13 16:36:46 +09:00
csmoe
5385a3d6a7 spell the real selftype 2021-02-13 14:45:53 +08:00
Tomasz Miąsko
361dcd5ca7 Use debug log level for developer oriented logs
The information logged here is of limited general interest, while at the
same times makes it impractical to simply enable logging and share the
resulting logs due to the amount of the output produced.

Reduce log level from info to debug for developer oriented information.

For example, when building cargo, this reduces the amount of logs
generated by `RUSTC_LOG=info cargo build` from 265 MB to 79 MB.

Continuation of changes from 81350.
2021-02-13 00:00:00 +00:00
Dylan DPC
1ef566fc7c
Rollup merge of #82030 - LingMan:init_directly, r=varkor
Use `Iterator::all` instead of open-coding it

Shorter code and by initializing to the final value directly, the variable
doesn't need to be mut.
2021-02-12 22:53:38 +01:00
Dylan DPC
ef7c45aa70
Rollup merge of #82022 - LingMan:single_char, r=jonas-schievink
Push a `char` instead of a `str` with len one into a String

``@rustbot`` modify labels +C-cleanup +T-compiler
2021-02-12 22:53:36 +01:00
Dylan DPC
b67be3aa6b
Rollup merge of #81911 - BoxyUwU:constgenericgaticefix, r=nikomatsakis
GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes #75415
Fixes #79666
cc ```@lcnr```

I've absolutely no idea who to r?  for this...
2021-02-12 22:53:34 +01:00
Dylan DPC
58d72aedee
Rollup merge of #81506 - vo4:hwasan, r=nagisa
HWAddressSanitizer support

#  Motivation
Compared to regular ASan, HWASan has a [smaller overhead](https://source.android.com/devices/tech/debug/hwasan). The difference in practice is that HWASan'ed code is more usable, e.g. Android device compiled with HWASan can be used as a daily driver.

# Example
```
fn main() {
    let xs = vec![0, 1, 2, 3];
    let _y = unsafe { *xs.as_ptr().offset(4) };
}
```
```
==223==ERROR: HWAddressSanitizer: tag-mismatch on address 0xefdeffff0050 at pc 0xaaaad00b3468
READ of size 4 at 0xefdeffff0050 tags: e5/00 (ptr/mem) in thread T0
    #0 0xaaaad00b3464  (/root/main+0x53464)
    #1 0xaaaad00b39b4  (/root/main+0x539b4)
    #2 0xaaaad00b3dd0  (/root/main+0x53dd0)
    #3 0xaaaad00b61dc  (/root/main+0x561dc)
    #4 0xaaaad00c0574  (/root/main+0x60574)
    #5 0xaaaad00b6290  (/root/main+0x56290)
    #6 0xaaaad00b6170  (/root/main+0x56170)
    #7 0xaaaad00b3578  (/root/main+0x53578)
    #8 0xffff81345e70  (/lib64/libc.so.6+0x20e70)
    #9 0xaaaad0096310  (/root/main+0x36310)

[0xefdeffff0040,0xefdeffff0060) is a small allocated heap chunk; size: 32 offset: 16
0xefdeffff0050 is located 0 bytes to the right of 16-byte region [0xefdeffff0040,0xefdeffff0050)
allocated here:
    #0 0xaaaad009bcdc  (/root/main+0x3bcdc)
    #1 0xaaaad00b1eb0  (/root/main+0x51eb0)
    #2 0xaaaad00b20d4  (/root/main+0x520d4)
    #3 0xaaaad00b2800  (/root/main+0x52800)
    #4 0xaaaad00b1cf4  (/root/main+0x51cf4)
    #5 0xaaaad00b33d4  (/root/main+0x533d4)
    #6 0xaaaad00b39b4  (/root/main+0x539b4)
    #7 0xaaaad00b61dc  (/root/main+0x561dc)
    #8 0xaaaad00b3578  (/root/main+0x53578)
    #9 0xaaaad0096310  (/root/main+0x36310)

Thread: T0 0xeffe00002000 stack: [0xffffc0590000,0xffffc0d90000) sz: 8388608 tls: [0xffff81521020,0xffff815217d0)
Memory tags around the buggy address (one tag corresponds to 16 bytes):
  0xfefcefffef80: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffef90: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffefa0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffefb0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffefc0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffefd0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffefe0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefcefffeff0: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
=>0xfefceffff000: a2  a2  05  00  e5 [00] 00  00  00  00  00  00  00  00  00  00
  0xfefceffff010: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff020: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff030: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff040: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff050: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff060: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff070: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  0xfefceffff080: 00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
Tags for short granules around the buggy address (one tag corresponds to 16 bytes):
  0xfefcefffeff0: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
=>0xfefceffff000: ..  ..  c5  ..  .. [..] ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
  0xfefceffff010: ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
See https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#short-granules for a description of short granule tags
Registers where the failure occurred (pc 0xaaaad00b3468):
    x0  e500efdeffff0050  x1  0000000000000004  x2  0000ffffc0d8f5a0  x3  0200efff00000000
    x4  0000ffffc0d8f4c0  x5  000000000000004f  x6  00000ffffc0d8f36  x7  0000efff00000000
    x8  e500efdeffff0050  x9  0200efff00000000  x10 0000000000000000  x11 0200efff00000000
    x12 0200effe000006b0  x13 0200effe000006b0  x14 0000000000000008  x15 00000000c00000cf
    x16 0000aaaad00a0afc  x17 0000000000000003  x18 0000000000000001  x19 0000ffffc0d8f718
    x20 ba00ffffc0d8f7a0  x21 0000aaaad00962e0  x22 0000000000000000  x23 0000000000000000
    x24 0000000000000000  x25 0000000000000000  x26 0000000000000000  x27 0000000000000000
    x28 0000000000000000  x29 0000ffffc0d8f650  x30 0000aaaad00b3468
```

# Comments/Caveats
* HWASan is only supported on arm64.
* I'm not sure if I should add a feature gate or piggyback on the existing one for sanitizers.
* HWASan requires `-C target-feature=+tagged-globals`. That flag should probably be set transparently to the user. Not sure how to go about that.

# TODO
* Need more tests.
* Update documentation.
* Fix symbolization.
* Integrate with CI
2021-02-12 22:53:30 +01:00
Dylan DPC
fc93e260e9
Rollup merge of #81479 - osa1:issue24151, r=lcnr
Allow casting mut array ref to mut ptr

Allow casting mut array ref to mut ptr

We now allow two new casts:

- mut array reference to mut ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *mut usize;

  We allow casting const array references to const pointers so not
  allowing mut references to mut pointers was inconsistent.

- mut array reference to const ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *const usize;

  This was similarly inconsistent as we allow casting mut references to
  const pointers.

Existing test 'vector-cast-weirdness' updated to test both cases.

Fixes #24151
2021-02-12 22:53:29 +01:00
bors
3f5aee2d52 Auto merge of #81744 - rylev:overlapping-early-exit2, r=lcnr
Try fast_reject::simplify_type in coherence before doing full check

This is a reattempt at landing #69010 (by `@jonas-schievink).` The change adds a fast path for coherence checking to see if there's no way for types to unify since full coherence checking can be somewhat expensive.

This has big effects on code generated by the [`windows`](https://github.com/microsoft/windows-rs) which in some cases spends as much as 20% of compilation time in the `specialization_graph_of` query. In local benchmarks this took a compilation that previously took ~500 seconds down to ~380 seconds.

This is surely not going to make a difference on much smaller crates, so the question is whether it will have a negative impact. #69010 was closed because some of the perf suite crates did show small regressions.

Additional discussion of this issue is happening [here](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/windows-rs.20perf).
2021-02-12 17:38:15 +00:00
Ryan Levick
0cc35f54e8 Don't check self type twice 2021-02-12 17:37:32 +01:00
Ryan Levick
bc5f4c4860 Switch boolean checks 2021-02-12 17:22:19 +01:00
LingMan
28347ebdb3 Drop an unnecessary intermediate variable
Neither does it shorten the code nor does it provide a helpful name.
2021-02-12 14:08:14 +01:00
Ryan Levick
8ea0973725 Short circuit full corherence check when dealing with types with different reference mutability 2021-02-12 14:04:09 +01:00
LingMan
fde59a8cb7 Use Iterator::all instead of open-coding it
Shorter code and by initializing to the final value directly, the variable
doesn't need to be mut.
2021-02-12 14:02:35 +01:00
Yuki Okushi
ff8b7f20d9
Rollup merge of #82017 - eltociear:patch-8, r=jyn514
Fix typo in mod.rs

insted -> instead
2021-02-12 19:32:22 +09:00
Yuki Okushi
55539cbdc0
Rollup merge of #82003 - ojeda:stack-probe-msg, r=estebank
Stack probes: fix error message
2021-02-12 19:32:17 +09:00
Yuki Okushi
44d28717da
Rollup merge of #81994 - jesusprubio:improve-long-explanation-e0542-e0546, r=GuillaumeGomez
Improve long explanation for E0542 and E0546

Helps with #61137

To keep the consistency with: https://github.com/rust-lang/rust/pull/81925
2021-02-12 19:32:15 +09:00
Yuki Okushi
46aef0e375
Rollup merge of #81990 - matsujika:suggest-mut-reference, r=estebank
Make suggestion of changing mutability of arguments broader

Fix #81421

Previously rustc tries to emit the suggestion of changing mutablity unless `!trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref)` and this led to some false negatives to occur.
2021-02-12 19:32:14 +09:00
Yuki Okushi
0b7fc80e45
Rollup merge of #81959 - therealprof:fix-typo, r=oli-obk
Fix assosiated typo

Introduced in d3c4dbd85d, noticed only
after the fact, sorry. 😅

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2021-02-12 19:32:12 +09:00
Yuki Okushi
c07260d534
Rollup merge of #81947 - camsteffen:to-ty, r=jyn514
Relax ItemCtxt::to_ty lifetime

Tiny simplification by relaxing a lifetime.
2021-02-12 19:32:08 +09:00
LingMan
fda71d676d Push a char instead of a str with len one into a String 2021-02-12 10:27:08 +01:00
Kevin Per
fba2f883f3 Implementing more sophisticated filter for fn in const or static 2021-02-12 09:18:03 +00:00
Aman Arora
96c12f90cf fixup! Implement the precise analysis pass for lint disjoint_capture_drop_reorder 2021-02-12 04:10:17 -05:00
csmoe
ed40b95925 spell out nested self type 2021-02-12 16:50:45 +08:00
Ikko Ashimine
c8eeb340bc
Fix typo in mod.rs
insted -> instead
2021-02-12 13:47:21 +09:00
Miguel Ojeda
0df8ddee53 Stack probes: fix error message
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-11 20:33:16 +01:00
bors
e9920ef774 Auto merge of #81760 - tmiasko:debug-borrow, r=pnkfelix
Borrow builder only once in debug derive
2021-02-11 16:46:08 +00:00
0yoyoyo
788e4bb4e5 Fix suggestion to introduce explicit lifetime 2021-02-12 00:48:44 +09:00
Jesus Rubio
a99d869e6c Improve long explanation for E0542 and E0546 2021-02-11 16:26:07 +01:00
bors
26e5bcd220 Auto merge of #81350 - tmiasko:instrument-debug, r=lcnr
Reduce log level used by tracing instrumentation from info to debug

Restore log level to debug to avoid make info log level overly verbose (the uses of instrument attribute modified there, were for the most part a replacement for `debug!`;  one use was novel).
2021-02-11 13:44:00 +00:00
Hirochika Matsumoto
e03f09730f Make suggestion of changing mutability of arguments broader 2021-02-11 17:03:03 +09:00
bors
2918062d1d Auto merge of #81129 - bugadani:lighter-move-errors, r=petrochenkov
Borrowck: don't calculate unused info when reporting move errors
2021-02-11 07:50:02 +00:00
bors
9ce7268bcf Auto merge of #80860 - camelid:nodeid-docs, r=sanxiyn
Document `NodeId`
2021-02-11 00:51:45 +00:00
Matthew Jasper
f852160a99 Keep existing names of regions in placeholder_error 2021-02-10 20:00:36 +00:00
Vadim Petrochenkov
8e74842089 resolve: Remove visibility hacks for enum variants and trait items
Special treatment like this was necessary before `pub(restricted)` had been implemented and only two visibilities existed - `pub` and non-`pub`.
Now it's no longer necessary and the desired behavior follows from `pub(restricted)`-style visibilities naturally assigned to enum variants and trait items.
2021-02-10 22:46:44 +03:00
Vadim Petrochenkov
b4b6b62e70 resolve: Cleanup visibility resolution in enums and traits 2021-02-10 22:46:44 +03:00
Ellen
7ca96ed2af rewrite the comments 2021-02-10 13:11:22 +00:00
bors
07194ffcd2 Auto merge of #79804 - tmiasko:improper-ctypes-no-niche, r=pnkfelix
Types with a hidden niche are not known to be non-null

Fixes #79787.
2021-02-10 12:56:09 +00:00
Ömer Sinan Ağacan
d64b749f2c Allow casting mut array ref to mut ptr
We now allow two new casts:

- mut array reference to mut ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *mut usize;

  We allow casting const array references to const pointers so not
  allowing mut references to mut pointers was inconsistent.

- mut array reference to const ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *const usize;

  This was similarly inconsistent as we allow casting mut references to
  const pointers.

Existing test 'vector-cast-weirdness' updated to test both cases.

Fixes #24151
2021-02-10 15:44:41 +03:00
Daniel Egger
a6d413715c Fix assosiated typo
Introduced in d3c4dbd85d, noticed only
after the fact, sorry. 😅

Signed-off-by: Daniel Egger <daniel@eggers-club.de>
2021-02-10 09:36:26 +01:00
Dániel Buga
3c1d792f49 Only initialize what is used 2021-02-10 09:20:41 +01:00
Ellen
0ffa2da186 comma... 2021-02-10 05:29:45 +00:00
Ellen
0422745585 Fix comment smol mistakes 2021-02-10 05:23:16 +00:00
Ellen
2c4337a70a Comments :3 2021-02-10 05:15:43 +00:00
Yuki Okushi
2e8e591a16
Rollup merge of #81926 - henryboisdequin:fix-81907, r=estebank
add suggestion to use the `async_recursion` crate

Closes #81907

CC `@estebank`
2021-02-10 12:24:30 +09:00
Yuki Okushi
40fa6fc43f
Rollup merge of #81925 - jesusprubio:add-long-explanation-e0547, r=GuillaumeGomez
Add long explanation for E0547

Helps with #61137
2021-02-10 12:24:29 +09:00
Yuki Okushi
a58feb9282
Rollup merge of #81913 - osa1:rename_unop_variants, r=matthewjasper
Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like `&*` instead of just `*`.
2021-02-10 12:24:28 +09:00
Yuki Okushi
fff36f199a
Rollup merge of #81909 - wcampbell0x2a:remove-unnecessary-refs, r=estebank
[compiler/rustc_typeck/src/check/expr.rs] Remove unnecessary refs in pattern matching
2021-02-10 12:24:25 +09:00
Yuki Okushi
3f09418cbe
Rollup merge of #81466 - sasurau4:fix/enhance-sugget-mut-method-for-loop, r=oli-obk
Add suggest mut method for loop

Part of #49839

This PR focus on [the comment case](https://github.com/rust-lang/rust/issues/49839#issuecomment-761930746)
2021-02-10 12:24:21 +09:00
Cameron Steffen
471ed5f80f Use ItemCtxt::to_ty 2021-02-09 19:27:33 -06:00
bors
ca98712ff9 Auto merge of #81411 - Skgland:deprecate_expr_method_call, r=varkor
Remove usages of `expr_method_call` in derive(Ord,PartialOrd,RustcEncode,RustcDecode)

Preparing for deprecation of `expr_method_call`  (#81295), by removing the remaining usages not covered by (#81294).

I am not sure about the changes to `derive(RustcEncode,RustcDecode)`
2021-02-10 00:25:11 +00:00
Tomasz Miąsko
1cf95059eb Borrow builder only once in debug derive 2021-02-10 00:00:00 +00:00
Nam Nguyen
615fd141bd Set the kind for local variables created by &str and slice arguments to LocalVariable 2021-02-09 15:59:28 -08:00
Matthew Jasper
9337d4fde8 Print closure signatures when reporting placeholder errors 2021-02-09 23:00:33 +00:00
Matthew Jasper
94c11dfe78 Report "nice" placeholder errors more often
If we have a cause containing `ValuePairs::PolyTraitRefs` but neither
TraitRef has any escaping bound regions then we report the same error as
for `ValuePairs::TraitRefs`.
2021-02-09 22:59:32 +00:00
Matthew Jasper
daab6db1a0 Avoid repeating self type in placeholder error 2021-02-09 22:28:09 +00:00
bors
87bacf22ec Auto merge of #81132 - bugadani:map-prealloc, r=matthewjasper
Borrowck: refactor visited map to a bitset

This PR refactors `Borrows`  and the `precompute_borrows_out_of_scope` function so that this initial phase has a much reduced memory pressure. This is achieved by reducing what is stored on the heap, and also reusing heap memory as much as possible.
2021-02-09 21:28:58 +00:00
Matthew Jasper
c2066cf069 Remove unnecessary note on errors
Seeing the trait definition doesn't help with implementation not general
enough errors, so don't make the error message larger to show it.
2021-02-09 21:16:00 +00:00
Matthew Jasper
638980a07f Using tracing macros in placeholder_error.rs 2021-02-09 21:03:00 +00:00
Matthew Jasper
1eb79f3c37 Use longer lifetime in try_report_from_nll return type 2021-02-09 20:56:45 +00:00
Ryan Levick
396022b90b Visit more targets when checking attrs 2021-02-09 21:54:46 +01:00
bors
097bc6a84f Auto merge of #81892 - jyn514:no-inline, r=cjgillot
[experiment] remove `#[inline]` from rustc_query_system::plumbing

These functions have a ton of generic parameters and are instantiated
over and over again. Hopefully this will reduce binary bloat and speed
up bootstrapping times.

r? `@cjgillot`
2021-02-09 18:37:33 +00:00
Jesús Rubio
8fbdd2d15e
Update compiler/rustc_error_codes/src/error_codes/E0547.md
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-02-09 14:13:40 +01:00
Henry Boisdequin
4af417a78a add suggestion to use the async_recursion crate 2021-02-09 18:43:39 +05:30
Jesus Rubio
7b84b62d29 Lost text re-added 2021-02-09 14:09:19 +01:00
Skgland
0375022c73
fix derive(RustcEncodable, RustcDecodable) 2021-02-09 13:42:36 +01:00
Skgland
091ef95f8e
use ufcs in derive(RustDecodable) 2021-02-09 13:42:36 +01:00
Skgland
525fc4b8e4
use ufcs in derive(RustEncodable) 2021-02-09 13:42:36 +01:00
Skgland
e1010424dc
add method to construct def site path as a vec of idents
like std_path but used dummy span for all path elements and does not perpend kw:DollarCrate
2021-02-09 13:42:35 +01:00
Skgland
2c33b070ad
use ufcs in derive(Ord) and derive(PartialOrd) 2021-02-09 13:42:35 +01:00
Kevin Per
49fc41f047 Running ./x.py fmt 2021-02-09 10:28:49 +00:00
Ellen
1d9ac3c22c Fix const generics in GAT 2021-02-09 08:58:05 +00:00
bors
c648bd5558 Auto merge of #81384 - tmiasko:partial-ord, r=petrochenkov
Fix derived PartialOrd operators

The derived implementation of `partial_cmp` compares matching fields one
by one, stopping the computation when the result of a comparison is not
equal to `Some(Equal)`.

On the other hand the derived implementation for `lt`, `le`, `gt` and
`ge` continues the computation when the result of a field comparison is
`None`, consequently those operators are not transitive and inconsistent
with `partial_cmp`.

Fix the inconsistency by using the default implementation that fall-backs
to the `partial_cmp`. This also avoids creating very deeply nested
closures that were quite costly to compile.

Fixes #81373.
Helps with #81278, #80118.
2021-02-09 08:47:38 +00:00
Kevin Per
95be69dabb Fixing codestyle 2021-02-09 08:42:08 +00:00
Ömer Sinan Ağacan
c4e3558b8c Rename HIR UnOp variants
This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".
2021-02-09 11:39:20 +03:00
Kevin Per
09d5d0766e Fixing bad suggestion for _ in const type when a function #81885 2021-02-09 08:35:58 +00:00
Aman Arora
5b54640128 Mark migration code that relies on Deref unreachable 2021-02-09 02:59:29 -05:00
Aman Arora
c01036af1d Implement the precise analysis pass for lint disjoint_capture_drop_reorder 2021-02-09 02:53:58 -05:00
bors
f4008fe949 Auto merge of #81905 - Dylan-DPC:rollup-mxpz1j7, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #72209 (Add checking for no_mangle to unsafe_code lint)
 - #80732 (Allow Trait inheritance with cycles on associated types take 2)
 - #81697 (Add "every" as a doc alias for "all".)
 - #81826 (Prefer match over combinators to make some Box methods inlineable)
 - #81834 (Resolve typedef in HashMap lldb pretty-printer only if possible)
 - #81841 ([rustbuild] Output rustdoc-json-types docs )
 - #81849 (Expand the docs for ops::ControlFlow a bit)
 - #81876 (parser: Fix panic in 'const impl' recovery)
 - #81882 (⬆️ rust-analyzer)
 - #81888 (Fix pretty printer macro_rules with semicolon.)
 - #81896 (Remove outdated comment in windows' mutex.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-09 05:57:18 +00:00
bors
36931ce3d9 Auto merge of #81901 - Mark-Simulacrum:use-string-not-cow, r=jackh726
Switch query descriptions to just String

In practice we never used the borrowed variant anyway.
2021-02-09 03:06:42 +00:00
wcampbell
7554c7742e
Remove unnecessary refs in pattern matching
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-02-08 22:02:35 -05:00
Dylan DPC
78c0153757
Rollup merge of #81888 - ehuss:macro_rules-pp, r=petrochenkov
Fix pretty printer macro_rules with semicolon.

The pretty printer was not including the trailing semicolon for a macro_rules definition that used parenthesis or brackets, which results in invalid code. This adds the semicolon in those two cases.
2021-02-09 02:40:05 +01:00
Dylan DPC
9ab05b4fe3
Rollup merge of #81876 - osa1:issue81806, r=matthewjasper
parser: Fix panic in 'const impl' recovery

The panic happens when in recovery parsing a full `impl`
(`parse_item_impl`) fails and we drop the `DiagnosticBuilder` for the
recovery suggestion and return the `parse_item_impl` error.

We now raise the original error "expected identifier found `impl`" when
parsing the `impl` fails.

Note that the regression test is slightly simplified version of the
original repro in #81806, to make the error output smaller and more
resilient to unrelated changes in parser error messages.

Fixes #81806
2021-02-09 02:40:01 +01:00
Dylan DPC
44e526b2c3
Rollup merge of #80732 - spastorino:trait-inheritance-self2, r=nikomatsakis
Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of #79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in #80648 and #79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of #79209 which was already approved.

This also could be considered part or the actual fix of #79560 but I guess for that to be closed and fixed completely we would need to land #80648 and #79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`
2021-02-09 02:39:50 +01:00
Dylan DPC
f8b330d9fb
Rollup merge of #72209 - Nemo157:lint-no-mangle-in-unsafe-code, r=nikomatsakis
Add checking for no_mangle to unsafe_code lint

fixes #72188

r? `@estebank`
2021-02-09 02:39:45 +01:00