Commit Graph

21431 Commits

Author SHA1 Message Date
Kyle Matsuda
c2414dfaa4 change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata 2023-01-26 20:28:25 -07:00
bors
db137ba7d4 Auto merge of #106959 - tmiasko:opt-funclets, r=davidtwco
Omit needless funclet partitioning
2023-01-27 03:25:16 +00:00
Kyle Matsuda
e982971ff2 replace usages of fn_sig query with bound_fn_sig 2023-01-26 20:15:36 -07:00
Ali MJ Al-Nasrawy
381187dc76 internally change regions to be covariant 2023-01-27 04:04:22 +03:00
bors
a2d002afe7 Auto merge of #107269 - bjorn3:sync_cg_clif-2023-01-24, r=bjorn3
Sync rustc_codegen_cranelift

For cg_clif itself there have been a couple of bug fixes since the last sync, a Cranelift update and implemented all remaining simd platform intrinsics used by `std::simd`. (`std::arch` still misses a lot though) Most of the diff is from reworking of the cg_clif build system though.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-01-27 00:03:09 +00:00
Tomasz Miąsko
e489971902 Fix def-use dominance check
A definition does not dominate a use in the same statement. For example
in MIR generated for compound assignment x += a (when overflow checks
are disabled).
2023-01-27 00:54:31 +01:00
Michael Goulet
2d5591df00 Make make_identity take CanonicalVarInfos 2023-01-26 20:33:40 +00:00
Michael Goulet
4ff674f942 Intern CanonicalVarValues 2023-01-26 20:33:40 +00:00
bors
d7948c843d Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkov
make `output_filenames` a real query

part of #105462

This may be a perf regression and is not obviously the right way forward. We may store this information in the resolver after freezing it for example.
2023-01-26 20:32:28 +00:00
Michael Goulet
9b5a2a4a48 Use new solver during selection 2023-01-26 20:09:39 +00:00
bors
c62665e09c Auto merge of #107328 - matthiaskrgr:rollup-lfqwo0o, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #106904 (Preserve split DWARF files when building archives.)
 - #106971 (Handle diagnostics customization on the fluent side (for one specific diagnostic))
 - #106978 (Migrate mir_build's borrow conflicts)
 - #107150 (`ty::tls` cleanups)
 - #107168 (Use a type-alias-impl-trait in `ObligationForest`)
 - #107189 (Encode info for Adt in a single place.)
 - #107322 (Custom mir: Add support for some remaining, easy to support constructs)
 - #107323 (Disable ConstGoto opt in cleanup blocks)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-26 15:58:08 +00:00
Matthias Krüger
4ed8cfc202
Rollup merge of #107323 - JakobDegen:const-goto, r=tmiasko
Disable ConstGoto opt in cleanup blocks

Fixes #107315 .

There is probably a smaller hammer that we could use here, but none that is super obviously correct. We can always revisit this in the future.

Could not add a test because custom mir does not support cleanup blocks. However, did check that the fallible_iterator crate no longer ICEs with the other PR cherry picked.

r? `@tmiasko`
2023-01-26 15:02:22 +01:00
Matthias Krüger
c87996a8ad
Rollup merge of #107322 - JakobDegen:custom-mir, r=tmiasko
Custom mir: Add support for some remaining, easy to support constructs

Some documentation for previous changes and support for `Deinit`, checked binops, len, and array repetition

r? ```@oli-obk``` or ```@tmiasko```
2023-01-26 15:02:22 +01:00
Matthias Krüger
82455a799e
Rollup merge of #107189 - cjgillot:meta-adt, r=compiler-errors
Encode info for Adt in a single place.

Split from https://github.com/rust-lang/rust/pull/98867
2023-01-26 15:02:21 +01:00
Matthias Krüger
3c145ff283
Rollup merge of #107168 - Nilstrieb:if-a-tait-falls-in-the-forest,can-we-know-it-wasnt-revealed, r=oli-obk
Use a type-alias-impl-trait in `ObligationForest`
2023-01-26 15:02:21 +01:00
Matthias Krüger
70a665a005
Rollup merge of #107150 - Nilstrieb:thread-local-cleanups, r=cjgillot
`ty::tls` cleanups

Pull it out into a separate file, make the conditional compilation more obvious and give the internal functions better names.

Pulled out of #106311

r? cjgillot
2023-01-26 15:02:20 +01:00
Matthias Krüger
e8c17de11d
Rollup merge of #106978 - mejrs:mir_build3, r=davidtwco
Migrate mir_build's borrow conflicts

This also changes the error message slightly, for two reasons:

- I'm not a fan of saying "value borrowed, by `x`, here"
- it simplifies the error implementation significantly.
2023-01-26 15:02:20 +01:00
Matthias Krüger
4b97f07534
Rollup merge of #106971 - oli-obk:tait_error, r=davidtwco
Handle diagnostics customization on the fluent side (for one specific diagnostic)

