Commit Graph

18041 Commits

Author SHA1 Message Date
Urgau
c084c26397 Split slice part of feature(half_open_range_patterns) to [...]_in_slices 2022-10-08 11:00:13 +02:00
Ali MJ Al-Nasrawy
fc3d7eb91d don't ICE when normalizing closure input tys
`normalize_and_add_constraints` doesn't add entries in `universe_causes`
when creating new universes, causing an ICE. Remove it!

Add spans to track normalization constraints.

Fix couple places where `universe_causes` is not updated correctly to
track newly added universes.
2022-10-08 04:56:25 +03:00
yukang
7b2f04a2b3 fix #102182, recover from impl Trait in type param bound 2022-10-08 06:47:26 +08:00
bors
8b0c05d9ad Auto merge of #102091 - RalfJung:const_err, r=oli-obk
make const_err a hard error

This lint has been deny-by-default with future incompat wording since [Rust 1.51](https://github.com/rust-lang/rust/pull/80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/71800
Fixes https://github.com/rust-lang/rust/issues/100114
2022-10-07 20:50:51 +00:00
Nathan Stocks
31c269ae75 avoid string dispatch in fluent 2022-10-07 14:39:09 -06:00
Eric Holk
0c47fdfedb Cast vtable type too 2022-10-07 13:05:45 -07:00
Oli Scherer
f85d3a7e33 Check hidden types in dead code 2022-10-07 19:43:46 +00:00
Oli Scherer
70d39abbc2 Remap hidden types from typeck before storing them in the TypeckResult 2022-10-07 19:43:46 +00:00
Oli Scherer
9eb69e82e0 Move ReverseMapper logic onto OpaqueHiddenType 2022-10-07 19:43:46 +00:00
Oli Scherer
d643ae1bbf Remove some dead code 2022-10-07 19:36:32 +00:00
Oli Scherer
5d15beb591 Unconditionally encode hidden types in typeck results 2022-10-07 19:36:32 +00:00
Nathan Stocks
57eba4f535 avoid string dispatch in fluent 2022-10-07 13:19:28 -06:00
Nathan Stocks
8e07a85ad7 Remove code that was removed in master, and the corresponding diagnostic 2022-10-07 13:19:28 -06:00
Nathan Stocks
965dbf6c28 First batch of review feedback changes from #102110 2022-10-07 13:19:28 -06:00
Nathan Stocks
be4059dd3e migrate stability.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
3fe8e004e9 migrate the rest of check_attr.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
a7aa1850b2 migrate dead.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
f0afb88302 migrate lang_items.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
b17ec43637 migrate entry.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
96f92eab68 migrate naked_functions.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
69766e4f16 migrate loops.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
572f3414b7 migrate check_const.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
c457abee2e migrate lib_features.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
40d5f00e16 migrate layout_test.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
0609c0f1da migrate diagnostic_items.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
3a748330af use cherry-picked commit from #100754 to emit note without error 2022-10-07 13:19:27 -06:00
David Wood
f8ebc72b4a errors: add emit_note/create_note
Add `Noted` marker struct that implements `EmissionGuarantee` so that
`emit_note` and `create_note` can be implemented for struct diagnostics.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-07 13:19:27 -06:00
Nathan Stocks
1e86226e9d migrate debugger_visualizer.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Nathan Stocks
c103c3059f migrate the rest of weak_lang_items.rs to translateable diagnostics 2022-10-07 13:19:27 -06:00
Diego de Oliveira
1222541cfd resolve merge conflict from cherry-picking 6a47326a04 2022-10-07 13:19:27 -06:00
Nathan Stocks
b8e03cfa55 use consistent names 2022-10-07 13:19:27 -06:00
Nathan Stocks
c24a87315a always put ftl message on next line, resolve all but 1 output comparison error 2022-10-07 13:19:27 -06:00
rdvdev2
2c3351c9a6 Migrate InvalidAttrAtCrateLevel
Co-authored-by: Nathan Stocks <cleancut@github.com>
Co-authored-by: rdvdev2 <rdvdev2@gmail.com>
2022-10-07 13:19:27 -06:00
rdvdev2
0315d7c9db Migrate derivable diagnostics in check_attr.rs 2022-10-07 13:19:27 -06:00
rdvdev2
17a4a68ab0 Migrate derivable diagnostics in lang_items.rs 2022-10-07 13:19:27 -06:00
rdvdev2
2f74d1d14f Migrate weak_lang_items.rs 2022-10-07 13:19:26 -06:00
rdvdev2
bde80f745b Add lint for diagnostic migration 2022-10-07 13:19:26 -06:00
bors
2d3a85b4f8 Auto merge of #102787 - Dylan-DPC:rollup-fvbb4t9, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #102300 (Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, NeverShortCircuit::wrap_mut_2_imp)).0` everywhere)
 - #102475 (unsafe keyword: trait examples and unsafe_op_in_unsafe_fn update)
 - #102760 (Avoid repeated re-initialization of the BufReader buffer)
 - #102764 (Check `WhereClauseReferencesSelf` after all other object safety checks)
 - #102779 (Fix `type_of` ICE)
 - #102780 (run Miri CI when std::sys changes)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-07 17:37:39 +00:00
Dylan DPC
d70e56aef8
Rollup merge of #102779 - TaKO8Ki:fix-type-of-ice-102768, r=fee1-dead
Fix `type_of` ICE

Fixes #102768
2022-10-07 22:05:32 +05:30
Dylan DPC
34dfd82de0
Rollup merge of #102764 - compiler-errors:issue-102762, r=jackh726
Check `WhereClauseReferencesSelf` after all other object safety checks

This fixes the ICE because it causes us to detect another *non-lint* `MethodViolationCode` first, instead of breaking on `WhereClauseReferencesSelf`.

We could also approach this issue by instead returning a vector of *all* of the `MethodViolationCode`s, and just reporting the first one we see, but treating it as a hard error if we return both `WhereClauseReferencesSelf` and some other violation code -- let me know if this is desired.

Fixes #102762
2022-10-07 22:05:31 +05:30
Oli Scherer
d90d055691 Allow transmutes between the same types after erasing lifetimes 2022-10-07 16:33:32 +00:00
Michael Goulet
8b9a1f1f4e Remove tuple candidate, nothing special about it 2022-10-07 16:19:21 +00:00
Ralf Jung
fd59d44f58 make const_err a hard error 2022-10-07 18:08:49 +02:00
Deadbeef
e8a2aee50d Remove DefId from some SelectionCandidate variants 2022-10-07 15:14:22 +00:00
Cameron Steffen
ff940db666 Rewrite representability 2022-10-07 09:33:46 -05:00
Jhonny Bill Mena
13d4f27c82 ADD - implement IntoDiagnostic for thorin::Error wrapper 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
a25f939170 Address PR comments
- UPDATE - revert migration of logs

- UPDATE - use derive on LinkRlibError enum

- [Gardening] UPDATE - alphabetically sort fluent_messages

- UPDATE - use PathBuf and unify both AddNativeLibrary to use Display (which is what PathBuf uses when conforming to IntoDiagnosticArg)

- UPDATE - fluent messages sort after rebase
2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
12aa84bdf3 ADD - initial port of link.rs 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
0f97d4a141 DELETE - unused error after PR# 100101 was merged 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
7548d952af UPDATE - resolve fixme and emit errors via Handler 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
67eb01c3f3 UPDATE - codege-ssa errors to new Diagnostic macro name 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
d9197dbbcd UPDATE - migrate write.rs to new diagnostics infra 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
086e70f13e UPDATE - migrate linker.rs to new diagnostics infra 2022-10-07 10:03:45 -04:00
Jhonny Bill Mena
0a2d7f83cb UPDATE - LibDefWriteFailure to accept type instead of formatted string
This follows team’s suggestions in this thread https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20diag.20translation/near/295305249
2022-10-07 10:00:32 -04:00
Jhonny Bill Mena
4e0de5319c ADD - migrate lib.def write fatal error
This diagnostic has no UI test 🤔 Should we add some? If so, how?
2022-10-07 10:00:32 -04:00
Jhonny Bill Mena
b0b072d747 ADD - codegen_ssa initial diags translations machinery
ADD - migrate MissingNativeStaticLibrary fatal error
2022-10-07 10:00:32 -04:00
Cameron Steffen
283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Takayuki Maeda
fa767868df fix a ICE #102768 2022-10-07 21:10:08 +09:00
Cameron Steffen
91269fa5b8 Remove a reference from Inherited 2022-10-07 07:06:19 -05:00
Cameron Steffen
349415d1c6 Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
Cameron Steffen
4a68373217 Introduce TypeErrCtxt
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.
2022-10-07 07:06:16 -05:00
Gary Guo
242348343b Fix MIR inlining of asm_unwind 2022-10-07 12:59:38 +01:00
bors
5854680388 Auto merge of #102767 - matthiaskrgr:rollup-vcbt81v, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #102577 (Warn about Visual Studio Code branding confusion)
 - #102720 (do not reverse the expected type and found type for ObligationCauseCo…)
 - #102744 (rustdoc: remove unused CSS `.content .item-list`)
 - #102747 (rustdoc: remove unused CSS `.docblock a:not(.srclink)`)
 - #102748 (Disable compressed debug sections on i586-gnu)
 - #102761 (let-else: test else block with non-never uninhabited type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-07 07:31:53 +00:00
Matthias Krüger
047ff20875
Rollup merge of #102720 - lyming2007:issue-102397-fix, r=compiler-errors
do not reverse the expected type and found type for ObligationCauseCo…

…de of IfExpressionWithNoElse

this will fix #102397
2022-10-07 07:28:10 +02:00
Matthias Krüger
1a2a3249bc
Rollup merge of #102577 - kornelski:non-code-visual-studio, r=wesleywiser
Warn about Visual Studio Code branding confusion

VS Code is a popular companion for Rust, but Microsoft's branding is confusing, and users [may not understand](https://users.rust-lang.org/t/complie-error-when-i-run-rustc/82127) they also need the *other* VS.
2022-10-07 07:28:09 +02:00
bors
cf0fa76f27 Auto merge of #101988 - petrochenkov:flavor2, r=lqd
rustc_target: Refactor internal linker flavors

In accordance with the design from https://github.com/rust-lang/rust/pull/96827#issuecomment-1208441595

`lld_flavor` and `linker_is_gnu` fields are removed from internal target specs, but still parsed from JSON specs using compatibility layer introduced in https://github.com/rust-lang/rust/pull/100552.
r? `@lqd`
2022-10-07 03:35:02 +00:00
Takayuki Maeda
57d0278d5c suggest == to the first expr which has ExprKind::Assign 2022-10-07 11:37:33 +09:00
Michael Goulet
414319468b Check WhereClauseReferencesSelf after all other object safety checks 2022-10-07 02:29:19 +00:00
Kornel
9b3db34072 Warn about Visual Studio Code branding confusion 2022-10-06 20:56:44 +01:00
Matthias Krüger
42df0a580f
Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwco
Remove `-Ztime`

Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups.

Best reviewed one commit at a time.

r? `@davidtwco`
2022-10-06 16:29:45 +02:00
Matthias Krüger
045fc18cde
Rollup merge of #102718 - compiler-errors:opaque-bound-lint-ice, r=fee1-dead
Fix `opaque_hidden_inferred_bound` lint ICE

Fixes #102705
2022-10-06 16:29:44 +02:00
Matthias Krüger
dd0fa6f871
Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnr
make `compare_const_impl` a query and use it in `instance.rs`

Fixes #88365

the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons:
- the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable)
- it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71))

