Commit Graph

12619 Commits

Author SHA1 Message Date
Vadim Petrochenkov
379ae12a1d expand: Remove ParseSess::missing_fragment_specifiers
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-09 15:44:19 +03:00
Dylan DPC
ece6b97f19
Rollup merge of #95810 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-borrowck, r=davidtwco
Use `format-args-capture` and remove unnecessary nested blocks
2022-04-09 12:52:07 +02:00
Dylan DPC
dfb4194e3b
Rollup merge of #95785 - RalfJung:interpret-size-mismatch, r=oli-obk
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal

We did this a while ago already for `to_i32()` and friends, but missed this one. That became quite annoying when I was debugging an ICE caused by `read_pointer` in a Miri shim where the code was passing an argument at the wrong type.

Having `scalar_to_ptr` be fallible is consistent with all the other `Scalar::to_*` methods being fallible. I added `unwrap` only in code outside the interpreter, which is no worse off than before now in terms of panics.

r? ````@oli-obk````
2022-04-09 12:52:05 +02:00
Camille GILLOT
f89d64d7aa Use def_key in tcx.item_name when possible. 2022-04-09 10:54:43 +02:00
bors
4bb685e471 Auto merge of #95835 - Dylan-DPC:rollup-l5mf2ad, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #90066 (Add new ThinBox type for 1 stack pointer wide heap allocated trait objects)
 - #95374 (assert_uninit_valid: ensure we detect at least arrays of uninhabited types)
 - #95599 (Strict provenance lints)
 - #95751 (Don't report numeric inference ambiguity when we have previous errors)
 - #95764 ([macro_metavar_expr] Add tests to ensure the feature requirement)
 - #95787 (reword panic vs result section to remove recoverable vs unrecoverable framing)
 - #95797 (Remove explicit delimiter token trees from `Delimited`.)
 - #95804 (rustdoc: Fix empty doc comment with backline ICE)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-09 04:53:34 +00:00
Dylan DPC
8f4680e37c
Rollup merge of #95804 - GuillaumeGomez:empty-doc-comment-with-backline, r=notriddle
rustdoc: Fix empty doc comment with backline ICE

Fixes #95800.

r? ```@notriddle```
2022-04-09 05:58:46 +02:00
Dylan DPC
747bd16214
Rollup merge of #95797 - nnethercote:rm-Delimited-all_tts, r=petrochenkov
Remove explicit delimiter token trees from `Delimited`.

They were introduced by the final commit in #95159 and gave a
performance win. But since the introduction of `MatcherLoc` they are no
longer needed. This commit reverts that change, making the code a bit
simpler.

r? `@petrochenkov`
2022-04-09 05:58:45 +02:00
Dylan DPC
d4e0ddf7c8
Rollup merge of #95751 - compiler-errors:ambig-int, r=jackh726
Don't report numeric inference ambiguity when we have previous errors

Fixes #95648
2022-04-09 05:58:42 +02:00
Dylan DPC
525438b6a9
Rollup merge of #95599 - niluxv:strict-provenance-lint, r=michaelwoerister
Strict provenance lints

See #95488.
This PR introduces two unstable (allow by default) lints to which lint on int2ptr and ptr2int casts, as the former is not possible in the strict provenance model and the latter can be written nicer using the `.addr()` API.
Based on an initial version of the lint by ```@Gankra``` in #95199.
2022-04-09 05:58:42 +02:00
bors
e980c62955 Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercote
Cached stable hash cleanups

r? `@nnethercote`

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
2022-04-09 02:31:24 +00:00
Nicholas Nethercote
7450c4e3e8 Remove explicit delimiter token trees from Delimited.
They were introduced by the final commit in #95159 and gave a
performance win. But since the introduction of `MatcherLoc` they are no
longer needed. This commit reverts that change, making the code a bit
simpler.
2022-04-09 10:11:40 +10:00
bors
f4a7ce997a Auto merge of #95519 - oli-obk:tait_ub2, r=compiler-errors
Enforce well formedness for type alias impl trait's hidden type

fixes #84657

This was not an issue with return-position-impl-trait because the generic bounds of the function are the same as those of the opaque type, and the hidden type must already be well formed within the function.

With type-alias-impl-trait the hidden type could be defined in a function that has *more* lifetime bounds than the type alias. This is fine, but the hidden type must still be well formed without those additional bounds.
2022-04-08 20:45:16 +00:00
Miguel Guarniz
f9781fd071 remove ItemLikeVisitor impls from monomorphize and rustc_typeck crates
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:23 -04:00
Miguel Guarniz
d2840d237c add mapping from DefKind to Target and remove more ItemLikeVisitor impls
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:23 -04:00
Miguel Guarniz
df10715463 remove CheckVisitor, CollectExternCrateVisitor and ItemLikeVisitor impls
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:23 -04:00
Miguel Guarniz
3d6f4c85ad remove ItemLikeVisitor impls and add fast paths using DefKind
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:23 -04:00
Miguel Guarniz
0d01ee9558 remove ItemLikeVisitor impls in incremental, interface, metadata and symbol_mangling crates
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:23 -04:00
Miguel Guarniz
28aa2dd3b4 remove some uses of visit_all_item_likes in typeck, symbol_mangling and passes crates
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 12:00:10 -04:00
Miguel Guarniz
0baf85e8b6 remove some uses of visit_all_item_likes in incremental, metadata and interface crates
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 11:59:59 -04:00
Miguel Guarniz
b73b4de982 Refactor HIR item-like traversal (part 1)
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08 11:59:59 -04:00
Oli Scherer
25d6f8e0f6 Avoid looking at the internals of Interned directly 2022-04-08 15:57:44 +00:00
niluxv
98a4834237 Split fuzzy_provenance_casts into lossy and fuzzy, feature gate and test it
* split `fuzzy_provenance_casts` into a ptr2int and a int2ptr lint
* feature gate both lints
* update documentation to be more realistic short term
* add tests for these lints
2022-04-08 17:41:28 +02:00
Aria Beingessner
1040cab53b WIP PROOF-OF-CONCEPT: Make the compiler complain about all int<->ptr casts.
ALL

OF

THEM
2022-04-08 17:40:33 +02:00
b-naber
8a5273bc99 use deref on ImmTy 2022-04-08 17:13:45 +02:00
Takayuki Maeda
470b4fca0e use format-args-capture and remove unnecessary nested blocks 2022-04-09 00:01:40 +09:00
Takayuki Maeda
71fea61bc9 suggest adding a local for vector to fix borrowck errors 2022-04-08 23:17:57 +09:00
b-naber
82217a6587 create leafs for slices 2022-04-08 15:45:14 +02:00
Guillaume Gomez
43d0497824 Fix invalid array access in beautify_doc_string 2022-04-08 15:30:37 +02:00
Caio
e946aa3a74 Left overs of #95761 2022-04-08 10:30:24 -03:00
b-naber
3be987e076 dont make lit_to_mir_constant a query 2022-04-08 11:56:21 +02:00
Dylan DPC
1f80881a94
Rollup merge of #95761 - c410-f3r:meta-var-stuff, r=petrochenkov
Kickstart the inner usage of `macro_metavar_expr`

There can be more use-cases but I am out of ideas.

cc #83527
r? ``@petrochenkov``
2022-04-08 11:48:24 +02:00
klensy
d0cc98689e check_doc_keyword: don't alloc string for emptiness check
check_doc_alias_value: get argument as Symbol to prevent needless string convertions

check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge

replace as_str() check with symbol check

get_single_str_from_tts: don't prealloc string

trivial string to str replace

LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String>

AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String>

CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-08 11:45:57 +03:00
Jacob Pratt
abf2b4c04d
Stabilize derive_default_enum 2022-04-07 20:03:19 -04:00
Camille GILLOT
b5dfa6a78d Compute ty_param_owner using DefIdTree. 2022-04-07 22:30:16 +02:00
Ralf Jung
38004b72bc interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal 2022-04-07 16:24:48 -04:00
Maybe Waffle
d5440926e2 Suggest replacing typeof(...) with an actual type
This commit suggests replacing typeof(...) with an actual type of "...",
for example in case of `typeof(1)` we suggest replacing it with `i32`.

If the expression
- Is not const (`{ let a = 1; let _: typeof(a); }`)
- Can't be found (`let _: typeof(this_variable_does_not_exist)`)
- Or has non-suggestable type (closure, generator, error, etc)
we don't suggest anything.
2022-04-07 23:40:32 +04:00
bors
e745b4ddbd Auto merge of #95767 - oli-obk:all_your_generics_belong_to_the_definitions, r=compiler-errors
Report opaque type mismatches directly during borrowck of the function instead of within the `type_of` query.