r? ```@davidtwco```
2023-01-26 15:02:19 +01:00
Matthias Krüger
1b442befca
Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwco
Preserve split DWARF files when building archives.

r? ```@davidtwco```
2023-01-26 15:02:19 +01:00
bors
3e97763872 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26 12:44:47 +00:00
Jakob Degen
f8aaf9aadb Disable ConstGoto opt in cleanup blocks 2023-01-26 03:50:37 -08:00
Jakob Degen
d7f59e91e0 Custom mir: Add support for some remaining, easy to support constructs 2023-01-26 03:29:28 -08:00
lcnr
727b987e06 solver comments + remove TyCtxt::evaluate_goal 2023-01-26 11:02:28 +01:00
bors
40fda7b3fe Auto merge of #107318 - matthiaskrgr:rollup-776kd81, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #97373 (impl DispatchFromDyn for Cell and UnsafeCell)
 - #106625 (Remove backwards compat for LLVM 12 coverage format)
 - #106779 (Avoid __cxa_thread_atexit_impl on Emscripten)
 - #106811 (Append .dwp to the binary filename instead of replacing the existing extension.)
 - #106836 (Remove optimistic spinning from `mpsc::SyncSender`)
 - #106946 (implement Hash for proc_macro::LineColumn)
 - #107074 (remove unnecessary check for opaque types)
 - #107287 (Improve fn pointer notes)
 - #107304 (Use `can_eq` to compare types for default assoc type error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-26 09:14:05 +00:00
Matthias Krüger
3aeafca070
Rollup merge of #107304 - Nilstrieb:ᐸTy as PartialEqᐳ::eq because what else are we gonna use in rustc_middle, r=compiler-errors
Use `can_eq` to compare types for default assoc type error

This correctly handles inference variables like `{integer}`. I had to move all of this `note_and_explain` code to `rustc_infer`, it made no sense for it to be in `rustc_middle` anyways.

The commits are reviewed separately.

Fixes #106968
2023-01-26 07:53:26 +01:00
Matthias Krüger
f2f123470f
Rollup merge of #107287 - mattjperez:improve-fn-pointer-notes, r=compiler-errors
Improve fn pointer notes

continuation of #105552

r? `@compiler-errors`
2023-01-26 07:53:25 +01:00
Matthias Krüger
c1d722c1cf
Rollup merge of #107074 - lcnr:validate-dont-skip-opaque, r=compiler-errors
remove unnecessary check for opaque types

this isn't needed and may hide some errors.

after analysis there are no opaque types so it's a noop anyways

before analysis there are opaque types but due to `Reveal::UserFacing` we don't reveal them. `is_subtype` simply discards the opaque type constraints as these will get checked again during mir borrowck.

r? types

want to land this after the beta-cutoff as mir validator changes are apparently pretty scary
2023-01-26 07:53:25 +01:00
Matthias Krüger
59fcb7a2ce
Rollup merge of #106811 - khuey:dwp_extension, r=davidtwco
Append .dwp to the binary filename instead of replacing the existing extension.

gdb et al. expect to find the dwp file at `<binary>`.dwp, even if <binary> already has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).
2023-01-26 07:53:23 +01:00
Matthias Krüger
b2448f9f9c
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
Remove backwards compat for LLVM 12 coverage format

The minimum external LLVM was updated to 13 recently in https://github.com/rust-lang/rust/pull/100611, so this PR removes backwards compat with older coverage formats.

I kept the version check and error message there, in accordance with this comment: https://github.com/rust-lang/rust/pull/91207#issuecomment-981121867
2023-01-26 07:53:22 +01:00
bors
e187f8871e Auto merge of #107314 - matthiaskrgr:rollup-j40lnlj, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #106407 (Improve proc macro attribute diagnostics)
 - #106960 (Teach parser to understand fake anonymous enum syntax)
 - #107085 (Custom MIR: Support binary and unary operations)
 - #107086 (Print PID holding bootstrap build lock on Linux)
 - #107175 (Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`)
 - #107204 (suggest qualifying bare associated constants)
 - #107248 (abi: add AddressSpace field to Primitive::Pointer )
 - #107272 (Implement ObjectSafe and WF in the new solver)
 - #107285 (Implement `Generator` and `Future` in the new solver)
 - #107286 (ICE in new solver if we see an inference variable)
 - #107313 (Add Style Team Triagebot config)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-26 06:23:14 +00:00
Matthias Krüger
dd08f35e87
Rollup merge of #107286 - compiler-errors:new-solver-deny-infers, r=lcnr
ICE in new solver if we see an inference variable

By construction, we do not expect to see any `ty::Infer(ty::TyVar(_))` inference types in the solver (we treat this as ambiguous, since we need to be able to structurally resolve the self type at least one layer to assemble candidates for it). Additionally, since we're doing no freshening, we also don't expect to see any fresh vars of any kind in the solver.

