Commit graph

7856 commits

Author SHA1 Message Date
Camille GILLOT
f8efe5d822 Compute proc_macros in resolutions. 2021-09-01 20:13:16 +02:00
Camille GILLOT
635978041d Compute all_traits_impls during resolution. 2021-09-01 20:13:16 +02:00
Camille GILLOT
26eeec0baf Compute item_generics_num_lifetimes during resolution. 2021-09-01 20:13:16 +02:00
Camille GILLOT
74fb87e3a0 Stop sorting bodies by span.
The definition order is already close to the span order, and only differs
in corner cases.
2021-09-01 20:13:16 +02:00
Noah Lev
4553a4baf2 Remove redundant Span in QueryJobInfo
Previously, `QueryJobInfo` was composed of two parts: a `QueryInfo` and
a `QueryJob`. However, both `QueryInfo` and `QueryJob` have a `span`
field, which seem to be the same. So, the `span` was recorded twice.

Now, `QueryJobInfo` is composed of a `QueryStackFrame` (the other field
of `QueryInfo`) and a `QueryJob`. So, now, the `span` is only recorded
once.
2021-09-01 11:10:58 -07:00
Theodore Luo Wang
bc9877c5af Undo debug statements 2021-09-01 12:02:11 -04:00
Theodore Luo Wang
ce9e76528a Update formatting 2021-09-01 11:55:36 -04:00
Theodore Luo Wang
5a863d594c Add checks for a block before a unary plus. Fix failing tests 2021-09-01 11:54:06 -04:00
lcnr
d18ff40a3d
use the correct feature gate
Co-authored-by: Boxy <supbscripter@gmail.com>
2021-09-01 17:43:07 +02:00
bjorn3
977f279553 Move add_rlib and add_native_library to cg_ssa
This deduplicates logic between codegen backends
2021-09-01 14:43:27 +02:00
lcnr
7207194dbb update FIXME 2021-09-01 11:42:52 +02:00
lcnr
fc2a2650e2 cleanup const generics FIXME 2021-09-01 11:41:06 +02:00
bors
3ed6c1d23f Auto merge of #88556 - m-ou-se:rollup-q636wyd, r=m-ou-se
Rollup of 9 pull requests

Successful merges:

 - #86376 (Emit specific warning to clarify that `#[no_mangle]` should not be applied on foreign statics or functions)
 - #88040 (BTree: remove Ord bound from new)
 - #88053 (Fix the flock fallback implementation)
 - #88350 (add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC)
 - #88410 (Remove bolding on associated constants)
 - #88525 (fix(rustc_typeck): produce better errors for dyn auto trait)
 - #88542 (Use the return value of readdir_r() instead of errno)
 - #88548 (Stabilize `Iterator::intersperse()`)
 - #88551 (Stabilize `UnsafeCell::raw_get()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-09-01 09:06:24 +00:00
Mara Bos
bbc94ed329
Rollup merge of #88525 - notriddle:notriddle/coherence-dyn-auto-trait, r=petrochenkov
fix(rustc_typeck): produce better errors for dyn auto trait

Fixes #85026
2021-09-01 09:23:28 +02:00
Mara Bos
494c563f3b
Rollup merge of #88350 - programmerjake:add-ppc-cr-xer-clobbers, r=Amanieu
add support for clobbering xer, cr, and cr[0-7] for asm! on OpenPower/PowerPC

Fixes #88315
2021-09-01 09:23:26 +02:00
Mara Bos
8fd53e3085
Rollup merge of #88053 - bjorn3:fix_flock_fallback_impl, r=cjgillot
Fix the flock fallback implementation
2021-09-01 09:23:25 +02:00
Mara Bos
dcefd6871d
Rollup merge of #86376 - asquared31415:extern-no-mangle-84204, r=Mark-Simulacrum
Emit specific warning to clarify that `#[no_mangle]` should not be applied on foreign statics or functions

Foreign statics and foreign functions should not have `#[no_mangle]` applied, as it does nothing to the name and has some extra hidden behavior that is normally unwanted.  There was an existing warning for this, but it says the attribute is only allowed on "statics or functions", which to the user can be confusing.

This PR adds a specific version of the unused `#[no_mangle]` warning that explains that the target is a *foreign* static or function and that they do not need the attribute.

Fixes #78989
2021-09-01 09:23:22 +02:00
bors
608b5e1c20 Auto merge of #88272 - willcrichton:mutable-sparse-matrix, r=ecstatic-morse
Add bit removal methods to SparseBitMatrix and factor *BitSet relational methods into more extensible trait

I need the ability to clear the bits out of a row from `SparseBitMatrix`. Currently, all the mutating methods only allow insertion of bits, and there is no way to get access to the underlying data.

One approach is simply to make `ensure_row` public, since it grants `&mut` access to the underlying `HybridBitSet`. This PR adds the `pub` modifier. However, presumably this method was private for a reason, so I'm open to other designs. I would prefer general mutable access to the rows, because that way I can add many mutating operations (`clear`, `intersect`, etc.) without filing a PR each time :-)