This allows us to only store a single hidden type per opaque type instead of having to store one per set of substitutions.

r? `@compiler-errors`

This does not affect diagnostics, because the diagnostic messages are exactly the same.
2022-04-07 19:37:43 +00:00
bors
dd38eea722 Auto merge of #95706 - petrochenkov:doclink4, r=GuillaumeGomez
rustdoc: Early doc link resolution fixes and refactorings

A subset of https://github.com/rust-lang/rust/pull/94857 that shouldn't cause perf regressions, but should fix some issues like https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/ICE.20in.20collect_intra_doc_links.2Ers https://github.com/rust-lang/rust/pull/95290 and improve performance in cases like https://github.com/rust-lang/rust/issues/95694.
2022-04-07 15:33:22 +00:00
Oli Scherer
7d2cad68d2 Deduplicate the error printing code for hidden type mismatches 2022-04-07 13:52:59 +00:00
Rémy Rakic
1906b7e967 port codegen_module activity to arg recorder API 2022-04-07 15:47:20 +02:00
Rémy Rakic
b6a7b5accd remove allocation from a self-profiling call in the LLVM backend 2022-04-07 15:47:20 +02:00
Rémy Rakic
af22801db0 simplify a self-profiling activity call in the cg_gcc backend 2022-04-07 15:47:20 +02:00
Rémy Rakic
3a8006714b simplify a self-profiling activity call in the LLVM backend
and so that it doesn't allocate unless event argument recording is turned on
2022-04-07 15:47:20 +02:00
Rémy Rakic
7585269673 add generic_activity_with_arg_recorder to the self-profiler
This allows profiling costly arguments to be recorded only when `-Zself-profile-events=args` is on: using a closure that takes an `EventArgRecorder` and call its `record_arg` or `record_args` methods.
2022-04-07 15:47:20 +02:00
Rémy Rakic
1c4ae7aa4a turn exec comment into doc comment 2022-04-07 15:47:19 +02:00
Oli Scherer
25876b3541 Report opaque type mismatches directly during borrowck of the function instead of within the type_of query.
This allows us to only store a single hidden type per opaque type instead of having to store one per set of substitutions.
2022-04-07 13:39:52 +00:00
Oli Scherer
2e0ef701c2 Document and rename the new wrapper type 2022-04-07 13:01:48 +00:00
bors
fa72316031 Auto merge of #95715 - nnethercote:shrink-Nonterminal, r=davidtwco
Shrink `Nonterminal`

Small consistency and performance improvements.

r? `@petrochenkov`
2022-04-07 12:52:32 +00:00
Caio
3191d27f48 Kickstart the inner usage of macro_metavar_expr 2022-04-07 08:13:41 -03:00
bors
ed6c958ee4 Auto merge of #95760 - Dylan-DPC:rollup-uskzggh, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #95189 (Stop flagging unexpected inner attributes as outer ones in certain diagnostics)
 - #95752 (Regression test for #82866)
 - #95753 (Correct safety reasoning in `str::make_ascii_{lower,upper}case()`)
 - #95757 (Use gender neutral terms)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-07 09:50:11 +00:00
Dylan DPC
d907ab87a0
Rollup merge of #95757 - zofrex:gender-neutral-terms, r=dtolnay
Use gender neutral terms

#95508 was not executed well, but it did find a couple of legitimate issues: some uses of unnecessarily gendered language, and some typos. This PR fixes (properly) the legitimate issues it found.
2022-04-07 11:17:17 +02:00
Dylan DPC
648d644c60
Rollup merge of #95189 - fmease:fix-issue-94340, r=estebank
Stop flagging unexpected inner attributes as outer ones in certain diagnostics

Fixes #94340.

In the issue to-be-fixed I write that the general message _an inner attribute is not permitted in this context_ should be more specific noting that the “context” is the `include` macro. This, however, cannot be achieved without touching a lot of things and passing a flag to the `parse_expr` and `parse_item` calls in `expand_include`. This seems rather hacky to me. That's why I left it as it. `Span::from_expansion` does not apply either AFAIK.

`@rustbot` label A-diagnostics T-compiler
2022-04-07 11:17:13 +02:00
James 'zofrex' Sanderson
ef59ab738e Use gender neutral terms 2022-04-07 08:51:59 +01:00
bors
f565016edd Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum
Bump bootstrap compiler to 1.61.0 beta

This PR bumps the bootstrap compiler to the 1.61.0 beta. The first commit changes the stage0 compiler, the second commit applies the "mechanical" changes and the third and fourth commits apply changes explained in the relevant comments.

r? `@Mark-Simulacrum`
2022-04-07 07:34:04 +00:00
Michael Goulet
39bff4bf9c don't report int/float ambiguity when we have previous errors 2022-04-06 21:27:46 -07:00
Michael Goulet
7bd22e29d0 only downgrade Error -> Ambiguous if type error is in predicate 2022-04-06 21:11:07 -07:00
Nicholas Nethercote
d9592c2d9f Shrink Nonterminal.
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`.
This slightly reduces cumulative and peak allocation amounts, most
notably on `deep-vector`.
2022-04-07 12:51:50 +10:00
Vadim Petrochenkov
69d6c3b2e6 rustdoc: Early doc link resolution fixes and refactorings 2022-04-07 00:19:48 +03:00
Dylan DPC
ebba894f19
Rollup merge of #95731 - oli-obk:lazy_tait_regression, r=compiler-errors
Check that all hidden types are the same and then deduplicate them.

fixes #95538

This used to trigger a sanity check. Now we accept that there may be multiple places where a hidden type is constrained and we merge all of these at the end.

Ideally we'd merge eagerly, but that is a larger refactoring that I don't want to put into a backport
2022-04-06 23:06:10 +02:00
Dylan DPC
9fa941c23e
Rollup merge of #95649 - ouz-a:mir-opt, r=oli-obk
New mir-opt deref_separator

This adds a new mir-opt that split certain derefs into this form:
`let x = (*a.b).c;` to => `tmp = a.b; let x = (*tmp).c;`

Huge thanks to ``@oli-obk`` for his patient mentoring.
2022-04-06 23:06:06 +02:00
León Orell Valerian Liehr
5ab0548500 Stop flagging certain inner attrs as outer ones 2022-04-06 19:54:05 +02:00
bors
c2afaba465 Auto merge of #95669 - nnethercote:call-compute_locs-once-per-rule, r=petrochenkov
Call `compute_locs` once per rule

This fixes the small regressions on `wg-grammar` and `hyper-0.14.18` seen in #95555.

r? `@petrochenkov`
2022-04-06 16:29:32 +00:00
Oli Scherer
27dc503556 Check that all hidden types are the same and then deduplicate them. 2022-04-06 15:02:37 +00:00
bors
b6ab1fae73 Auto merge of #95707 - RalfJung:initialized, r=oli-obk
interp/validity: enforce Scalar::Initialized

This is a follow-up to https://github.com/rust-lang/rust/pull/94527, to also account for the new kind of `Scalar` layout inside the validity checker.

r? `@oli-obk`
2022-04-06 14:07:27 +00:00
Oli Scherer
b30bcfae38 Fix some fallout around type alias impl trait in associated types 2022-04-06 12:56:22 +00:00
bors
201cf3dba3 Auto merge of #95723 - SparrowLii:const_goto, r=fee1-dead
enhance `ConstGoto` mir-opt by moving up `StorageDead` statements

From the `FIXME` in the implementation of `ConstGoto` miropt. We can move `StorageDead` statements up to the predecessor. This can expand the scope of application of this opt.
2022-04-06 10:08:08 +00:00
b-naber
c3491378e3 get rid of visit_constant in thir visitor 2022-04-06 10:43:58 +02:00
SparrowLii
a91b347768 enhance ConstGoto mir-opt by moving up StorageDead statements 2022-04-06 15:17:41 +08:00
Dylan DPC
acdba55b53
Rollup merge of #95693 - RalfJung:more-context, r=oli-obk
interp: pass TyCtxt to Machine methods that do not take InterpCx

This just seems like something you might need, so let's consistently have it.

One day we might have to add `ParamEnv` as well, though that seems less likely (and in Miri you can always use `reveal_all` anyway). It might make sense to have a type that packages `TyCtxt` and `ParamEnv`, this pairing occurs quite frequently in rustc...

r? `@oli-obk`
2022-04-06 03:39:08 +02:00
Nicholas Nethercote
238d9076fc Call compute_locs once per rule.
Currently it's called in `parse_tt` every time a match rule is invoked.
This commit moves it so it's called instead once per match rule, in
`compile_declarative_macro. This is a performance win.

