Commit graph

3026 commits

Author SHA1 Message Date
Daiki Ihara f03907b33f Add pointing const identifier when emitting E0435 2021-01-07 20:20:58 +09:00
bors bf5f30684a Auto merge of #80648 - Aaron1011:expn-data-private, r=petrochenkov
Make `ExpnData` fields `krate` and `orig_id` private

These fields are only used by hygiene serialized, and should not be
accessed by anything outside of `rustc_span`.
2021-01-07 08:25:39 +00:00
bors dfdfaa1f04 Auto merge of #80200 - mahkoh:dst-offset, r=nagisa
Optimize DST field access

For

    struct X<T: ?Sized>(T)
    struct Y<T: ?Sized>(u8, T)

the offset of the unsized field is

    0
    mem::align_of_val(&self.1)

respectively. This patch changes the expression used to compute these
offsets so that the optimizer can perform this optimization.

Consider

```rust
fn f(x: &X<dyn Any>) -> &dyn Any {
    &x.0
}
```

Before:

```asm
test:
	movq	%rsi, %rdx
	movq	16(%rsi), %rax
	leaq	-1(%rax), %rcx
	negq	%rax
	andq	%rcx, %rax
	addq	%rdi, %rax
	retq
```

After:

```asm
test:
	movq	%rsi, %rdx
	movq	%rdi, %rax
	retq
```
2021-01-07 03:13:21 +00:00
bors 5b3d52414e Auto merge of #80425 - camelid:resolve-moduledata-docs, r=petrochenkov
Document `ModuleData` and improve names

- Document `ModuleData`
- Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod`
- Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod`

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/mentoring/near/221029702

r? `@petrochenkov`
2021-01-07 00:31:09 +00:00
bors d7769b9bea Auto merge of #80754 - sunfishcode:path-cleanup/rustc-fs-util, r=davidtwco
Optimize away a `fs::metadata` call.

This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
2021-01-06 21:48:06 +00:00
Camelid ff75da89b1 Rename to nearest_parent_mod
* Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod`

`normal_ancestor_id` is a very confusing name if you don't already
understand what it means. Adding docs helps, but using a clearer and
more obvious name is also important.

* Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod`

* Add more docs
2021-01-06 12:55:44 -08:00
Camelid 06931988c0 Document ModuleData
* Convert comments on fields to doc comments so they're visible in API
  docs
* Add new documentation
* Get rid of "normal module" terminology
2021-01-06 12:51:36 -08:00
Dan Gohman 68338bc2b0 Optimize away a fs::metadata call.
This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
2021-01-06 08:33:15 -08:00
Dan Gohman 304643c00d Optimize away some fs::metadata calls.
This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
2021-01-06 08:31:25 -08:00
Daniel Henry-Mantilla a4de27aeec Fixed non-declarative-nor-opaque macros effective privacy.
cc @petrochenkov
2021-01-06 15:13:39 +01:00
Daniel Henry-Mantilla dd15f410df WIP: attempt to fix the undocument re-export issue 2021-01-06 15:13:39 +01:00
Lzu Tao 8ee804dc2b Change related spec files to use the new enum 2021-01-06 13:34:20 +00:00
Lzu Tao fa4d8bc878 Prefer enum Endian in rustc_target::Target 2021-01-06 13:34:19 +00:00
bors 8fec6c7bb9 Auto merge of #80714 - jakevossen5:master, r=lcnr
fixed const_generics error help

Closes https://github.com/rust-lang/rust/issues/80702
2021-01-06 10:25:18 +00:00
Guillaume Gomez 7bc22e96d3 Don't use to_string on Symbol 2021-01-06 10:59:50 +01:00
Andrew Sun bf80159050 Make target-cpu=native detect individual features 2021-01-06 03:23:54 -05:00
bors 41601ef394 Auto merge of #80415 - cjgillot:issue-77828, r=petrochenkov
Compute parent module when collecting hir::MacroDef.

Fixes #77828.

r? `@jyn514`
2021-01-06 00:36:14 +00:00
Arlie Davis 4721b6518c Split a func into cold/hot parts, reducing binary size
I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.

Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.

This reduces binary size by 24 KB. By itself, that's not a substantial
reduction. However, changes like this often reduce pressure on
instruction-caches, since it reduces the amount of code that is inlined
into hot code paths. Or more precisely, it removes cold code from hot
cache lines. It also removes all conditionals from Size::bits(),
which is called in many places.
2021-01-05 12:52:34 -08:00
Camille GILLOT 4fb12369b3 Do not swallow parent for MacroDef. 2021-01-05 21:10:35 +01:00
Camille GILLOT 59f1ccd35c Compute parent module when collecting hir::MacroDef. 2021-01-05 21:10:34 +01:00
bors da305a2b00 Auto merge of #80711 - camelid:intrinsic-of-val-safety, r=oli-obk
Make `size_of_val` and `min_align_of_val` intrinsics unsafe