Let's make that an ICE so we can catch any mistakes.

When #107282 lands, we should also ICE there too if we see a non-int/float infer.

r? `@lcnr`
2023-01-26 06:15:29 +01:00
Matthias Krüger
5be2f51428
Rollup merge of #107285 - compiler-errors:new-solver-future-and-generator, r=lcnr
Implement `Generator` and `Future` in the new solver

r? `@lcnr`
2023-01-26 06:15:28 +01:00
Matthias Krüger
a84e060173
Rollup merge of #107272 - compiler-errors:new-solver-more-predicates, r=lcnr
Implement ObjectSafe and WF in the new solver

r? ``@lcnr``
2023-01-26 06:15:27 +01:00
Matthias Krüger
a8b5e5d9db
Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obk
abi: add AddressSpace field to Primitive::Pointer

...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string (and various other changes),
which will be done in a followup.
(That is, if it's actually worth it to support multiple different pointer sizes.
There is a lot of code that would be affected by that.)

Fixes #106367

r? ``@oli-obk``
cc ``@Patryk27``
2023-01-26 06:15:27 +01:00
Matthias Krüger
a8e8406e60
Rollup merge of #107204 - euclio:assoc-const-suggestion, r=petrochenkov
suggest qualifying bare associated constants

Fixes #107199.
2023-01-26 06:15:26 +01:00
Matthias Krüger
5bc49807dd
Rollup merge of #107175 - compiler-errors:bad-types-in-vec-push, r=estebank
Fix escaping inference var ICE in `point_at_expr_source_of_inferred_type`

Fixes #107158

`point_at_expr_source_of_inferred_type` uses `lookup_probe` to adjust the self type of a method receiver -- but that method returns inference variables from inside a probe. That means that the ty vars are no longer valid, so we can't use any infcx methods on them.

Also, pass some extra span info to hack a quick solution to bad labels, resulting in this diagnostic improvement:

```rust
fn example2() {
    let mut x = vec![1];
    x.push("");
}
```

```diff
  error[E0308]: mismatched types
   --> src/main.rs:5:12
    |
  5 |     x.push("");
    |       ---- ^^
    |       |    |
    |       |    expected integer, found `&str`
-   |       |    this is of type `&'static str`, which causes `x` to be inferred as `Vec<{integer}>`
    |       arguments to this method are incorrect