r? `@lcnr`
2022-10-06 16:29:43 +02:00
ouz-a
d59c7ff000 Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
Vadim Petrochenkov
572b6a9c60 rustc_target: Refactor internal linker flavors
In accordance with the design from https://github.com/rust-lang/rust/pull/96827#issuecomment-1208441595
2022-10-06 13:41:12 +04:00
Boxy
25ed5d5db2 reviews 2022-10-06 07:00:38 +01:00
bors
4bd30785eb Auto merge of #102726 - matthiaskrgr:rollup-2ghn38b, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #102672 (rustdoc: remove unused CSS class `in-band`)
 - #102693 (Revert "Use getentropy when possible on all Apple platforms")
 - #102694 (Suggest calling method if fn does not exist)
 - #102708 (Suggest `==` to wrong assign expr)
 - #102710 (Add test for issue 82633)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-06 05:58:27 +00:00
Matthias Krüger
0512a06186
Rollup merge of #102708 - TaKO8Ki:improve-eqeq-suggestion, r=estebank
Suggest `==` to wrong assign expr

Given the following code:

```rust
fn main() {
    let x = 3;
    let y = 3;
    if x == x && y = y {
        println!("{}", x);
    }
}
```

Current output is:

```
error[E0308]: mismatched types
 --> src/main.rs:4:18
  |
4 |     if x == x && y = y {
  |                  ^ expected `bool`, found integer

error[E0308]: mismatched types
 --> src/main.rs:4:8
  |
4 |     if x == x && y = y {
  |        ^^^^^^^^^^^^^^^ expected `bool`, found `()`
```

This adds a suggestion:

```diff
error[E0308]: mismatched types
 --> src/main.rs:6:18
  |
6 |     if x == x && y = y {
  |                  ^ expected `bool`, found integer

error[E0308]: mismatched types
 --> src/main.rs:6:8
  |
6 |     if x == x && y = y {
  |        ^^^^^^^^^^^^^^^ expected `bool`, found `()`
  |
+ help: you might have meant to compare for equality
+   |
+ 6 |     if x == x && y == y {
+   |                     +
```

And this fixes a part of #97469
2022-10-06 07:07:37 +02:00
Matthias Krüger
a9b3441c17
Rollup merge of #102694 - compiler-errors:fn-to-method, r=davidtwco
Suggest calling method if fn does not exist

I tried to split this up into two commits, the first where we stash the resolution error until typeck (which causes a bunch of diagnostics changes because the ordering of error messages change), then the second commit is the actual logic that actually implements the suggestion.

I am not in love with the presentation of the suggestion, so I could use some advice for how to format the actual messaging.

r? diagnostics

Fixes #102518
2022-10-06 07:07:36 +02:00
Nicholas Nethercote
4e8faff3a1 Be consistent about deciding whether to print pass data.
`print_time_passes_entry` unconditionally prints data about a pass. The
most commonly used call site, in `VerboseTimingGuard::drop`, guards it
with a `should_print_passes` test. But there are a couple of other call
sites that don't do that test.

This commit moves the `should_print_passes` test within
`print_time_passes_entry` so that all passes are treated equally.
2022-10-06 15:50:10 +11:00
Nicholas Nethercote
9110d925d0 Remove -Ztime option.
The compiler currently has `-Ztime` and `-Ztime-passes`. I've used
`-Ztime-passes` for years but only recently learned about `-Ztime`.