Fixes #80668.

r? `@oli-obk`
2021-01-05 17:07:25 +00:00
oli 41a732dfd4 Remove a FIXME and explain the decision 2021-01-05 12:10:56 +00:00
bors f4b9d32ef5 Auto merge of #80686 - GuillaumeGomez:error-doc-alias-same-name, r=jyn514
Error when #[doc(alias)] has same name as the item

Something I came across when reviewing some doc alias PRs.

r? `@jyn514`
2021-01-05 08:47:46 +00:00
Jake Vossen f37e737535 fixed const_generics error help 2021-01-05 00:01:48 -07:00
Camelid bbf175df3c Make size_of_val and min_align_of_val intrinsics unsafe 2021-01-04 19:23:55 -08:00
Yuki Okushi 598d189e9b
Rollup merge of #80643 - LingMan:unwrap, r=oli-obk
Move variable into the only branch where it is relevant

At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`.
We can branch on the parameter, move the binding into the `if`, and the complexity of handling
`Option<Option<_>` largely dissolves.

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

Note: I have no idea how hot this code is. If this method frequently gets called with a `None` filter, there might be a small perf improvement.
2021-01-05 09:52:44 +09:00
Yuki Okushi faf8beddef
Rollup merge of #80637 - LingMan:filter, r=oli-obk
Use Option::filter instead of open-coding it

`@rustbot` modify labels +C-cleanup +T-compiler
2021-01-05 09:52:42 +09:00
Yuki Okushi be2a3f8642
Rollup merge of #80538 - JulianKnodt:err_usize, r=lcnr
Add check for `[T;N]`/`usize` mismatch in astconv

Helps clarify the issue in #80506
by adding a specific check for mismatches between [T;N] and usize.

r? `@lcnr`
2021-01-05 09:52:37 +09:00
oli 65ee418e5c Do not run const prop on the mir_for_ctfe of const fn 2021-01-04 22:29:45 +00:00
oli 3af7989a7c No doc comments on expressions 2021-01-04 21:40:38 +00:00
oli a76dae4946 Fix wording of query description 2021-01-04 21:40:38 +00:00
oli 9eaec139d0 Small comment adjustments 2021-01-04 21:40:38 +00:00
oli caeb3d525d Move MIR body loading to a machine function 2021-01-04 21:40:38 +00:00
oli f6d54aa0c1 Adjust imports 2021-01-04 21:40:38 +00:00
oli 7202054800 Document all the things 2021-01-04 21:40:38 +00:00
oli 680c4022ae Comment nit 2021-01-04 21:40:38 +00:00
oli db90150b91 Polymorphization should look at the runtime MIR of const fn 2021-01-04 21:40:38 +00:00
oli eb4e94b2e5 Simplify the optimize_mir query 2021-01-04 21:40:38 +00:00
oli 1f5fb3e056 Differentiate between the availability of ctfe MIR and runtime MIR 2021-01-04 21:40:38 +00:00
oli cccd40f9b5 Keep an unoptimized duplicate of const fn around
This allows CTFE to reliably detect UB, as otherwise
optimizations may hide UB.
2021-01-04 21:40:38 +00:00
oli 8e4fe6647f Require the encode_promoted_mir caller to know whether MIR for this item actually exists 2021-01-04 21:40:38 +00:00
oli 248b4dbc4f Limit trait item mir encoding to items with default bodies 2021-01-04 21:40:38 +00:00
oli dadf937a12 Remove mir encode calls that didn't actually encode anything 2021-01-04 21:40:38 +00:00
oli 552f391969 Make encode_optimized_mir always perform its action and instead require the callers to know whether they actually want this 2021-01-04 21:40:38 +00:00
oli 68ff5f0a18 Stop optimizing promoteds 2021-01-04 21:40:38 +00:00
bors 61f5a00923 Auto merge of #80624 - RalfJung:place-ref, r=oli-obk
use PlaceRef more consistently instead of loosely coupled local+projection

Instead of working directly with the `projections` array, use `iter_projections` and `last_projection`. This avoids having to construct new `PlaceRef` from the pieces everywhere.

I only did this for a few files, to see how people think about this. If y'all are happy with this, I'll open an E-mentor issue to complete this. I grepped for `Place::ty_from` to find the places that need adjusting -- this could miss some, but I am not sure what else to grep for.
2021-01-04 20:56:34 +00:00
Rich Kadel e4aa99fe7a Inlining enabled by -mir-opt-level > 1 is incompatible with coverage
Fixes: #80060

Also adds additional test cases for coverage of doctests.
2021-01-04 11:06:42 -08:00
Guillaume Gomez c4c010f534 Add an error in case the doc alias is the same as the item it's aliasing 2021-01-04 15:05:36 +01:00
bors ab5b9aecb9 Auto merge of #80651 - GroteGnoom:issue-78123-fix, r=Nadrieril
Add note to non-exhaustive match on reference to empty

Rust prints "type `&A` is non-empty" even is A is empty.
This is the intended behavior, but can be confusing.
This commit adds a note to non-exhaustive pattern errors if they are a
reference to something uninhabited.

I did not add tests to check that the note is not shown for
non-references or inhabited references, because this is already done
in other tests.

Maybe the added test is superfluous, because
`always-inhabited-union-ref` already checks for this case.

This does not handle &&Void or &&&void etc. I could add those as special
cases as well and ignore people who need quadruple
references.

Fixes #78123
2021-01-04 13:23:08 +00:00
kadmin 54883e0a1c Add check for array/usize mismatch in astconv 2021-01-04 10:07:15 +00:00
bors 887398ff68 Auto merge of #80610 - Aaron1011:unhash-def-path-hash, r=varkor
Use `UnhashMap` whenever we have a key of `DefPathHash`
2021-01-04 07:49:01 +00:00
bors 8989689e72 Auto merge of #80418 - oli-obk:this_could_have_been_so_simple, r=RalfJung
Allow references to interior mutable data behind a feature gate

supercedes #80373 by simply not checking for interior mutability on borrows of locals that have `StorageDead` and thus can never be leaked to the final value of the constant

tracking issue: https://github.com/rust-lang/rust/issues/80384

r? `@RalfJung`
2021-01-04 02:15:57 +00:00
pierwill 9a240e4857 Edit rustc_ast::tokenstream docs
Fix some punctuation and wording, and add intra-documentation links.
2021-01-03 11:54:56 -08:00
Daniel Noom 998bf0ab88 Add note to non-exhaustive match on reference to empty
Rust prints "type `&A` is non-empty" even is A is empty.
This is the intended behavior, but can be confusing.
This commit adds a note to non-exhaustive pattern errors if they are a
reference to something uninhabited.

I did not add tests to check that the note is not shown for
non-references or inhabited references, because this is already done
in other tests.

Maybe the added test is superfluous, because
`always-inhabited-union-ref` already checks for this case.

This does not handle &&Void or &&&void etc. I could add those as special
cases as well and ignore people who need quadruple
references.

Fixes #78123
2021-01-03 19:05:23 +01:00
Guillaume Gomez 539c435b50
Rollup merge of #80646 - bugadani:meta, r=petrochenkov
Clean up in `each_child_of_item`

This PR hopes to eliminate some of the surprising elements I encountered while reading the function.
- `macros_only` is checked against inside the loop body, but if it is `true`, the loop is skipped anyway
- only query `span` when relevant
- no need to allocate attribute vector
2021-01-03 17:09:13 +01:00
Guillaume Gomez ff1f21a8fd
Rollup merge of #80628 - matthiaskrgr:match_ref_pats, r=varkor
reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats)
2021-01-03 17:09:11 +01:00
oli 90b56b94f6 Stylistic fixes to diagnostic messages 2021-01-03 15:11:34 +00:00
oli d3992f36ad Refactor the non-transient cell borrow error diagnostic 2021-01-03 14:46:49 +00:00
Oli Scherer 8968c8a103
Dangling pointers point to everything and nothing
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-01-03 15:19:07 +01:00
Oli Scherer e5e4a851c4
Grammar fixes
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-01-03 15:15:23 +01:00
Aaron Hill 21b8f2ecde
Make ExpnData fields krate and orig_id private
These fields are only used by hygiene serialized, and should not be
accessed by anything outside of `rustc_span`.
2021-01-03 08:58:43 -05:00
oli a137ff1706 Update now-more-precise operation with a preciser message 2021-01-03 13:45:16 +00:00
Oli Scherer e5330a4f52 Apply suggestions from code review
comment nits

Co-authored-by: Ralf Jung <post@ralfj.de>
2021-01-03 13:32:56 +00:00
Ralf Jung afa7408041 use PlaceRef more consistently instead of loosely coupled local+projection 2021-01-03 14:14:55 +01:00
Dániel Buga 4d3227fe1c Move variable into condition where it's used 2021-01-03 13:55:43 +01:00
Dániel Buga 250fb72d1b No need to collect result of get_item_attrs 2021-01-03 13:55:40 +01:00
Matthias Krüger e2272cdffc remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00
Dániel Buga 675059a9eb Clean up convoluted macros_only logic 2021-01-03 12:47:38 +01:00
bors 18cb4ad3b9 Auto merge of #80247 - tmiasko:indent, r=bjorn3
Fix indentation of -Z meta-stats output
2021-01-03 09:16:24 +00:00
LingMan af7134e7de Move variable into the only branch where it is relevant
At the `if` branch `filter` (the `let` binding) is `None` iff `filter` (the parameter) was `None`.
We can branch on the parameter, move the binding into the `if`, and the complexity of handling
`Option<Option<_>` largely dissolves.
2021-01-03 10:07:22 +01:00
LingMan 203d5025bb Use Option::filter instead of open-coding it 2021-01-03 05:53:15 +01:00
bors c7d6c3dfdc Auto merge of #80592 - Skynoodle:snake-case-lint-reserved-identifier, r=davidtwco
Suggest renaming or escaping when fixing non-snake-case identifiers which would conflict with keywords

Fixes #80575
2021-01-02 22:06:17 +00:00
Matthias Krüger 8a90626a46 reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats) 2021-01-02 20:09:17 +01:00
Skynoodle 750c52af73 Add snake case lint note about keyword identifiers which cannot be raw 2021-01-02 15:46:41 +00:00
bors 90ccf4f5ad Auto merge of #80615 - m-ou-se:rollup-xz67at2, r=m-ou-se
Rollup of 6 pull requests

Successful merges:

 - #80546 (clippy fixes for librustdoc)
 - #80555 (Improve library tracking issue template)
 - #80574 (Clean bootstrap artifacts on `x.py clean`)
 - #80578 (improve unconditional_panic description)
 - #80599 (`const_generics_defaults`: don't ICE in the unimplemented parts)
 - #80613 (Diag: print enum variant instead of enum type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-02 12:40:32 +00:00
Mara Bos 4172756c80
Rollup merge of #80613 - bugadani:issue-80607, r=matthewjasper
Diag: print enum variant instead of enum type

Closes #80607
2021-01-02 11:29:15 +00:00
Mara Bos 7a1b01ec02
Rollup merge of #80599 - lqd:issue_805889, r=varkor
`const_generics_defaults`: don't ICE in the unimplemented parts

The thought was that we could use `todo!`s to ensure we wouldn't forget to implement parts of the experimental gate.

However, that can also lead to a suboptimal experience for users as shown in #80589 having both the error/warning about the experimental feature, and the ICE.

Fixes #80589

r? `@varkor`
2021-01-02 11:29:14 +00:00
Mara Bos bb703058b7
Rollup merge of #80578 - RalfJung:panic-lint-description, r=lcnr
improve unconditional_panic description

The fact that the lint is triggered by the ConstProp pass is an implementation detail, I do not think that this should be mentioned in the description.

Cc `@oli-obk` `@ehuss`
2021-01-02 11:29:12 +00:00
Dániel Buga e0300716ef Print actual enum variant 2021-01-02 11:06:30 +01:00
bors 929f66af9b Auto merge of #80115 - tgnottingham:specialize_opaque_u8_sequences, r=oli-obk
rustc_serialize: specialize opaque encoding and decoding of some u8 sequences

This specializes encoding and decoding of some contiguous u8 sequences to use a more efficient implementation. The default implementations process each u8 individually, but that isn't necessary for the opaque encoder and decoder. The opaque encoding for u8s is a no-op, so we can just copy entire sequences as-is, rather than process them byte by byte.

This also changes some encode and decode implementations for contiguous sequences to forward to the slice and vector implementations, so that they can take advantage of the new specialization when applicable.
2021-01-02 09:52:26 +00:00
bors 5986dd878f Auto merge of #79883 - frewsxcv:frewsxcv-san, r=shepmaster
Enable ASan, TSan, UBSan for aarch64-apple-darwin.

I confirmed ASan, TSan, UBSan all work for me locally with `clang` on my new Macbook Air.

~This requires https://github.com/rust-lang/llvm-project/pull/86~
2021-01-02 06:58:59 +00:00
Tyson Nottingham be79f493fb rustc_serialize: specialize opaque decoding of some u8 sequences 2021-01-01 22:49:16 -08:00
Tyson Nottingham 7c6274d464 rustc_serialize: have read_raw_bytes take MaybeUninit<u8> slice 2021-01-01 22:49:16 -08:00
Tyson Nottingham a4daa63a90 rustc_serialize: specialize opaque encoding of some u8 sequences 2021-01-01 22:49:14 -08:00
Aaron Hill 0dc9b26523
Use UnhashMap whenever we have a key of DefPathHash 2021-01-01 23:51:07 -05:00
Rémy Rakic ea0f6396aa const_generics_defaults: don't use todo
So that at least it won't ICE for users whether or not they enable the gate. For developers the FIXMEs are enough.
2021-01-01 22:35:56 +01:00
Skynoodle 91f436b456 Add suggestion to use raw identifiers when fixing snake-case lints 2021-01-01 18:38:30 +00:00
oli aaee3f27ee Don't mix feature gates and hard errors, decide on one per op and stick with it 2021-01-01 16:59:12 +00:00
oli 3ed14033f7 Reinstate the error-code error over the feature gate error 2021-01-01 16:59:12 +00:00
oli 4158e58d79 Enhance some comments 2021-01-01 16:59:12 +00:00
oli 354e510f7d Fix cell checks in const fn 2021-01-01 16:59:12 +00:00
oli 3a44a20ed1 The proper name for the rule is "enclosing scope" 2021-01-01 16:59:12 +00:00
oli 0b841846ba Allow references to interior mutable data behind a feature gate 2021-01-01 16:59:12 +00:00
Ralf Jung b31400a226 improve unconditional_panic description 2021-01-01 15:00:27 +01:00
Rémy Rakic 942b7ce2c1 make const_generics_defaults use the unstable syntax mechanism
This is important to not accidentally stabilize the parsing of the syntax while it still is experimental and not formally accepted
2021-01-01 11:01:01 +01:00
Rémy Rakic 1fc3c4c16d adjust const generics defaults FIXMEs to the new feature gate 2021-01-01 11:01:01 +01:00
Rémy Rakic ea8fa36bb4 mark const_generics_defaults as an incomplete feature 2021-01-01 10:55:16 +01:00
Rémy Rakic 5f4bb468c1 fix typo in feature gates file 2021-01-01 10:55:16 +01:00
Julian Knodt 61f33bfd29 first pass at default values for const generics
- Adds optional default values to const generic parameters in the AST
  and HIR
- Parses these optional default values
- Adds a `const_generics_defaults` feature gate
2021-01-01 10:55:10 +01:00
Corey Farwell d482de30ea Merge remote-tracking branch 'origin/master' into frewsxcv-san 2020-12-31 23:27:33 -05:00
bors f8ab56bf32 Auto merge of #79576 - m-ou-se:2021, r=Mark-Simulacrum
Add edition 2021.

🎆 Happy new ~~year~~ Rust. 🍾

This adds --edition=2021, and updates suggestions about 2018 to say "2018 *or later*".

Related Cargo PR: https://github.com/rust-lang/cargo/pull/8922

---

Edit: This adds the new edition as *unstable*. Without `-Z unstable-options`, `--edition=2021` results in:
```
$ rustc --edition=2021
error: edition 2021 is unstable and only available with -Z unstable-options.
```
2021-01-01 03:41:31 +00:00
Dylan DPC 96c11f98d7
Rollup merge of #80551 - lcnr:const-arg-wildcard, r=varkor
support pattern as const parents in type_of

nice to know that there's still stuff about rust i didn't know about 😆

fixes #80531

r? `@varkor`
2020-12-31 22:21:00 +01:00
Dylan DPC 33806d2599
Rollup merge of #80548 - JohnTitor:wfcheck-foreign-fn-ice, r=davidtwco
FIx ICE on wf check for foreign fns

Fixes #80468

r? `@davidtwco` `@lcnr`
2020-12-31 22:20:59 +01:00
Dylan DPC 1f431f9066
Rollup merge of #80519 - max-heller:issue-80512-fix, r=varkor
Take type defaults into account in suggestions to reorder generic parameters

Fixes #80512
2020-12-31 22:20:53 +01:00
Dylan DPC 55cfcd596f
Rollup merge of #80323 - camelid:codegen-base-docs, r=nagisa
Update and improve `rustc_codegen_{llvm,ssa}` docs

Fixes #75342.

These docs were very out of date and misleading. They even said that
they codegen'd the *AST*!

For some reason, the `rustc_codegen_ssa::base` docs were exactly
identical to the `rustc_codegen_llvm::base` docs. They didn't really
make sense, because they had LLVM-specific information even though
`rustc_codegen_ssa` is supposed to be somewhat generic. So I removed
them as they were misleading.

r? ``@pnkfelix`` maybe?
2020-12-31 22:20:43 +01:00
Mara Bos 3cbdbe8dcd Enable Pat2021 in edition 2021. 2020-12-31 19:39:44 +01:00
Mara Bos 3d9d0e9d3e Require -Z unstable-options for unstable editions. 2020-12-31 19:06:09 +01:00
Mara Bos c574ded57d Consistently call editions "Rust 20xx" in messages. 2020-12-31 19:06:09 +01:00
Mara Bos f16ef7d7ce Add edition 2021. 2020-12-31 19:06:09 +01:00
bors 44e3daf5ee Auto merge of #80459 - mark-i-m:or-pat-reg, r=petrochenkov
Implement edition-based macro :pat feature

This PR does two things:
1. Fixes the perf regression from https://github.com/rust-lang/rust/pull/80100#issuecomment-750893149
2. Implements `:pat2018` and `:pat2021` matchers, as described by `@joshtriplett`  in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090 behind the feature gate `edition_macro_pat`.

r? `@petrochenkov`

cc `@Mark-Simulacrum`
2020-12-31 14:52:26 +00:00
Bastian Kauschke 2aef46b17b support pattern as const parents in type_of 2020-12-31 14:10:49 +01:00
bors a6bd5246da Auto merge of #80267 - 0urobor0s:ouro/61592, r=jyn514
Rustdoc render public underscore_imports as Re-exports

Fixes #61592
2020-12-31 09:07:52 +00:00
bors cb4553bdae Rustdoc render public underscore_imports as Re-exports
Fixes #61592
2020-12-31 09:07:51 +00:00
bors 923e3d2400 Auto merge of #80500 - jyn514:track-caller, r=nagisa
Add `#[track_caller]` to `bug!` and `register_renamed`

