Commit Graph

4125 Commits

Author SHA1 Message Date
Camille GILLOT cebbba081e Only store a LocalDefId in hir::Item.
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
Camille GILLOT bd3cd5dbed Use an ItemId inside mir::GlobalAsm. 2021-02-15 19:24:58 +01:00
Camille GILLOT c676e358a5 Use ItemId as a strongly typed index. 2021-02-15 19:24:58 +01:00
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
Andrea Nall 5ef202520f add diagnostic items
Add diagnostic items to the following types:
  OsString (os_string_type)
  PathBuf (path_buf_type)
  Owned (to_owned_trait)

As well as the to_vec method on slice/[T]
2021-02-15 02:27:28 +00: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
Mara Bos 2a0c42450e Formatting. 2021-02-14 19:51:15 +01:00
Mara Bos 37c532c010 Suggest correct replacement for panic![123].
Before this change, the suggestion was `std::panic::panic_any(123]`,
changing the opening brace but not the closing one.
2021-02-14 19:44:48 +01:00
Reese Williams 7879099ad3 Clarify error message and remove pretty printing in help suggestions. 2021-02-14 13:15:37 -05:00
Mara Bos a428ab17ab Improve suggestion for panic!(format!(..)). 2021-02-14 18:52:47 +01:00
Mara Bos ef778e7965 Fix span in non_fmt_panic for panic!(some_macro!()). 2021-02-14 18:14:23 +01: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
Simonas Kazlauskas 16c71886c9 Set path of the compile unit to the source directory
As part of the effort to implement split dwarf debug info, we ended up
setting the compile unit location to the output directory rather than
the source directory. Furthermore, it seems like we failed to remap the
prefixes for this as well!

The desired behaviour is to instead set the `DW_AT_GNU_dwo_name` to a
path relative to compiler's working directory. This still allows
debuggers to find the split dwarf files, while not changing the
behaviour of the code that is compiling with regular debug info, and not
changing the compiler's behaviour with regards to reproducibility.

Fixes #82074
2021-02-14 17:12:14 +02: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
Henry Boisdequin eace240ebe use option<PlaceRef<'tcx>> to clean up mir code a little 2021-02-14 14:39:24 +05:30
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
Esteban Küber 04c2454b1e Fix ICE caused by suggestion with no code substitutions
Change suggestion logic to filter and checking _before_ creating
specific resolution suggestion.

Assert earlier that suggestions contain code substitions to make it
easier in the future to debug invalid uses. If we find this becomes too
noisy in the wild, we can always make the emitter resilient to these
cases and remove the assertions.

Fix #78651.
2021-02-13 19:52:12 -08:00
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
Xidorn Quan 38e4233a32 Replace const_cstr with cstr crate 2021-02-14 09:45:35 +11: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
Casey Rodarmor 66f4883308
[librustdoc] Reform lang string token splitting
Only split doctest lang strings on `,`, ` `, and `\t`. Additionally, to
preserve backwards compatibility with pandoc-style langstrings, strip a
surrounding `{}`, and remove leading `.`s from each token.

Prior to this change, doctest lang strings were split on all
non-alphanumeric characters except `-` or `_`, which limited future
extensions to doctest lang string tokens, for example using `=` for
key-value tokens.