The commit also moves `compute_locs` out of `TtParser`, because there's
no longer any reason for it to be in there.
2022-04-06 10:23:06 +10:00
Ralf Jung
d214b38755 interp/validity: enforce Scalar::Initialized 2022-04-05 19:46:51 -04:00
Pietro Albini
b744bb67fd
rustc_trait_selection changes 2022-04-05 23:18:41 +02:00
Pietro Albini
181d28bb61
trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
Dylan DPC
728f2636ac
Rollup merge of #95681 - petrochenkov:doclinkregr2, r=Dylan-DPC
resolve: Fix resolution of empty paths passed from rustdoc

Fixes https://github.com/rust-lang/rust/pull/95337#issuecomment-1088426179
2022-04-05 22:59:01 +02:00
Dylan DPC
1e555bac14
Rollup merge of #95663 - notriddle:notriddle/unsafe-fn-closure, r=compiler-errors
diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut

Fixes #90073
2022-04-05 22:58:59 +02:00
Dylan DPC
42ab448bb4
Rollup merge of #95585 - compiler-errors:ref-clone, r=estebank
Explain why `&T` is cloned when `T` is not `Clone`

Fixes #95535
2022-04-05 22:58:57 +02:00
Dylan DPC
c5e7e95292
Rollup merge of #95473 - lqd:macro-expansion, r=petrochenkov
track individual proc-macro expansions in the self-profiler

As described in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Macro.20expansion.20performance.20on.20complex.20macros/near/275063190), users don't currently have a lot of information to diagnose macro expansion performance issues. That comment suggests using the macro names to add further timing information.

This PR starts to do this for proc-macros which have the same issue, and performance problems happening in the wild in [this other zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns) could be helped by such information.

It uses the available proc-macro name to track their individual expansions with self-profiling events.

r? `@Aaron1011` who mentioned this idea originally
2022-04-05 22:58:55 +02:00
ouz-a
1cf6d6940c kill temp early 2022-04-05 22:38:03 +03:00
Ralf Jung
fcdfc3e1c1 interp: pass TyCtxt to Machine methods that do not take InterpCx 2022-04-05 13:31:51 -04:00
bors
f262ca12aa Auto merge of #94527 - oli-obk:undef_scalars, r=nagisa,erikdesjardin
Let CTFE to handle partially uninitialized unions without marking the entire value as uninitialized.

follow up to #94411

To fix https://github.com/rust-lang/rust/issues/69488 and by extension fix https://github.com/rust-lang/rust/issues/94371, we should stop treating types like `MaybeUninit<usize>` as something that the `Scalar` type in the interpreter engine can represent. So we add a new field to `abi::Primitive` that records whether the primitive is nested in a union

cc `@RalfJung`

r? `@ghost`
2022-04-05 16:46:13 +00:00
Michael Goulet
d12689c022 Explain why &T is cloned when T is not Clone 2022-04-05 09:40:42 -07:00
Dylan DPC
68329648ac
Rollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwco
Refactor: remove unused function parameters
2022-04-05 15:56:51 +02:00
Dylan DPC
a1e7f6db51
Rollup merge of #95654 - notriddle:notriddle/issue-95616, r=davidtwco
diagnostics: use correct span for const generics

Fixes #95616
2022-04-05 15:56:50 +02:00
Dylan DPC
661b0e5b32
Rollup merge of #95525 - ohno418:suggest-derivable-trait-E0277, r=compiler-errors
Suggest derivable trait on E0277 error

Closes https://github.com/rust-lang/rust/issues/95099 .
2022-04-05 15:56:49 +02:00
Vadim Petrochenkov
7faaf8f4aa resolve: Fix resolution of empty paths passed from rustdoc 2022-04-05 16:55:53 +03:00
Rémy Rakic
9ac8d2fe4e track proc-macro expansions in the self-profiler
Use the proc-macro descr to track their individual expansions with
self-profiling events. This will help diagnose performance issues
with slow proc-macros.
2022-04-05 15:37:14 +02:00
Oli Scherer
d57b755909 Use WrappingRange::full instead of hand-rolling it 2022-04-05 13:18:22 +00:00
Oli Scherer
09b291f0b2 mir-interpret now treats unions as non-immediate, even if they have scalar layout, allowing partially initializing them 2022-04-05 13:18:22 +00:00
Oli Scherer
d32ce37a17 Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
Takayuki Maeda
975980427b remove unused function parameters 2022-04-05 19:33:22 +09:00
Dylan DPC
2a7e7bd0e0
Rollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011
Note invariance reason for FnDef types

Fixes #95272. Is it worthwhile even printing a variance explanation here? Or should I try to track down which function parameter is responsible for the invariance?

r? ``@Aaron1011`` since you wrote #89336
2022-04-05 09:33:23 +02:00
Dylan DPC
d4730244d7
Rollup merge of #95512 - davidtwco:diagnostic-translation, r=oli-obk
diagnostics: translation infrastructure

An implementation of the infrastructure required to have translatable diagnostic messages.