```
(since that "which causes `x` to be inferred as `Vec<{integer}>` part is wrong)

r? `@estebank`

(we really should make this code better in general, cc #106590, but that's a bit bigger issue that needs some more thinking about)
2023-01-26 06:15:26 +01:00
Matthias Krüger
f3644ca64d
Rollup merge of #107085 - tmiasko:custom-mir-operators, r=oli-obk
Custom MIR: Support binary and unary operations

Lower binary and unary operations directly to corresponding unchecked MIR
operations. Ultimately this might not be syntax we want, but it allows for
experimentation in the meantime.

r? ````@oli-obk```` ````@JakobDegen````
2023-01-26 06:15:24 +01:00
Matthias Krüger
ba928ba041
Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillot
Teach parser to understand fake anonymous enum syntax

Parse `Ty | OtherTy` in function argument and return types.
Parse type ascription in top level patterns.

Minimally address #100741.
2023-01-26 06:15:24 +01:00
Matthias Krüger
8ae5116fae
Rollup merge of #106407 - mejrs:attr_check, r=compiler-errors
Improve proc macro attribute diagnostics

Closes https://github.com/rust-lang/rust/issues/102923
2023-01-26 06:15:23 +01:00
Matthew J Perez
3016f55579 improve fn pointer notes
- add note and suggestion for casting both expected and found fn items
  to fn pointers
- add note for casting expected fn item to fn pointer
2023-01-26 05:07:34 +00:00
Michael Goulet
0f24e11ef5 ICE in new solver if we see an inference variable 2023-01-26 03:18:36 +00:00
Michael Goulet
d600b94ebb Implement Generator and Future 2023-01-26 03:15:36 +00:00
Michael Goulet
8434b43a7f Report the right fulfillment errors 2023-01-26 03:14:26 +00:00
bors
885bf62887 Auto merge of #105582 - saethlin:instcombine-assert-inhabited, r=cjgillot
InstCombine away intrinsic validity assertions

This optimization (currently) fires 246 times on the standard library. It seems to fire hardly at all on the big crates in the benchmark suite. Interesting.
2023-01-26 03:10:52 +00:00
Michael Goulet
02b80d2f9c Don't normalize obligations in WF goal for the new solver 2023-01-25 21:28:22 +00:00
Michael Goulet
b3f0085376 Implement ObjectSafe and WF in the new solver 2023-01-25 21:27:12 +00:00
Matthias Krüger
a20b86f881
Rollup merge of #107282 - BoxyUwU:erica_builtin_pointee_impls, r=compiler-errors
erica solver: implement builtin `Pointee` trait impl candidates

r? ```@compiler-errors```
2023-01-25 22:19:56 +01:00
Matthias Krüger
c2f46df5a5
Rollup merge of #107256 - JakobDegen:delete-sai, r=cjgillot
Delete `SimplifyArmIdentity` and `SimplifyBranchSame` mir opts

I had attempted to fix the first of these opts in #94177 . However, despite that PR already being a full re-write, it still did not fix some of the core soundness issues. The optimizations that are attempted here are likely to be desirable, but I do not expect any of the currently written code to survive into a sound implementation. Deleting the code keeps us from having to maintain the passes in the meantime.

Closes #77359 , closes #72800 , closes #78628

r? ```@cjgillot```
2023-01-25 22:19:55 +01:00
Matthias Krüger
9e3f330656
Rollup merge of #106897 - estebank:issue-99430, r=davidtwco
Tweak E0597

CC #99430
2023-01-25 22:19:52 +01:00
Matthias Krüger
f21728fee4
Rollup merge of #105345 - yanchen4791:issue-103582-fix, r=jackh726
Add hint for missing lifetime bound on trait object when type alias is used

Fix issue #103582.

The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.

The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.
2023-01-25 22:19:51 +01:00
Nilstrieb
943000fdcf Use can_eq to compare types for default assoc type error
This works correctly with inference variables.
2023-01-25 21:25:42 +01:00
Nilstrieb
b222f2e266 Move note_and_explain_type_err from rustc_middle to rustc_infer
This way we can properly deal with the types.
2023-01-25 21:18:35 +01:00
Michael Goulet
b83ab0ce96 Suggest mutable borrows correctly 2023-01-25 19:37:10 +00:00
Michael Goulet
800f1f3513 Liberate late-bound regions correctly 2023-01-25 19:26:53 +00:00
Vadim Petrochenkov
957bc606dd rustdoc: Collect rustdoc-reachable items during early doc link resolution 2023-01-25 23:14:09 +04:00
bors
027c8507b4 Auto merge of #103902 - vincenzopalazzo:macros/obligation_rulesv2, r=oli-obk
use `LocalDefId` instead of `HirId` in trait resolution to simplify the obligation clause resolution

This commit introduces a refactoring suggested by `@lcnr` to simplify the obligation clause resolution.

This is just the first PR that introduces a type of refactoring, but others PRs will follow this to introduce name changing to change from the variable name from `body_id` to something else.

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

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

`@rustbot` r? `@lcnr`
2023-01-25 16:39:29 +00:00
bjorn3
3808bc4639 Fix CI 2023-01-25 16:27:28 +01:00
bjorn3
1578b1c73f Vendor newer version of cranelift-native
It fixes a bug that caused compilation on 32bit x86 to fail
2023-01-25 15:19:40 +01:00
Andy Russell
8b12d5f42f
suggest qualifying bare associated constants 2023-01-25 08:58:27 -05:00
Dylan DPC
139a3c5b0a
Rollup merge of #107227 - lcnr:solver-new-external-api, r=compiler-errors
`new_outside_solver` ->  `evaluate_root_goal`

r? ```@rust-lang/initiative-trait-system-refactor```
2023-01-25 17:01:44 +05:30
Dylan DPC
4e2b5d1f54
Rollup merge of #107213 - edward-shen:edward-shen/fix-accidental-let-else, r=compiler-errors
Add suggestion to remove if in let..else block

Adds an additional hint to failures where we encounter an else keyword while we're parsing an if-let expression.

This is likely that the user has accidentally mixed if-let and let..else together.

Fixes #103791.
2023-01-25 17:01:43 +05:30
Dylan DPC
a788ce243a
Rollup merge of #107166 - petrochenkov:nooptable, r=oli-obk
rustc_metadata: Support non-`Option` nullable values in metadata tables

This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent.
Tables using `Table<DefIndex, ()>` are migrated in this PR, some other cases can be migrated later.
This helps `DocFlags` in https://github.com/rust-lang/rust/pull/107136 in particular.
2023-01-25 17:01:42 +05:30
Dylan DPC
9e6873f788
Rollup merge of #106767 - chbaker0:disable-unstable-features, r=Mark-Simulacrum
Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0

Two locations check whether this build-time environment variable is defined. Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.
2023-01-25 17:01:41 +05:30
Dylan DPC
b36a8dcea3
Rollup merge of #106583 - estebank:suggest-result-coercion, r=compiler-errors
Suggest coercion of `Result` using `?`

Fix #47560.
2023-01-25 17:01:40 +05:30
Erik Desjardins
adc1890448 create and use GlobalAlloc::address_space 2023-01-25 01:46:19 -05:00
Vadim Petrochenkov
c70b7aafae rustc_metadata: Fix encode_attrs
This function didn't do what the authors intended it to do.

- Due to `move` in the closure `is_public` wasn't captured by mutalbe reference and wasn't used as a cache.
- Due to iterator cloning all the `should_encode_attr` logic run for the second time to calculate `may_have_doc_links`

This PR fixes these issues, and calculates all the needed attribute flags in one go.
2023-01-25 10:08:48 +04:00
Michal Rostecki
1cd7dbfbf8 Add target_has_atomic* symbols if any atomic width is supported
Atomic operations for different widths (8-bit, 16-bit, 32-bit etc.) are
guarded by `target_has_atomic = "value"` symbol (i.e. `target_has_atomic
= "8"`) (and the other derivatives), but before this change, there was
no width-agnostic symbol indicating a general availability of atomic
operations.

This change introduces:

* `target_has_atomic_load_store` symbol when atomics for any integer
  width are supported by the target.
* `target_has_atomic` symbol when also CAS is supported.

Fixes #106845

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-25 10:44:03 +08:00
Boxy
a418e39b75 no without_constness 2023-01-24 23:32:47 +00:00
Boxy
2f924b0e3c sorry erica 2023-01-24 23:29:02 +00:00
Boxy
430dab0b42 implement builtin candidate 2023-01-24 23:24:30 +00:00
Matthew J Perez
1e22280f23
Add suggestions for function pointers
- On compiler-error's suggestion of moving this lower down the stack,
along the path of `report_mismatched_types()`, which is used
by `rustc_hir_analysis` and `rustc_hir_typeck`.
- update ui tests, add test
- add suggestions for references to fn pointers
- modify `TypeErrCtxt::same_type_modulo_infer` to take `T: relate::Relate` instead of `Ty`
2023-01-24 14:02:56 -05:00
bjorn3
b829bb7431 Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24 2023-01-24 18:56:42 +01:00
Mara Bos
db731e42b3 Work around issue 106930. 2023-01-24 16:44:00 +01:00
Jakob Degen
ad7393668f Delete SimplifyArmIdentity and SimplifyBranchSame mir opts 2023-01-24 04:13:52 -08:00
Edward Shen
a8b77cfe54
Add suggestion to remove if in let...else block
Adds an additional hint to failures where we encounter an else keyword
while we're parsing an if-let block.

This is likely that the user has accidentally mixed if-let and let...else
together.
2023-01-23 20:33:04 -08:00
Ben Kimock
5bfad5cc85 Thread a ParamEnv down to might_permit_raw_init 2023-01-23 19:25:10 -05:00
Bryan Garza
1bbd655888 Improve efficiency of has_back_edge(...) 2023-01-24 00:01:37 +00:00
Bryan Garza
7618163a1c Add comments and remove unnecessary code 2023-01-23 23:56:22 +00:00
Bryan Garza
f9982ea24a Add comment on cause of panic in dominators algorithm 2023-01-23 23:56:22 +00:00
Bryan Garza
aae331d610 During MirBorrowck, ignore ConstEvalCounter 2023-01-23 23:56:22 +00:00
Bryan Garza
999d19d8aa Move CtfeLimit MirPass to inner_mir_for_ctfe 2023-01-23 23:56:22 +00:00
Bryan Garza
d3c13a0102 Revert "Move CtfeLimit to mir_const's set of passes"
This reverts commit 332542a92223b2800ed372d2d461921147f29477.
2023-01-23 23:56:22 +00:00
Bryan Garza
172662dede Add back Machine::before_terminator(...) method
Added it back because it's used by Miri, but in the compiler itself, it
will not do anything (just return `Ok(())`.
2023-01-23 23:56:22 +00:00
Bryan Garza
08de246cd7 Move CtfeLimit to mir_const's set of passes 2023-01-23 23:56:22 +00:00
Bryan Garza
164ff64013 Update codegen cranelift for ConstEvalCounter 2023-01-23 23:56:22 +00:00
Bryan Garza
eea42733ac Replace terminator-based const eval limit
- Remove logic that limits const eval based on terminators, and use the
  stable metric instead (back edges + fn calls)
- Add unstable flag `tiny-const-eval-limit` to add UI tests that do not
  have to go up to the regular 2M step limit
2023-01-23 23:56:22 +00:00
Bryan Garza
8d99b0fc8d Abstract out has_back_edge fn 2023-01-23 23:56:22 +00:00
Bryan Garza
009beb00bc Change code to use map insead of for-loop 2023-01-23 23:56:22 +00:00
Bryan Garza
b763f9094f Remove debugging-related code 2023-01-23 23:56:22 +00:00
Bryan Garza
026a67377f Clean up CtfeLimit MirPass 2023-01-23 23:56:22 +00:00
Bryan Garza
360db516cc Create stable metric to measure long computation in Const Eval
This patch adds a `MirPass` that tracks the number of back-edges and
function calls in the CFG, adds a new MIR instruction to increment a
counter every time they are encountered during Const Eval, and emit a
warning if a configured limit is breached.
2023-01-23 23:56:22 +00:00
Esteban Küber
020cca8d36 review comment: Remove AST AnonTy 2023-01-23 18:21:08 +00:00
yanchen4791
62a1e76d2b Add hint for missing lifetime bound on trait object when type alias is used 2023-01-23 09:54:45 -08:00
Michael Goulet
9f933b5642 Hack to suppress bad labels in type mismatch inference deduction code 2023-01-23 17:02:50 +00:00
Michael Goulet
bed3bb53d2 Don't resolve type var roots in point_at_expr_source_of_inferred_type 2023-01-23 17:02:50 +00:00
Michael Goulet
da3ecb09d8 Use proper InferCtxt when probing for associated types in astconv 2023-01-23 16:53:23 +00:00
Vadim Petrochenkov
91fdbd7343 rustc_metadata: Support non-Option nullable values in metadata tables
This is a convenience feature for cases in which "no value in the table" and "default value in the table" are equivalent.
Tables using `Table<DefIndex, ()>` are migrated in this PR, some other cases can be migrated later.

This helps `DocFlags` in https://github.com/rust-lang/rust/pull/107136 in particular.
2023-01-23 19:35:03 +04:00
lcnr
033047a72c new_outside_solver -> evaluate_root_goal 2023-01-23 15:58:28 +01:00
Esteban Küber
62aff3bbc7 tweak wording 2023-01-23 14:47:00 +00:00
Esteban Küber
df81147b51 Ensure suggestion correctness 2023-01-23 14:47:00 +00:00
Esteban Küber
fcf0ed9018 Do not erase regions 2023-01-23 14:47:00 +00:00
Esteban Küber
ddd9a9fb46 Add call in emit_type_mismatch_suggestions 2023-01-23 14:46:59 +00:00
Esteban Küber
d5a1609ec4 review comment: use fcx.infcx 2023-01-23 14:46:59 +00:00
Esteban Küber
e477cf9475 Suggest coercion of Result using ?
Fix #47560.
2023-01-23 14:46:59 +00:00
Oli Scherer
d924a8ca59 Evaluate output_filenames before one of its dependencies gets stolen 2023-01-23 14:22:33 +00:00
bors
c8e6a9e8b6 Auto merge of #107220 - JohnTitor:rollup-5pvuz0z, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #106796 (BPF: Disable atomic CAS)
 - #106886 (Make stage2 rustdoc and proc-macro-srv disableable in x.py install)
 - #107101 (Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`)
 - #107109 (ThinBox: Add intra-doc-links for Metadata)
 - #107148 (remove error code from `E0789`, add UI test/docs)
 - #107151 (Instantiate dominators algorithm only once)
 - #107153 (Consistently use dominates instead of is_dominated_by)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-23 13:07:16 +00:00