r? `@ecstatic-morse`
2021-09-01 06:13:15 +00:00
Michael Howell
59b245e754 fix(rustc_lint): better detect when parens are necessary
Fixes #88519
2021-08-31 21:48:25 -07:00
bors
c4f26b15e3 Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebank
Improve errors for recursive type aliases

Fixes #17539.
2021-09-01 03:43:37 +00:00
Theodore Luo Wang
e7fb98e725 Apply formatting 2021-08-31 23:09:43 -04:00
Theodore Luo Wang
6cfe98f196 Improve error checking on unary plus 2021-08-31 23:07:58 -04:00
bors
c2a408840a Auto merge of #87688 - camsteffen:let-else, r=cjgillot
Introduce `let...else`

Tracking issue: #87335

The trickiest part for me was enforcing the diverging else block with clear diagnostics. Perhaps the obvious solution is to expand to `let _: ! = ..`, but I decided against this because, when a "mismatched type" error is found in typeck, there is no way to trace where in the HIR the expected type originated, AFAICT. In order to pass down this information, I believe we should introduce `Expectation::LetElseNever(HirId)` or maybe add `HirId` to `Expectation::HasType`, but I left that as a future enhancement. For now, I simply assert that the block is `!` with a custom `ObligationCauseCode`, and I think this is clear enough, at least to start. The downside here is that the error points at the entire block rather than the specific expression with the wrong type. I left a todo to this effect.

Overall, I believe this PR is feature-complete with regard to the RFC.
2021-09-01 01:02:42 +00:00
Daniel Paoliello
77a96ed564 Include debug info for the allocator shim
Issue Details:
In some cases it is necessary to generate an "allocator shim" to forward various Rust allocation functions (e.g., `__rust_alloc`) to an underlying function (e.g., `malloc`). However, since this allocator shim is a manually created LLVM module it is not processed via the normal module processing code and so no debug info is generated for it (if debugging info is enabled).

Fix Details:
* Modify the `debuginfo` code to allow creating debug info for a module without a `CodegenCx` (since it is difficult, and expensive, to create one just to emit some debug info).
* After creating the allocator shim add in basic debug info.
2021-08-31 15:24:20 -07:00
bors
a3956106d1 Auto merge of #88533 - oli-obk:tait_🧊, r=spastorino
Concrete regions can show up in mir borrowck if the originated from there

We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore. Instead mir borrock does all the logic, and it can handle concrete regions just fine, as long as it created them itself.

fixes #83190 which was introduced by #87287

r? `@spastorino`
2021-08-31 22:15:26 +00:00
Mara Bos
7189c85413 Improve closure dummy capture suggestion in macros. 2021-08-31 22:17:51 +02:00
bors
29ef6cf163 Auto merge of #88506 - Mark-Simulacrum:fix-rlibs, r=ehuss
Fix loading large rlibs

Bumps object crate to permit parsing archives with 64-bit table entries. These
are primarily encountered when there's more than 4GB of archive data.

cc https://github.com/gimli-rs/object/issues/365

Helps with https://github.com/rust-lang/rust/issues/88351, but will also need a beta backport

r? `@ehuss` (mostly for the test)
2021-08-31 19:33:06 +00:00
Camille GILLOT
8d7d488d3b Lint Abi in ast validation. 2021-08-31 20:30:17 +02:00
Matthias Krüger
7f2df9ad65 some low hanging clippy::perf fixes 2021-08-31 20:29:04 +02:00
Mara Bos
13f6d7e4cc
Rollup merge of #88504 - m-ou-se:turbofish-please-stay, r=oli-obk
Keep turbofish in prelude collision lint.

Fixes https://github.com/rust-lang/rust/issues/88442
2021-08-31 17:55:00 +02:00
Mara Bos
91c4fee9fc
Rollup merge of #88501 - m-ou-se:prelude-collusion-oh-no-macros-help, r=estebank
Use right span in prelude collision suggestions with macros.

Fixes https://github.com/rust-lang/rust/issues/88347

r? `@estebank`
2021-08-31 17:54:59 +02:00
Mara Bos
41249cad91
Rollup merge of #88445 - inquisitivecrystal:ast-lowering, r=cjgillot
Clean up the lowering of AST items

This PR simplifies and improves `rustc_ast_lowering::item` in various minor ways. The reasons for the changes should mostly be self evident, though I'm happy to specifically explain anything if needed.

These changes used to be part of #88019, but I removed them after it was pointed out that some of my other changes to `rustc_ast_lowering` were unnecessary. It felt like a bad idea to clean up code which I didn't even need to touch anymore.

r? `@cjgillot`
2021-08-31 17:54:57 +02:00
Mara Bos
ab37e49611
Rollup merge of #88418 - fee1-dead:trait-assoc-tilde-const, r=oli-obk
Allow `~const` bounds on trait assoc functions

r? `@oli-obk`
2021-08-31 17:54:56 +02:00
Mara Bos
4d089088f6
Rollup merge of #88399 - nagisa:nagisa/aapcs-on-aarch, r=petrochenkov
Disallow the aapcs CC on Aarch64