- Introduces a `DiagnosticMessage` type which can represent both the current non-translatable messages and identifiers for [Fluent](https://projectfluent.org/).
- Modifies current diagnostic API so that existing calls still work but `DiagnosticMessage`s can be provided too.
- Adds support for always loading a "fallback bundle" containing the English diagnostic messages, which are used when a `DiagnosticMessage::FluentIdentifier` is used in a diagnostic being emitted.
- Adds support for loading a "primary bundle" which contains the user's preferred language translation, and is used preferentially when it contains a diagnostic message being emitted. Primary bundles are loaded either from the path provided to `-Ztranslate-alternate-ftl` (for testing), or from the sysroot at `$sysroot/locale/$locale/*.ftl` given a locale with `-Ztranslate-lang` (which is parsed as a language identifier).
- Adds "diagnostic args" which enable normally-interpolated variables to be made available as variables for Fluent messages to use.
- Updates `#[derive(SessionDiagnostic)]` so that it can only be used for translatable diagnostics and update the handful of diagnostics which used the derive to be translatable.

For example, the following diagnostic...

```rust
#[derive(SessionDiagnostic)]
#[error = "E0195"]
pub struct LifetimesOrBoundsMismatchOnTrait {
    #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"]
    #[label = "lifetimes do not match {item_kind} in trait"]
    pub span: Span,
    #[label = "lifetimes in impl do not match this {item_kind} in trait"]
    pub generics_span: Option<Span>,
    pub item_kind: &'static str,
    pub ident: Ident,
}
```

...becomes...

```rust
#[derive(SessionDiagnostic)]
#[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
pub struct LifetimesOrBoundsMismatchOnTrait {
    #[primary_span]
    #[label]
    pub span: Span,
    #[label = "generics-label"]
    pub generics_span: Option<Span>,
    pub item_kind: &'static str,
    pub ident: Ident,
}
```

```fluent
typeck-lifetimes-or-bounds-mismatch-on-trait =
    lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration
    .label = lifetimes do not match {$item_kind} in trait
    .generics-label = lifetimes in impl do not match this {$item_kind} in trait
```

r? `@estebank`
cc `@oli-obk` `@Manishearth`
2022-04-05 09:33:22 +02:00
Nicholas Nethercote
7300bd6a38 Move the missing fragment identifier checking.
In #95555 this was moved out of `parse_tt_inner` and `nameize` into
`compute_locs`. But the next commit will be moving `compute_locs`
outwards to a place that isn't suitable for the missing fragment
identifier checking. So this reinstates the old checking.
2022-04-05 17:23:30 +10:00
Nicholas Nethercote
896d8f5905 Remove the lifetime from TtParser and MatcherLoc.
It's a slight performance loss for now, but that will be recouped by the
next commit.
2022-04-05 17:19:38 +10:00
ouz-a
72070d8103 remove region check 2022-04-05 10:08:32 +03:00
David Wood
ccd4820326 errors: support fluent + parallel compiler
Conditional on the parallel compiler being enabled, use a different
`IntlLangMemoizer` which supports being sent between threads in
`FluentBundle`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
66f22e550b errors: use impl Into<FluentId>
`FluentId` is the type alias that is used everywhere else so it should
be used here too so that this doesn't need updated if the alias changes.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
3c2f864ffb session: opt for enabling directionality markers
Add an option for enabling and disabling Fluent's directionality
isolation markers in output. Disabled by default as these can render in
some terminals and applications.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
e27389b068 errors: add links to fluent documentation
Add some links to the Fluent documentation to
`DiagnosticMessage::FluentIdentifier` which explain what a Fluent
message and attribute are.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
c6a3349bd7 typeck: remove now-unnecessary parameter from diag
Removes `expected_pluralize` parameter from diagnostic struct which is
no longer necessary as the Fluent message can determine the correct
pluralization.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
141f8404a8 errors: don't try load default locale from sysroot
If the user requests a diagnostic locale of "en-US" then it doesn't make
sense to try and load that from the `$sysroot` because it is just the
default built-in locale.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
22685b9607 macros: support translatable suggestions
Extends support for generating `DiagnosticMessage::FluentIdentifier`
messages from `SessionDiagnostic` derive to `#[suggestion]`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
b40ee88a28 macros: note/help in SessionDiagnostic derive
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
a88717cef0 macros: support translatable labels
Extends support for generating `DiagnosticMessage::FluentIdentifier`
messages from `SessionDiagnostic` derive to `#[label]`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
72dec56028 macros: optional error codes
In an effort to make it easier to port diagnostics to
`SessionDiagnostic` (for translation) and since translation slugs could
replace error codes, make error codes optional in the
`SessionDiagnostic` derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
70ee0c96fc macros: add #[no_arg] to skip set_arg call
A call to `set_arg` is generated for every field of a
`SessionDiagnostic` struct without attributes, but not all types support
being an argument, so `#[no_arg]` is introduced to skip these fields.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
8100541d54 macros: rename #[message] to #[primary_span]
Small commit renaming `#[message]` to `#[primary_span]` as this more
accurately reflects what it does now.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
d0fd8d7880 macros: translatable struct attrs and warnings
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
f0de7df204 macros: update session diagnostic errors
Small commit adding backticks around types and annotations in the error
messages from the session diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:03 +01:00
David Wood
a52b5072ac errors: disable directionality isolation markers
Fluent diagnostics can insert directionality isolation markers around
interpolated variables indicating that there may be a shift from
right-to-left to left-to-right text (or vice-versa). These are disabled
because they are sometimes visible in the error output, but may be worth
investigating in future (for example: if type names are left-to-right
and the surrounding diagnostic messages are right-to-left, then these
might be helpful).

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:02 +01:00
David Wood
9956d4f99d macros: add args for non-subdiagnostic fields
Non-subdiagnostic fields (i.e. those that don't have `#[label]`
attributes or similar and are just additional context) have to be added
as arguments for Fluent messages to refer them. This commit extends the
`SessionDiagnostic` derive to do this for all fields that do not have
attributes and introduces an `IntoDiagnosticArg` trait that is
implemented on all types that can be converted to a argument for Fluent.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:02 +01:00
David Wood
8677fef192 macros: move suggestion type handling to fn
Move the handling of `Span` or `(Span, Applicability)` types in
`#[suggestion]` attributes to its own function.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:02 +01:00
David Wood
2bf64d6483 macros: update comments
Various small changes to comments, like wrapping code in backticks,
changing comments to doc comments and adding newlines.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:02 +01:00
David Wood
d5119c5b9f errors: implement sysroot/testing bundle loading
Extend loading of Fluent bundles so that bundles can be loaded from the
sysroot based on the language requested by the user, or using a nightly
flag.

Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:02 +01:00
David Wood
7f91697b50 errors: implement fallback diagnostic translation
This commit updates the signatures of all diagnostic functions to accept
types that can be converted into a `DiagnosticMessage`. This enables
existing diagnostic calls to continue to work as before and Fluent
identifiers to be provided. The `SessionDiagnostic` derive just
generates normal diagnostic calls, so these APIs had to be modified to
accept Fluent identifiers.

In addition, loading of the "fallback" Fluent bundle, which contains the
built-in English messages, has been implemented.

Each diagnostic now has "arguments" which correspond to variables in the
Fluent messages (necessary to render a Fluent message) but no API for
adding arguments has been added yet. Therefore, diagnostics (that do not
require interpolation) can be converted to use Fluent identifiers and
will be output as before.
2022-04-05 07:01:02 +01:00
David Wood
c45f29595d span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
David Wood
8c684563a5 errors: introduce DiagnosticMessage
Introduce a `DiagnosticMessage` type that will enable diagnostic
messages to be simple strings or Fluent identifiers.
`DiagnosticMessage` is now used in the implementation of the standard
`DiagnosticBuilder` APIs.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 06:53:39 +01:00
bors
949b98cab8 Auto merge of #95337 - petrochenkov:doclink3, r=camelid
rustdoc: Fix resolution of `crate`-relative paths in doc links

Resolve `crate::foo` paths transparently to rustdoc, so their resolution no longer affects diagnostics and modules used for determining traits in scope.

The proper solution is to account for the current `module_id`/`parent_scope` in `fn resolve_crate_root`, but it's a slightly larger compiler changes. This PR moves the code closer to it, but keeps it rustdoc-specific.

Fixes https://github.com/rust-lang/rust/issues/78696
Fixes https://github.com/rust-lang/rust/issues/94924
2022-04-05 04:39:34 +00:00
Michael Goulet
2a129d4fa5 Format invariance notes with backticks 2022-04-04 20:26:31 -07:00
ohno418
de237823e0 Suggest only when all fields impl the trait 2022-04-05 11:40:25 +09:00
Michael Goulet
a8877cf738 Handle reporting invariance of fn pointer 2022-04-04 19:37:14 -07:00
ohno418
0ff2f58330 Suggest only when Rhs for PartialEq and PartialOrd is the same type as self 2022-04-05 11:31:11 +09:00
ohno418
0d2a00058b Suggest derivable trait on E0277 2022-04-05 11:14:32 +09:00
Michael Howell
bec8dbdb60 diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut
Fixes #90073
2022-04-04 17:39:35 -07:00
Dylan DPC
b3c3eda728
Rollup merge of #95642 - lcnr:probe-smol, r=compiler-errors
`CandidateSource::XCandidate` -> `CandidateSource::X`
2022-04-05 01:53:36 +02:00
Dylan DPC
5b8ac2d1b6
Rollup merge of #95631 - TaKO8Ki:remove-unnecessary-nested-blocks, r=davidtwco
Refactor: remove unnecessary nested blocks
2022-04-05 01:53:35 +02:00
Dylan DPC
78f81f0d10
Rollup merge of #95620 - RalfJung:memory-no-extras, r=oli-obk
interpret: remove MemoryExtra in favor of giving access to the Machine

The Miri PR for this is upcoming.

r? ``@oli-obk``
2022-04-05 01:53:33 +02:00
Dylan DPC
92e53f5cc9
Rollup merge of #95603 - compiler-errors:dyn-return, r=oli-obk
Fix late-bound ICE in `dyn` return type suggestion

This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with.

Fixes #91801
Fixes #91803

This fix also includes some drive-by changes, specifically:

1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value).
2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial.
3. Split up the multipart suggestion because there's a 6-line max in the printed output...

I am open to splitting out the above changes, if we just want to fix the ICE first.

cc: ```@terrarier2111``` and #92289
2022-04-05 01:53:32 +02:00
Dylan DPC
a5c81695a9
Rollup merge of #91873 - estebank:mention-impls-for-unsatisfied-trait, r=davidtwco
Mention implementers of unsatisfied trait

When encountering an unsatisfied trait bound, if there are no other
suggestions, mention all the types that *do* implement that trait:

```
error[E0277]: the trait bound `f32: Foo` is not satisfied
  --> $DIR/impl_wf.rs:22:6
   |
LL | impl Baz<f32> for f32 { }
   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `Baz`
  --> $DIR/impl_wf.rs:18:31
   |
LL | trait Baz<U: ?Sized> where U: Foo { }
   |                               ^^^ required by this bound in `Baz`
```
```
error[E0277]: the trait bound `u32: Foo` is not satisfied
  --> $DIR/associated-types-path-2.rs:29:5
   |
LL |     f1(2u32, 4u32);
   |     ^^ the trait `Foo` is not implemented for `u32`
   |
   = help: the trait `Foo` is implemented for `i32`
note: required by a bound in `f1`
  --> $DIR/associated-types-path-2.rs:13:14
   |
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
   |              ^^^ required by this bound in `f1`
```

Suggest dereferencing in more cases.