Vincenzo Palazzo
7d2c1103d7 fix: use LocalDefId instead of HirId in trait res
use LocalDefId instead of HirId in trait resolution to simplify
the obligation clause resolution

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-23 11:42:18 +00:00
Oli Scherer
261bbd7dba Store the gctxt instead of fetching it twice. 2023-01-23 10:35:21 +00:00
Oli Scherer
3ddb54f155 Prefer queries over Compiler methods 2023-01-23 10:35:21 +00:00
Oli Scherer
bcc8b05d5c Make output_filenames a real query 2023-01-23 10:35:21 +00:00
Yuki Okushi
eae7f947b5
Rollup merge of #107153 - tmiasko:dominates, r=oli-obk
Consistently use dominates instead of is_dominated_by

There is a number of APIs that answer dominance queries. Previously they were named either "dominates" or "is_dominated_by". Consistently use the "dominates" form.

No functional changes.
2023-01-23 19:30:02 +09:00
Yuki Okushi
c0f80e7166
Rollup merge of #107151 - tmiasko:dominators-no-inline, r=compiler-errors
Instantiate dominators algorithm only once

Remove inline from BasicBlocks::dominators to instantiate the dominator algorithm only once - in the rustc_middle crate.
2023-01-23 19:30:01 +09:00
Yuki Okushi
809d4aa478
Rollup merge of #107148 - Ezrashaw:uncode-e0789, r=compiler-errors,GuillaumeGomez
remove error code from `E0789`, add UI test/docs

