Commit Graph

19767 Commits

Author SHA1 Message Date
Dan Gohman
98ae83daae Mangle "main" as "__main_void" on wasm32-wasi
On wasm, the age-old C trick of having a main function which can either have
no arguments or argc+argv doesn't work, because wasm requires caller and
callee signatures to match. WASI's current strategy is to have compilers
mangle main's name to indicate which signature they're using. Rust uses the
no-argument form, which should be mangled as `__main_void`.

This is needed on wasm32-wasi as of #105395.
2022-12-08 13:15:40 -08:00
Matthias Krüger
4968af0ee8
Rollup merge of #105418 - BelovDV:fix-libc-hack, r=petrochenkov
fix: remove hack from link.rs

This logic implemented in libc.

r? `@petrochenkov`
2022-12-07 15:39:09 +01:00
Matthias Krüger
b23419b03d
Rollup merge of #105400 - BoxyUwU:braced_param_evaluatability, r=oli-obk
normalize before handling simple checks for evaluatability of `ty::Const`

`{{{{{{{ N }}}}}}}` is desugared into a `ConstKind::Unevaluated` for an anonymous `const` item so when calling `is_const_evaluatable` on it we skip the `ConstKind::Param(_) => Ok(())` arm which is incorrect.
2022-12-07 15:39:08 +01:00
Matthias Krüger
52cec8c99f
Rollup merge of #105368 - WaffleLapkin:deref-even-harder, r=TaKO8Ki
Remove more `ref` patterns from the compiler

Previous PR: #105045
2022-12-07 15:39:07 +01:00
Matthias Krüger
95da525982
Rollup merge of #105343 - nbdd0121:hir, r=fee1-dead
Simplify attribute handling in rustc_ast_lowering

Given that attributes is stored in a separate BTreeMap, it's not necessary to pass it in when constructing `hir::Expr`. We can just construct `hir::Expr` and then call `self.lower_attrs` later if it needs attributes.

As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-07 15:39:07 +01:00
Matthias Krüger
3bcfa4c459
Rollup merge of #105267 - compiler-errors:issue-104613, r=oli-obk
Don't ICE in ExprUseVisitor on FRU for non-existent struct

Fixes #104613
Fixes #105202
2022-12-07 15:39:06 +01:00
bors
91b8f34ac2 Auto merge of #104799 - pcc:linkage-fn, r=tmiasko
Support Option and similar enums as type of static variable with linkage attribute

Compiler MCP:
rust-lang/compiler-team#565
2022-12-07 10:24:59 +00:00
Daniil Belov
a9cf163c08 fix: remove hack from link.rs (moved to libc) 2022-12-07 13:13:58 +03:00
bors
e491d2b24d Auto merge of #105291 - nnethercote:remove-LintPassObjects, r=cjgillot
Remove `{Early,Late}LintPassObjects`.

`EarlyContextAndPass` wraps a single early lint pass. We aggregate multiple passes into that single pass by using `EarlyLintPassObjects`.

This commit removes `EarlyLintPassObjects` by changing `EarlyContextAndPass` into `EarlyContextAndPasses`. I.e. it just removes a level of indirection. This makes the code simpler and slightly faster.

The commit does likewise for late lints.

r? `@cjgillot`
2022-12-07 03:52:19 +00:00
Boxy
9f438bef0b normalize before matching on ConstKind 2022-12-06 22:53:13 +00:00
Matthias Krüger
280501d6bc
Rollup merge of #105382 - BoxyUwU:fixme_typo_sadface, r=lcnr
remove an excess `this`
2022-12-06 23:13:51 +01:00
Matthias Krüger
e434f613fd
Rollup merge of #105298 - krasimirgg:llvm-16-dec-1, r=cuviper
llvm-wrapper: adapt for an LLVM API change

Adapts llvm-wrapper for 8c7c20f033.
No functional changes intended.