This never really worked and makes LLVM assert.
2021-08-31 17:54:55 +02:00
Mara Bos
175c8cb851
Rollup merge of #86362 - ptrojahn:insert_vars_and_temps, r=jackh726
Avoid cloning LocalDecls
2021-08-31 17:54:53 +02:00
Michael Howell
6e70678f7d Change wording to less jaron-y "non-auto trait"
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-08-31 08:53:23 -07:00
Oli Scherer
43738c6787 Concrete regions can show up in mir borrowck if the originated from there.
We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore.
2021-08-31 14:38:21 +00:00
Mara Bos
7c0479bd8c Use and_then instead of unwrap_or_default. 2021-08-31 16:26:27 +02:00
Mara Bos
a15dab9ce2 Use right span in prelude collision suggestions with macros. 2021-08-31 16:25:51 +02:00
Mara Bos
2a06daa863 Pull Span::find_ancestor_inside loop into its own function. 2021-08-31 16:25:51 +02:00
Paul Trojahn
99a3d64673 Remove single use variables 2021-08-31 15:54:41 +02:00
Paul Trojahn
7bcc9ae422 Avoid cloning LocalDecls 2021-08-31 14:51:16 +02:00
Mara Bos
feafda8cd3
Rollup merge of #88509 - m-ou-se:dyn-no-left-shift-right-shift-just-single-angle-brackets-please-thanks, r=petrochenkov
Don't suggest extra <> in dyn suggestion.

Fixes https://github.com/rust-lang/rust/issues/88508
2021-08-31 10:41:30 +02:00
Mara Bos
caca256b52
Rollup merge of #88503 - m-ou-se:array-into-inter-ambiguous, r=cjgillot
Warn when [T; N].into_iter() is ambiguous in the new edition.

Fixes https://github.com/rust-lang/rust/issues/88475

In https://github.com/rust-lang/rust/issues/88475, a situation was found where `[T; N].into_iter()` becomes *ambiguous* in the new edition. This is different than the case where `(&[T; N]).into_iter()` resolves differently, which was the only case handled by the `array_into_iter` lint. This is almost identical to the new-traits-in-the-prelude problem. Effectively, due to the array-into-iter hack disappearing in Rust 2021, we effectively added `IntoIterator` to the 'prelude' in Rust 2021 specifically for arrays.

This modifies the prelude collisions lint to detect that case and emit a `array_into_iter` lint in that case.
2021-08-31 10:41:29 +02:00
Mara Bos
db44069482
Rollup merge of #88497 - m-ou-se:prelude-collision-glob, r=nikomatsakis
Fix prelude collision suggestions for glob imported traits.

Fixes https://github.com/rust-lang/rust/issues/88471

cc `@nikomatsakis`
2021-08-31 10:41:28 +02:00
Mara Bos
fdf9c09c50
Rollup merge of #88496 - m-ou-se:prelude-collision-lifetime-generics, r=petrochenkov
Fix prelude collision lint suggestion for generics with lifetimes

Fixes https://github.com/rust-lang/rust/issues/88470

cc `@nikomatsakis`
2021-08-31 10:41:27 +02:00
Mara Bos
4adacfd43e
Rollup merge of #88492 - est31:maybe_uninit_write, r=wesleywiser
Use MaybeUninit::write in functor.rs

MaybeUninit::write is stable as of 1.55.0.
2021-08-31 10:41:26 +02:00
Mara Bos
e094380025
Rollup merge of #88486 - bjorn3:better_arena_macro, r=jackh726
Remove unused arena macro args
2021-08-31 10:41:25 +02:00
Mara Bos
7696aca55f
Rollup merge of #88450 - notriddle:notriddle/maybe_whole_expr, r=cjgillot
fix(rustc_parse): correct span in `maybe_whole_expr!`

Fixes #87812
2021-08-31 10:41:22 +02:00
bors
d4f263a558 Auto merge of #88467 - sexxi-goose:issue-88431, r=nikomatsakis
2229: Drop any deref in move closure

Fixes: #88431

r? `@nikomatsakis`
2021-08-31 06:01:52 +00:00
Michael Howell
435cdd0f9a
Update E0785.md 2021-08-30 22:18:55 -07:00
Michael Howell
026322c34b fix(rustc_typeck): produce better errors for dyn auto trait
Fixes #85026
2021-08-30 22:15:11 -07:00
bors
1e37e83dc0 Auto merge of #88414 - Aaron1011:guess-foreign-head-span, r=estebank
Don't use `guess_head_span` in `predicates_of` for foreign span

Previously, the result of `predicates_of` for a foreign trait
would depend on the *current* state of the corresponding source
file in the foreign crate. This could lead to ICEs during incremental
compilation, since the on-disk contents of the upstream source file
could potentially change without the upstream crate being recompiled.