`E0789` shouldn't have an error code, it's explicitly internal-only and is tiny in scope. (I wonder if we can tighten the standard for this in the RFC?) I also added a UI test and error docs (done like `E0208`, they are "no longer emitted").

r? `@GuillaumeGomez` (shouldn't need a compiler review, it's pretty minor)
2023-01-23 19:30:00 +09:00
Yuki Okushi
17023496a2
Rollup merge of #107101 - compiler-errors:perf-106309-1, r=petrochenkov
Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`

cc #106309 https://github.com/rust-lang/rust/pull/106757#issuecomment-1396616318

r? `@ghost`
2023-01-23 19:29:59 +09:00
Yuki Okushi
9e79642a7b
Rollup merge of #106796 - vadorovsky:revert-105708-enable-atomic-cas-bpf, r=bjorn3
BPF: Disable atomic CAS

Enabling CAS for BPF targets (https://github.com/rust-lang/rust/pull/105708) breaks the build of core library.
The failure occurs both when building rustc for BPF targets and when
building crates for BPF targets with the current nightly.

The LLVM BPF backend does not correctly lower all `atomicrmw` operations
and crashes for unsupported ones.

Before we can enable CAS for BPF in Rust, we need to fix the LLVM BPF
backend first.

Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-23 19:29:58 +09:00
Oli Scherer
abee6137f7 Remove another unneeded use of the resolver 2023-01-23 10:18:45 +00:00
bors
5bef91c6e9 Auto merge of #107136 - petrochenkov:dochidden, r=cjgillot
rustc_metadata: Encode `doc(hidden)` flag to metadata

To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance.

This is especially important for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
2023-01-23 10:12:57 +00:00
Ezra Shaw
00ff718da8
add UI test + docs for E0789 2023-01-23 20:38:14 +13:00
Dylan DPC
66d6a0b5da
Rollup merge of #107203 - chenyukang:yukang/fix-106496-remove-deref, r=compiler-errors
Suggest remove deref for type mismatch

Fixes #106496
2023-01-23 11:52:07 +05:30
Dylan DPC
e4ed082579
Rollup merge of #107195 - smoelius:patch-2, r=Nilstrieb
Fix typo in universal_regions.rs comment
2023-01-23 11:52:06 +05:30
Dylan DPC
f4f3335114
Rollup merge of #107108 - sulami:issue-83968-doc-alias-typo-suggestions, r=compiler-errors
Consider doc(alias) when providing typo suggestions

This means that

```rust
impl Foo {
    #[doc(alias = "quux")]
    fn bar(&self) {}
}