Found via our experimental rust + llvm @ HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15404#0184d95d-5a68-4db6-ad32-51ddbc3ab543/202-571
2022-12-06 23:13:49 +01:00
bors
b28d30e1e3 Auto merge of #105378 - matthiaskrgr:rollup-fjeorw5, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104898 (Put all cached values into a central struct instead of just the stable hash)
 - #105004 (Fix `emit_unused_delims_expr` ICE)
 - #105174 (Suggest removing struct field from destructive binding only in shorthand scenario)
 - #105250 (Replace usage of `ResumeTy` in async lowering with `Context`)
 - #105286 (Add -Z maximal-hir-to-mir-coverage flag)
 - #105320 (rustdoc: simplify CSS selectors on top-doc and non-exhaustive toggles)
 - #105349 (Point at args in associated const fn pointers)
 - #105362 (Cleanup macro-expanded code in `rustc_type_ir`)
 - #105370 (Remove outdated syntax from trait alias pretty printing)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-06 18:51:14 +00:00
Krasimir Georgiev
75aec4703d llvm-wrapper: adapt for and LLVM API change 2022-12-06 18:25:33 +00:00
Boxy
0070fae2dc typo :( 2022-12-06 16:40:57 +00:00
Matthias Krüger
97008a23fc
Rollup merge of #105370 - WaffleLapkin:pp, r=oli-obk
Remove outdated syntax from trait alias pretty printing

Given the following program:
```rust
#![feature(trait_alias)]
trait A = ?Sized;

fn main() {}
```
Old output of `rustc +nightly ./t.rs -Zunpretty=normal`:
```rust
#![feature(trait_alias)]
trait A for ? Sized ;

fn main() {}
```
New output of `rustc +a ./t.rs -Zunpretty=normal`:
```rust
#![feature(trait_alias)]
trait A = ?Sized;

fn main() {}
```

cc `@durka` (you've written the `FIXME` in #45047, see https://github.com/rust-lang/rust/pull/45047#discussion_r144960751)
2022-12-06 16:54:57 +01:00
Matthias Krüger
4f527a55de
Rollup merge of #105362 - WaffleLapkin:🙅, r=oli-obk
Cleanup macro-expanded code in `rustc_type_ir`

We could of course just leave this as-is, but every time I go-to-def to this file it's painful to see all this `(&A(ref __self_1_0),)` stuff.
2022-12-06 16:54:56 +01:00
Matthias Krüger
4f919e4628
Rollup merge of #105349 - compiler-errors:point-at-assoc-ct-fn-ptr-arg, r=cjgillot
Point at args in associated const fn pointers

Tiny follow-up to #105201, not so sure it's worth it but 🤷

The UI test example is a bit more compelling when it's `GlUniformScalar::FACTORY`

r? `@cjgillot`
2022-12-06 16:54:56 +01:00
Matthias Krüger
c699b05306
Rollup merge of #105286 - willcrichton:maximal-hir-to-mir-coverage, r=cjgillot
Add -Z maximal-hir-to-mir-coverage flag

This PR adds a new unstable flag `-Z maximal-hir-to-mir-coverage` that changes the behavior of `maybe_lint_level_root_bounded`, pursuant to [a discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Mapping.20MIR.20to.20HIR). When enabled, this function will not search upwards for a lint root, but rather immediately return the provided HIR node ID. This change increases the granularity of the mapping between MIR locations and HIR nodes inside the `SourceScopeLocalData` data structures. This increase in granularity is useful for rustc consumers like [Flowistry](https://github.com/willcrichton/flowistry) that rely on getting source-mapping information about the MIR CFG that is as precise as possible.

A test `maximal_mir_to_hir_coverage.rs` has been added to verify that this flag does not break anything.

r? `@cjgillot`

cc `@gavinleroy`
2022-12-06 16:54:55 +01:00
Matthias Krüger
967085ecdf
Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk
Replace usage of `ResumeTy` in async lowering with `Context`

Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.

fixes https://github.com/rust-lang/rust/issues/104828 and https://github.com/rust-lang/rust/pull/104321#issuecomment-1336363077

r? `@oli-obk`
2022-12-06 16:54:54 +01:00
Matthias Krüger
90d84ce3a2
Rollup merge of #105174 - chenyukang:yukang/fix-105028-unused, r=eholk
Suggest removing struct field from destructive binding only in shorthand scenario

Fixes #105028
2022-12-06 16:54:53 +01:00
Matthias Krüger
b29a4f9bac
Rollup merge of #105004 - TaKO8Ki:fix-104897, r=wesleywiser
Fix `emit_unused_delims_expr` ICE

Fixes #104897

This is also related to #104433.
2022-12-06 16:54:53 +01:00
Matthias Krüger
db416ea195
Rollup merge of #104898 - oli-obk:group_all_the_things, r=wesleywiser
Put all cached values into a central struct instead of just the stable hash

cc `@nnethercote`

this allows re-use of the type for Predicate without duplicating all the logic for the non-hash cached fields
2022-12-06 16:54:52 +01:00
bors
e60fbaf4ce Auto merge of #105229 - saethlin:zst-writes-to-unions, r=oli-obk
Re-enable removal of ZST writes to unions

This was previously disabled because Miri was lazily allocating unsized locals. But we aren't doing that anymore since  https://github.com/rust-lang/rust/pull/98831, so we can have this optimization back.
2022-12-06 15:35:55 +00:00
Maybe Waffle
700c095306 rustc_builtin_macros: remove ref patterns
... and other pattern matching improvements
2022-12-06 14:45:58 +00:00
Maybe Waffle
244990a6e9 rustc_attr remove ref patterns
...and some if-let-elses too :P
2022-12-06 14:45:58 +00:00
Maybe Waffle
c75817fb1b rustc_borrowck: remove ref patterns 2022-12-06 14:45:58 +00:00
Maybe Waffle
12ce0c2a89 Remove outdated syntax from trait alias pretty printing 2022-12-06 13:45:11 +00:00
Maybe Waffle
e12d22239a Add debug asserts to hand-implemented Ord/Eq impls 2022-12-06 13:38:50 +00:00
Matthias Krüger
a9ffe7c738
Rollup merge of #105342 - compiler-errors:note_cause_code-takes-predicate, r=fee1-dead
Make `note_obligation_cause_code`  take a `impl ToPredicate` for predicate

The only usecase that wasn't `impl ToPredicate` was noting overflow errors while revealing opaque types, which passed in an `Obligation<'tcx, Ty<'tcx>>`... Since this only happens in a `RevealAll` environment, which is after typeck (and probably primarily within `normalize_erasing_regions`) we're unlikely to display anything useful while noting this code, evidenced by the lack of UI test changes.
2022-12-06 13:27:45 +01:00
Matthias Krüger
07fd8089a4
Rollup merge of #105340 - estebank:ice-ice-baby, r=compiler-errors
Avoid ICE by accounting for missing type

Fix #105330
2022-12-06 13:27:45 +01:00
Matthias Krüger
762d2545f4
Rollup merge of #105339 - BoxyUwU:wf_ct_kind_expr, r=TaKO8Ki
support `ConstKind::Expr` in `is_const_evaluatable` and `WfPredicates::compute`

Fixes #105205

Currently we haven't implemented a way to evaluate `ConstKind::Expr(Expr::Binop(Add, 1, 2))` so I just left that with a `FIXME` and a `delay_span_bug` since I have no idea how to do that and it would make this a much larger (and more complicated) PR :P
2022-12-06 13:27:44 +01:00
Matthias Krüger
e29a510ff0
Rollup merge of #105318 - compiler-errors:issue-105304, r=jackh726
Make `get_impl_future_output_ty` work with AFIT

Fixes #105304
2022-12-06 13:27:44 +01:00
Matthias Krüger
61189b6ae3
Rollup merge of #105310 - compiler-errors:issue-105288, r=eholk
Be more careful about unresolved exprs in suggestion

Fixes #105288
2022-12-06 13:27:43 +01:00
Matthias Krüger
0a07ffe4ad
Rollup merge of #105287 - compiler-errors:issue-105275, r=eholk
Synthesize substitutions for bad auto traits in dyn types

Auto traits are stored as just `DefId`s inside a `dyn Trait`'s existential predicates list. This is usually fine, since auto traits are forbidden to have generics -- but this becomes a problem for an ill-formed auto trait.

But since this will always result in an error, just synthesize some dummy (error) substitutions which are used at least to keep trait selection code happy about the number of substs in a trait ref.

Fixes #104808
2022-12-06 13:27:43 +01:00
Matthias Krüger
ddb98e0aac
Rollup merge of #105254 - cjgillot:issue-105251, r=oli-obk
Recurse into nested impl-trait when computing variance.

Fixes https://github.com/rust-lang/rust/issues/105251
2022-12-06 13:27:42 +01:00
Matthias Krüger
48172ff64b
Rollup merge of #105098 - lyming2007:issue-103869-fix, r=eholk
propagate the error from parsing enum variant to the parser and emit out

While parsing enum variant, the error message always disappear
Because the error message that emit out is from main error of parser
The information of enum variant disappears while parsing enum variant with error
We only check the syntax of expecting token, i.e, in case https://github.com/rust-lang/rust/issues/103869
It will error it without telling the message that this error is from pasring enum variant.
Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err
Check the sub-error before emitting the main error of parser and attach it.
Fix https://github.com/rust-lang/rust/issues/103869
2022-12-06 13:27:41 +01:00
Matthias Krüger
be3ad5d6b0
Rollup merge of #105005 - estebank:where-clause-lts, r=compiler-errors
On E0195 point at where clause lifetime bounds

Fix #104733
2022-12-06 13:27:41 +01:00
Maybe Waffle
07fbb1b372 Cleanup macro-expanded code in rustc_type_ir 2022-12-06 11:17:49 +00:00
bors
9db224fc90 Auto merge of #105175 - michaelwoerister:add-stable-ord-trait, r=nagisa
Add StableOrd trait as proposed in MCP 533.

The `StableOrd` trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.

See https://github.com/rust-lang/compiler-team/issues/533 for more information.
2022-12-06 09:21:49 +00:00
Arpad Borsos
cf031a3355
Replace usage of ResumeTy in async lowering with Context
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces
the raw pointer in `ResumeTy` and the `get_context` fn that pulls the
correct lifetimes out of thin air.
2022-12-06 10:16:23 +01:00
bors
c5351ad4dc Auto merge of #105348 - JohnTitor:rollup-q9bichr, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #104967 (Fix UI issues with Rustdoc scrape-examples feature.)
 - #105207 (interpret: clobber return place when calling function)
 - #105246 (Fix --pass in compiletest)
 - #105256 (Add small comment explaining what `method-margins.goml` test is about)
 - #105289 (Fix dupe word typos)
 - #105309 (rustdoc: remove no-op mobile CSS `.sidebar { margin: 0; padding: 0 }`)
 - #105313 (Update books)
 - #105315 (Normalize inherent associated types after substitution)
 - #105324 (Point at GAT `where` clause when an obligation is unsatisfied)
 - #105338 (Tweak "the following other types implement trait")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-06 06:34:13 +00:00
Esteban Küber
e802165dfe On E0195 point at where clause lifetime bounds
Fix #104733
2022-12-05 20:43:41 -08:00
Esteban Küber
eff76455fd Avoid ICE by accounting for missing type
Fix #105330
2022-12-05 20:30:17 -08:00
Michael Goulet
9c9c476774 Point at args in associated const fn pointers 2022-12-06 03:51:19 +00:00
Yuki Okushi
1310d9bd2b
Rollup merge of #105338 - estebank:other-impls, r=compiler-errors
Tweak "the following other types implement trait"

When *any* of the suggested impls is an exact match, *only* show the exact matches. This is particularly relevant for integer types.

r? `@compiler-errors`
2022-12-06 12:48:54 +09:00
Yuki Okushi
e09c71e4c1
Rollup merge of #105324 - compiler-errors:gat-where-clause-binding-obl, r=jackh726
Point at GAT `where` clause when an obligation is unsatisfied

Slightly helps with #105306
2022-12-06 12:48:54 +09:00
Yuki Okushi
7ba37adbfd
Rollup merge of #105315 - fmease:norm-subst-iat, r=compiler-errors
Normalize inherent associated types after substitution

Fixes #105314.

r? ````@cjgillot```` (#105224)
````@rustbot```` label F-inherent_associated_types
2022-12-06 12:48:53 +09:00
Yuki Okushi
fa7d3ec630
Rollup merge of #105289 - Rageking8:fix-dupe-word-typos, r=cjgillot
Fix dupe word typos
2022-12-06 12:48:52 +09:00
Yuki Okushi
aa0831092b
Rollup merge of #105207 - RalfJung:interpret-clobber-return, r=oli-obk
interpret: clobber return place when calling function

Makes sure the callee cannot observe the previous contents of the return place, and the caller cannot read any of the old return place contents even if the function unwinds.

I don't think we can test for this though, that would require some strange hand-written MIR.

r? `````@oli-obk`````
2022-12-06 12:48:50 +09:00