Additionally, this ensure that that the metadata we produce for a crate
only depends on its *compiled* upstream dependencies (e.g an rlib or
rmeta file), *not* the current on-disk state of the upstream crate
source files.
2021-08-31 03:34:22 +00:00
Cameron Steffen
df9a2e0687 Handle irrufutable or unreachable let-else 2021-08-30 20:18:43 -05:00
Cameron Steffen
dc028f6568 Calculate LetSource later 2021-08-30 20:18:42 -05:00
Cameron Steffen
29bc94ff0d Handle let-else initializer edge case errors 2021-08-30 20:18:42 -05:00
Cameron Steffen
2f4e86b9ef Enforce diverging let...else 2021-08-30 20:18:42 -05:00
Cameron Steffen
960ea093ab Add let_else feature gate 2021-08-30 20:18:39 -05:00
Cameron Steffen
ae32e88909 Lower let-else to HIR 2021-08-30 20:17:46 -05:00
Cameron Steffen
120d46e255 Refactor lower_stmts 2021-08-30 20:17:45 -05:00
Cameron Steffen
581abbfc6d Move some methods to block module 2021-08-30 20:17:45 -05:00
Cameron Steffen
89d2600d01 Add let-else to AST 2021-08-30 20:17:45 -05:00
bors
56ea5e0ee9 Auto merge of #88100 - HTG-YT:edition2021-compopt-stabilization, r=m-ou-se
Make Edition 2021 Stable

An item of #87959.

This is an "on-demand" pull request, which means it will be merged when it is the right time to.
2021-08-31 01:03:55 +00:00
bors
6f388bb369 Auto merge of #88369 - lcnr:cec-rename, r=oli-obk
update const generics feature gates

**tl;dr: split const generics into three features: `adt_const_params`, `const_generics_defaults` and `generic_const_exprs`**

continuing the work of `@BoxyUwU` in #88324, this PR
- renames `feature(const_evaluatable_checked)` to `feature(generic_const_exprs)` which now doesn't need any other feature gate to work. Previously `feature(const_evaluatable_checked)` was only useful in combination with `feature(const_generics)`.
- completely removes `feature(lazy_normalization_consts)`. This feature only supplied the parents generics to anonymous constants, which is pretty useless as generic anon consts are only allowed with `feature(generic_const_exprs)` anyways.
- moves the ability to use additional const param types from `feature(const_generics)` into `feature(adt_const_params)`. As `feature(const_generics)` is now mostly useless without `feature(generic_const_exprs)` we also remove that feature flag.
- updates tests, removing duplicates and unnecessary revisions in some cases and also deletes all unused `*.stderr` files.

I not also remove the ordering restriction for const and type parameters if any of the three const generics features is active.
This ordering restriction feels like the only "real" use of the current `feature(const_generics)` right now so this change isn't a perfect solution, but as I intend to stabilize the ordering - and `feature(const_generics_defaults)` -  in the very near future, I think this is acceptable for now.

---

cc `@rust-lang/project-const-generics` about the new feature names and this change in general.

I don't think we need any external approval for this change but I do intend to publish an update to the const generics tracking issue the day this PR lands, so I don't want this merged yet.

Apologies to whoever ends up reviewing this PR 😅 ❤️

r? rust-lang/project-const-generics
2021-08-30 22:21:01 +00:00
Mara Bos
ac93ca3b94 Turn to ifs into a match. 2021-08-30 23:57:16 +02:00
Mara Bos
90080f4703 Don't give invalid suggestions in array_into_iter. 2021-08-30 23:43:38 +02:00
Mara Bos
422ad3bec2 Upgrade array_into_iter lint to include Deref-to-array types. 2021-08-30 23:43:38 +02:00
Mara Bos
23d2cb8435 Don't suggest extra <> in dyn suggestion. 2021-08-30 22:34:34 +02:00
Mark Rousskov
4c7c97a208 Fix loading large rlibs
Bumps object crate to permit parsing archives with 64-bit table entries. These
are primarily encountered when there's more than 4GB of archive data.
2021-08-30 16:22:53 -04:00
Mara Bos
4986bbf135 Keep turbofish in prelude collision lint. 2021-08-30 21:55:10 +02:00
Mara Bos
336f31432d Warn when [T; N].into_iter() is ambiguous in the new edition. 2021-08-30 21:27:31 +02:00
bors
5d6804469d Auto merge of #88466 - sexxi-goose:issue-88372, r=nikomatsakis
2229: Handle update to capture kind properly

Fixes: #88372

r? `@nikomatsakis`
2021-08-30 18:27:54 +00:00
David Carlier
8539a3c001 sunos systems add sanitizer supported. 2021-08-30 18:49:56 +01:00
Mara Bos
51e4fbaed1 Fix prelude collision suggestions for glob imported traits. 2021-08-30 19:21:22 +02:00
Mara Bos
e2abf06890 Fix lifetime generics in <T<..> as Trait>::try_from suggestion. 2021-08-30 19:02:06 +02:00
Mara Bos
a4f6d3e5c2 Fix lifetime generics in <T as Trait<..>>::try_from suggestion. 2021-08-30 19:01:34 +02:00
est31
403b80d32e Use MaybeUninit::write in functor.rs
MaybeUninit::write is stable as of 1.55.0.
2021-08-30 17:23:49 +02:00
Mara Bos
6adbbb6be7 Update LATEST_STABLE_EDITION to 2021. 2021-08-30 15:33:09 +02:00
HTG-YT
388d90ac4c make edition 2021 stable 2021-08-30 15:27:00 +02:00
bjorn3
1a2fe87b09 Remove unused arena macro args 2021-08-30 13:09:38 +02:00
Simonas Kazlauskas
748a089acd Disallow the aapcs CC on Aarch64
This never really worked and makes LLVM assert.
2021-08-30 13:46:07 +03:00
bors
6cfa773583 Auto merge of #87680 - mati865:stacker-psm-update, r=Mark-Simulacrum,nagisa
Update stacker and psm crates