What's the difference? Let's look at the `-Zhelp` output:
```
  -Z        time=val -- measure time of rustc processes (default: no)
  -Z time-passes=val -- measure time of each rustc pass (default: no)
```
The `-Ztime-passes` description is clear, but the `-Ztime` one is less so.
Sounds like it measures the time for the entire process?

No. The real difference is that `-Ztime-passes` prints out info about passes,
and `-Ztime` does the same, but only for a subset of those passes. More
specifically, there is a distinction in the profiling code between a "verbose
generic activity" and an "extra verbose generic activity". `-Ztime-passes`
prints both kinds, while `-Ztime` only prints the first one. (It took me
a close reading of the source code to determine this difference.)

In practice this distinction has low value. Perhaps in the past the "extra
verbose" output was more voluminous, but now that we only print stats for a
pass if it exceeds 5ms or alters the RSS, `-Ztime-passes` is less spammy. Also,
a lot of the "extra verbose" cases are for individual lint passes, and you need
to also use `-Zno-interleave-lints` to see those anyway.

Therefore, this commit removes `-Ztime` and the associated machinery. One thing
to note is that the existing "extra verbose" activities all have an extra
string argument, so the commit adds the ability to accept an extra argument to
the "verbose" activities.
2022-10-06 15:49:44 +11:00
Nicholas Nethercote
eea06de0c8 Fix some comments.
- It's `--print`, not `--prints`.
- `-Ztime` and `-Ztime-passes` print to stderr, not stdout.
2022-10-06 14:22:12 +11:00
bors
0152393048 Auto merge of #99324 - reez12g:issue-99144, r=jyn514
Enable doctests in compiler/ crates

Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
Yiming Lei
0501d615bb do not reverse the expected type and found type for ObligationCauseCode of IfExpressionWithNoElse
this will fix #102397
2022-10-05 14:00:51 -07:00
bors
c97d02cdb5 Auto merge of #102394 - dingxiangfei2009:issue-102317, r=oli-obk
Fix unwind drop glue for if-then scopes

cc `@est31`

Fix #102317
Fix #99852

This PR fixes the drop glue for unwinding from a panic originated in a drop while breaking out for the else block in an `if-then` scope.
MIR validation does not fail for the synchronous versions of the test program, because `StorageDead` statements are skipped over in the unwinding process. It is only becoming a problem when it is inside a generator where `StorageDead` must be kept around.
2022-10-05 20:47:39 +00:00
Michael Goulet
fe0533638c Use proper subdiagnostic 2022-10-05 19:55:19 +00:00
Michael Goulet
8e7783bd13 Fix opaque_hidden_inferred_bound lint ICE 2022-10-05 19:47:19 +00:00
Michael Goulet
ea3837072c
Update compiler/rustc_hir_analysis/src/check/callee.rs
Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2022-10-05 10:13:47 -07:00
bors
24ac6a26bc Auto merge of #102704 - Dylan-DPC:rollup-66ff8sm, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #100986 (Stop suggesting adding generic args for turbofish)
 - #101061 (panic-on-uninit: adjust checks to 0x01-filling)
 - #102440 (Only export `__tls_*` on wasm32-unknown-unknown.)
 - #102496 (Suggest `.into()` when all other coercion suggestions fail)
 - #102699 (Fix hamburger button color)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-05 14:48:17 +00:00
Ding Xiang Fei
565c35aa5c
fix doc and dedup diverge_cleanup 2022-10-05 22:24:12 +08:00
Takayuki Maeda
b7c42c55a2 suggest == to the rest of assign expr 2022-10-05 22:51:22 +09:00
Takayuki Maeda
760279f3cc use smaller span 2022-10-05 22:46:44 +09:00
Dylan DPC
cec087a202
Rollup merge of #102496 - compiler-errors:into-suggestion, r=davidtwco
Suggest `.into()` when all other coercion suggestions fail

Also removes some bogus suggestions because we now short-circuit when offering coercion suggestions(instead of, for example, suggesting every one that could possibly apply)

Fixes #102415
2022-10-05 17:27:33 +05:30
Dylan DPC
814b827efe
Rollup merge of #102440 - sunfishcode:sunfishcode/wasm-no-export-tls-api, r=oli-obk
Only export `__tls_*` on wasm32-unknown-unknown.

From talking with `@abrown,` we aren't planning to have hosts call these `__tls_*` functions; instead, TLS initialization will be handled transparently within libc. Consequently, these functions don't need to be exported.

Leave them exported on wasm32-unknown-unknown though, as wasm-bindgen does call them.
2022-10-05 17:27:33 +05:30
Dylan DPC
ab88c19f15
Rollup merge of #101061 - RalfJung:panic-on-uninit, r=oli-obk
panic-on-uninit: adjust checks to 0x01-filling