fn main() {
    (Foo {}).quux();
}
```

will suggest `bar`. This currently uses the "there is a method with a similar name" help text, because the point where we choose and emit a suggestion is different from where we gather the suggestions. Changes have mainly been made to the latter.

The selection code will now fall back to aliased candidates, but generally only if there is no candidate that matches based on the existing Levenshtein methodology.

Fixes #83968.
2023-01-23 11:52:05 +05:30
Dylan DPC
3d4c3125be
Rollup merge of #104926 - spastorino:calculate_diverging_fallback-cleanups, r=lcnr
Move relationships from FulfillmentContext to Inherited

r? `@lcnr`
2023-01-23 11:52:04 +05:30
Erik Desjardins
009192b01b abi: add AddressSpace field to Primitive::Pointer
...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string, which will be done in a followup.
2023-01-22 23:41:39 -05:00
Erik Desjardins
96f8f99589 rustc_abi: remove Primitive::{is_float,is_int}
there were fixmes for this already

i am about to remove is_ptr (since callers need to properly distinguish
between pointers in different address spaces), so might as well do this
at the same time
2023-01-22 21:02:07 -05:00
Robin Schroer
f908f0be5a
Consider doc(alias) when providing typo suggestions
This means that

```rust
impl Foo {
    #[doc(alias = "quux")]
    fn bar(&self) {}
}