Primarily to include https://github.com/rust-lang/stacker/pull/54
2021-08-30 10:42:53 +00:00
lcnr
87e781799a feature(const_param_types) -> feature(adt_const_params) 2021-08-30 12:07:36 +02:00
Wesley Wiser
846c372f86 Don't allow both the +bundle and +whole-archive modifiers for rlibs 2021-08-30 11:51:27 +02:00
Michael Woerister
522f9757f6 Fix handling of +whole-archive native link modifier. 2021-08-30 11:49:49 +02:00
lcnr
4747cbb3bb allow unordered const/ty params if any cg feature is active 2021-08-30 11:00:21 +02:00
lcnr
0c28e028b6 feature(const_generics) -> feature(const_param_types) 2021-08-30 11:00:21 +02:00
Ellen
c0e853f274 remove lazy_normalization_consts 2021-08-30 11:00:21 +02:00
Ellen
fcc2badf9b rename const_evaluatable_checked to generic_const_exprs
2021-08-30 11:00:21 +02:00
inquisitivecrystal
147f74a3c3 Clean up the lowering of AST items 2021-08-29 20:05:34 -07:00
Noah Lev
d96234bed7 Retrieve DefKind from HIR map to reduce chance of cycles
`tcx.def_kind()` could theoretically invoke another query, which could
cause an infinite query loop. Accessing the HIR map directly makes that
less likely to happen.

I also changed it to use `as_local()` (`tcx.def_kind()` seems to
implicitly call `expect_local()`) and `opt_def_kind()` to reduce the
chance of panicking on valid code.
2021-08-29 19:38:47 -07:00
asquared31415
fc125a52ec emit specific warning to clarify that foreign items can't have no_mangle
remove extra commented code
Deduplicate some diagnostics code
add code symbols, machine applicable suggestion
clarify error message
2021-08-29 20:22:19 -04:00
bors
9556d7a09a Auto merge of #88337 - eddyb:field-failure-is-not-an-option, r=nagisa
rustc_target: `TyAndLayout::field` should never error.

This refactor (making `TyAndLayout::field` return `TyAndLayout` without any `Result` around it) is based on a simple observation, regarding `TyAndLayout::field`:

If `cx.layout_of(ty)` succeeds (for some `cx` and `ty`), then `.field(cx, i)` on the resulting `TyAndLayout` should *always* succeed in computing `cx.layout_of(field_ty)` (where `field_ty` is the type of the `i`th field of `ty`).

The reason for this is that no matter which field is chosen, `cx.layout_of(field_ty)` *will have already been computed*, as part of computing `cx.layout_of(ty)`, as we cannot determine the layout of *any* type without considering the layouts of *all* of its fields.

And so it should be fine to turn any errors into ICEs, since they likely indicate a `cx` mismatch, or some other edge case that is due to a compiler bug (as opposed to ever being an user-facing error).

<hr/>

Each commit should probably be reviewed separately, though note that there's some `where` clauses (in `rustc_target::abi::call::*`) that change in most commits.

cc `@nagisa` `@oli-obk`
2021-08-29 22:54:26 +00:00
Eduard-Mihai Burtescu
78778fc6aa rustc_target: remove LayoutOf bound from TyAbiInterface. 2021-08-30 00:44:12 +03:00
Eduard-Mihai Burtescu
8e6d126b7d rustc_target: TyAndLayout::field should never error. 2021-08-30 00:44:09 +03:00
Aman Arora
793fbc73e8 2229: Drop any deref in move closure 2021-08-29 16:28:58 -04:00
bors
2f662b1403 Auto merge of #88280 - sexxi-goose:non-exhaustive, r=nikomatsakis
Handle match statements with non exhaustive variants in closures

This PR ensures that the behavior for match statements with non exhaustive variants is the same inside and outside closures.

If we have a non-exhaustive SingleVariant which is defined in a different crate, then we should handle the case the same way we would handle a MultiVariant: borrow the match discriminant.

Closes https://github.com/rust-lang/project-rfc-2229/issues/59
r? `@nikomatsakis`
2021-08-29 20:27:14 +00:00
Aman Arora
fbd775ff29 2229: Handle update to capture kind properly 2021-08-29 15:37:03 -04:00
bors
ae0b03bc6b Auto merge of #88262 - klensy:pprust-cow, r=nagisa
Cow'ify some pprust methods