Now that `mem::uninitiailized` actually fills memory with `0x01` (https://github.com/rust-lang/rust/pull/99182), we can make it panic in a few less cases without risking a lot more UB -- which hopefully slightly improves compatibility with some old code, and which might increase the chance that we can check inside arrays in the future.

We detect almost all of these with our lint, so authors of such code should still be warned -- but if this happens deep inside a dependency, the panic can be quite interruptive, so it might be better not to do it when there is no risk of LLVM UB.  Therefore, adjust the `might_permit_raw_init` logic to care primarily about LLVM UB. To my knowledge, it actually covers all cases of LLVM UB now.

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

Cc ``@5225225``
2022-10-05 17:27:32 +05:30
Dylan DPC
f8f501997a
Rollup merge of #100986 - TaKO8Ki:do-not-suggest-adding-generic-args-for-turbofish, r=compiler-errors
Stop suggesting adding generic args for turbofish

Fixes #100137
2022-10-05 17:27:31 +05:30
bors
8c71b67159 Auto merge of #98736 - alex:lipo-magic, r=bjorn3
resolve error when attempting to link a universal library on macOS

Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by invoking `lipo -thin` to extract a library for the target platform when passed a univeral library.

Fixes #55235

It's worth acknowledging that this implementation is kind of a horrible hack. Unfortunately I don't know how to do anything better, hopefully this PR will be a jumping off point.
2022-10-05 11:41:40 +00:00
Takayuki Maeda
45257962d3 stop suggesting adding generic args for turbofish 2022-10-05 16:58:29 +09:00
Ralf Jung
a0131f0a36 change might_permit_raw_init to fully detect LLVM UB, but not more than that 2022-10-05 09:22:50 +02:00
Michael Goulet
61cf3bfaf6 Suggest calling method if fn does not exist 2022-10-05 06:42:49 +00:00
Michael Goulet
66c8c5ad1d Delay function resolution error until typeck 2022-10-05 06:42:35 +00:00
Michael Goulet
9a5936b814 Validate opaques in default trait bodies, don't normalize unless a body is provided 2022-10-05 04:16:09 +00:00
Michael Goulet
79450360d2 Fix test for default body with impl 2022-10-05 04:16:05 +00:00
Michael Howell
8dea87d9f4
Rollup merge of #102670 - lyming2007:issue-101866-fix, r=compiler-errors
follow-up fix about 101866 to print the self type.

	modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
	modified:   src/test/ui/error-codes/E0283.stderr
	modified:   src/test/ui/error-codes/E0790.stderr
	modified:   src/test/ui/traits/static-method-generic-inference.stderr
	modified:   src/test/ui/type/issue-101866.stderr
2022-10-04 20:45:14 -07:00
Michael Howell
55ebb61c68
Rollup merge of #102650 - Rageking8:slightly-improve-no-return-for-returning-function-error, r=compiler-errors
Slightly improve no return for returning function error

Fixes #100607

The rationale is that absolute beginners will be slightly confused as to why certain lines of code in a function does not require a semicolon. (I have actually witness a beginner having this confusion). Hence, a slight rationale is added "to return this value", which signals to the user that after removing said semicolon the value is returned resolving that error.

However, if this is not desirable, I welcome any other suggestions. Thanks.
2022-10-04 20:45:13 -07:00
Michael Goulet
28eda9b18a Suggest .into() when all other coercion suggestions fail 2022-10-05 02:47:31 +00:00
Michael Goulet
21047f1a1c Support default-body trait functions with RPITIT 2022-10-05 02:45:01 +00:00
Nicholas Nethercote
1e848a564b Remove TokenStreamBuilder.
`TokenStreamBuilder` exists to concatenate multiple `TokenStream`s
together. This commit removes it, and moves the concatenation
functionality directly into `TokenStream`, via two new methods
`push_tree` and `push_stream`. This makes things both simpler and
faster.

`push_tree` is particularly important. `TokenStreamBuilder` only had a
single `push` method, which pushed a stream. But in practice most of the
time we push a single token tree rather than a stream, and `push_tree`
avoids the need to build a token stream with a single entry (which
requires two allocations, one for the `Lrc` and one for the `Vec`).

The main `push_tree` use arises from a change to one of the `ToInternal`
impls in `proc_macro_server.rs`. It now returns a `SmallVec` instead of
a `TokenStream`. This return value is then iterated over by
`concat_trees`, which does `push_tree` on each element. Furthermore, the
use of `SmallVec` avoids more allocations, because there is always only
one or two token trees.

Note: the removed `TokenStreamBuilder::push` method had some code to
deal with a quadratic blowup case from #57735. This commit removes the
code. I tried and failed to reproduce the blowup from that PR, before
and after this change. Various other changes have happened to
`TokenStreamBuilder` in the meantime, so I suspect the original problem
is no longer relevant, though I don't have proof of this. Generally
speaking, repeatedly extending a `Vec` without pre-determining its
capacity is *not* quadratic. It's also incredibly common, within rustc
and many other Rust programs, so if there were performance problems
there you'd think it would show up in other places, too.
2022-10-05 12:42:54 +11:00
reez12g
488eb4209e Temporarily reinstate doctest=false 2022-10-05 09:53:49 +09:00
Nicholas Nethercote
1e8dc45fb5 Rearrange to_internal.
`TokenTree::Punct` is handled outside the `match`. This commits moves it
inside the `match`, avoiding the need for the `return`s and making it
easier to read.
2022-10-05 10:36:56 +11:00
Eric Holk
43499da753 Support casting boxes to dyn* 2022-10-04 10:59:40 -07:00
Yiming Lei
4f3b6ac91f follow-up fix about 101866 to print the self type.
modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
	modified:   src/test/ui/error-codes/E0283.stderr
	modified:   src/test/ui/error-codes/E0790.stderr
	modified:   src/test/ui/traits/static-method-generic-inference.stderr
	modified:   src/test/ui/type/issue-101866.stderr
2022-10-04 10:30:25 -07:00
Matthias Krüger
db94aeda38
Rollup merge of #102653 - lcnr:delay_span_bug, r=fee1-dead
resolve instance: missing value to `delay_span_bug`
2022-10-04 18:26:41 +02:00
Matthias Krüger
0dd0c6c1e6
Rollup merge of #102651 - oli-obk:non_region_things, r=lcnr
It's not about types or consts, but the lack of regions

pulled out of https://github.com/rust-lang/rust/pull/101900 which adds a fourth kind of non-lifetime generic parameter, and the naming of these methods would get ridiculous.
2022-10-04 18:26:41 +02:00
Matthias Krüger
f55fef165e
Rollup merge of #102647 - oli-obk:tilde_const_bounds, r=fee1-dead
Only allow ~const bounds for traits with #[const_trait]

r? `@fee1-dead`
2022-10-04 18:26:39 +02:00
Matthias Krüger
5d584516b2
Rollup merge of #102488 - compiler-errors:gat-compatibility, r=oli-obk
Check generic argument compatibility when projecting assoc ty

Fixes #102114
2022-10-04 18:26:39 +02:00
lcnr
93a17c8aea missing value to delay_span_bug 2022-10-04 17:35:26 +02:00
Oli Scherer
c7b6ebdf7c It's not about types or consts, but the lack of regions 2022-10-04 14:10:44 +00:00
bors
02cd79afb8 Auto merge of #102652 - Dylan-DPC:rollup-6ff8ct8, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #101189 (Implement `Ready::into_inner()`)
 - #101642 (Fix in-place collection leak when remaining element destructor panic)
 - #102489 (Normalize substs before resolving instance in `NoopMethodCall` lint)
 - #102559 (Don't ICE when trying to copy unsized value in const prop)
 - #102568 (Lint against nested opaque types that don't satisfy associated type bounds)
 - #102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-04 13:04:57 +00:00
yukang
e747201ad8 find the correct lang item for ranges 2022-10-04 21:02:07 +08:00
Alex Gaynor
c65c36242e
resolve error when attempting to link a universal library on macOS
Previously attempting to link universal libraries into libraries (but not binaries) would produce an error that "File too small to be an archive". This works around this by using `object` to extract a library for the target platform when passed a univeral library.

Fixes #55235
2022-10-04 07:39:51 -04:00
Rageking8
5ddaece650 slightly improve no return for returning function error 2022-10-04 19:13:40 +08:00
Dylan DPC
35f92ed1bf
Rollup merge of #102568 - compiler-errors:lint-unsatisfied-opaques, r=oli-obk
Lint against nested opaque types that don't satisfy associated type bounds

See the test failures for examples of places where this lint would fire.

r? `@oli-obk`
2022-10-04 16:11:02 +05:30
Dylan DPC
32dde232d8
Rollup merge of #102559 - compiler-errors:issue-102553, r=oli-obk
Don't ICE when trying to copy unsized value in const prop

When we have a trivially false where-clause predicate like `Self: Sized` where `Self = dyn Trait`, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type.

This, unfortunately, cannot be made into an error (at least not without some migration -- see #95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example.

r? `@RalfJung` since I think you added these assertions? but feel free to reassign.

Fixes #102553
2022-10-04 16:11:02 +05:30
Dylan DPC
d89d21412b
Rollup merge of #102489 - compiler-errors:issue-102074, r=oli-obk
Normalize substs before resolving instance in `NoopMethodCall` lint

Fixes #102074

r? types
2022-10-04 16:11:01 +05:30
yukang
5dd44d4d4c fix #102396, suggest parentheses for possible range methods 2022-10-04 17:30:52 +08:00
bors
ead49f0beb Auto merge of #102622 - camsteffen:move-layout, r=fee1-dead
Move layout_of and friends from rustc_middle to rustc_ty_utils

Breaks up the very large module that is `rustc_middle::ty::layout` by fork-lifting some queries into `rustc_ty_utils::{abi, layout}`.

This does set back `rustc_ty_utils` to having untranslatable diagnostics. I'd like to leave this as a separate task.
2022-10-04 09:29:07 +00:00
Oli Scherer
c72c6e01c8 Merge the ~const and impl const checks and add some explanatory notes 2022-10-04 08:59:20 +00:00
Oli Scherer
33bcea8f61 Only allow ~const bounds for traits with #[const_trait] 2022-10-04 08:06:54 +00:00
bors
f1112099eb Auto merge of #102644 - matthiaskrgr:rollup-rg0sw41, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #102441 (Suggest unwrap_or_else when a closure is given)
 - #102547 (Migrate CSS theme for search results)
 - #102567 (Delay evaluating lint primary message until after it would be suppressed)
 - #102624 (rustdoc: remove font family CSS on `.rustdoc-toggle summary::before`)
 - #102628 (Change the parameter name of From::from to `value`)
 - #102637 (Ignore fuchsia on two compiler tests)
 - #102639 (Improve spans when splitting multi-char operator tokens for proc macros.)

Failed merges:

 - #102496 (Suggest `.into()` when all other coercion suggestions fail)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-04 06:47:21 +00:00
Matthias Krüger
185ca0f181
Rollup merge of #102639 - nnethercote:improve-spans-splitting, r=Aaron1011
Improve spans when splitting multi-char operator tokens for proc macros.

When a two-char (or three-char) operator token is split into single-char operator tokens before being passed to a proc macro, the single-char tokens are given the original span of length two (or three). This PR gives them more accurate spans.

r? `@Aaron1011`
cc `@petrochenkov`
2022-10-04 06:14:13 +02:00
Matthias Krüger
8a0fda2ec1
Rollup merge of #102567 - compiler-errors:issue-102561, r=davidtwco
Delay evaluating lint primary message until after it would be suppressed

Fixes #102561
Fixes #102572
2022-10-04 06:14:11 +02:00
Matthias Krüger
a2126e752f
Rollup merge of #102441 - chenyukang:fix-102320-unwrap_or_else, r=compiler-errors
Suggest unwrap_or_else when a closure is given

Fixes #102320

r? `@compiler-errors`
2022-10-04 06:14:10 +02:00
bors
d9f8b4b985 Auto merge of #102395 - davidtwco:translation-rename-typeck, r=compiler-errors
errors: rename `typeck.ftl` to `hir_analysis.ftl`

In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the diagnostic resources were not renamed - which is what this pull request changes.
2022-10-04 03:57:50 +00:00
Michael Goulet
e1b313af46 We are able to resolve methods even if they need subst 2022-10-04 03:29:19 +00:00
Michael Goulet
8c600120e6 Normalize substs before resolving instance in NoopMethodCall lint 2022-10-04 03:20:49 +00:00
Nicholas Nethercote
88dab8d9b3 Improve spans when splitting multi-char operator tokens for proc macros. 2022-10-04 09:08:02 +11:00
bors
f83e0266cf Auto merge of #102632 - matthiaskrgr:rollup-h8s3zmo, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #98218 (Document the conditional existence of `alloc::sync` and `alloc::task`.)
 - #99216 (docs: be less harsh in wording for Vec::from_raw_parts)
 - #99460 (docs: Improve AsRef / AsMut docs on blanket impls)
 - #100470 (Tweak `FpCategory` example order.)
 - #101040 (Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds)
 - #101308 (introduce `{char, u8}::is_ascii_octdigit`)
 - #102486 (Add diagnostic struct for const eval error in `rustc_middle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-03 20:22:18 +00:00
Matthias Krüger
1b9014f273
Rollup merge of #102486 - pierwill:middle-const-eval-err, r=compiler-errors
Add diagnostic struct for const eval error in `rustc_middle`

Part of #100717.

r? `@ghost`
2022-10-03 20:58:56 +02:00
Matthias Krüger
df11395a55
Rollup merge of #101040 - danielhenrymantilla:no-bounds-for-default-annotated-derive, r=joshtriplett
Fix `#[derive(Default)]` on a generic `#[default]` enum adding unnecessary `Default` bounds

That is, given something like:

```rs
// #[default] on a generic enum does not add `Default` bounds to the type params.
#[derive(Default)]
enum MyOption<T> {
    #[default]
    None,
    Some(T),
}
```

then `MyOption<T> : Default`_as currently implemented_ only holds when `T : Default`, as reported by ```@5225225``` [over Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.23.5Bderive.28Default.29.5D.20for.20enums.20with.20fields).

This is contrary to [what the accepted RFC proposes](https://rust-lang.github.io/rfcs/3107-derive-default-enum.html#generated-bounds) (_i.e._, that `T` be allowed not to be itself `Default`), and indeed seems to be a rather unnecessary limitation.
2022-10-03 20:58:55 +02:00
pierwill
b9c0467e0c Add diagnostic struct for const eval error in rustc_middle
Co-authored-by: Michael Goulet <michael@errs.io>
2022-10-03 12:29:49 -05:00
Matthias Krüger
f50b72ffc5
Rollup merge of #102617 - lcnr:deferred_transmute_checks, r=compiler-errors
`HirId` for `deferred_transmute_checks`

directly interacting with spans is annoying 
2022-10-03 19:12:19 +02:00
Matthias Krüger
e64177c3f8
Rollup merge of #102615 - Nilstrieb:there-are-many-error-codes, r=compiler-errors
Cleanup some error code explanations

E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed
2022-10-03 19:12:19 +02:00
Matthias Krüger
aa076d6144
Rollup merge of #102613 - TaKO8Ki:fix-part-of-101739, r=compiler-errors
Fix ICE #101739

Fixes a part of #101739

This cannot cover the following case. It causes `too many args provided` error and obligation does not have references error. I want your advice to solve the following cases as well in this pull request or a follow-up.

```rust
#![crate_type = "lib"]
#![feature(transmutability)]
#![allow(dead_code, incomplete_features, non_camel_case_types)]

mod assert {
    use std::mem::BikeshedIntrinsicFrom;

    pub fn is_transmutable<
        Src,
        Dst,
        Context,
        const ASSUME_ALIGNMENT: bool,
        const ASSUME_LIFETIMES: bool,
        const ASSUME_VALIDITY: bool,
        const ASSUME_VISIBILITY: bool,
    >()
    where
        Dst: BikeshedIntrinsicFrom<
            Src,
            Context,
            ASSUME_ALIGNMENT,
            ASSUME_LIFETIMES,
            ASSUME_VALIDITY,
            ASSUME_VISIBILITY,
        >,
    {}
}

fn via_const() {
    struct Context;
    #[repr(C)] struct Src;
    #[repr(C)] struct Dst;

    const FALSE: bool = false;

    assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
}
```
2022-10-03 19:12:19 +02:00
Matthias Krüger
8ede2340b7
Rollup merge of #102597 - compiler-errors:issue-102571, r=davidtwco
Avoid ICE in printing RPITIT type

Fixes #102571
2022-10-03 19:12:18 +02:00
b-naber
e83dcf4ecd re-name params + add comments 2022-10-03 17:37:22 +02:00
Cameron Steffen
95b689b1d5 Move utils from rustc_middle to rustc_ty_utils 2022-10-03 09:12:03 -05:00
David Wood
c4418e1940 errors: rename typeck.ftl to hir_analysis.ftl
In #102306, `rustc_typeck` was renamed to `rustc_hir_analysis` but the
diagnostic resources were not renamed - which is what this commit
changes.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-03 13:52:17 +01:00
lcnr
550715d74d HirId for deferred_transmute_checks 2022-10-03 13:53:17 +02:00
bors
f47e9af824 Auto merge of #102551 - bjorn3:cg_ssa_cleanup, r=davidtwco
Some more cleanup for rustc_codegen_ssa

With the aim to make non-LLVM like backends, like Cranelift, easier to support using cg_ssa.
2022-10-03 11:02:58 +00:00
Takayuki Maeda
0e615caa8d check if const is ADT or not 2022-10-03 17:51:18 +09:00
bors
6b139c5b3e Auto merge of #102614 - matthiaskrgr:rollup-fjyu7oo, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #102550 (rustdoc: remove no-op CSS on `.impl, .method` etc)
 - #102591 (Fix duplicate usage of `a` article.)
 - #102592 (Remove a couple lifetimes that can be infered)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-03 07:30:34 +00:00
nils
1df0a1890a Cleanup some error code explanations
E0045: Use a stable non-C ABI instead
E0092: Use an atomic intrinsic that actually exists
E0161: Don't use box_syntax
E0579: Format ranges in the rustfmt style
E0622: Use the rustfmt style
E0743: Remove feature gate as it's not needed
2022-10-03 08:53:06 +02:00
Matthias Krüger
d5fb8d2aef
Rollup merge of #102592 - WaffleLapkin:less_lifetimes, r=cjgillot
Remove a couple lifetimes that can be infered

From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r974497497

r? `@cjgillot`
2022-10-03 08:00:48 +02:00
Matthias Krüger
d679ec5e2f
Rollup merge of #102591 - JarvisCraft:fix-double-a-article, r=compiler-errors
Fix duplicate usage of `a` article.

This fixes a typo first appearing in #94624 in which test-macro diagnostic uses "a" article twice.

Since I searched the sources for " a a " sequences, I also fixed the same issue in a few files where I found it.
2022-10-03 08:00:47 +02:00
Takayuki Maeda
82510b90c6 return when obligation has references_error 2022-10-03 14:17:42 +09:00
bors
dbaf3e67aa Auto merge of #102508 - nnethercote:even-more-lexer-improvements, r=matklad
Even more lexer improvements

These are just about code clarity, rather than performance.

r? `@matklad`
2022-10-03 04:49:46 +00:00
bors
607b8296e0 Auto merge of #102503 - cuviper:x86-stack-probes, r=nagisa
Enable inline stack probes on X86 with LLVM 16

The known problems with x86 inline-asm stack probes have been solved on LLVM main (16), so this flips the switch. Anyone using bleeding-edge LLVM with rustc can start testing this, as I have done locally. We'll get more direct rust-ci when LLVM 16 branches and we start our upgrade, and we can always patch or disable it then if we find new problems.

The previous attempt was #77885, reverted in #84708.
2022-10-03 02:09:05 +00:00
Nicholas Nethercote
4e5ddf1adf Invert is_top_level to avoid negation. 2022-10-03 11:42:29 +11:00
Nicholas Nethercote
a822d08bd1 Remove TokenStreamBuilder.
It's now only used in one function. Also, the "should we glue the
tokens?" check is only necessary when pushing a `TokenTree::Token`, not
when pushing a `TokenTree::Delimited`.

As part of this, we now do the "should we glue the tokens?" check
immediately, which avoids having look back at the previous token. It
also puts all the logic dealing with token gluing in a single place.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
8d0754d602 Inline and remove parse_token_tree_non_delim_non_eof.
It has a single call site.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
ce7676829e Merge parse_token_trees_until_close_delim and parse_all_token_trees.
Because they're very similar, and this will allow some follow-up
changes.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
9de9cf19d7 Add comments to TokenCursor::desugar.
It took me some time to work out what this code was doing.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
40e4827fd2 Rewrite Token::is_op.
An exhaustive match is more readable and more future-proof.
2022-10-03 11:42:29 +11:00
Nicholas Nethercote
bbb53bf772 Add comments to Spacing. 2022-10-03 11:42:21 +11:00
Nicholas Nethercote
3be86e6528 Clarify operator splitting.
I found this code hard to read.
2022-10-03 11:41:36 +11:00
Michael Goulet
90a8d67491 Avoid ICE in printing RPITIT type 2022-10-02 20:43:13 +00:00
Michael Goulet
7a8854037b Add example to opaque_hidden_inferred_bound lint 2022-10-02 19:54:39 +00:00
Michael Goulet
426424b320 Make it a lint for all opaque types 2022-10-02 19:50:19 +00:00
Michael Goulet
d0d6af9146 Lint for unsatisfied nested opaques 2022-10-02 19:50:19 +00:00
Michael Goulet
c7d1ec009c Don't ICE when trying to copy unsized value in const prop 2022-10-02 19:21:06 +00:00
Petr Portnov
afae9576dc
Fix duplicate usage of a article.
This fixes a typo first appearing in #94624
in which test-macro diagnostic uses "a" article twice.

Since I searched sources for " a a " sequences,
I also fixed the same issue in a few source files where I found it.

Signed-off-by: Petr Portnov <gh@progrm-jarvis.ru>
2022-10-02 21:40:39 +03:00
Maybe Waffle
8cc8140775 Remove a couple lifetimes that could be infered 2022-10-02 15:40:20 +00:00
bors
39323a5877 Auto merge of #102586 - Dylan-DPC:rollup-g107h6z, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #100451 (Do not panic when a test function returns Result::Err.)
 - #102098 (Use fetch_update in sync::Weak::upgrade)
 - #102538 (Give `def_span` the same SyntaxContext as `span_with_body`.)
 - #102556 (Make `feature(const_btree_len)` implied by `feature(const_btree_new)`)
 - #102566 (Add a known-bug test for #102498)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-02 15:31:06 +00:00
Dylan DPC
f3ab5a66a9
Rollup merge of #102538 - cjgillot:def-span-ctxt, r=fee1-dead
Give `def_span` the same SyntaxContext as `span_with_body`.

https://github.com/rust-lang/rust/issues/102217

I'm not sure how to add a test, since the erroneous span was crafted using a proc macro.
The debug assertion in `def_span` will ensure we have the correct behaviour.
2022-10-02 20:42:21 +05:30
bjorn3
268e02c387 Remove type argument of array_alloca and rename to byte_array_alloca 2022-10-02 13:42:14 +00:00
bjorn3
0fe84bc38b Remove dynamic_alloca from BuilderMethods 2022-10-02 13:42:02 +00:00
bors
91931ec2fc Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-se
Change `is_some_and` to take by value

Consistent with other function-accepting `Option` methods.

Tracking issue: #93050

r? `@m-ou-se`
2022-10-02 12:48:15 +00:00
yukang
01882733c9 fix #102320, suggest unwrap_or_else when a closure is passed to unwrap_or instead of suggesting calling it 2022-10-02 18:36:52 +08:00
Michael Goulet
f088e543cb Delay evaluating lint primary message until after it would be suppressed 2022-10-02 06:32:40 +00:00
bors
47b2eee173 Auto merge of #102424 - sunfishcode:sunfishcode/hidden-main, r=nagisa
Declare `main` as visibility hidden on targets that default to hidden.

On targets with `default_hidden_visibility` set, which is currrently just WebAssembly, declare the generated `main` function with visibility hidden. This makes it consistent with clang's WebAssembly target, where `main` is just a user function that gets the same visibility as any other user function, which is hidden on WebAssembly unless explicitly overridden.

This will help simplify use cases which in the future may want to automatically wasm-export all visibility-"default" symbols. `main` isn't intended to be wasm-exported, and marking it hidden prevents it from being wasm-exported in that scenario.
2022-10-02 04:12:09 +00:00
reez12g
ebcec30182 Remove 'E0312' from 'compile_fail,E0312' statement temporarily 2022-10-02 11:00:43 +09:00
bors
57f097ea25 Auto merge of #102236 - cjgillot:compute_lint_levels_by_def, r=oli-obk
Compute lint levels by definition

Second attempt to https://github.com/rust-lang/rust/pull/101620.

I think that I have removed the perf regression.
2022-10-01 19:54:55 +00:00
stoozy
2657f9d5da Removed unnecessary for loop 2022-10-01 13:55:26 -04:00
bors
56a35bc906 Auto merge of #102545 - matthiaskrgr:rollup-13i3tc3, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #101675 (Improve `File::set_times` error handling)
 - #102500 (Remove `expr_parentheses_needed` from `ParseSess`)
 - #102533 (rustdoc: remove unused CSS selector `a.source`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-01 17:11:19 +00:00
bjorn3
62cf644c64 Merge apply_attrs_callsite into call and invoke
Some codegen backends are not able to apply callsite attrs after the fact.
2022-10-01 17:01:31 +00:00
Cameron Steffen
4f12de0660 Change feature name to is_some_and 2022-10-01 11:45:52 -05:00
bjorn3
a3cc67c796 Remove unused target_cpu and tune_cpu methods from ExtraBackendMethods 2022-10-01 16:45:33 +00:00
bjorn3
c431ea681c Remove several unused methods from MiscMethods 2022-10-01 16:45:07 +00:00
bjorn3
7c91ec4652 Remove unused Context assoc type from WriteBackendMethods 2022-10-01 16:34:45 +00:00
Matthias Krüger
cc009bc536
Rollup merge of #102500 - compiler-errors:parse-sess-cleanup, r=cjgillot
Remove `expr_parentheses_needed` from `ParseSess`

Not sure why this method needed to exist on `ParseSess`, but we can achieve the same behavior by just inlining it everywhere.
2022-10-01 16:45:05 +02:00
Camille GILLOT
fec53fd9db Add sanity Drop impl. 2022-10-01 16:24:44 +02:00
Camille GILLOT
299e10d7ad Add FIXME. 2022-10-01 16:24:34 +02:00
Camille GILLOT
9f2ab5b9ad Use a SortedMap instead of a VecMap. 2022-10-01 16:24:30 +02:00
Camille GILLOT
13608715d8 Replace retain with assertion. 2022-10-01 16:23:20 +02:00
Camille GILLOT
c2d5dd2566 Add fast path without visiting. 2022-10-01 16:23:10 +02:00
Camille GILLOT
e78dd6d781 Simplify LintLevelsProvider. 2022-10-01 16:23:00 +02:00
Camille GILLOT
d08669c4fa Compute by owner instead of HirId. 2022-10-01 16:22:40 +02:00
Camille GILLOT
26e5fe9e85 Do not fetch HIR node when iterating to find lint. 2022-10-01 16:20:21 +02:00
Camille GILLOT
6e76599f5f Correct Key impl for HirId. 2022-10-01 16:20:08 +02:00
Camille GILLOT
273b54d6ac Add FIXME. 2022-10-01 16:19:52 +02:00
Camille GILLOT
af495f8bb6 Comment LintLevelSets. 2022-10-01 16:19:40 +02:00
Camille GILLOT
34bc5c8824 Move lint level computation to rustc_middle::lint. 2022-10-01 16:18:54 +02:00
Camille GILLOT
6977f7dbe9 Reduce visibilities and remove dead code. 2022-10-01 16:18:42 +02:00
Camille GILLOT
41db9b152f Move code to rustc_lint. 2022-10-01 16:18:13 +02:00
bors
edadc7ccdd Auto merge of #102519 - Alexendoo:format-args-macro-str, r=m-ou-se
Fix `format_args` capture for macro expanded format strings

Since #100996 `format_args` capture for macro expanded strings aren't prevented when the span of the expansion points to a string literal, e.g.

```rust
// not a terribly realistic example, but also happens for proc_macros that set
// the span of the output to an input str literal, such as indoc
macro_rules! x {
    ($e:expr) => { $e }
}

fn main() {
    let a = 1;
    println!(x!("{a}"));
}
```

The tests didn't catch it as the span of `concat!()` points to the macro invocation

r? `@m-ou-se`
2022-10-01 14:15:29 +00:00
Camille GILLOT
107170b9c3 Remove unused tool_name. 2022-10-01 16:12:54 +02:00
Deadbeef
3cb1811e45 Compute lint_levels by definition 2022-10-01 16:12:50 +02:00
Camille GILLOT
6019cbbfd3 Allow query system to recover a HirId. 2022-10-01 15:58:42 +02:00
bors
744e397d88 Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
Move lint level source explanation to the bottom

So, uhhhhh

r? `@estebank`

## User-facing change

"note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic:
```diff
-   = note: `#[warn(unsupported_calling_conventions)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
+   = note: `#[warn(unsupported_calling_conventions)]` on by default
```

Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO.

## Developer-facing change

`struct_span_lint` and similar methods have a different signature.

Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)`
After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>`

The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion.

Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere.

## Subtle problem

By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings...

I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate.

## P.S.

I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01 10:44:25 +00:00
Maybe Waffle
b5b3ffe3fc Remove LintDiagnosticBuilder 2022-10-01 10:03:07 +00:00
Maybe Waffle
d028db9dbd ui-fulldeps: adopt to the new rustc lint API 2022-10-01 10:03:07 +00:00
Maybe Waffle
ad3d1fc9d5 Move lint level source explanation to the bottom 2022-10-01 10:03:06 +00:00
Maybe Waffle
a8f7e244b7 Refactor rustc lint API 2022-10-01 10:03:06 +00:00
Camille GILLOT
c321933e22 Give def_span the same SyntaxContext as span_with_body. 2022-10-01 11:38:59 +02:00
Colin Baumgarten
b9e85bf60a Detect and reject out-of-range integers in format string literals
Until now out-of-range integers in format string literals
were silently ignored. They wrapped around to zero at
usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string
literals even cause an 'attempt to add with overflow' panic in
rustc.

Fix this by producing an error diagnostic for integers in format
string literals which do not fit into usize.

Fixes #102528
2022-10-01 01:05:01 +02:00
Boxy
611db1d3f3 remove unnecessary Key impl 2022-09-30 22:52:02 +01:00
Matthias Krüger
eaf1c7a0da
Rollup merge of #102493 - nnethercote:improve-size-assertions-some-more, r=lqd
Group together more size assertions.

Also add a few more assertions for some relevant token-related types.

And fix an erroneous comment in `rustc_errors`.

r? `@lqd`
2022-09-30 23:38:27 +02:00
Matthias Krüger
842a7d34f5
Rollup merge of #102492 - compiler-errors:simplify-deny-assoc-bindings, r=cjgillot
Don't lower assoc bindings just to deny them

Some clean-up: https://github.com/rust-lang/rust/pull/102338#discussion_r981590931
2022-09-30 23:38:26 +02:00
Matthias Krüger
808f197ed4
Rollup merge of #102490 - compiler-errors:closure-body-impl-lifetime, r=cjgillot
Generate synthetic region from `impl` even in closure body within an associated fn

Fixes #102209
2022-09-30 23:38:26 +02:00
Matthias Krüger
05b9f0e360
Rollup merge of #102483 - spastorino:create-defs-on-lowering, r=cjgillot
create def ids for impl traits during ast lowering

r? `@cjgillot`
2022-09-30 23:38:25 +02:00
Matthias Krüger
9ec772e223
Rollup merge of #102373 - Nilstrieb:cannot-get-layout-of-branch-error, r=cjgillot
Flush delayed bugs before codegen

Sometimes it can happen that invalid code like a TyKind::Error makes its way through the compiler without triggering any errors (this is always a bug in rustc but bugs do happen sometimes :)). These ICEs will manifest in the backend like as cg_llvm not being able to get the layout of `[type error]`, which makes it hard to debug. By flushing before codegen, we display all the delayed bugs, making it easier to trace it to the root of the problem.

I tried this on #102366 and it showed tons of of delayed bugs and no error in cg_llvm, so it seems to be working.
2022-09-30 23:38:25 +02:00
Matthias Krüger
c07ebeb74b
Rollup merge of #102361 - fee1-dead-contrib:fix-102156, r=eholk
Fix ICE in const_trait check code

This fixes #102156.
2022-09-30 23:38:24 +02:00
Nicholas Nethercote
5ab68a82d5 Group together more size assertions.
Also add a few more assertions for some relevant token-related types.

And fix an erroneous comment in `rustc_errors`.
2022-10-01 07:30:23 +10:00
nils
e8f1bfe193
Fix typo 2022-09-30 21:02:53 +02:00
Santiago Pastorino
b2bef02bcd
create def ids for impl traits during ast lowering 2022-09-30 15:12:01 -03:00
Boxy
c1a9cf42b4 make query take (LocalDefId, DefId) 2022-09-30 18:53:32 +01:00
Camille Gillot
4b1cf846bd
Update compiler/rustc_interface/src/queries.rs 2022-09-30 19:50:48 +02:00
Matthias Krüger
a8777580ee
Rollup merge of #102506 - TaKO8Ki:specify-dyn-kind, r=lcnr
Specify `DynKind::Dyn`

ref: https://github.com/rust-lang/rust/pull/101212#discussion_r958861297
2022-09-30 19:06:07 +02:00
Matthias Krüger
f7f253ea47
Rollup merge of #102421 - lyming2007:issue-101866, r=lcnr
remove the unused :: between trait and type to give user correct diag…

…nostic information

	modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
	new file:   src/test/ui/type/issue-101866.rs
	new file:   src/test/ui/type/issue-101866.stderr
2022-09-30 19:06:05 +02:00
Matthias Krüger
e2bc6b8172
Rollup merge of #102382 - cuviper:defid-order, r=fee1-dead
Manually order `DefId` on 64-bit big-endian

`DefId` uses different field orders on 64-bit big-endian vs. others, in
order to optimize its `Hash` implementation. However, that also made it
derive different lexical ordering for `PartialOrd` and `Ord`. That
caused spurious differences wherever `DefId`s are sorted, like the
candidate sources list in `report_method_error`.

Now we manually implement `PartialOrd` and `Ord` on 64-bit big-endian to
match the same lexical ordering as other targets, fixing at least one
test, `src/test/ui/methods/method-ambig-two-traits-cross-crate.rs`.
2022-09-30 19:06:05 +02:00
Boxy
86a8a3beb4 make compare_const_impl a query and use it in instance.rs 2022-09-30 17:47:44 +01:00
Alex Macleod
71db0dd918 Fix format_args capture for macro expanded format strings 2022-09-30 17:40:14 +01:00
est31
2c72ea7748 Stabilize map_first_last 2022-09-30 17:00:07 +02:00
b-naber
e1f735a5d1 don't repeat lifetime names from outer binder in print 2022-09-30 15:44:38 +02:00
X
fb52dc7c3b
apply suggestion
Co-authored-by: SafariMonkey <charlton.rodda@gmail.com>
2022-09-30 21:03:08 +08:00
nils
477846f491
Add comment explaining why we flush delayed bugs before codegen 2022-09-30 14:11:18 +02:00
bors
f914b82a75 Auto merge of #102509 - matthiaskrgr:rollup-gtenet8, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #101075 (Migrate rustc_codegen_gcc to SessionDiagnostics )
 - #102350 (Improve errors for incomplete functions in struct definitions)
 - #102481 (rustdoc: remove unneeded CSS `.rust-example-rendered { position }`)
 - #102491 (rustdoc: remove no-op source sidebar `opacity`)
 - #102499 (Adjust the s390x data layout for LLVM 16)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-30 10:39:09 +00:00
Matthias Krüger
588a25a6f8
Rollup merge of #102499 - cuviper:llvm-16-s390x, r=nikic
Adjust the s390x data layout for LLVM 16

LLVM [D131158] changed the SystemZ data layout to always set 64-bit
vector alignment, which used to be conditional on the "vector" feature.

[D131158]: https://reviews.llvm.org/D131158

r? `@nikic`
2022-09-30 10:22:39 +02:00
Matthias Krüger
6906e64c30
Rollup merge of #102350 - TaKO8Ki:incomplete-fn-in-struct-definition, r=fee1-dead
Improve errors for incomplete functions in struct definitions

Given the following code:

```rust
fn main() {}

struct Foo {
    fn
}
```

[playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=29139f870511f6918324be5ddc26c345)

The current output is:

```
   Compiling playground v0.0.1 (/playground)
error: functions are not allowed in struct definitions
 --> src/main.rs:4:5
  |
4 |     fn
  |     ^^
  |
  = help: unlike in C++, Java, and C#, functions are declared in `impl` blocks
  = help: see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information

error: could not compile `playground` due to previous error
```

In this case, rustc should suggest escaping `fn` to use it as an identifier.
2022-09-30 10:22:37 +02:00
Matthias Krüger
25017f8bce
Rollup merge of #101075 - ellishg:rustc_codegen_gcc_diagnostics, r=davidtwco
Migrate rustc_codegen_gcc to SessionDiagnostics

As part of #100717 this pr migrates diagnostics to `SessionDiagnostics` for the `rustc_codegen_gcc` crate.

``@rustbot`` label +A-translation
2022-09-30 10:22:36 +02:00
bors
4a0ee3cdc6 Auto merge of #102387 - nnethercote:inline-Token-PartialEq, r=lqd
Inline a few functions.

r? `@ghost`
2022-09-30 07:57:12 +00:00
Takayuki Maeda
1ca33851df specify DynKind::Dyn 2022-09-30 15:52:20 +09:00
bors
b3aa4997d4 Auto merge of #102164 - compiler-errors:rpitit-foreign, r=TaKO8Ki
Serialize return-position `impl Trait` in trait hidden values in foreign libraries

Fixes #101630
2022-09-30 04:24:14 +00:00
Josh Stone
ed9e6f2ad8 Enable inline stack probes on X86 with LLVM 16 2022-09-29 19:49:23 -07:00
Michael Goulet
85a726e754 Remove expr_parentheses_needed from ParseSess 2022-09-30 01:39:20 +00:00
bors
d45feb3ad2 Auto merge of #102304 - lcnr:coherence-cleanup, r=compiler-errors
remove outdated coherence hack

we have a more precise detection for downstream conflicts in candidate assembly: the `is_knowable` check in `candidate_from_obligation_no_cache`.

r? types cc `@nikomatsakis`
2022-09-30 01:32:15 +00:00
Josh Stone
2e7a964485 Adjust the s390x data layout for LLVM 16
LLVM [D131158] changed the SystemZ data layout to always set 64-bit
vector alignment, which used to be conditional on the "vector" feature.

[D131158]: https://reviews.llvm.org/D131158
2022-09-29 18:18:26 -07:00
fee1-dead
d7fe44d988 Use let chains instead of let else 2022-09-30 00:31:53 +00:00
Dan Gohman
2d9e61f0c7 Only export __tls_* on wasm32-unknown-unknown.
From talking with @abrown, we aren't planning to have hosts call these
`__tls_*` functions; instead, TLS initialization will be handled
transparently within libc. Consequently, these functions don't need to
be exported.

Leave them exported on wasm32-unknown-unknown though, as wasm-bindgen
does call them.
2022-09-29 16:28:03 -07:00
bors
1bb8d276c9 Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino
Shrink `hir::def::Res`

r? `@spastorino`
2022-09-29 22:45:24 +00:00