Before:

```
thread 'rustc' panicked at 'compiler/rustc_lint/src/context.rs:267:18: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:34:26
```

After:

```
thread 'rustc' panicked at 'src/librustdoc/core.rs:455:24: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:35:26
```

The reason I added it to `register_renamed` too is that any panic in
that function will be the caller's fault.
2020-12-31 03:17:50 +00:00
Yuki Okushi 7008911080 FIx ICE on wf check for foreign fns 2020-12-31 11:25:53 +09:00
bors 9775ffef2a Auto merge of #80530 - m-ou-se:rollup-zit69ko, r=m-ou-se
Rollup of 9 pull requests

Successful merges:

 - #78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength)
 - #79479 (Add `Iterator::intersperse`)
 - #80128 (Edit rustc_ast::ast::FieldPat docs)
 - #80424 (Don't give an error when creating a file for the first time)
 - #80458 (Some Promotion Refactoring)
 - #80488 (Do not create dangling &T in Weak<T>::drop)
 - #80491 (Miri: make size/align_of_val work for dangling raw ptrs)
 - #80495 (Rename kw::Invalid -> kw::Empty)
 - #80513 (Add regression test for #80062)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 21:25:15 +00:00
max-heller 947b279bc6 Take type defaults into account in suggestions to reorder generic parameters 2020-12-30 16:00:25 -05:00
Mara Bos 9e8edc8c22
Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkov
Rename kw::Invalid -> kw::Empty