Reduce number of potential needless de/allocations by using `Cow<'static, str>` instead of explicit `String` type.
2021-08-29 17:46:29 +00:00
bors
daa4dc997c Auto merge of #88461 - GuillaumeGomez:rollup-khgu0eb, r=GuillaumeGomez
Rollup of 13 pull requests

Successful merges:

 - #80543 (Notify when an `I-prioritize` issue is closed or reopened)
 - #83251 (Suggestion for call on immutable binding of mutable type)
 - #85534 (add rustc-demangle assertion on mangled symbol)
 - #88173 (Refactor Markdown length-limited summary implementation)
 - #88349 (Add const and static TAIT tests)
 - #88357 (add unsized coercion test)
 - #88381 (Handle stack_t.ss_sp type change for DragonFlyBSD)
 - #88387 (Remove vestigial rustfix tests.)
 - #88396 (Bump vulnerable crates)
 - #88407 (Fix formatting in release notes from 52a988344b)
 - #88411 (Remove `Session.if_let_suggestions`)
 - #88417 (RELEASES.md: fix broken link)
 - #88419 (Fix code blocks color in Ayu theme)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-29 15:18:58 +00:00
Guillaume Gomez
b7388024eb
Rollup merge of #88411 - Aaron1011:remove-session-if-let, r=estebank
Remove `Session.if_let_suggestions`

We can instead if either the LHS or RHS types contain
`TyKind::Error`. In addition to covering the case where
we would have previously updated `if_let_suggestions`, this might
also prevent redundant errors in other cases as well.
2021-08-29 16:25:35 +02:00
Guillaume Gomez
63cfbf5d9f
Rollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister
add rustc-demangle assertion on mangled symbol

cc https://github.com/rust-lang/rust/issues/60705#issuecomment-844880365
r? `@michaelwoerister`
2021-08-29 16:25:28 +02:00
Guillaume Gomez
22973a8844
Rollup merge of #83251 - estebank:issue-83241, r=oli-obk
Suggestion for call on immutable binding of mutable type

When calling a method requiring a mutable self borrow on an inmutable
to a mutable borrow of the type, suggest making the binding mutable.

Fix #83241.
2021-08-29 16:25:26 +02:00
bors
ef52471066 Auto merge of #88208 - petrochenkov:lowspan, r=Aaron1011
ast_lowering: Introduce `lower_span` for catching all spans entering HIR

This PR cherry-picks the `fn lower_span` change from https://github.com/rust-lang/rust/pull/84373.
I also introduced `fn lower_ident` for lowering spans in identifiers, and audited places where HIR structures with spans or identifiers are constructed and added a few missing `lower_span`s/`lower_ident`s.

Having a hook for spans entering HIR can be useful for things other than https://github.com/rust-lang/rust/pull/84373, e.g. https://github.com/rust-lang/rust/issues/35148.
I also want to check whether this change causes perf regressions due to some accidental inlining issues.

r? `@cjgillot`
2021-08-29 12:38:05 +00:00
bors
59ce765484 Auto merge of #88312 - jackh726:issue-87748, r=nikomatsakis
Treat types in unnormalized function signatures as well-formed

Fixes #87748

r? `@nikomatsakis`
2021-08-29 10:12:54 +00:00
Esteban Kuber
a6af6d6506 Provide structured suggestion for removal of &mut 2021-08-29 08:34:53 +00:00
Esteban Küber
e4368de7b1 Suggestion for call on immutable binding of mutable type
When calling a method requiring a mutable self borrow on an inmutable
to a mutable borrow of the type, suggest making the binding mutable.

Fix #83241.
2021-08-29 08:34:53 +00:00
Vadim Petrochenkov
59013cdebe ast_lowering: Introduce lower_span for catching all spans entering HIR 2021-08-29 10:49:40 +03:00
bors
757a65bfdf Auto merge of #88250 - rusticstuff:macos-lld, r=nagisa
Make `-Z gcc-ld=lld` work for Apple targets

`-Z gcc-ld=lld` was introduced in #85961. It does not work on Macos because lld needs be either named `ld64` or passed `-flavor darwin` as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls `ld` as linker binary and not `ld64`, so just creating an `ld64` binary and modifying the search path with `-B` does not work.

In order to solve this patch does:
* Set the `lld_flavor` for all Apple-derived targets to `LldFlavor::Ld64`. As far as I can see this actually works towards fixing `-Xlinker=rust-lld` as all those targets use the Mach-O object format.
* Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
* If `-Z gcc-ld=lld` is used and the target lld flavor is Ld64 add `-fuse-ld=/path/to/ld64` to the linker invocation.

Fixes #86945.
2021-08-29 04:51:14 +00:00
Michael Howell
f7c0566b12 fix(rustc_parse): incorrect span information for macro path expr
Old error output:

    3  |         let _: usize = $f;
       |                -----     ^ expected `usize`, found struct `Baz`
       |                |
       |                expected due to this

New error output:

    3  |         let _: usize = $f;
       |                -----   ^^ expected `usize`, found struct `Baz`
       |                |
       |                expected due to this