fn main() {
    (Foo {}).quux();
}
```

will suggest `bar`. This currently uses the "there is a method with a
similar name" help text, because the point where we choose and emit a
suggestion is different from where we gather the suggestions. Changes
have mainly been made to the latter.

The selection code will now fall back to aliased candidates, but
generally only if there is no candidate that matches based on the
existing Levenshtein methodology.

Fixes #83968.
2023-01-23 10:07:10 +09:00
bors
a5fa99eed2 Auto merge of #106975 - tmiasko:basic-blocks-cache, r=cjgillot
Refactor basic blocks control flow caches

No functional changes.
2023-01-22 21:35:21 +00:00
yukang
2aa5555ad3 Fix #106496, suggest remove deref for type mismatch 2023-01-23 00:42:20 +08:00
Santiago Pastorino
6155a80380
Rename relationships to infer_var_info 2023-01-22 11:02:28 -03:00
Santiago Pastorino
fb0a4e9589
Move relationships::update to Inherited::update_infer_var_info 2023-01-22 11:02:28 -03:00
Santiago Pastorino
7fe472223e
Store relationships on Inherent 2023-01-22 11:02:28 -03:00
Santiago Pastorino
81ee6aebaa
Remove duplicated debug call 2023-01-22 11:02:28 -03:00
Samuel Moelius
12a72f0329
Update universal_regions.rs 2023-01-22 07:38:02 -05:00
Konrad Borowski
f72e17f8fb Remove dependency on slice_internals feature in rustc_ast 2023-01-22 13:05:47 +01:00
Camille GILLOT
4d11206ee7 Tweak comments. 2023-01-22 11:13:19 +00:00
Camille GILLOT
6ecf30d67d Inline encode_enum_variant_info. 2023-01-22 11:04:53 +00:00
Camille GILLOT
d7f6564fdd Encode AdtDef in the def-id loop. 2023-01-22 11:04:52 +00:00
Matthias Krüger
d779a592dd
Rollup merge of #107127 - uweigand:s390x-sanitizer, r=Mark-Simulacrum
Enable sanitizers for s390x-linux

Include sanitizers supported by LLVM on s390x (asan, lsan, msan, tsan) in the target definition, as well as in the compiletest supported list.

Build sanitizer runtime for the target.  Enable sanitizers in the CI.
2023-01-22 11:43:07 +01:00
Matthias Krüger
6e79310c55
Rollup merge of #107111 - chenyukang:yukang/fix-107090-fluent-parameters, r=petrochenkov
Fix missing arguments issues and copy-paste bug for fluent

Fixes #107090
2023-01-22 11:43:06 +01:00
Matthias Krüger
d022013eb7
Rollup merge of #107102 - compiler-errors:new-solver-new-candidats-4, r=lcnr
Implement some more predicates in the new solver

Implement a few more goals. The subtype goal specifically is important, since it's required for this code to compile:

```
fn main() {
  let mut x = vec![];
  x.push(1i32);
}
```

(I think we emit a subtype goal here because of coercion).

Drive-by: Also implements `--compare-mode=next-solver` -- I've been using this locally a lot to find out what works and what doesn't. I'm also happy to split this out into another PR.

r? `@lcnr`
2023-01-22 11:43:05 +01:00
bors
940d00f2f6 Auto merge of #107185 - compiler-errors:rollup-wkomjma, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #103418 (Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` to future-incompat report)
 - #106113 (llvm-wrapper: adapt for LLVM API change)
 - #106144 (Improve the documentation of `black_box`)
 - #106578 (Label closure captures/generator locals that make opaque types recursive)
 - #106749 (Update cc to 1.0.77)
 - #106935 (Fix `SingleUseLifetime` ICE)
 - #107015 (Re-enable building rust-analyzer on riscv64)
 - #107029 (Add new bootstrap members to triagebot.toml)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-22 06:53:36 +00:00
Michael Goulet
8a830cf182
Rollup merge of #106935 - TaKO8Ki:fix-104440, r=cjgillot
Fix `SingleUseLifetime` ICE

Fixes #104440
cc: ``@matthiaskrgr``
2023-01-21 23:21:00 -05:00
Michael Goulet
1d2c9a84fa
Rollup merge of #106578 - compiler-errors:recursive-opaque-closure, r=TaKO8Ki
Label closure captures/generator locals that make opaque types recursive

cc https://github.com/rust-lang/rust/issues/46415#issuecomment-1374665828
2023-01-21 23:20:59 -05:00
Michael Goulet
2504c8d1ee
Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic
llvm-wrapper: adapt for LLVM API change

No functional changes intended.

The LLVM commit e6b02214c6 added `TargetExtTyID` to the `TypeID` enum. This adapts `RustWrapper` accordingly.
2023-01-21 23:20:58 -05:00
bors
85da15c016 Auto merge of #107133 - pnkfelix:revert-pr-84022-for-issue-106337, r=Mark-Simulacrum
Revert "Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error"

This reverts commit 7d82cadd97 aka PR #84022

I am doing this to buy us some time with respect to issue #106337 w.r.t. the 1.67 release.
2023-01-22 03:58:52 +00:00
Aaron Hill
dc8876196b
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS to future-incompat report 2023-01-21 14:38:25 -06:00
Nilstrieb
f74ca88384 Use a type-alias-impl-trait in ObligationForest 2023-01-21 20:13:56 +01:00
Vadim Petrochenkov
415c14129b rustc_metadata: Encode doc(hidden) flag to metadata
To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance.

This is especially for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
2023-01-21 22:35:20 +04:00
Michael Goulet
444cbcd729 Address goal nits 2023-01-21 17:15:00 +00:00
Michael Goulet
d6a411c086 Implement some more predicates 2023-01-21 16:37:33 +00:00
bors
005fc0f00f Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obk
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc)

This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble.

The changes required are moderate but non-zero:
- In some places the collections are extracted into sorted vecs.
- There are a few instances where for-loops have been changed to extends.

~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~

Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)).

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

r? `@ghost`
2023-01-21 14:18:17 +00:00