This is a breaking change, although it is not expected to be disruptive,
because lang strings using separators other than `,` and ` ` are not
very common
2021-02-12 00:02:52 -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
Jacob Pratt c28f2a8bee
Stabilize str_split_once 2021-02-09 23:17:11 -05: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
Tomasz Miąsko e4efccd4a6 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.
2021-02-09 08:15:37 +01:00
Mark Rousskov f564d7abba Switch query descriptions to just String
In practice we never used the borrowed variant anyway.
2021-02-08 17:20:41 -05:00
Eric Huss cadffa74df Fix pretty printer macro_rules with semicolon. 2021-02-08 12:08:27 -08:00
Joshua Nelson 4f77a1afc2 [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.
2021-02-08 14:57:15 -05:00
Santiago Pastorino 8d17c6a85d
Anonymize late bound regions on transitive bounds that define assoc type 2021-02-08 16:47:51 -03:00
Dániel Buga 5271c628be Remove RCs from Borrows 2021-02-08 20:37:16 +01:00
Mara Bos 9d1e8fe045
Rollup merge of #81865 - bugadani:typeck2, r=jyn514
Clean up weird Option mapping
2021-02-08 19:28:25 +01:00
Mara Bos b376c50aa2
Rollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiser
Show MIR bytes separately in -Zmeta-stats output

The size of serialized MIR is substantial enough to deserve its own category.
2021-02-08 19:28:23 +01:00
Mara Bos b9045fabf8
Rollup merge of #81828 - davidhewitt:capture-raw-format-strings, r=estebank
parse_format: treat r" as a literal

This PR changes `format_args!` internal parsing machinery to treat raw strings starting `r"` as a literal.

Currently `"` and `r#` are recognised as valid starting combinations for string literals, but `r"` is not.

This was noticed when debugging https://github.com/rust-lang/rust/issues/67984#issuecomment-753413156

As well as fixing the behavior observed in that comment, this improves diagnostic spans for `r"` formatting strings.
2021-02-08 19:28:20 +01:00
Mara Bos b263981fd7
Rollup merge of #81779 - geogriff:const-ptr-to-int-error, r=lcnr
improve error message for disallowed ptr-to-int casts in const eval

Improves an error message as [suggested](https://github.com/rust-lang/rust/issues/80875#issuecomment-762754580) in #80875.

Does the wording make enough sense? I tried to follow precedent for error message style while maintaining brevity.

It seems like the rest of the `ConstEvalErrKind::NeedsRfc` error messages could be improved as well. I could give that a go if this approach works.

Closes #80875
2021-02-08 19:28:17 +01:00
Mara Bos 2c8d1c8cef
Rollup merge of #81735 - klensy:span-fix, r=varkor
faster few span methods

Touched few methods, so it should be (hopefully) faster.

First two changes: instead splitting string from start and taking only last piece, split it from the end.
Last: swapped conditions, to first check boolean parameter.
2021-02-08 19:28:15 +01:00
Jesus Rubio 4d33d41ef3 Add long explanation for E0547 2021-02-08 18:25:05 +01:00
Tri Vo c7d9bffe76 HWASan support 2021-02-07 23:48:58 -08:00
Ömer Sinan Ağacan 6eb1bd4c3e 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-08 10:46:19 +03:00
Camelid 0f3e2f68d3 Clarify docs for `DUMMY_NODE_ID` 2021-02-07 19:42:12 -08:00
1000teslas b2eed3a559 Point out implicit deref coercions in borrow
Clean up code
2021-02-08 13:24:37 +11:00
bors 0b7a598e12 Auto merge of #72603 - jsgf:extern-loc, r=nikomatsakis
Implement `--extern-location`

This PR implements `--extern-location` as a followup to #72342 as part of the implementation of #57274. The goal of this PR is to allow rustc, in coordination with the build system, to present a useful diagnostic about how to remove an unnecessary dependency from a dependency specification file (eg Cargo.toml).

EDIT: Updated to current PR state.

The location is specified for each named crate - that is, for a given `--extern foo[=path]` there can also be `--extern-location foo=<location>`. It supports ~~three~~ two styles of location:
~~1. `--extern-location foo=file:<path>:<line>` - a file path and line specification
1. `--extern-location foo=span:<path>:<start>:<end>` - a span specified as a file and start and end byte offsets~~
1. `--extern-location foo=raw:<anything>` - a raw string which is included in the output
1. `--extern-location foo=json:<anything>` - an arbitrary Json structure which is emitted via Json diagnostics in a `tool_metadata` field.

~~1 & 2 are turned into an internal `Span`, so long as the path exists and is readable, and the location is meaningful (within the file, etc). This is used as the `Span` for a fix suggestion which is reported like other fix suggestions.~~

`raw` and `json` are for the case where the location isn't best expressed as a file and location within that file. For example, it could be a rule name and the name of a dependency within that rule. `rustc` makes no attempt to parse the raw string, and simply includes it in the output diagnostic text. `json` is only included in json diagnostics. `raw` is emitted as text and also as a json string in `tool_metadata`.

If no `--extern-location` option is specified then it will emit a default json structure consisting of `{"name": name, "path": path}` corresponding to the name and path in `--extern name=path`.

This is a prototype/RFC to make some of the earlier conversations more concrete. It doesn't stand on its own - it's only useful if implemented by Cargo and other build systems. There's also a ton of implementation details which I'd appreciate a second eye on as well.

~~**NOTE** The first commit in this PR is #72342 and should be ignored for the purposes of review. The first commit is a very simplistic implementation which is basically raw-only, presented as a MVP. The second implements the full thing, and subsequent commits are incremental fixes.~~

cc `@ehuss` `@est31` `@petrochenkov` `@estebank`
2021-02-08 02:23:17 +00:00
Dániel Buga 37cbc08a92 Clean up weird option mapping 2021-02-08 00:24:36 +01:00
Jeremy Fitzhardinge 91d8c3b521 Make sure all fields are accounted for in `encode_fields!`
This will make sure the encoder will get updated if any new fields are
added to Diagnostic.
2021-02-07 14:54:22 -08:00
Jeremy Fitzhardinge 50572d6629 Implement Encoder for Diagnostic manually
...so we can skip serializing `tool_metadata` if it hasn't been set.
This makes the output a bit cleaner, and avoiding having to update a
bunch of unrelated tests.
2021-02-07 14:54:22 -08:00
Jeremy Fitzhardinge 82ccb6582a Add `--extern-loc` to augment unused crate dependency diagnostics
This allows a build system to indicate a location in its own dependency
specification files (eg Cargo's `Cargo.toml`) which can be reported
along side any unused crate dependency.

This supports several types of location:
 - 'json' - provide some json-structured data, which is included in the json diagnostics
     in a `tool_metadata` field
 - 'raw' - emit the provided string into the output. This also appears as a json string in
     `tool_metadata`.

If no `--extern-location` is explicitly provided then a default json entry of the form
`"tool_metadata":{"name":<cratename>,"path":<cratepath>}` is emitted.
2021-02-07 14:54:20 -08:00
bors bb587b1a17 Auto merge of #80652 - calebzulawski:simd-lanes, r=nagisa
Improve SIMD type element count validation

Resolves rust-lang/stdsimd#53.

These changes are motivated by `stdsimd` moving in the direction of const generic vectors, e.g.:
```rust
#[repr(simd)]
struct SimdF32<const N: usize>([f32; N]);
```

This makes a few changes:
* Establishes a maximum SIMD lane count of 2^16 (65536).  This value is arbitrary, but attempts to validate lane count before hitting potential errors in the backend.  It's not clear what LLVM's maximum lane count is, but cranelift's appears to be much less than `usize::MAX`, at least.
* Expands some SIMD intrinsics to support arbitrary lane counts.  This resolves the ICE in the linked issue.
* Attempts to catch invalid-sized vectors during typeck when possible.

Unresolved questions:
* Generic-length vectors can't be validated in typeck and are only validated after monomorphization while computing layout.  This "works", but the errors simply bail out with no context beyond the name of the type.  Should these errors instead return `LayoutError` or otherwise provide context in some way?  As it stands, users of `stdsimd` could trivially produce monomorphization errors by making zero-length vectors.

cc `@bjorn3`
2021-02-07 22:25:14 +00:00
Dániel Buga 46f30455f4 Optimize Borrows
Reuse as much memory as possible, reduce number of allocations.
Use BitSet instead of a HashMap, since only a single bit of
information was used as the map's value.
2021-02-07 22:26:21 +01:00
Ömer Sinan Ağacan 7e94641ee9 Fix SourceMap::start_point
`start_point` needs to return the *first* character's span, but it would
previously call `find_width_of_character_at_span` which returns the span
of the *last* character. The implementation is now fixed.

Other changes:

- Docs for start_point, end_point, find_width_of_character_at_span
  updated

- Minor simplification in find_width_of_character_at_span code

Fixes #81800
2021-02-07 23:23:09 +03:00
bors 9778068cbc Auto merge of #79078 - petrochenkov:derattr, r=Aaron1011
expand/resolve: Turn `#[derive]` into a regular macro attribute

This PR turns `#[derive]` into a regular attribute macro declared in libcore and defined in `rustc_builtin_macros`, like it was previously done with other "active" attributes in https://github.com/rust-lang/rust/pull/62086, https://github.com/rust-lang/rust/pull/62735 and other PRs.
This PR is also a continuation of #65252, #69870 and other PRs linked from them, which layed the ground for converting `#[derive]` specifically.

`#[derive]` still asks `rustc_resolve` to resolve paths inside `derive(...)`, and `rustc_expand` gets those resolution results through some backdoor (which I'll try to address later), but otherwise `#[derive]` is treated as any other macro attributes, which simplifies the resolution-expansion infra pretty significantly.

The change has several observable effects on language and library.
Some of the language changes are **feature-gated** by [`feature(macro_attributes_in_derive_output)`](https://github.com/rust-lang/rust/issues/81119).

#### Library

- `derive` is now available through standard library as `{core,std}::prelude::v1::derive`.

#### Language

- `derive` now goes through name resolution, so it can now be renamed - `use derive as my_derive; #[my_derive(Debug)] struct S;`.
- `derive` now goes through name resolution, so this resolution can fail in corner cases. Crater found one such regression, where import `use foo as derive` goes into a cycle with `#[derive(Something)]`.
- **[feature-gated]** `#[derive]` is now expanded as any other attributes in left-to-right order. This allows to remove the restriction on other macro attributes following `#[derive]` (https://github.com/rust-lang/reference/issues/566). The following macro attributes become a part of the derive's input (this is not a change, non-macro attributes following `#[derive]` were treated in the same way previously).
- `#[derive]` is now expanded as any other attributes in left-to-right order. This means two derive attributes `#[derive(Foo)] #[derive(Bar)]` are now expanded separately rather than together. It doesn't generally make difference, except for esoteric cases. For example `#[derive(Foo)]` can now produce an import bringing `Bar` into scope, but previously both `Foo` and `Bar` were required to be resolved before expanding any of them.
- **[feature-gated]** `#[derive()]` (with empty list in parentheses) actually becomes useful. For historical reasons `#[derive]` *fully configures* its input, eagerly evaluating `cfg` everywhere in its target, for example on fields.
Expansion infra doesn't do that for other attributes, but now when macro attributes attributes are allowed to be written after `#[derive]`, it means that derive can *fully configure* items for them.
    ```rust
	#[derive()]
	#[my_attr]
	struct S {
		#[cfg(FALSE)] // this field in removed by `#[derive()]` and not observed by `#[my_attr]`
		field: u8
	}
    ```
- `#[derive]` on some non-item targets is now prohibited. This was accidentally allowed as noop in the past, but was warned about since early 2018 (#50092), despite that crater found a few such cases in unmaintained crates.
- Derive helper attributes used before their introduction are now reported with a deprecation lint. This change is long overdue (since macro modularization, https://github.com/rust-lang/rust/issues/52226#issuecomment-422605033), but it was hard to do without fixing expansion order for derives. The deprecation is tracked by #79202.
```rust
    #[trait_helper] // warning: derive helper attribute is used before it is introduced
    #[derive(Trait)]
    struct S {}
```

Crater analysis: https://github.com/rust-lang/rust/pull/79078#issuecomment-731436821
2021-02-07 19:36:10 +00:00
Vadim Petrochenkov d8af6de911 Address review comments 2021-02-07 20:08:45 +03:00
Vadim Petrochenkov f6caae52c1 Feature gate macro attributes in `#[derive]` output 2021-02-07 20:08:45 +03:00
Vadim Petrochenkov dbdbd30bf2 expand/resolve: Turn `#[derive]` into a regular macro attribute 2021-02-07 20:08:45 +03:00
bors 36ecbc94eb Auto merge of #80632 - Nadrieril:fix-80501, r=varkor
Identify unreachable subpatterns more reliably

In https://github.com/rust-lang/rust/pull/80104 I used `Span`s to identify unreachable sub-patterns in the presence of or-patterns during exhaustiveness checking. In https://github.com/rust-lang/rust/issues/80501 it was revealed that `Span`s are complicated and that this was not a good idea.
Instead, this PR identifies subpatterns logically: as a path in the tree of subpatterns of a given pattern. I made a struct that captures a set of such subpatterns. This is a bit complex, but thankfully self-contained; the rest of the code does not need to know anything about it.
Fixes https://github.com/rust-lang/rust/issues/80501. I think I managed to keep the perf neutral.

r? `@varkor`
2021-02-07 16:48:57 +00:00
Smitty c6cb014ad6 Clarify error message wording 2021-02-07 11:02:53 -05:00
Guillaume Gomez b2beb67fac
Rollup merge of #81835 - jesusprubio:improve-long-eplanation-e0546, r=GuillaumeGomez
Improve long explanation for E0546

Helps with #61137
2021-02-07 14:45:54 +01:00
Guillaume Gomez 6c648822c5
Rollup merge of #81830 - jesusprubio:add-log-explanation-e0542, r=GuillaumeGomez
Add long error explanation for E0542

Helps with #61137
2021-02-07 14:45:53 +01:00
bors 43e1ea29c4 Auto merge of #81498 - thomaseizinger:ice-workaround-56935-rustc-index, r=matthewjasper
Apply workaround from #72003 for #56935 to allow for cross-compilation of `rustc_index` crate

This patch applies the same workaround as #72003 to the `rustc_index` crate. This allows recent versions of rustfmt to compile to wasm again.

Related: #72017.
2021-02-07 08:09:58 +00:00
Smitty 651d289405 Add note about encoding when null bytes found 2021-02-06 19:17:14 -05:00
Tomasz Miąsko a14ec1cedf Show MIR bytes separately in -Zmeta-stats output 2021-02-07 00:00:00 +00:00
bors 08fdbd59b7 Auto merge of #78052 - da-x:path-trimming-type-aliases, r=davidtwco
path trimming: ignore type aliases

Continuation of #73996.
2021-02-06 23:44:42 +00:00
Jesus Rubio ac6c09a980 Typo fix 2021-02-06 19:45:43 +01:00
Jesus Rubio 777582228c References added 2021-02-06 19:44:09 +01:00
Jesus Rubio 023c6d2e04 Comments updated to keep the consistency 2021-02-06 19:41:03 +01:00
Jesus Rubio 0d8a071f98 Improve long explanation for E0546 2021-02-06 18:27:19 +01:00
Jesus Rubio 9be5d2d01f Format fixes 2021-02-06 18:05:21 +01:00
Jesús Rubio 956c81355a
Update compiler/rustc_error_codes/src/error_codes/E0542.md
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-02-06 17:39:11 +01:00
Jonas Schievink 96e843ce6a
Rollup merge of #81738 - camelid:misc-small-diag-cleanup, r=lcnr
Miscellaneous small diagnostics cleanup
2021-02-06 17:01:49 +01:00
Jonas Schievink f631410159
Rollup merge of #81737 - camelid:typeck-structure-sugg, r=lcnr
typeck: Emit structured suggestions for tuple struct syntax

And tuple variant syntax, but that didn't fit in the subject :)

Now the fact that these are suggestions is exposed both to the layout
engine and to IDEs and rustfix for automatic application.
2021-02-06 17:01:47 +01:00
Jonas Schievink 85fb5cdf26
Rollup merge of #81680 - camsteffen:primty, r=oli-obk
Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-06 17:01:45 +01:00
Jonas Schievink 7acf9ecf4f
Rollup merge of #81402 - ehuss:md-tidy, r=jyn514
tidy: Run tidy style against markdown files.

This adds tidy checks for markdown files.  I think it is useful to have some style enforcement (for the same reasons the style is enforced on other files).  I think it is worthwhile to avoid `ignore` on rust examples since having broken code in documentation is frustrating.  Avoiding trailing whitespace is good because it has semantic meaning in markdown, which I think should be avoided.
2021-02-06 17:01:42 +01:00
Jesus Rubio be159379f6 Add long error explanation for E0542 2021-02-06 16:42:34 +01:00
David Hewitt 04a19b93c6 parse_format: treat r" as a literal 2021-02-06 15:01:07 +00:00
Dan Aloni eaefe4a230 path trimming: ignore type aliases 2021-02-06 12:03:48 +02:00
bors cfba499271 Auto merge of #81810 - m-ou-se:rollup-q3nborp, r=m-ou-se
Rollup of 7 pull requests

Successful merges:

 - #80011 (Stabilize `peekable_next_if`)
 - #81580 (Document how `MaybeUninit<Struct>` can be initialized.)
 - #81610 (BTreeMap: make Ord bound explicit, compile-test its absence)
 - #81664 (Avoid a hir access inside get_static)
 - #81675 (Make rustdoc respect `--error-format short` in doctests)
 - #81753 (Never MIR inline functions with a different instruction set)
 - #81795 (Small refactor with Iterator::reduce)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-06 04:55:09 +00:00
Mara Bos 51c68034b9
Rollup merge of #81795 - camsteffen:diagnostics-reduce, r=oli-obk
Small refactor with Iterator::reduce
2021-02-06 00:14:17 +01:00
Mara Bos 728c955ac0
Rollup merge of #81753 - tmiasko:inline-instruction-set, r=oli-obk
Never MIR inline functions with a different instruction set
2021-02-06 00:14:16 +01:00
Mara Bos add80c9d4b
Rollup merge of #81664 - bjorn3:no_codegen_hir, r=lcnr
Avoid a hir access inside get_static

Together with #81056 this ensures that the codegen unit DepNode doesn't have a direct dependency on any part of the hir.
2021-02-06 00:14:13 +01:00
bors 16b805713c Auto merge of #79253 - rcvalle:fix-rustc-sysroot-cas, r=nagisa
Fix rustc sysroot in systems using CAS

Change filesearch::get_or_default_sysroot() to check if sysroot is found using env::args().next() if rustc in argv[0] is a symlink; otherwise, or if it is not found, use env::current_exe() to imply sysroot. This makes the rustc binary able to locate Rust libraries in systems using content-addressable storage (CAS).
2021-02-05 22:58:13 +00:00
Santiago Pastorino fd092557ce
Adapt to latest master changes by using PredicateKind 2021-02-05 18:56:57 -03:00
Santiago Pastorino 7aa602b84c
Revert "Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum"
This reverts commit b4def89d76, reversing
changes made to 7dc1e852d4.
2021-02-05 18:56:56 -03:00
bors 23adf9fd84 Auto merge of #81215 - cjgillot:defkey-mir, r=oli-obk
Encode MIR metadata by iterating on DefId instead of traversing the HIR tree

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

This part only traverses `mir_keys` and encodes MIR according to the def kind.

r? `@oli-obk`
2021-02-05 18:21:47 +00:00
Cameron Steffen c89b9d97e2 Small refactor with Iterator::reduce 2021-02-05 09:34:40 -06:00
bors 5605b5d693 Auto merge of #81257 - pnkfelix:issue-80949-short-term-resolution-via-revert-of-pr-78373, r=matthewjasper
Revert 78373 ("dont leak return value after panic in drop")

Short term resolution for issue #80949.

Reopen #47949 after this lands.

(We plan to fine-tune PR #78373 to not run into this problem.)
2021-02-05 14:52:57 +00:00
Daiki Ihara d3c4dbd85d Add suggest mu method for loop 2021-02-05 22:12:31 +09:00
bors f9435f4c92 Auto merge of #81784 - m-ou-se:rollup-s23fow7, r=m-ou-se
Rollup of 15 pull requests

Successful merges:

 - #79554 (Generic associated types in trait paths)
 - #80726 (relax adt unsizing requirements)
 - #81307 (Handle `Span`s for byte and raw strings and add more detail )
 - #81318 (rustdoc-json: Fix has_body)
 - #81456 (Make remote-test-server easier to use with new targets)
 - #81497 (rustdoc: Move `display_fn` struct inside `display_fn`)
 - #81500 (Remove struct_type from union output)
 - #81542 (Expose correct symlink API on WASI)
 - #81676 (Add more information to the error code for 'crate not found')
 - #81682 (Add additional bitset benchmarks)
 - #81730 (Make `Allocator` object-safe)
 - #81763 (Cleanup rustdoc pass descriptions a bit)
 - #81767 (Update LayoutError/LayoutErr stability attributes)
 - #81771 (Indicate change in RSS from start to end of pass in time-passes output)
 - #81781 (Fix `install-awscli.sh` error in CI)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-05 12:11:05 +00:00
Wesley Wiser dce5e9e1bf Run x.py fmt to fix tidy issues 2021-02-05 06:35:32 -05:00
Mara Bos 08d8fc14be
Rollup merge of #81771 - tgnottingham:time-passes-rss-delta, r=oli-obk
Indicate change in RSS from start to end of pass in time-passes output

Previously, this was omitted because it could be misleading, but the
functionality seems too useful not to include.

r? ``@oli-obk``
2021-02-05 12:26:08 +01:00
Mara Bos 21c276f9c8
Rollup merge of #81682 - JulianKnodt:bit_set_iter_benchmarks, r=oli-obk
Add additional bitset benchmarks

Add additional benchmarks for operations in bitset, I realize that it was a bit lacking when I intended to optimize it earlier, so I was hoping to put some in so I can verify my work later.
2021-02-05 12:26:03 +01:00
Mara Bos 29371c2504
Rollup merge of #81676 - jyn514:crate-not-found, r=oli-obk
Add more information to the error code for 'crate not found'

This comes up a lot when bootstrapping.
2021-02-05 12:26:02 +01:00
Mara Bos 8d49ca11a2
Rollup merge of #81307 - estebank:invalid-byte-str-span, r=petrochenkov
Handle `Span`s for byte and raw strings and add more detail

CC #81208.
2021-02-05 12:25:53 +01:00
Mara Bos 676ff77fb7
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk
relax adt unsizing requirements

Changes unsizing of structs in case the last struct field shares generic params with other adt fields which do not change.
This change is currently insta stable and changes the language, so it at least requires a lang fcp. I feel like the current state is fairly unintuitive.

An example for what's now allowed would be https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6dd331d23f5c9ffc8c978175aae2e967
```rust
struct A<T, U: ?Sized>(T, B<T, U>); // previously ERR
// struct A<T, U: ?Sized>(T, B<[u32; 1], U>); // ok
struct B<T, U: ?Sized>(T, U);

fn main() {
    let x = A([0; 1], B([0; 1], [0; 1]));
    let y: &A<[u32; 1], [u32]> = &x;
    assert_eq!(y.1.1.len(), 1);
}
```
2021-02-05 12:25:52 +01:00
Mara Bos deec6a96d4
Rollup merge of #79554 - b-naber:generic-associated-types-in-trait-paths, r=jackh726
Generic associated types in trait paths

This is the second part of https://github.com/rust-lang/rust/pull/78978

This should fix:

Fixes #67510
Fixes #68648
Fixes #68649
Fixes #68650
Fixes #68652
Fixes #74684
Fixes #76535
Fixes #79422
Fixes #80433

and implement the remaining functionality needed for https://github.com/rust-lang/rust/issues/44265

r? ``@matthewjasper``
2021-02-05 12:25:50 +01:00
bors 730d6dfddd Auto merge of #81736 - tgnottingham:tune-cgu-scheduling-for-memory, r=nagisa
rustc_codegen_ssa: tune codegen scheduling to reduce memory usage

For better throughput during parallel processing by LLVM, we used to sort
CGUs largest to smallest. This would lead to better thread utilization
by, for example, preventing a large CGU from being processed last and
having only one LLVM thread working while the rest remained idle.

However, this strategy would lead to high memory usage, as it meant the
LLVM-IR for all of the largest CGUs would be resident in memory at once.

Instead, we can compromise by ordering CGUs such that the largest and
smallest are first, second largest and smallest are next, etc. If there
are large size variations, this can reduce memory usage significantly.
2021-02-05 09:20:51 +00:00
Tyson Nottingham 4253919f1d Indicate change in RSS from start to end of pass in time-passes output
Previously, this was omitted because it could be misleading, but the
functionality seems too useful not to include.
2021-02-05 01:11:52 -08:00
Jeffrey Griffin ff315e34e8 improve error message for disallowed ptr-to-int casts in const eval 2021-02-05 00:52:19 -08:00
Felix S. Klock II dac354fc32 Revert "Simplify unscheduling of drops after moves"
This reverts commit b766abc88f.
2021-02-04 21:29:50 -05:00
Felix S. Klock II bed69c6134 Revert "Use `record_operands_moved` more aggresively"
This reverts commit 7f3e8551dd.
2021-02-04 21:29:50 -05:00
Felix S. Klock II a71a819480 Revert "Avoid leaking block expression values"
This reverts commit 4fef39113a.
2021-02-04 21:29:49 -05:00
Tomasz Miąsko eb5e2d08c7 Never MIR inline functions with a different instruction set 2021-02-05 00:00:00 +00:00
b-naber 9e920151a3 remove subst_supertrait call 2021-02-04 21:37:23 +01:00
b-naber 6a68966663 use generic arguments of associated item in trait_ref method 2021-02-04 21:37:14 +01:00
Mara Bos 113e27fcfc
Rollup merge of #81727 - m-ou-se:unstabilize-bits, r=Mark-Simulacrum
Revert stabilizing integer::BITS.

We agreed in the libs meeting just now to revert stablization, since the [breakage](https://github.com/rust-lang/rust/issues/81654) is significant throughout the ecosystem, through `lexical-core`.

cc https://github.com/rust-lang/rust/issues/76904

Fixes https://github.com/rust-lang/rust/issues/81654
2021-02-04 21:10:42 +01:00
Mara Bos 87b269ab66
Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995
Add lint for `panic!(123)` which is not accepted in Rust 2021.

This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021.

It suggests to add `"{}",` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming guidelines.

![image](https://user-images.githubusercontent.com/783247/106520928-675ea680-64d5-11eb-81f7-d8fa48b93a0b.png)

This is part of #80162.

r? ```@estebank```
2021-02-04 21:10:36 +01:00
Mara Bos c5990dd8ad
Rollup merge of #81556 - nikomatsakis:forbidden-lint-groups-lint, r=pnkfelix
introduce future-compatibility warning for forbidden lint groups

We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect.

r? ``@Mark-Simulacrum``
2021-02-04 21:10:34 +01:00
Camelid ed6232927b typeck: Emit structured suggestions for tuple struct syntax
And tuple variant syntax, but that didn't fit in the subject :)

Now the fact that these are suggestions is exposed both to the layout
engine and to IDEs and rustfix for automatic application.
2021-02-04 11:58:55 -08:00
Camille GILLOT 09ac459bc7 Encode less consts. 2021-02-04 18:02:14 +01:00
Eric Huss bb22eaf39e tidy: Run tidy style against markdown files. 2021-02-04 09:01:50 -08:00
b-naber da2cf9b9d1 substitutions in trait predicates 2021-02-04 16:35:52 +01:00
b-naber 760a6654fb lowering of generic args in AssocTyConstraint 2021-02-04 16:20:58 +01:00
b-naber 16af7bf3d9 hir pretty printing 2021-02-04 16:20:57 +01:00
b-naber fdaf603102 add generic args to hir::TypeBinding 2021-02-04 16:20:56 +01:00
Mara Bos 24e0940169 Stabilize feature(iterator_fold_self): Iterator::reduce 2021-02-04 11:31:11 +01:00
Mara Bos 5c056ed2f5 Rename Iterator::fold_first to reduce. 2021-02-04 11:30:42 +01:00
bjorn3 da536554a0 Use is_local instead of as_local 2021-02-04 11:17:01 +01:00
Ryan Levick cdfc52fbd6 Try fast_reject::simplify_type in coherence before doing full check
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Ryan Levick <me@ryanlevick.com>
2021-02-04 10:45:17 +01:00
Camelid 253a970c3d Miscellaneous small diagnostics cleanup 2021-02-03 22:09:37 -08:00
Tyson Nottingham 29711d8c96 rustc_codegen_ssa: tune codegen scheduling to reduce memory usage
For better throughput during parallel processing by LLVM, we used to sort
CGUs largest to smallest. This would lead to better thread utilization
by, for example, preventing a large CGU from being processed last and
having only one LLVM thread working while the rest remained idle.

However, this strategy would lead to high memory usage, as it meant the
LLVM-IR for all of the largest CGUs would be resident in memory at once.

Instead, we can compromise by ordering CGUs such that the largest and
smallest are first, second largest and smallest are next, etc. If there
are large size variations, this can reduce memory usage significantly.
2021-02-03 18:55:05 -08:00
klensy 60cca83975 faster spans 2021-02-04 04:54:23 +03:00
Bastian Kauschke 031cce8cfc add `relaxed_struct_unsize` feature gate 2021-02-04 00:00:41 +01:00
Bastian Kauschke 50e394a05e relax adt unsizing requirements 2021-02-04 00:00:28 +01:00
Mara Bos 34d5ac25c5 Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
Mara Bos a616f8267e Add lint for `panic!(123)` which is not accepted in Rust 2021.
This extends the `panic_fmt` lint to warn for all cases where the first
argument cannot be interpreted as a format string, as will happen in
Rust 2021.

It suggests to add `"{}", ` to format the message as a string. In the
case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming
guidelines.
2021-02-03 22:42:53 +01:00
Esteban Küber 3b5d018ebb Handle `Span`s for byte and raw strings and add more detail 2021-02-03 13:34:28 -08:00
Mara Bos 89882388d9 Revert stabilizing integer::BITS. 2021-02-03 22:23:58 +01:00
bors e708cbd91c Auto merge of #81717 - Aaron1011:fix/closure-diag, r=estebank
Fix panic when emitting diagnostic for closure mutable binding error

Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 20:53:08 +00:00
bors 120b2a704a Auto merge of #81718 - m-ou-se:rollup-3ftbymt, r=m-ou-se
Rollup of 5 pull requests

Successful merges:

 - #80394 (make const_err a future incompat lint)
 - #81532 (Remove incorrect `delay_span_bug`)
 - #81692 (Update clippy)
 - #81715 (Reduce tab formatting assertions to debug only)
 - #81716 (Fix non-existent-field ICE for generic fields.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-03 18:01:37 +00:00
Mara Bos 46174188e8
Rollup merge of #81716 - m-ou-se:fix-ice, r=eddyb
Fix non-existent-field ICE for generic fields.

I mentioned this ICE in a chat and it took about 3 milliseconds before `@eddyb` found the problem and said this change would fix it. :)

This also changes one the field types in the related test to one that triggered the ICE.

Fixes #81627.
Fixes #81672.
Fixes #81709.

Cc https://github.com/rust-lang/rust/pull/81480 `@b-naber` `@estebank.`
2021-02-03 18:51:18 +01:00
Mara Bos 65b3c0caf0
Rollup merge of #81715 - jryans:tab-handling-ice-81614, r=estebank
Reduce tab formatting assertions to debug only

The tab replacement for diagnostics added in #79757 included a few assertions to ensure all tab characters are handled appropriately. We've started getting reports of these assertions firing (#81614). Since it's only a cosmetic issue, this downgrades the assertions to debug only, so we at least continue compiling even if the diagnostics might be a tad wonky.

Minimizes the impact of #81614
2021-02-03 18:51:17 +01:00
Mara Bos 66959448e6
Rollup merge of #81532 - estebank:ice-ice-baby, r=pnkfelix
Remove incorrect `delay_span_bug`

The following code is supposed to compile

```rust
use std::ops::BitOr;

pub trait IntWrapper {
    type InternalStorage;
}

impl<T> BitOr for dyn IntWrapper<InternalStorage = T>
where
    Self: Sized,
    T: BitOr + BitOr<Output = T>,
{
    type Output = Self;
    fn bitor(self, _other: Self) -> Self {
        todo!()
    }
}
```

Before this change it would ICE. In #70998 the removed logic was added
to provide better suggestions, and the `delay_span_bug` guard was added
to  protect against a potential logic error when returning traits. As it
happens, there are cases, like the one above, where traits can indeed be
returned, so valid code was being rejected.

Fix (but not close) #80207.
2021-02-03 18:51:14 +01:00
Mara Bos 00dabfbd28
Rollup merge of #80394 - RalfJung:const-err-future, r=oli-obk
make const_err a future incompat lint

This is the first step for https://github.com/rust-lang/rust/issues/71800: make const_err a future-incompat lint. I also rewrote the const_err lint description as the old one seemed wrong.

This has the unfortunate side-effect of making const-eval error even more verbose by making the const_err message longer without fixing the redundancy caused by additionally emitting an error on each use site of the constant. We cannot fix that redundancy until const_err is a *hard* error (at that point the error-on-use-site can be turned into a `delay_span_bug!` for uses of monomorphic consts, and into a nicely rendered error for [lazily / post-monomorhization evaluated] associated consts).

~~The one annoying effect of this PR is that `let _x = &(1/(1-1));` now also shows the future-incompat warning, even though of course we will *not* make this a hard error. We'll instead (hopefully) stop promoting it -- see https://github.com/rust-lang/rfcs/pull/3027. The only way I see to avoid the future-incompat warning is to use a different lint for "failure to evaluate promoted".~~

Cc `@rust-lang/wg-const-eval`
2021-02-03 18:51:12 +01:00
Mara Bos 68cc12ab71 Fix non-existent-field ICE for generic fields.
Co-authored-by: eddyb <eddyb@lyken.rs>
2021-02-03 18:36:48 +01:00
Aaron Hill bc84e21107
Fix panic when emitting diagnostic for closure mutable binding error
Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 12:36:24 -05:00
J. Ryan Stinnett 18f6cc6c5d Reduce tab formatting assertions to debug only
The tab replacement for diagnostics added in #79757 included a few assertions to
ensure all tab characters are handled appropriately. We've started getting
reports of these assertions firing (#81614). Since it's only a cosmetic issue,
this downgrades the assertions to debug only, so we at least continue compiling
even if the diagnostics might be a tad wonky.

Fixes #81614
2021-02-03 17:17:15 +00:00
Esteban Küber ede0a71b9e Remove incorrect `delay_span_bug`
The following code is supposed to compile

```rust
use std::ops::BitOr;

pub trait IntWrapper {
    type InternalStorage;
}

impl<T> BitOr for dyn IntWrapper<InternalStorage = T>
where
    Self: Sized,
    T: BitOr + BitOr<Output = T>,
{
    type Output = Self;
    fn bitor(self, _other: Self) -> Self {
        todo!()
    }
}
```

Before this change it would ICE. In #70998 the removed logic was added
to provide better suggestions, and the `delay_span_bug` guard was added
to  protect against a potential logic error when returning traits. As it
happens, there are cases, like the one above, where traits can indeed be
returned, so valid code was being rejected.

Fix #80207.
2021-02-03 08:52:57 -08:00
Joshua Nelson 82914a5031 Add more information to the error code for 'crate not found'
This comes up a lot when bootstrapping.
2021-02-03 11:51:42 -05:00
bors 186f7ae5b0 Auto merge of #81294 - pnkfelix:issue-81211-use-ufcs-in-derive-debug, r=oli-obk
Use ufcs in derive(Debug)

Cc #81211.

(Arguably this *is* the fix for it.)
2021-02-03 15:12:19 +00:00
Ralf Jung 8477d352ac make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
Cameron Steffen fba747a06e Refactor out PrimitiveTypeTable 2021-02-03 08:32:23 -06:00
Camille GILLOT 0658d8c097 Address review. 2021-02-03 14:29:18 +01:00
bors 6ad11e2e25 Auto merge of #81699 - jethrogb:fix-81531, r=petrochenkov
Really fix early lints inside an async desugaring

Fixes #81531

cc `@Aaron1011`

r? `@petrochenkov`
2021-02-03 11:42:09 +00:00
Jethro Beekman 37cb9d30fa Really fix early lints inside an async desugaring 2021-02-03 10:05:58 +01:00
bors b593389edb Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievink
Add a new ABI to support cmse_nonsecure_call

This adds support for the `cmse_nonsecure_call` feature to be able to perform non-secure function call.

See the discussion on Zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Support.20for.20callsite.20attributes/near/223054928).

This is a followup to #75810 which added `cmse_nonsecure_entry`. As for that PR, I assume that the changes are small enough to not have to go through a RFC but I don't mind doing one if needed 😃
I did not yet create a tracking issue, but if most of it is fine, I can create one and update the various files accordingly (they refer to the other tracking issue now).

On the Zulip chat, I believe `@jonas-schievink` volunteered to be a reviewer 💯
2021-02-03 06:00:43 +00:00
Henry Boisdequin c2e849c022 added a suggestion to create a `const` item if the `fn` in the array repeat expression is a `const fn` 2021-02-03 10:18:08 +05:30
kadmin 6e6608d8b5 Add additional benchmarks to bit_set 2021-02-02 23:31:30 +00:00
Niko Matsakis b6b897b02c introduce future-compatibility warning for forbidden lint groups
We used to ignore `forbid(group)` scenarios completely. This changed
in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where
a group is forbidden but then an individual lint within that group
is allowed. We now issue a FCW when we see the "allow", but permit
it to take effect.
2021-02-02 18:21:37 -05:00
bors d95d4f0189 Auto merge of #81678 - jackh726:rollup-3nerni4, r=jackh726
Rollup of 14 pull requests

Successful merges:

 - #80593 (Upgrade Chalk)
 - #81260 (Add .editorconfig)
 - #81455 (Add AArch64 big-endian and ILP32 targets)
 - #81517 (Remove remnants of the santizer runtime crates from bootstrap)
 - #81530 (sys: use `process::abort()` instead of `arch::wasm32::unreachable()`)
 - #81544 (Add better diagnostic for unbounded Abst. Const)
 - #81588 (Add doc aliases for "delete")
 - #81603 (rustbuild: Don't build compiler twice for error-index-generator.)
 - #81634 (Add long explanation e0521)
 - #81636 (Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on)
 - #81647 (Fix bug with assert!() calling the wrong edition of panic!().)
 - #81655 (Improve wording of suggestion about accessing field)
 - #81665 (Fix out of date `Scalar` documentation)
 - #81671 (Add more associated type tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-02 23:15:22 +00:00
Jack Huey 70d16d506c
Rollup merge of #81665 - jacob-hughes:mir_doc_fix, r=estebank
Fix out of date `Scalar` documentation

Scalars can represent integers up to `u128`, but the docs state otherwise.
2021-02-02 16:01:49 -05:00
Jack Huey 7edb3ad39b
Rollup merge of #81655 - matsujika:suggest-accessing-field-rewording, r=estebank
Improve wording of suggestion about accessing field

Follow-up to #81504

The compiler at this moment suggests "you might have meant to use field `b` of type `B`", sounding like it's type `B` which has the field `b`.
r? ```@estebank```
2021-02-02 16:01:48 -05:00
Jack Huey 7f2eeb10c7
Rollup merge of #81647 - m-ou-se:assert-2021-fix, r=petrochenkov
Fix bug with assert!() calling the wrong edition of panic!().

The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version.

Also adds tests for the 2021 edition of panic and assert, that would've caught this.
2021-02-02 16:01:46 -05:00
Jack Huey 86e23cc9f1
Rollup merge of #81636 - LingMan:slice_not_vec, r=petrochenkov
Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on

```@rustbot``` modify labels +C-cleanup +T-compiler
2021-02-02 16:01:45 -05:00
Jack Huey fd4f4adede
Rollup merge of #81634 - jesusprubio:jesusprubio/add-long-explanation-e0521, r=GuillaumeGomez
Add long explanation e0521

Helps with #61137
2021-02-02 16:01:44 -05:00
Jack Huey 3aed8b17a8
Rollup merge of #81544 - JulianKnodt:sat_where, r=lcnr
Add better diagnostic for unbounded Abst. Const

~~In the case where a generic abst. const requires a trivial where bound: `where TypeWithConst<const_fn(N)>: ,`,
instead of requiring a where bound, just check that only consts are being substituted in to skip over where check.~~

~~This is pretty sketchy, but I think it works. Presumably, if there is checking for type bounds added later, it can first check nested requirements, and see if they're satisfied by the current `ParamEnv`.~~

Changed the diagnostic to add a better example, which is more practical than what was previously proposed.

r? ```@lcnr```
2021-02-02 16:01:39 -05:00
Jack Huey 399c0a8e52
Rollup merge of #81455 - Amanieu:aarch64_ilp32, r=sanxiyn
Add AArch64 big-endian and ILP32 targets

This PR adds 3 new AArch64 targets:
- `aarch64_be-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu_ilp32`
- `aarch64_be-unknown-linux-gnu_ilp32`

It also fixes some ABI issues on big-endian ARM and AArch64.
2021-02-02 16:01:35 -05:00
Jack Huey c1623a2ee7
Rollup merge of #80593 - jackh726:chalk-upgrade, r=nikomatsakis
Upgrade Chalk

~~Blocked on rust-lang/chalk#670~~
~~Now blocked on rust-lang/chalk#680 and release~~

In addition to the straight upgrade, I also tried to fix some tests by properly returning variables and max universes in the solution. Unfortunately, this actually triggers the same perf problem that rustc traits code runs into in `canonicalizer`. Not sure what the root cause of this problem is, or why it's supposed to be solved in chalk.

r? ```@nikomatsakis```
2021-02-02 16:01:32 -05:00
bors 368275062f Auto merge of #81541 - Aaron1011:early-lint-async-fn, r=petrochenkov
Fix early lints inside an async desugaring

Fixes #81531

When we buffer an early lint for a macro invocation,
we need to determine which NodeId to take the lint level from.
Currently, we use the NodeId of the closest def parent. However, if
the macro invocation is inside the desugared closure from an `async fn`
or async closure, that NodeId does not actually exist in the AST.

This commit uses the parent of a desugared closure when computing
`lint_node_id`, which is something that actually exists in the AST (an
`async fn` or async closure).
2021-02-02 20:27:09 +00:00
Aaron Hill a74b2fb946
Fix early lints inside an async desugaring
Fixes #81531

When we buffer an early lint for a macro invocation,
we need to determine which NodeId to take the lint level from.
Currently, we use the `NodeId` of the closest def parent. However, if
the macro invocation is inside the desugared closure from an `async fn`
or async closure, that `NodeId` does not actually exist in the AST.

This commit explicitly calls `check_lint` for the `NodeId`s of closures
desugared from async expressions, ensuring that we do not miss any
buffered lints.
2021-02-02 13:57:46 -05:00
Jack Huey a0622d60e0 Update Chalk 2021-02-02 12:37:22 -05:00
bors 3182375e06 Auto merge of #81405 - bugadani:ast, r=cjgillot
Box the biggest ast::ItemKind variants

This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs.

The three affected item kind enums are:
 - `ast::ItemKind` (208 -> 112 bytes)
 - `ast::AssocItemKind` (176 -> 72 bytes)
 - `ast::ForeignItemKind` (176 -> 72 bytes)
2021-02-02 17:34:08 +00:00
kadmin 65256717f2 Add better diagnostic for missing where clause
Previously, it's not clear what exactly should be added in the suggested where clause,
so this adds an example to demonstrate.
2021-02-02 17:01:53 +00:00
Jake Hughes 07c4eeb836 Fix out of date `Scalar` documentation
Scalars can represent integers up to u128, but the docs state otherwise.
2021-02-02 16:15:32 +00:00
bjorn3 fbe109a2fc Avoid a hir access inside get_static 2021-02-02 16:36:54 +01:00
bors b81f5811f9 Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
2021-02-02 14:52:53 +00:00
Mark Rousskov d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Hugues de Valon ce9818f2b7 Add a new ABI to support cmse_nonsecure_call
This commit adds a new ABI to be selected via `extern
"C-cmse-nonsecure-call"` on function pointers in order for the compiler to
apply the corresponding cmse_nonsecure_call callsite attribute.
For Armv8-M targets supporting TrustZone-M, this will perform a
non-secure function call by saving, clearing and calling a non-secure
function pointer using the BLXNS instruction.

See the page on the unstable book for details.

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2021-02-02 13:04:31 +00:00
Jonas Schievink 73f859e912
Rollup merge of #81631 - LingMan:rem_var, r=davidtwco
Remove unneeded `mut` variable

`arg_elide` gets initialized, immediately cloned, and only written to after that.
The last reading access was removed back in
7704762604
2021-02-02 12:15:08 +01:00
Jonas Schievink 285524f8da
Rollup merge of #81609 - Julian-Wollersberger:no-query-categories, r=davidtwco
Remove the remains of query categories

Back in October 2020 in #77830 ``@cjgillot`` removed the query categories information from the profiler, but the actual definitions which query was in which category remained, although unused.
Here I clean that up, to simplify the query definitions even further.

It's unfortunate that this loses all the context for `git blame`, ~~but I'm working on moving those query definitions into `rustc_query_system`, which will lose that context anyway.~~ EDIT: Might not work out.

The functional changes are in the first commit. The second one only changes the indentation.
2021-02-02 12:15:04 +01:00
Jonas Schievink 255e0764c0
Rollup merge of #81608 - Aaron1011:macro-res-parse-err, r=davidtwco
Improve handling of spans around macro result parse errors

Fixes #81543

After we expand a macro, we try to parse the resulting tokens as a AST
node. This commit makes several improvements to how we handle spans when
an error occurs:

* Only ovewrite the original `Span` if it's a dummy span. This preserves
  a more-specific span if one is available.
* Use `self.prev_token` instead of `self.token` when emitting an error
  message after encountering EOF, since an EOF token always has a dummy
  span
* Make `SourceMap::next_point` leave dummy spans unused. A dummy span
  does not have a logical 'next point', since it's a zero-length span.
  Re-using the span span preserves its 'dummy-ness' for other checks
2021-02-02 12:15:02 +01:00
Jonas Schievink efec2bbbce
Rollup merge of #81577 - BoxyUwU:subexpr_const_evaluatable, r=oli-obk
const_evaluatable: consider sub-expressions to be evaluatable

see [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const_evaluatable.3A.20subexpressions) for more info

cc `@lcnr`
r? `@oli-obk`
2021-02-02 12:14:59 +01:00
Jonas Schievink a1887912e8
Rollup merge of #80629 - sexxi-goose:migrations_1, r=nikomatsakis
Add lint for 2229 migrations

Implements the first for RFC 2229 where we make the decision to migrate a root variable based on if the type of the variable needs Drop and if the root variable would be moved into the closure when the feature isn't enabled.

r? `@nikomatsakis`
2021-02-02 12:14:44 +01:00
Hirochika Matsumoto bad0f288d3 Improve wording of suggestion about accessing field 2021-02-02 15:16:07 +09:00
Aman Arora 84f0a0a1c6 New migration 2021-02-01 22:52:25 -05:00
Aman Arora 8f15cc1d88 PR fixup 2021-02-01 22:13:43 -05:00
Aman Arora caf06bf5f5 Mark the lint doc as compile_fail 2021-02-01 22:13:42 -05:00
Aman Arora cc5e6db5f2 Migrations first pass 2021-02-01 18:38:41 -05:00
Aman Arora d3e85014a7 Process mentioned upvars for analysis first pass after ExprUseVisitor
- This allows us add fake information after handling migrations if
  needed.
- Capture analysis also priortizes what we see earlier, which means
  fake information should go in last.
2021-02-01 18:32:50 -05:00
Mara Bos ed1de99b4f Fix bug with assert!() calling the wrong edition of panic!().
The span of `panic!` produced by the `assert` macro did not carry the
right edition. This changes `assert` to call the right version.
2021-02-01 23:23:27 +01:00
Felix S. Klock II a7745d965e placate tidy. 2021-02-01 17:08:38 -05:00
Felix S. Klock II 2307d08d2f Use UFCS instead of method calls in `derive(Debug)`. See issue 81211 for discussion. 2021-02-01 17:08:37 -05:00
Ellen 7f8530f16b more things are const evaluatable *sparkles* 2021-02-01 20:05:50 +00:00
bors d4e3570db4 Auto merge of #80641 - Danue1:patch-1, r=oli-obk
Add visitors for checking #[inline]

For #80564
2021-02-01 19:31:01 +00:00
Nadrieril ae6fcab733 Make `SubPatSet` clearer by flipping its meaning 2021-02-01 19:29:38 +00:00
LingMan b35d601ab7 Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on 2021-02-01 19:51:24 +01:00
Jesus Rubio ee5ea24d36 Add long error explanation for E0521 2021-02-01 18:22:13 +01:00
Jack Huey 4b64bc1fc9 Upgrade Chalk 2021-02-01 10:37:45 -05:00
LingMan 8e34522309 Remove unneeded `mut` variable
`arg_elide` gets initialized, immediately cloned, and only written to after that.
The last reading access was removed back in
7704762604
2021-02-01 15:37:46 +01:00
Danuel 8bbb2d057d Fixed #[inline] to be warned in fields, arms, macro defs
Add visitors for checking #[inline]

Add visitors for checking #[inline] with struct field

Fix test for #[inline]

Add visitors for checking #[inline] with #[macro_export] macro

Add visitors for checking #[inline] without #[macro_export] macro

Add use alias with Visitor

Fix lint error

Reduce unnecessary variable

Co-authored-by: LingMan <LingMan@users.noreply.github.com>

Change error to warning

Add warning for checking field, arm with #[allow_internal_unstable]

Add name resolver

Formatting

Formatting

Fix error fixture

Add checking field, arm, macro def
2021-02-01 23:36:19 +09:00
Jonas Schievink b3339ab828
Rollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3
Sync rustc_codegen_cranelift

The highlight of this sync are abi compatibility with cg_llvm allowing mixing of cg_clif and cg_llvm compiled crates and switching to the x64 cranelift backend based on the new backend framework.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler
2021-02-01 14:29:47 +01:00
Jonas Schievink 82b00ec606
Rollup merge of #81536 - tgnottingham:time-passes-rss, r=oli-obk
Indicate both start and end of pass RSS in time-passes output

Previously, only the end of pass RSS was indicated. This could easily
lead one to believe that the change in RSS from one pass to the next was
attributable to the second pass, when in fact it occurred between the
end of the first pass and the start of the second.

Also, improve alignment of columns.

Sample of output:

```
time:   0.739; rss:   607MB ->   637MB	item_types_checking
time:   8.429; rss:   637MB ->   775MB	item_bodies_checking
time:  11.063; rss:   470MB ->   775MB	type_check_crate
time:   0.232; rss:   775MB ->   777MB	match_checking
time:   0.139; rss:   777MB ->   779MB	liveness_and_intrinsic_checking
time:   0.372; rss:   775MB ->   779MB	misc_checking_2
time:   8.188; rss:   779MB ->  1019MB	MIR_borrow_checking
time:   0.062; rss:  1019MB ->  1021MB	MIR_effect_checking
```
2021-02-01 14:29:40 +01:00
Jonas Schievink 39ea34744b
Rollup merge of #81529 - estebank:case_lints, r=davidtwco
Fix invalid camel case suggestion involving unicode idents

Follow up to #77805.
2021-02-01 14:29:39 +01:00
Jonas Schievink 853cfd462f
Rollup merge of #81504 - matsujika:suggestion-field-access, r=estebank
Suggest accessing field when appropriate

Fix #81222

r? ``@estebank``
2021-02-01 14:29:37 +01:00
Jonas Schievink 9e8753e2bb
Rollup merge of #81463 - matsujika:nll-ensure-c-case, r=varkor
Rename NLL* to Nll* accordingly to C-CASE

Given [C-CASE](https://rust-lang.github.io/api-guidelines/naming.html#casing-conforms-to-rfc-430-c-case), `NLLRegionVariableOrigin` and `NLL` are encouraged to be `NllRegionVariableOrigin` and `Nll` respectively.
2021-02-01 14:29:35 +01:00
Jonas Schievink ab74346b96
Rollup merge of #81364 - camelid:improve-build-matches-docs, r=varkor
Improve `rustc_mir_build::matches` docs

- Fix typos
- Add more information
- General cleanup
2021-02-01 14:29:31 +01:00
Jonas Schievink 21d0e9b8dc
Rollup merge of #79291 - JulianKnodt:ce_priv, r=petrochenkov
Add error message for private fn

Attempts to add a more detailed error when a `const_evaluatable` fn from another scope is used inside of a scope which cannot access it.

r? ````@lcnr````
2021-02-01 14:29:29 +01:00
bors e0d9f79399 Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkov
Implement Rust 2021 panic

This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007.

It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller.

This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: c5273bdfb2 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-02-01 10:25:31 +00:00
bjorn3 27855331e8 Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01 2021-02-01 10:11:46 +01:00
Dániel Buga 003fba3fda Assert the size of the refactored enums 2021-02-01 09:23:40 +01:00
Dániel Buga b87e1ecdf0 Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
Aman Arora bf4bdd95c3 Add lint for 2229 migrations 2021-01-31 23:21:04 -05:00
Camelid 8b52cdc942 Update outdated comment
The highest-priority item is the *first* in the list, not the last.
See [this code][1] for more.

[this code]: 0e63af5da3/compiler/rustc_mir_build/src/build/matches/mod.rs (L1334-L1335)
2021-01-31 15:41:17 -08:00
kadmin 6a03f0350d Add error message for private fn
Bless tests

Update with changes from comments
2021-01-31 20:45:13 +00:00
Julian Wollersberger 988d93c8a0 Indent the code correctly again after removing the query categories. 2021-01-31 21:40:03 +01:00
Julian Wollersberger 7bc09f78af Remove the remains of the query categories. 2021-01-31 21:37:17 +01:00
Aaron Hill 6c14aad58e
Improve handling of spans around macro result parse errors
Fixes #81543

After we expand a macro, we try to parse the resulting tokens as a AST
node. This commit makes several improvements to how we handle spans when
an error occurs:

* Only ovewrite the original `Span` if it's a dummy span. This preserves
  a more-specific span if one is available.
* Use `self.prev_token` instead of `self.token` when emitting an error
  message after encountering EOF, since an EOF token always has a dummy
  span
* Make `SourceMap::next_point` leave dummy spans unused. A dummy span
  does not have a logical 'next point', since it's a zero-length span.
  Re-using the span span preserves its 'dummy-ness' for other checks
2021-01-31 15:24:34 -05:00
Jonas Schievink 9165676d91
Rollup merge of #81590 - KodrAus:stabilize/int_bits_const, r=m-ou-se
Stabilize int_bits_const

Closes #76904

The FCP to stabilize the `int_bits_const` feature completed on the tracking issue.
2021-01-31 16:36:57 +01:00
Jonas Schievink 36af32a740
Rollup merge of #81572 - pierwill:edit-error-codes-1, r=jonas-schievink
Edit multiple error code Markdown files

Makes small edits to several error code files. Fixes some missing punctuation. Changes some wording, grammar, and formatting for clarity and readability.

Adds a link to the rustup book in E0658.
2021-01-31 16:36:54 +01:00
Jonas Schievink 86c01ddc22
Rollup merge of #81571 - schteve:fix_e0759_typo, r=jonas-schievink
Fix typo in E0759

Minor typo in E0759 error message.
2021-01-31 16:36:52 +01:00
Jonas Schievink 024848d013
Rollup merge of #81568 - osa1:remove_old_fixme, r=jonas-schievink
Fix an old FIXME in redundant paren lint

Referenced bug was fixed a while ago
2021-01-31 16:36:51 +01:00
Jonas Schievink 991b31377c
Rollup merge of #81480 - b-naber:nested_fields_suggestion, r=estebank
Add suggestion for nested fields

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

r? ```@estebank```
2021-01-31 16:36:46 +01:00
Jonas Schievink ed5614599a
Rollup merge of #81255 - sunfishcode:wasi-no-export-dynamic, r=alexcrichton
Don't link with --export-dynamic on wasm32-wasi

Remove --export-dynamic from the link arguments on the wasm32-wasi
target, as it emits spurious exports and increases code size.

Leave it in place for wasm32-unknown-unknown and
wasm32-unknown-emscripten. Even though it isn't a great solution
there, users are likely depending on its behavior there.
2021-01-31 16:36:44 +01:00