2021-08-28 20:56:55 -07:00
bors
3a21a5b324 Auto merge of #88088 - nbdd0121:const2, r=nagisa
Forbid inline const block referencing params from being used in patterns

Fix #82518
2021-08-29 02:21:07 +00:00
Michael Howell
d562848268 fix(rustc_parse): incorrect span information for macro block expr
Old error output:

   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
help: wrap this expression in parentheses
   |
4  |             break '_l $f(;)
   |                         ^ ^

New error output:

   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
help: wrap this expression in parentheses
   |
4  |             break '_l ($f);
   |                       ^  ^
2021-08-28 17:59:00 -07:00
Roxane
20de556a26 Handle match with non axhaustive variants in closures 2021-08-28 19:27:32 -04:00
bors
5eacec9ec7 Auto merge of #85690 - bstrie:m2_arena, r=jackh726,nagisa
Macros 2.0-ify rustc_arena

For the purpose of battle-testing macros 2.0 I'm looking to dogfood it in rustc, one crate at a time.

(Note that there are only 12 changed lines if you ignore whitespace.)
2021-08-28 20:58:12 +00:00
Camille GILLOT
bcefd487c3 Comment drop_serialized_data. 2021-08-28 21:49:51 +02:00
Camille GILLOT
98007e2ce6 Drop the query result memmap before serializing it back. 2021-08-28 21:45:02 +02:00
Camille GILLOT
6b47e1ece8 Move save_in to file_format. 2021-08-28 21:45:02 +02:00
Camille GILLOT
4afdeaaabd Mmap the incremental data instead of reading it. 2021-08-28 21:45:02 +02:00
bors
42a2a53ec1 Auto merge of #88390 - sexxi-goose:missing-case, r=nikomatsakis
Add missing const edge case

We don't "process" const so we need to check for additional cases when the PatKind is a Path. We need to make sure that if there is only one variant that there is no field. If there is one or more field, we will want to borrow the match scrutinee

Closes https://github.com/rust-lang/rust/issues/88331
r? `@nikomatsakis`
2021-08-28 15:36:38 +00:00
bors
84b0183412 Auto merge of #88388 - ldm0:outliner, r=nikic
Revert "Disable the machine outliner by default"

The fix commit is already in the fork: https://github.com/rust-lang/llvm-project/commit/6c78dbd4ca1f
Linked:
- https://github.com/rust-lang/rust/issues/85351
- https://github.com/rust-lang/rust/pull/86020
2021-08-28 13:10:26 +00:00
bors
05cccdc9b3 Auto merge of #88019 - inquisitivecrystal:macro-def, r=cjgillot
Treat macros as HIR items

Macros have historically been treated differently from other items at the HIR level. This PR makes them just like normal items. There are a few special cases left over, which I've attempted to lay out below. By normalizing the treatment of macro items, this PR simplifies a fair bit of code and fixes some bugs at the same time. For more information, see #87406.

r? `@cjgillot`

## Backwards incompatibility

This is backwards incompatible in one small way. Due to a mistake, it was previously possible to apply stability attributes to an exported macro, even without enabling the `staged_api` feature. This never should have worked. After this PR, it will error, as it should. We could make it a warning instead, but that would require a special case for a feature that shouldn't ever have worked and is likely used by no or very few crates, so I'm not thrilled about the idea.

## Notes for reviewers
### Commit seperation

I'd recommend reviewing this PR commit by commit. The commit chunking wasn't perfect, but it's better than looking at the combined diff, which is quite overwhelming. The compiler and standard library build after each commit, although tests do not necessarily pass and tools do not necessarily build till the end of the series.

### Special cases
There are a few special cases that remain after this change. Here are the notable ones I remember:

1. Visibility works a bit differently for `macro_rules!` macros than other items, since they aren't generally marked with `pub` but instead with `#[macro_export]`.
2. Since `#[macro_export]` macros always have paths at the top level of the crate, some additional handling needs to be done on the reexport to top level.
### Performance impact

I don't know for sure, but theses changes may slightly hurt performance. They create more work for the compiler in a few places. For instance, some operations that were previously run only for exported macros are now run for all macros. A perf run is probably advisable. For all I know we'll see performance improvements instead. :)

## Issues resolved

This resolves #87406 (the tracking issue for this change). It also fixes several bugs:

Fixes #59306.
Fixes #73754.
Fixes #87257.
2021-08-28 10:45:28 +00:00
bors
2031fd6e46 Auto merge of #88245 - Sl1mb0:s390-asm, r=Amanieu
S390x inline asm

This adds register definitions and constraint codes for the s390x general and floating point registers necessary for fixing #85931; as well as a few tests.