Fix #87437, fix #90970.
2022-04-05 01:53:31 +02:00
Esteban Kuber
e1ef833bca Remove hack, fix fmt and tests 2022-04-04 21:14:08 +00:00
Esteban Kuber
a6301cab5e Highlight is in the message for emphasis 2022-04-04 21:06:35 +00:00
Esteban Kuber
3109c931b4 Refer to the TraitRef::identity in the message to be clearer 2022-04-04 21:06:35 +00:00
Esteban Kuber
ef91519b45 Dedup logic and improve output for other types that impl trait 2022-04-04 21:06:35 +00:00
Esteban Kuber
e2bba0708a Fix list length 2022-04-04 21:06:35 +00:00
Esteban Kuber
883b93c7b7 Suggest dereferncing when possible in E0277, fix #87437 2022-04-04 21:06:35 +00:00
Esteban Kuber
ac8cbbd200 Fix #90970, doesn't address #87437 2022-04-04 21:06:33 +00:00
Esteban Kuber
3aac307ca6 Mention implementers of unsatisfied trait
When encountering an unsatisfied trait bound, if there are no other
suggestions, mention all the types that *do* implement that trait:

```
error[E0277]: the trait bound `f32: Foo` is not satisfied
  --> $DIR/impl_wf.rs:22:6
   |
LL | impl Baz<f32> for f32 { }
   |      ^^^^^^^^ the trait `Foo` is not implemented for `f32`
   |
   = help: the following other types implement trait `Foo`:
             Option<T>
             i32
             str
note: required by a bound in `Baz`
  --> $DIR/impl_wf.rs:18:31
   |
LL | trait Baz<U: ?Sized> where U: Foo { }
   |                               ^^^ required by this bound in `Baz`
```

Mention implementers of traits in `ImplObligation`s.

Do not mention other `impl`s for closures, ranges and `?`.
2022-04-04 21:01:42 +00:00
ouz-a
904d6c8662 destroy temp at the end and avoid ICE 2022-04-04 23:46:21 +03:00
bors
60e50fc1cf Auto merge of #95653 - Dylan-DPC:rollup-2p9hzi3, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #92942 (stabilize windows_process_extensions_raw_arg)
 - #94817 (Release notes for 1.60.0)
 - #95343 (Reduce unnecessary escaping in proc_macro::Literal::character/string)
 - #95431 (Stabilize total_cmp)
 - #95438 (Add SyncUnsafeCell.)
 - #95467 (Windows: Synchronize asynchronous pipe reads and writes)
 - #95609 (Suggest borrowing when trying to coerce unsized type into `dyn Trait`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-04 19:51:52 +00:00
Michael Howell
6ece80fcb6 diagnostics: use correct span for const generics
Fixes #95616
2022-04-04 12:16:20 -07:00
ouz-a
105e90f836 fixed error, made function leaner and tighter 2022-04-04 21:54:01 +03:00
Dylan DPC
0c5f879203
Rollup merge of #95609 - compiler-errors:borrow-unsized-to-dyn, r=nagisa
Suggest borrowing when trying to coerce unsized type into `dyn Trait`

A helpful error in response to #95598, since we can't coerce e.g. `&str` into `&dyn Display`, but we can coerce `&&str` into `&dyn Display` :)

Not sure if the suggestion message needs some help. Let me know, and I can refine this PR.
2022-04-04 20:41:34 +02:00
Dylan DPC
2d1496a8f6
Rollup merge of #95343 - dtolnay:literals, r=petrochenkov
Reduce unnecessary escaping in proc_macro::Literal::character/string

I noticed that https://doc.rust-lang.org/proc_macro/struct.Literal.html#method.character is producing unreadable literals that make macro-expanded code unnecessarily hard to read. Since the proc macro server was using `escape_unicode()`, every char is escaped using `\u{…}` regardless of whether there is any need to do so. For example `Literal::character('=')` would previously produce `'\u{3d}'` which unnecessarily obscures the meaning when reading the macro-expanded code.

I've changed Literal::string also in this PR because `str`'s `Debug` impl is also smarter than just calling `escape_debug` on every char. For example `Literal::string("ferris's")` would previously produce `"ferris\'s"` but will now produce `"ferris's"`.
2022-04-04 20:41:30 +02:00
bors
6a9080b25e Auto merge of #95555 - nnethercote:parse_tt-new-representation, r=petrochenkov
A new matcher representation for use in `parse_tt`

By transforming the matcher into a different form, `parse_tt` can run faster and be easier to understand.

r? `@petrochenkov`
2022-04-04 17:27:48 +00:00
ouz-a
4332b5f903 New mir-opt deref_separator 2022-04-04 18:51:32 +03:00
bors
d5139f4469 Auto merge of #95119 - OliverMD:method_suggestions, r=davidtwco
Improve method name suggestions

Attempts to improve method name suggestions when a matching method name
is not found. The approach taken is use the Levenshtein distance and
account for substrings having a high distance but can sometimes be very
close to the intended method (eg. empty vs is_empty).

resolves #94747
2022-04-04 13:00:25 +00:00
lcnr
58dfe26045 CandidateSource::XCandidate -> CandidateSource::X 2022-04-04 11:48:47 +02:00
Nicholas Nethercote
0bd47e8a39 Reorder match arms in parse_tt_inner.
To match the order the variants are declared in.
2022-04-04 17:03:36 +10:00
Nicholas Nethercote
88f8fbcce0 A new matcher representation for use in parse_tt.
`parse_tt` currently traverses a `&[TokenTree]` to do matching. But this
is a bad representation for the traversal.
- `TokenTree` is nested, and there's a bunch of expensive and fiddly
  state required to handle entering and exiting nested submatchers.
- There are three positions (sequence separators, sequence Kleene ops,
  and end of the matcher) that are represented by an index that exceeds
  the end of the `&[TokenTree]`, which is clumsy and error-prone.

This commit introduces a new representation called `MatcherLoc` that is
designed specifically for matching. It fixes all the above problems,
making the code much easier to read. A `&[TokenTree]` is converted to a
`&[MatcherLoc]` before matching begins. Despite the cost of the
conversion, it's still a net performance win, because various pieces of
traversal state are computed once up-front, rather than having to be
recomputed repeatedly during the macro matching.

Some improvements worth noting.
- `parse_tt_inner` is *much* easier to read. No more having to compare
  `idx` against `len` and read comments to understand what the result
  means.
- The handling of `Delimited` in `parse_tt_inner` is now trivial.
- The three end-of-sequence cases in `parse_tt_inner` are now handled in
  three separate match arms, and the control flow is much simpler.
- `nameize` is no longer recursive.
- There were two places that issued "missing fragment specifier" errors:
  one in `parse_tt_inner()`, and one in `nameize()`. Presumably the
  latter was never executed. There's now a single place issuing these
  errors, in `compute_locs()`.
- The number of heap allocations done for a `check full` build of
  `async-std-1.10.0` (an extreme example of heavy macro use) drops from
  11.8M to 2.6M, and most of these occur outside of macro matching.
- The size of `MatcherPos` drops from 64 bytes to 16 bytes. Small enough
  that it no longer needs boxing, which partly accounts for the
  reduction in allocations.
- The rest of the drop in allocations is due to the removal of
  `MatcherKind`, because we no longer need to record anything for the
  parent matcher when entering a submatcher.
- Overall it reduces code size by 45 lines.
2022-04-04 17:01:28 +10:00
bors
ec667fbcfc Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011
Do not use `ParamEnv::and` when building a cache key from a param-env and trait eval candidate

Do not use `ParamEnv::and` to cache a param-env with a selection/evaluation candidate.

This is because if the param-env is `RevealAll` mode, and the candidate looks global (i.e. it has erased regions, which can show up when we normalize a projection type under a binder<sup>1</sup>), then when we use `ParamEnv::and` to pair the candidate and the param-env for use as a cache key, we will throw away the param-env's caller bounds, and we'll end up caching a candidate that we inferred from the param-env with a empty param-env, which may cause cache-hit later when we have an empty param-env, and possibly mess with normalization like we see in the referenced issue during codegen.

Not sure how to trigger this with a more structured test, but changing `check-pass` to `build-pass` triggers the case that https://github.com/rust-lang/rust/issues/94903 detected.

<sup>1.</sup> That is, we will replace the late-bound region with a placeholder, which gets canonicalized and turned into an infererence variable, which gets erased during region freshening right before we cache the result. Sorry, it's quite a few steps.

Fixes #94903
r? `@Aaron1011` (or reassign as you see fit)
2022-04-04 04:48:36 +00:00
Takayuki Maeda
a56f21466e format cond 2022-04-04 12:49:02 +09:00
bors
ac4b3450ed Auto merge of #95606 - petrochenkov:linkregr, r=wesleywiser
linker: Implicitly link native libs as whole-archive in some more cases