See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.

r? `@petrochenkov`
2020-12-30 20:56:58 +00:00
Mara Bos 067f1b7030
Rollup merge of #80491 - RalfJung:dangling-of-val, r=oli-obk
Miri: make size/align_of_val work for dangling raw ptrs

This is needed for https://github.com/rust-lang/rust/issues/80365#issuecomment-752128105.

r? `@oli-obk`
2020-12-30 20:56:56 +00:00
Mara Bos 46111c1901
Rollup merge of #80458 - RalfJung:promotion-refactor, r=oli-obk
Some Promotion Refactoring

Clean up promotion a bit:
* factor out some common code
* more exhaustive matches

This *should* not break anything... the only potentially-breaking change is that `BorrowKind::Shallow | BorrowKind::Unique` are now rejected for internal references.

r? ``@oli-obk``
2020-12-30 20:56:52 +00:00
Mara Bos 3d7cdf667e
Rollup merge of #80128 - pierwill:pierwill-docs-fieldpat, r=jyn514
Edit rustc_ast::ast::FieldPat docs

Punctuation fixes.
2020-12-30 20:56:49 +00:00
bors e226704685 Auto merge of #80511 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump bootstrap compiler to 1.50 beta

r? `@pietroalbini`
2020-12-30 18:32:31 +00:00
mark 40bf3c0f09 Implement edition-based macro pat feature 2020-12-30 09:57:49 -06:00
bors 507bff92fa Auto merge of #80510 - JohnTitor:rollup-gow7y0l, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #80185 (Fix ICE when pointing at multi bytes character)
 - #80260 (slightly more typed interface to panic implementation)
 - #80311 (Improvements to NatVis support)
 - #80337 (Use `desc` as a doc-comment for queries if there are no doc comments)
 - #80381 (Revert "Cleanup markdown span handling")
 - #80492 (remove empty wraps, don't return Results from from infallible functions)
 - #80509 (where possible, pass slices instead of &Vec or &String (clippy::ptr_arg))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 15:30:56 +00:00