Further testing is needed, but I am a little unsure of what specific tests should be added to `src/test/assembly/asm/s390x.rs` to address this.
2021-08-28 08:04:41 +00:00
Deadbeef
523490e94a
Allow ~const bounds on trait assoc functions 2021-08-28 08:03:16 +00:00
inquisitivecrystal
0299ed8bbb Remove obsolete MacroDef variant of OwnerNode 2021-08-28 00:24:30 -07:00
inquisitivecrystal
8c62fa0575 Treat macros as HIR items 2021-08-28 00:16:34 -07:00
liudingming
bf2f6656bc Revert machine outliner disabling on LLVM 13 2021-08-28 15:11:46 +08:00
Aaron Hill
c9157efad6
Don't use guess_head_span in predicates_of for foreign span
Previously, the result of `predicates_of` for a foreign trait
would depend on the *current* state of the corresponding source
file in the foreign crate. This could lead to ICEs during incremental
compilation, since the on-disk contents of the upstream source file
could potentially change without the upstream crate being recompiled.

Additionally, this ensure that that the metadata we produce for a crate
only depends on its *compiled* upstream dependencies (e.g an rlib or
rmeta file), *not* the current on-disk state of the upstream crate
source files.
2021-08-27 23:19:49 -05:00
Aaron Hill
672d370764
Remove Session.if_let_suggestions
We can instead if either the LHS or RHS types contain
`TyKind::Error`. In addition to covering the case where
we would have previously updated `if_let_suggestions`, this might
also prevent redundant errors in other cases as well.
2021-08-27 18:28:22 -05:00
Will Crichton
e340a0e249 Suggested changes 2021-08-27 16:21:25 -07:00
Mateusz Mikuła
f58289cc51 Update stacker and psm crates 2021-08-28 00:40:49 +02:00
Noah Lev
c861964735 Note that trait aliases cannot be recursive 2021-08-27 14:50:52 -07:00
Noah Lev
cd0fc444fb Note that type aliases cannot be recursive 2021-08-27 14:50:51 -07:00
bors
ac50a53359 Auto merge of #88328 - fee1-dead:not-quite-const, r=oli-obk
Introduce `~const`

 - [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [x] Update UI Tests
 - [x] Add enum `BoundConstness` (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [x] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps for this PR
      - [x] Fix #88155
      - [x] ~~Do something with constness bounds in chalk~~ Must be done to rust-lang/chalk (just tried to refactor, there are a lot of errors to resolve :( )
      - [ ] Adjust Error messages for `~const` bounds that can't be satisfied.

r? `@oli-obk`
2021-08-27 21:35:08 +00:00
Niko Matsakis
c4dba5a64e use |= 2021-08-27 17:13:41 -04:00
Niko Matsakis
f34909d68f simplify the logic and document 2021-08-27 16:30:45 -04:00
Will Crichton
86bd551e4c Addd missing domain size assertions 2021-08-27 11:17:27 -07:00
Simonas Kazlauskas
fb5fbaaab0 Tracking issue for UNSUPPORTED_CALLING_CONVENTIONS 2021-08-27 20:47:00 +03:00
Esteban Kuber
c6d800d854 Point at unclosed delimiters as part of the primary MultiSpan
Both the place where the parser encounters a needed closed delimiter and
the unclosed opening delimiter are important, so they should get the
same level of highlighting in the output.
2021-08-27 14:24:47 +00:00
csmoe
5eb960c8d9 add rustc-demangle assertion on mangled symbol 2021-08-27 21:18:20 +08:00
Roxane
110a9b3b1c Add comment and fix fmt issue 2021-08-27 09:00:50 -04:00
Roxane
8fcfd6e136 Add missing const edge case 2021-08-27 08:25:06 -04:00
Eduard-Mihai Burtescu
87d1fb747f rustc_target: require TyAbiInterface in LayoutOf. 2021-08-27 13:09:32 +03:00
Eduard-Mihai Burtescu
8486571a10 rustc_target: rename TyAndLayoutMethods to TyAbiInterface. 2021-08-27 13:09:32 +03:00
Eduard-Mihai Burtescu
83d986aa28 rustc_target: add lifetime parameter to LayoutOf. 2021-08-27 13:09:32 +03:00
Michael Woerister
af1b65cb18 Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. 2021-08-27 11:50:44 +02:00
bors
4a6547cca6 Auto merge of #88227 - 12101111:nobundle-link-order, r=petrochenkov
Adjust linking order of static nobundle libraries

Link the static libraries with "-bundle" modifier from upstream rust crate right after linking this rust crate.
Some linker such as GNU linker `ld.bdf` treat order of linking as order of dependency.

After this change, static libraries with "-bundle" modifier is linked in the same order as "+bundle" modifier.
So we can change the value of "bundle" modifier without causing linking error.

fix: https://github.com/rust-lang/rust/issues/87541

r? `@petrochenkov`
2021-08-27 09:18:14 +00:00
Deadbeef
f3d96e9391
fmt 2021-08-27 08:09:00 +00:00
Deadbeef
80e1ee5aee
Add ty::BoundConstness 2021-08-27 06:49:18 +00:00
bors
dfd6306d26 Auto merge of #88326 - eddyb:inline-ty-layout-methods, r=oli-obk
`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`.

Mostly doing this as a perf curiosity, having spotted that `#[inline]` usage is a bit spotty.
2021-08-27 06:37:21 +00:00
Deadbeef
c75aeaac0b
Fix #88155 2021-08-27 05:07:38 +00:00