Partially revert changes from https://github.com/rust-lang/rust/pull/93901 to address regressions like https://github.com/rust-lang/rust/issues/95561.

Fixes https://github.com/rust-lang/rust/issues/95561
r? `@wesleywiser`
2022-04-04 02:23:15 +00:00
Takayuki Maeda
e0919de0fd remove unnecessary nested blocks 2022-04-04 11:10:40 +09:00
Dylan DPC
19a90c7018
Rollup merge of #95553 - jam1garner:naked-function-compile-error, r=tmiasko
Don't emit non-asm contents error for naked function composed of errors

## Motivation

For naked functions an error is emitted when they are composed of anything other than a single asm!() block. However, this error triggers in a couple situations in which it adds no additional information or is actively misleading.

One example is if you do have an asm!() block but simply one with a syntax error:
```rust
#[naked]
unsafe extern "C" fn compiler_errors() {
    asm!(invalid_syntax)
}
```

This results in two errors, one for the syntax error itself and another telling you that you need an asm block in your function:

```rust
error[E0787]: naked functions must contain a single asm block
 --> src/main.rs:6:1
  |
6 | / unsafe extern "C" fn naked_compile_error() {
7 | |     asm!(blah)
8 | | }
  | |_^
```

This issue also comes up when [utilizing `compile_error!()` for improving your diagnostics](https://twitter.com/steveklabnik/status/1509538243020218372), such as raising a compiler error when compiling for an unsupported target.

## Implementation

The rules this PR implements are as follows:

1. If any non-erroneous  non-asm statement is included, an error will still occur
2. If multiple asm statements are included, an error will still occur
3. If 0 or 1 asm statements are present, as well as any non-zero number of erroneous statements, then this error will *not* be raised as it is likely either redundant or incorrect

The rule of thumb is effectively "if an error is present and its correction could change things, don't raise an error".
2022-04-03 23:21:42 +02:00
Dylan DPC
796bc7e9aa
Rollup merge of #95202 - Urgau:check-cfg-perf-well-known-values, r=petrochenkov
Reduce the cost of loading all built-ins targets

This PR started by measuring the exact slowdown of checking of well known conditional values.
Than this PR implemented some technics to reduce the cost of loading all built-ins targets.

cf. https://github.com/rust-lang/rust/issues/82450#issuecomment-1073992323
2022-04-03 23:21:41 +02:00
Ralf Jung
84a343d1b5 tweak some function names 2022-04-03 15:31:25 -04:00
Loïc BRANSTETT
1a1f5b89a4 Cleanup after some refactoring in rustc_target 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
c16a558f24 Replace LinkArgs with Cow<'static, str> 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
ce61d4044d Replace every Vec in Target(Options) with it's Cow equivalent 2022-04-03 21:29:57 +02:00
Loïc BRANSTETT
ccff48f97b Replace every String in Target(Options) with Cow<'static, str> 2022-04-03 21:29:57 +02:00
Ralf Jung
f0ec783bf9 interpret: remove MemoryExtra in favor of giving access to the Machine 2022-04-03 15:28:34 -04:00
bors
168a020900 Auto merge of #92686 - saethlin:unsafe-debug-asserts, r=Amanieu
Add debug assertions to some unsafe functions

As suggested by https://github.com/rust-lang/rust/issues/51713

~~Some similar code calls `abort()` instead of `panic!()` but aborting doesn't work in a `const fn`, and the intrinsic for doing dispatch based on whether execution is in a const is unstable.~~

This picked up some invalid uses of `get_unchecked` in the compiler, and fixes them.

I can confirm that they do in fact pick up invalid uses of `get_unchecked` in the wild, though the user experience is less-than-awesome:
```
     Running unittests (target/x86_64-unknown-linux-gnu/debug/deps/rle_decode_fast-04b7918da2001b50)

running 6 tests
error: test failed, to rerun pass '--lib'

Caused by:
  process didn't exit successfully: `/home/ben/rle-decode-helper/target/x86_64-unknown-linux-gnu/debug/deps/rle_decode_fast-04b7918da2001b50` (signal: 4, SIGILL: illegal instruction)
```

~~As best I can tell these changes produce a 6% regression in the runtime of `./x.py test` when `[rust] debug = true` is set.~~
Latest commit (6894d559bd) brings the additional overhead from this PR down to 0.5%, while also adding a few more assertions. I think this actually covers all the places in `core` that it is reasonable to check for safety requirements at runtime.

Thoughts?
2022-04-03 16:04:47 +00:00
Oliver Downard
e2dfa23eac Improve method name suggestions
Attempts to improve method name suggestions when a matching method name
is not found. The approach taken is use the Levenshtein distance and
account for substrings having a high distance but can sometimes be very
close to the intended method (eg. empty vs is_empty).
2022-04-03 16:38:57 +01:00
bors
15a242a432 Auto merge of #90791 - drmorr0:drmorr-memcmp-cint-cfg, r=petrochenkov
make memcmp return a value of c_int_width instead of i32

This is an attempt to fix #32610 and #78022, namely, that `memcmp` always returns an `i32` regardless of the platform.  I'm running into some issues and was hoping I could get some help.

Here's what I've been attempting so far:

1. Build the stage0 compiler with all the changes _expect_ for the changes in `library/core/src/slice/cmp.rs` and `compiler/rustc_codegen_llvm/src/context.rs`; this is because `target_c_int_width` isn't passed through and recognized as a valid config option yet.  I'm building with `./x.py build --stage 0 library/core library/proc_macro compiler/rustc`
2. Next I add in the `#[cfg(c_int_width = ...)]` params to `cmp.rs` and `context.rs` and build the stage 1 compiler by running `./x.py build --keep-stage 0 --stage 1 library/core library/proc_macro compiler/rustc`.  This step now runs successfully.
3. Lastly, I try to build the test program for AVR mentioned in #78022 with `RUSTFLAGS="--emit llvm-ir" cargo build --release`, and look at the resulting llvm IR, which still shows:

```
...
%11 = call addrspace(1) i32 `@memcmp(i8*` nonnull %5, i8* nonnull %10, i16 5) #7, !dbg !1191                                                                                                                                                                                                                                %.not = icmp eq i32 %11, 0, !dbg !1191
...
; Function Attrs: nounwind optsize                                                                                                                                                                                                                                                                                          declare i32 `@memcmp(i8*,` i8*, i16) local_unnamed_addr addrspace(1) #4
```

Any ideas what I'm missing here?  Alternately, if this is totally the wrong approach I'm open to other suggestions.

cc `@Rahix`
2022-04-03 11:16:22 +00:00
bors
ec7b753ea9 Auto merge of #85321 - cjgillot:mir-cycle, r=bjorn3
Use DefPathHash instead of HirId to break inlining cycles.

The `DefPathHash` is stable across incremental compilation sessions, so provides a total order on `LocalDefId`. Using it instead of `HirId` ensures the MIR inliner has the same behaviour for incremental and non-incremental compilation.

A downside is that the cycle tie break is not as predictable is with `HirId`.
2022-04-03 07:53:10 +00:00
bors
133859d680 Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwco
Suggest `i += 1` when we see `i++` or `++i`

Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--`
is tricky to handle).

This is a continuation of #83536.

r? `@estebank`
2022-04-03 05:24:20 +00:00
David Morrison
aa67016624 make memcmp return a value of c_int_width instead of i32 2022-04-02 17:21:08 -07:00
Michael Goulet
7d7715fbbc Suggest borrowing when trying to coerce unsized type into dyn Trait 2022-04-02 16:43:17 -07:00
bors
c1550e3f8c Auto merge of #95590 - GuillaumeGomez:multi-line-attr-handling-doctest, r=notriddle
Fix multiline attributes handling in doctests

Fixes #55713.

I needed to have access to the `unclosed_delims` field in order to check that the attribute was completely parsed and didn't have missing parts, so I created a getter for it.

r? `@notriddle`
2022-04-02 23:39:25 +00:00
Michael Goulet
b899251f2d Fix late-bound ICE in unsized return suggestion 2022-04-02 15:29:55 -07:00
Vadim Petrochenkov
a169d337e4 linker: Implicitly link native libs as whole-archive in some more cases 2022-04-03 00:33:39 +03:00
Camille GILLOT
297dde9b1a Less manipulation of the callee_def_id. 2022-04-02 23:28:09 +02:00
Camille GILLOT
2d3d9b26a4 Use only local hash. 2022-04-02 23:23:19 +02:00
Camille GILLOT
e1b36f5ae2 Use DefPathHash instead of HirId to break cycles. 2022-04-02 23:23:19 +02:00
bors
76d770ac21 Auto merge of #95600 - Dylan-DPC:rollup-580y2ra, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #95587 (Remove need for associated_type_bounds in std.)
 - #95589 (Include a header in .rlink files)
 - #95593 (diagnostics: add test case for bogus T:Sized suggestion)
 - #95597 (Refer to u8 by absolute path in expansion of thread_local)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-02 20:58:33 +00:00
Dylan DPC
30c0738d1f
Rollup merge of #95589 - Kobzol:rlink-header, r=bjorn3
Include a header in .rlink files

I couldn't find the right place where to put tests. Is there some location that tests `.rlink` creation and loading?
I only found `src/test/run-make-fulldeps/separate-link/Makefile`, but I'm not sure how to check the error message in the Makefile.

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

r? `@bjorn3`
2022-04-02 22:38:20 +02:00
Guillaume Gomez
c37cd911a4 Fix doctest multi-line mod attributes handling 2022-04-02 20:53:19 +02:00
bors
8f96ef4bb5 Auto merge of #94911 - jackh726:gats_extended_2, r=compiler-errors
Make GATs object safe under generic_associated_types_extended feature

Based on #94869

Let's say we have
```rust
trait StreamingIterator {
    type Item<'a> where Self: 'a;
}
```
And `dyn for<'a> StreamingIterator<Item<'a> = &'a i32>`.

If we ask `(dyn for<'a> StreamingIterator<Item<'a> = &'a i32>): StreamingIterator`, then we have to prove that `for<'x> (&'x i32): Sized`. So, we generate *new* bound vars to subst for the GAT generics.

Importantly, this doesn't fully verify that these are usable and sound.

r? `@nikomatsakis`
2022-04-02 18:34:26 +00:00
Jack Huey
52b00db235 Make GATs object safe under generic_associated_types_extended feature 2022-04-02 14:01:17 -04:00
Jakub Beránek
b81d873cdf
Address review comments and add a test 2022-04-02 17:26:39 +02:00
Jakub Beránek
e0d4226677
Include a header in .rlink files to provide nicer error messages when a wrong file is parsed as .rlink 2022-04-02 16:50:08 +02:00
bors
fbc45b650a Auto merge of #95537 - GuillaumeGomez:type_of-doc, r=Dylan-DPC
Improve TyCtxt::type_of documentation

r? `@oli-obk`
2022-04-02 12:13:11 +00:00
Guillaume Gomez
6fdeee4be3 Improve TyCtxt::type_of documentation 2022-04-02 13:57:27 +02:00
b-naber
14e3d038c0 rebase and remove dead code 2022-04-02 12:47:06 +02:00
b-naber
9b28d3b494 try to evaluate in from_opt_const_arg_anon_const 2022-04-02 12:21:02 +02:00
b-naber
0078e54185 rebase and use ty::Const in patterns again 2022-04-02 12:21:00 +02:00
b-naber
ac60db231c do use ty::Const in patterns and abstract consts 2022-04-02 12:20:59 +02:00
b-naber
b38077ea0b change thir to use mir::ConstantKind instead of ty::Const 2022-04-02 12:20:56 +02:00
bors
07a461ad52 Auto merge of #95571 - petrochenkov:nowrapident2, r=Aaron1011
ast_lowering: Stop wrapping `ident` matchers into groups

The lowered forms goes to metadata, for example during encoding of macro definitions.
This is a missing part of https://github.com/rust-lang/rust/pull/92472.

Fixes https://github.com/rust-lang/rust/issues/95569
r? `@Aaron1011`
2022-04-02 07:42:50 +00:00
Jacob Pratt
6b75406f5a
Create 2024 edition 2022-04-02 02:45:49 -04:00
bors
95f68702ff Auto merge of #95509 - nnethercote:simplify-MatcherPos-some-more, r=petrochenkov
Simplify `MatcherPos` some more

A few more improvements.

r? `@petrochenkov`
2022-04-02 04:59:16 +00:00
Dylan DPC
1c82fac3f7
Rollup merge of #95560 - lcnr:obligation-cause, r=oli-obk
convert more `DefId`s to `LocalDefId`
2022-04-02 03:34:27 +02:00
Dylan DPC
1e43cf46bd
Rollup merge of #95559 - lcnr:inferctxt-typeck, r=oli-obk
small type system refactoring
2022-04-02 03:34:26 +02:00
Dylan DPC
556c7411cc
Rollup merge of #95544 - jam1garner:improve-naked-noreturn-diagnostic, r=tmiasko
Add error message suggestion for missing noreturn in naked function

I had to google the syntax for inline asm's `noreturn` option when I got this error earlier today, so I figured I'd save others the trouble and add the syntax/fix as a suggestion in the error.
2022-04-02 03:34:23 +02:00
Dylan DPC
46a4754df0
Rollup merge of #95430 - ChrisDenton:disable-tls-i686-msvc, r=nagisa
Disable #[thread_local] support on i686-pc-windows-msvc

Fixes #95429
2022-04-02 03:34:22 +02:00
Dylan DPC
be7c363182
Rollup merge of #95373 - RalfJung:invalid_value, r=davidtwco
invalid_value lint: detect invalid initialization of arrays
2022-04-02 03:34:21 +02:00
Dylan DPC
d7a24003d8
Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnr
Handle rustc_const_stable attribute in library feature collector

The library feature collector in [compiler/rustc_passes/src/lib_features.rs](551b4fa395/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were:

- When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable".

    This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase:

    ```console
    error[E0635]: unknown feature `const_ptr_offset`
      --> $DIR/offset_from_ub.rs:1:35
       |
    LL | #![feature(const_ptr_offset_from, const_ptr_offset)]
       |                                   ^^^^^^^^^^^^^^^^
    ```

- We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes.

This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-02 03:34:21 +02:00
bors
eb82facb16 Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obk
Encode even more metadata through tables instead of EntryKind

This should move us closer to getting rid of `EntryKind`.
2022-04-01 21:16:41 +00:00
Vadim Petrochenkov
a150fc2990 ast_lowering: Stop wrapping ident matchers into groups
The lowered forms goes to metadata, for example during encoding of macro definitions
2022-04-02 00:09:34 +03:00
bors
297a8018b5 Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #95032 (Clean up, categorize and sort unstable features in std.)
 - #95260 (Better suggestions for `Fn`-family trait selection errors)
 - #95293 (suggest wrapping single-expr blocks in square brackets)
 - #95344 (Make `impl Debug for rustdoc::clean::Item` easier to read)
 - #95388 (interpret: make isize::MAX the limit for dynamic value sizes)
 - #95530 (rustdoc: do not show primitives and keywords as private)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-01 17:19:15 +00:00
jam1garner
f793b696c8 Reword purpose description of noreturn in naked function 2022-04-01 11:28:45 -04:00
jam1garner
0df84cdc49 Don't emit non-asm contents error for naked function composed of errors 2022-04-01 11:02:36 -04:00
Ralf Jung
af24588a06 invalid_value lint: detect invalid initialization of arrays 2022-04-01 09:59:11 -04:00
lcnr
8eacf6078f update comment 2022-04-01 13:47:01 +02:00
lcnr
796b828371 convert more DefIds to LocalDefId 2022-04-01 13:38:43 +02:00
lcnr
389c83b474 remove unused incorrect EqUnifyValue impl 2022-04-01 12:57:24 +02:00
lcnr
c2b5a7ea52 remove unify_key::replace_if_possible 2022-04-01 12:41:46 +02:00
lcnr
18fae7b2e5 update comments 2022-04-01 12:41:46 +02:00
Matthias Krüger
f37bca4d7c
Rollup merge of #95531 - petrochenkov:metacount, r=nnethercote
expand: Do not count metavar declarations on RHS of `macro_rules`

They are 0 by definition there.

Addresses https://github.com/rust-lang/rust/pull/95425#discussion_r837410476
r? ```@nnethercote```
2022-04-01 12:07:04 +02:00
Matthias Krüger
cdf178f776
Rollup merge of #95388 - RalfJung:rust-val-limit, r=oli-obk
interpret: make isize::MAX the limit for dynamic value sizes

We are currently enforcing `data_layout.obj_size_bound()` as the maximal dynamic size of a Rust value (including for `size_of_val_raw`), but that does not match the docs.

In particular, Miri currently falsely says that this code has UB:
```rust
#![feature(layout_for_ptr)]
fn main() {
    let size = isize::MAX as usize;
    // Creating a raw slice of size isize::MAX and asking for its size is okay.
    let s = std::ptr::slice_from_raw_parts(1usize as *const u8, size);
    assert_eq!(size, unsafe { std::mem::size_of_val_raw(s) });
}
```
2022-04-01 06:59:44 +02:00
Matthias Krüger
8f493fd46a
Rollup merge of #95293 - compiler-errors:braces, r=davidtwco
suggest wrapping single-expr blocks in square brackets

Suggests a fix in cases like:

```diff
- const A: [i32; 1] = { 1 };

+ const A: [i32; 1] = [ 1 ];
                      ^   ^
```

Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`).

Fixes #95289
2022-04-01 06:59:42 +02:00
Matthias Krüger
94b1960535
Rollup merge of #95260 - compiler-errors:fn, r=davidtwco
Better suggestions for `Fn`-family trait selection errors

1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}`
2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments)
3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required).

Fixes #95147
2022-04-01 06:59:41 +02:00
jam1garner
b657cb5577 Add error message suggestion for missing noreturn in naked function 2022-03-31 18:34:20 -04:00
Caio
6ee3c47a3a [let_chains] Forbid let inside parentheses 2022-03-31 18:33:05 -03:00
Fausto
8c2353b6c1 remove find_use_placement
A more robust solution to finding where to place use suggestions was added.
The algorithm uses the AST to find the span for the suggestion so we pass this span
down to the HIR during lowering and use it.

Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-31 17:20:03 -04:00
David Tolnay
5d30180634
Handle rustc_const_stable attribute in library feature collector 2022-03-31 12:34:46 -07:00
bors
0677edc86e Auto merge of #95526 - Dylan-DPC:rollup-0ikl5l5, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #91416 (Specialize infinite-type "insert some indirection" suggestion for Option)
 - #95384 (Update target_has_atomic documentation for stabilization)
 - #95517 (small rustc_borrowck cleanup)
 - #95520 (Fix typos in core::ptr docs)
 - #95523 (remove unused field from `infcx`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-31 17:45:26 +00:00
Camille GILLOT
15b2d1a97c Merge impl_constness and is_const_fn_raw. 2022-03-31 18:33:46 +02:00
Camille GILLOT
e62f483842 Create trait_def table. 2022-03-31 18:14:54 +02:00
Camille GILLOT
618138b923 Store fn constness in impl_constness. 2022-03-31 18:14:49 +02:00
Vadim Petrochenkov
9ab4f732cb expand: Do not count metavar declarations on RHS of macro_rules
They are 0 by definition there.
2022-03-31 19:09:40 +03:00
Camille GILLOT
f2bf484e3a Introduce repr_options table. 2022-03-31 17:56:32 +02:00
Dylan DPC
1074c814af
Rollup merge of #95523 - lcnr:yeet-unused-field, r=oli-obk
remove unused field from `infcx`

r? `@oli-obk` did we stop needing that for opaque types?
2022-03-31 17:29:56 +02:00
Dylan DPC
1f86789bb3
Rollup merge of #95517 - lcnr:rustc_borrowck-misc, r=jackh726
small rustc_borrowck cleanup

r? `@jackh726` because of the second commit, seems like that comment was missed in #91243
2022-03-31 17:29:54 +02:00
Dylan DPC
521c590c9f
Rollup merge of #91416 - compiler-errors:infinite-ty-option-box, r=estebank
Specialize infinite-type "insert some indirection" suggestion for Option

Suggest `Option<Box<_>>` instead of `Box<Option<_>>` for infinitely-recursive members of a struct.

Not sure if I can get the span of the generic subty of the Option so I can make this a `+++`-style suggestion. The current output is a tiny bit less fancy looking than the original suggestion.

Should I limit the specialization to just `Option<Box<TheOuterStruct>>`? Because right now it applies to all `Option` members in the struct that are returned by `Representability::SelfRecursive`.

Fixes #91402

r? `@estebank`
(since you wrote the original suggestion and are definitely most familiar with it!)
2022-03-31 17:29:52 +02:00
bors
bd1a8692f6 Auto merge of #90204 - cjgillot:owner-pull, r=michaelwoerister
Make lowering pull-based

~Based on https://github.com/rust-lang/rust/pull/90451~
Part of https://github.com/rust-lang/rust/pull/88186

The current lowering code visits all the item-likes in the AST in order, and lowers them one by one.
This PR changes it to index the AST and then proceed to lowering on-demand. This is closer to the logic of query-based lowering.
2022-03-31 15:20:59 +00:00
lcnr
a5c68d747e remove unused field from infcx 2022-03-31 17:14:42 +02:00
Michael Goulet
c74f7a310f address comments, add test for shadowed Box type 2022-03-31 08:04:53 -07:00
Michael Goulet
de04c05dea Specialize suggestion for Option<T> 2022-03-31 08:04:53 -07:00
Oli Scherer
6ffd654683 Check that the cached stable hash is the right one if debug assertions are enabled 2022-03-31 14:54:04 +00:00
Oli Scherer
33d0ce95a9 inline a trivial function 2022-03-31 14:54:04 +00:00
Oli Scherer
00c24dd8ce Move stable hash from TyS into a datastructure that can be shared with other interned types. 2022-03-31 14:54:04 +00:00
Oli Scherer
eca0ead17d Enforce well formedness for type alias impl trait's hidden type 2022-03-31 13:52:40 +00:00
lcnr
89c66eb42d update comment 2022-03-31 15:41:52 +02:00
Ralf Jung
a417911c16 catch overflow in slice size computation 2022-03-31 08:57:45 -04:00
Ralf Jung
53c540a666 audit check_mul uses in interpret 2022-03-31 08:57:45 -04:00
Ralf Jung
a421cbbead interpret: make isize::MAX the limit for dynamic value sizes 2022-03-31 08:57:45 -04:00
bors
03314912f1 Auto merge of #95511 - Dylan-DPC:rollup-4n880fd, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #95445 (Don't build the full compiler before running unit tests)
 - #95470 (Fix last rustdoc-gui spurious test)
 - #95478 (Add note to the move size diagnostic)
 - #95495 (Remove unneeded `to_string` call)
 - #95505 (Fix library/std compilation on openbsd.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-31 12:55:13 +00:00
Camille GILLOT
6b099db18c Record item-likes in ItemLowerer. 2022-03-31 13:48:16 +02:00
Camille GILLOT
e5d482eeca Create a new LoweringContext for each item-like. 2022-03-31 13:47:56 +02:00
Camille GILLOT
6e4fb2038a Make lowering pull-based. 2022-03-31 13:47:22 +02:00
Camille GILLOT
41902f2859 Implement with_parent_item_lifetime_defs on ItemLowerer. 2022-03-31 13:47:02 +02:00
Camille GILLOT
dc8b6b4be4 Move lower_crate outside the LoweringContext. 2022-03-31 13:46:40 +02:00
Camille GILLOT
4b598d3f75 Stop emitting lints during lowering. 2022-03-31 13:46:06 +02:00
Camille GILLOT
c10a1cebe7 Store next_disambiguator in Definitions. 2022-03-31 13:34:54 +02:00
Camille GILLOT
b29fa94d22 Remove mutability in ResolverAstLowering. 2022-03-31 13:24:33 +02:00
Dylan DPC
4388ac58a2
Rollup merge of #95478 - InfRandomness:infrandomness/lint_largemove_note, r=compiler-errors
Add note to the move size diagnostic

context: https://github.com/rust-lang/rust/issues/83518
2022-03-31 13:09:53 +02:00
lcnr
d7cada1767 obligation cause: RepeatVec -> RepeatValueCopy 2022-03-31 12:51:46 +02:00
bors
df20355fa9 Auto merge of #95456 - RalfJung:size, r=oli-obk
allow large Size again

This basically reverts most of https://github.com/rust-lang/rust/pull/80042, and instead does the panic in `bits()` with a `#[cold]` function to make sure it does not get inlined.

https://github.com/rust-lang/rust/pull/80042 added a comment about an invariant ("The top 3 bits are ALWAYS zero") that is not actually enforced, and if it were enforced that would be a problem for https://github.com/rust-lang/rust/pull/95388. So I think we should not have that invariant, and I adjusted the code accordingly.

r? `@oli-obk` Cc `@sivadeilra`
2022-03-31 10:33:56 +00:00
Vadim Petrochenkov
f5ee822098 rustdoc: Fix resolution of crate-relative paths in doc links 2022-03-31 10:58:36 +03:00