Joshua Nelson edeac1778c Rename kw::Invalid -> kw::Empty
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
Mark Rousskov fe031180d0 Bump bootstrap compiler to 1.50 beta 2020-12-30 09:27:19 -05:00
Yuki Okushi 41fa0dba27
Rollup merge of #80509 - matthiaskrgr:ptr_arg, r=varkor
where possible, pass slices instead of &Vec or &String (clippy::ptr_arg)
2020-12-30 22:49:26 +09:00
Yuki Okushi 07083739fb
Rollup merge of #80492 - matthiaskrgr:tasty_wraps, r=varkor
remove empty wraps, don't return Results from from infallible functions

This makes code easier to understand because it is more obvious when a function actually can't fail (return Err or None)

Make functions that only ever return Some(x), return x directly
Remove return type from functions that return Option<(), Err> but would only ever return Ok(()).

Found with `clippy::unnecessary_wraps`
2020-12-30 22:49:24 +09:00
Yuki Okushi 18ac1ecac9
Rollup merge of #80337 - jyn514:add-query-desc, r=varkor
Use `desc` as a doc-comment for queries if there are no doc comments

This at least gives *some* idea of what the query does even if it's not very readable. Some examples:

![image](https://user-images.githubusercontent.com/23638587/103021399-13e15c00-4518-11eb-8121-940774ae2fd1.png)
![image](https://user-images.githubusercontent.com/23638587/103021448-222f7800-4518-11eb-8ee6-cc10795fdc22.png)
![image](https://user-images.githubusercontent.com/23638587/103021434-1d6ac400-4518-11eb-885b-59d00c57bc70.png)

I want to turn `{}` into either `_` or the stringified expr, but [I'm not sure how to do that](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Evaluate.20format.20string.20in.20proc-macro). In the meantime, this is better than having no docs at all.
2020-12-30 22:49:21 +09:00
Yuki Okushi 4ae99cc843 Fix ICE when pointing at multi bytes character 2020-12-30 22:33:13 +09:00
bors bbcaed03bf Auto merge of #79684 - usbalbin:const_copy, r=oli-obk
Make copy[_nonoverlapping] const

Constifies
* `intrinsics::copy` and `intrinsics::copy_nonoverlapping`
* `ptr::read` and `ptr::read_unaligned`
  * `*const T::read` and `*const T::read_unaligned`
  * `*mut T::read` and `*mut T::read_unaligned`
* `MaybeUninit::assume_init_read`
2020-12-30 12:43:02 +00:00
Matthias Krüger e5ead5fc58 remove unused return types such as empty Results or Options that would always be Some(..)
remove unused return type of dropck::check_drop_obligations()
don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..)
remove redundant return type of back::write::optimize()
don't Option-wrap return type of compute_type_parameters() since we always return Some(..)
don't return empty Result in assemble_generator_candidates()
don't return empty Result in assemble_closure_candidates()
don't return empty result in assemble_fn_pointer_candidates()
don't return empty result in assemble_candidates_from_impls()
don't return empty result in assemble_candidates_from_auto_impls()
don't return emtpy result in assemble_candidates_for_trait_alias()
don't return empty result in assemble_builtin_bound_candidates()
don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait()
remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..)
remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-30 13:15:40 +01:00
Matthias Krüger bdc9291ed9 where possible, pass slices instead of &Vec or &String (clippy::ptr_arg) 2020-12-30 13:11:52 +01:00
bors d107a87d34 Auto merge of #80503 - JohnTitor:rollup-b26vglu, r=JohnTitor
Rollup of 13 pull requests

Successful merges:

 - #79812 (Lint on redundant trailing semicolon after item)
 - #80348 (remove redundant clones (clippy::redundant_clone))
 - #80358 (Edit rustc_span documentation)
 - #80457 (Add missing commas to `rustc_ast_pretty::pp` docs)
 - #80461 (Add llvm-libunwind change to bootstrap CHANGELOG)
 - #80464 (Use Option::map_or instead of open coding it)
 - #80465 (Fix typo in ffi-pure.md)
 - #80467 (More uses of the matches! macro)
 - #80469 (Fix small typo in time comment)
 - #80472 (Use sans-serif font for the "all items" page links)
 - #80477 (Make forget intrinsic safe)
 - #80482 (don't clone copy types)
 - #80487 (don't redundantly repeat field names)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 09:51:42 +00:00
Yuki Okushi 3812909919
Rollup merge of #80487 - matthiaskrgr:field_names, r=jyn514
don't redundantly repeat field names

r? `@Dylan-DPC`
2020-12-30 18:15:29 +09:00
Yuki Okushi 039b62e888
Rollup merge of #80482 - matthiaskrgr:cl0ne_on_copy, r=jyn514
don't clone copy types

r? `@Dylan-DPC`
2020-12-30 18:15:27 +09:00
Yuki Okushi 9576ee97d1
Rollup merge of #80477 - tmiasko:safe-forget, r=oli-obk
Make forget intrinsic safe
2020-12-30 18:15:25 +09:00
Yuki Okushi 231727d6e7
Rollup merge of #80467 - LingMan:more_matches, r=oli-obk
More uses of the matches! macro

`@rustbot` modify labels +C-cleanup +T-compiler
2020-12-30 18:15:20 +09:00
Yuki Okushi 30ddc91d41
Rollup merge of #80464 - LingMan:map_or, r=oli-obk
Use Option::map_or instead of open coding it

``@rustbot`` modify labels +C-cleanup +T-compiler
2020-12-30 18:15:16 +09:00
Yuki Okushi d8cabe1855
Rollup merge of #80457 - camelid:pretty-docs-commas, r=jonas-schievink
Add missing commas to `rustc_ast_pretty::pp` docs
2020-12-30 18:15:13 +09:00
Yuki Okushi 6064be7ced
Rollup merge of #80358 - pierwill:edit_rustc_span, r=lcnr
Edit rustc_span documentation

Various changes to the `rustc_span` docs, including the following:

- Additions to top-level docs
- Edits to the source_map module docs
- Edits to documentation for `Span` and `SpanData`
- Added intra-docs links
- Documentation for Levenshtein distances
- Fixed missing punctuation
2020-12-30 18:15:11 +09:00
Yuki Okushi a309468a8c
Rollup merge of #80348 - matthiaskrgr:less_clones, r=Dylan-DPC
remove redundant clones (clippy::redundant_clone)
2020-12-30 18:15:04 +09:00
Yuki Okushi 3fe423663b
Rollup merge of #79812 - Aaron1011:lint-item-trailing-semi, r=oli-obk
Lint on redundant trailing semicolon after item

We now lint on code like this:

```rust
fn main() {
    fn foo() {};
    struct Bar {};
}
```

Previously, this caused warnings in Cargo, so it was disabled.
2020-12-30 18:15:03 +09:00
bors b9c403be11 Auto merge of #79472 - Aaron1011:new-remove-pretty-print-hack, r=petrochenkov
Replace pretty-print/compare/retokenize hack with targeted workarounds

Based on https://github.com/rust-lang/rust/pull/78296
cc https://github.com/rust-lang/rust/issues/43081

The 'pretty-print/compare/retokenize' hack is used to try to avoid passing an outdated `TokenStream` to a proc-macro when the underlying AST is modified in some way (e.g. cfg-stripping before derives). Unfortunately, retokenizing throws away spans (including hygiene information), which causes issues of its own. Every improvement to the accuracy of the pretty-print/retokenize comparison has resulted in non-trivial ecosystem breakage due to hygiene changes. In extreme cases, users deliberately wrote unhygienic `macro_rules!` macros (likely because they did not realize that the compiler's behavior was a bug).

Additionaly, the comparison between the original and pretty-printed/retoknized token streams comes at a non-trivial runtime cost, as shown by https://github.com/rust-lang/rust/pull/79338

This PR removes the pretty-print/compare/retokenize logic from `nt_to_tokenstream`. We only discard the original `TokenStream` under two circumstances:
* Inner attributes are used (detected by examining the AST)
* `cfg`/`cfg_attr` processing modifies the AST. This is detected by making the visitor update a flag when it performs a modification, instead of trying to detect the modification after-the-fact. Note that a 'matching' `cfg` (e.g. `#[cfg(not(FALSE)]`) does not actually get removed from the AST, allowing us to preserve the original `TokenStream`.

In all other cases, we preserve the original `TokenStream`.

This could use a bit of refactoring/renaming - opening for a Crater run.

r? `@ghost`
2020-12-30 07:04:49 +00:00
Joshua Nelson 56ea926b1c Add #[track_caller] to bug! and register_renamed
Before:

```
thread 'rustc' panicked at 'compiler/rustc_lint/src/context.rs:267:18: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:34:26
```

After:

```
thread 'rustc' panicked at 'src/librustdoc/core.rs:455:24: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:35:26
```

The reason I added it to `register_renamed` too is that any panic in
that function will be the caller's fault.
2020-12-29 23:18:11 -05:00
Joshua Nelson e67f9d3105 Use desc as a doc-comment if none exist yet
- Replace {} with the stringified expr

  Giant thank you to `@danielhenrymantilla` for figuring out how to make
  this work ❤️

- Note that this is just an approximation and it would be better to add
  a doc-comment
2020-12-29 21:13:06 -05:00
Ralf Jung 95aed7ab3b Miri: make size/align_of_val work for dangling raw ptrs 2020-12-29 22:46:17 +01:00
Aaron Hill c857cbeb06
Lint on redundant trailing semicolon after item
We now lint on code like this:

```rust
fn main() {
    fn foo() {};
    struct Bar {};
}
```

Previously, this caused warnings in Cargo, so it was disabled.
2020-12-29 16:30:02 -05:00
Matthias Krüger 0c3af22e08 don't redundantly repeat field names 2020-12-29 22:26:58 +01:00
Vadim Petrochenkov 4d2d0bad4e Remove compile-fail test suite 2020-12-29 23:39:56 +03:00