Commit Graph

211679 Commits

Author SHA1 Message Date
Nicholas Nethercote
2fd364acff Remove token::Lit from ast::MetaItemLit.
`token::Lit` contains a `kind` field that indicates what kind of literal
it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has
its own `kind` field. This means that `ast::MetaItemLit` encodes the
literal kind in two different ways.

This commit changes `ast::MetaItemLit` so it no longer wraps
`token::Lit`. It now contains the `symbol` and `suffix` fields from
`token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-12-02 13:49:19 +11:00
Nicholas Nethercote
a7f35c42d4 Add StrStyle to ast::LitKind::ByteStr.
This is required to distinguish between cooked and raw byte string
literals in an `ast::LitKind`, without referring to an adjacent
`token::Lit`. It's a prerequisite for the next commit.
2022-12-02 10:38:58 +11:00
Nicholas Nethercote
e658144586 Rename LitKind::to_token_lit as LitKind::synthesize_token_lit.
This makes it clearer that it's not a lossless conversion, which I find
helpful.
2022-12-02 10:23:44 +11:00
bors
c090c6880c Auto merge of #105125 - matthiaskrgr:rollup-fr0snmj, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #105078 (Fix `expr_to_spanned_string` ICE)
 - #105087 (Extract llvm datalayout parsing out of spec module)
 - #105088 (rustdoc: remove redundant CSS `div.desc { display: block }`)
 - #105106 (Fix ICE from #105101)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-01 17:47:12 +00:00
bors
367ecffe52 Auto merge of #105003 - flba-eb:only_windows, r=Mark-Simulacrum
Run Windows-only tests only on Windows

This removes the need to maintain an ignore-list of all other OSs.

See https://github.com/rust-lang/rust/pull/102305 for a similar change.
2022-12-01 14:27:34 +00:00
Florian Bartels
c04d67444f Ignore gnu systems (windows-msvc only) 2022-12-01 14:40:10 +01:00
Matthias Krüger
ee9eaa695c
Rollup merge of #105106 - jhpratt:issue-105101, r=TaKO8Ki
Fix ICE from #105101

Fixes #105101

Rather than comparing idents, compare spans, which should be unique to each variant.
2022-12-01 11:59:01 +01:00
Matthias Krüger
3ec9a6dd74
Rollup merge of #105088 - notriddle:notriddle/search-results-div-desc, r=GuillaumeGomez
rustdoc: remove redundant CSS `div.desc { display: block }`

DIV tags have block display by default. It is from when this rule used to target a SPAN tag, but became redundant in 4bd6748bb9.
2022-12-01 11:59:00 +01:00
Matthias Krüger
adec7eeb17
Rollup merge of #105087 - HKalbasi:master, r=eddyb
Extract llvm datalayout parsing out of spec module

fix https://github.com/rust-lang/rust/pull/103693#discussion_r1033250846
2022-12-01 11:59:00 +01:00
Matthias Krüger
741f8c9166
Rollup merge of #105078 - TaKO8Ki:fix-105011, r=nnethercote
Fix `expr_to_spanned_string` ICE

Fixes #105011
2022-12-01 11:58:59 +01:00
bors
9c0bc3028a Auto merge of #104975 - JakobDegen:custom_mir_let, r=oli-obk
`#![custom_mir]`: Various improvements

This PR makes a bunch of improvements to `#![custom_mir]`. Ideally this would be 4 PRs, one for each commit, but those would take forever to get merged and be a pain to juggle. Should still be reviewed one commit at a time though.

### Commit 1: Support arbitrary `let`

Before this change, all locals used in the body need to be declared at the top of the `mir!` invocation, which is rather annoying. We attempt to change that.

Unfortunately, we still have the requirement that the output of the `mir!` macro must resolve, typecheck, etc. Because of that, we can't just accept this in the THIR -> MIR parser because something like
```rust
{
    let x = 0;
    Goto(other)
}
other = {
    RET = x;
    Return()
}
```
will fail to resolve. Instead, the implementation does macro shenanigans to find the let declarations and extract them as part of the `mir!` macro. That *works*, but it is fairly complicated and degrades debuginfo by quite a bit. Specifically, the spans for any statements and declarations that are affected by this are completely wrong. My guess is that this is a net improvement though.

One way to recover some of the debuginfo would be to not support type annotations in the `let` statements, which would allow us to parse like `let $stmt:stmt`. That seems quite surprising though.

### Commit 2: Parse consts

Reuses most of the const parsing from regular Mir building for building custom mir

### Commit 3: Parse statics

Statics are slightly weird because the Mir primitive associated with them is a reference/pointer to them, so this is factored out separately.

### Commit 4: Fix some spans

A bunch of the spans were non-ideal, so we adjust them to be much more helpful.

r? `@oli-obk`
2022-12-01 10:40:10 +00:00
bors
d6c4de0fb2 Auto merge of #104861 - nnethercote:attr-cleanups, r=petrochenkov
Attribute cleanups

Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-01 07:13:45 +00:00
bors
744a97b98c Auto merge of #105095 - matthiaskrgr:rollup-9pu7vrx, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103065 (rustdoc-json: Document and Test that args can be patterns.)
 - #104865 (Don't overwrite local changes when updating submodules)
 - #104895 (Avoid Invalid code suggested when encountering unsatisfied trait bounds in derive macro code)
 - #105063 (Rustdoc Json Tests: Don't assume that core::fmt::Debug will always have one item.)
 - #105064 (rustdoc: add comment to confusing CSS `main { min-width: 0 }`)
 - #105074 (Add Nicholas Bishop to `.mailmap`)
 - #105081 (Add a regression test for #104322)
 - #105086 (rustdoc: clean up sidebar link CSS)
 - #105091 (add Tshepang Mbambo to .mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-01 04:16:30 +00:00
bors
1dcf6add3d Auto merge of #104160 - Ayush1325:windows-args, r=m-ou-se
Extract WStrUnits to sys_common::wstr

This commit extracts WStrUnits from sys::windows::args to sys_common::wstr. This allows using the same structure for other targets which use wtf8 (example UEFI).

This was originally a part of https://github.com/rust-lang/rust/pull/100316

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-12-01 01:22:32 +00:00
Jacob Pratt
ab264ae612
Fix ICE from #105101 2022-11-30 21:18:31 +00:00
Matthias Krüger
ffb071f906
Rollup merge of #105091 - tshepang:mailmap, r=compiler-errors
add Tshepang Mbambo to .mailmap

... because my surname has changed

```
# before
❯ git shortlog --summary --email | rg Tshepang
   326  Tshepang Lekhonkhobe <tshepang@gmail.com>
     8  Tshepang Mbambo <tshepang@gmail.com>

# after
❯ git shortlog --summary --email | rg Tshepang
   334  Tshepang Mbambo <tshepang@gmail.com>
2022-11-30 19:53:21 +01:00
Matthias Krüger
e005d0406f
Rollup merge of #105086 - notriddle:notriddle/sidebar-css, r=GuillaumeGomez
rustdoc: clean up sidebar link CSS

Group `text-overflow: ellipses` along with `white-space: nowrap`. It makes no sense to try to apply it to links with `overflow-wrap: anywhere`, because it can't actually make ellipses when that's turned on.

Simplify the selector for the 25rem left padding on sidebar links, to match up with the style for the container left padding that makes room for it.
2022-11-30 19:53:20 +01:00
Matthias Krüger
6c4b5a2bdb
Rollup merge of #105081 - weiznich:regression_test_for_104322, r=compiler-errors
Add a regression test for #104322

r? ``@compiler-errors``
2022-11-30 19:53:20 +01:00
Matthias Krüger
c56c377183
Rollup merge of #105074 - nicholasbishop:bishop-mailmap, r=Mark-Simulacrum
Add Nicholas Bishop to `.mailmap`
2022-11-30 19:53:19 +01:00
Matthias Krüger
4357c2d018
Rollup merge of #105064 - notriddle:notriddle/main-min-width, r=GuillaumeGomez
rustdoc: add comment to confusing CSS `main { min-width: 0 }`

This CSS was added in cad0fce205, but the reason why it was necessary was unclear. This comment makes it clear.
2022-11-30 19:53:19 +01:00
Matthias Krüger
cbf1a0ed3a
Rollup merge of #105063 - aDotInTheVoid:rdj-dont-assume-core, r=notriddle
Rustdoc Json Tests: Don't assume that core::fmt::Debug will always have one item.

See https://github.com/rust-lang/rust/pull/104525#issuecomment-1330837047 and https://github.com/rust-lang/rust/pull/104525#issuecomment-1331087852 for motivation.

This still assumes that `fmt` is the first method, but thats alot less brittle than assuming it will be the only method.

Sadly, we can't use a aux crate to insulate the tests from core changes, because core is special, so all we can do is try not to depend on things that may change.
2022-11-30 19:53:18 +01:00
Matthias Krüger
eabc0720a6
Rollup merge of #104895 - chenyukang:yukang/fix-104884-serde, r=TaKO8Ki
Avoid Invalid code suggested when encountering unsatisfied trait bounds in derive macro code

Fixes #104884
2022-11-30 19:53:18 +01:00
Matthias Krüger
3d64420fa9
Rollup merge of #104865 - pratushrai0309:bootstrap, r=jyn514
Don't overwrite local changes when updating submodules

Fixes https://github.com/rust-lang/rust/issues/103485
2022-11-30 19:53:17 +01:00
Matthias Krüger
091f5e1a6c
Rollup merge of #103065 - aDotInTheVoid:rdj-arg-pattern, r=GuillaumeGomez
rustdoc-json: Document and Test that args can be patterns.
2022-11-30 19:53:17 +01:00
hkalbasi
56126fb149 Extract llvm datalayout parsing out of spec module 2022-11-30 21:13:54 +03:30
Tshepang Mbambo
fe6d9e951a add Tshepang Mbambo to .mailmap 2022-11-30 19:36:05 +02:00
bors
c97b539e40 Auto merge of #104940 - cjgillot:query-feed-simple, r=oli-obk
Allow to feed a value in another query's cache

Restricted version of https://github.com/rust-lang/rust/pull/96840

A query can create new definitions.

If those definitions are created after HIR lowering, they do not appear in the initial HIR map, and information for them cannot be provided in the normal pull-based way.

In order to make those definitions useful, we allow to feed values as query results for the newly created definition.

The API is as follows:
```rust
let feed = tcx.create_def(<parent def id>, <DefPathData>);
// `feed` is a TyCtxtFeed<'tcx>.

// Access the created definition.
let def_id: LocalDefId = feed.def_id;

// Assign `my_query(def_id) := my_value`.
feed.my_query(my_value).
```

This PR keeps the consistency checks introduced by https://github.com/rust-lang/rust/pull/96840, even if they are not reachable. This allows to extend the behaviour later without forgetting them.

cc `@oli-obk` `@spastorino`
2022-11-30 17:20:14 +00:00
Nicholas Bishop
f6e8580d63 Add Nicholas Bishop to .mailmap 2022-11-30 11:25:16 -05:00
Michael Howell
2405e60769 rustdoc: remove redundant CSS div.desc { display: block }
DIV tags have block display by default. It is from when this rule
used to target a SPAN tag, but became redundant in
4bd6748bb9.
2022-11-30 09:03:08 -07:00
Michael Howell
3a61ab6116 rustdoc: clean up sidebar link CSS
Group `text-overflow: ellipses` along with `white-space: nowrap`. It makes
no sense to try to apply it to links with `overflow-wrap: anywhere`, because
it can't actually make ellipses when that's turned on.

Simplify the selector for the 25rem left padding on sidebar links, to match
up with the style for the container left padding that makes room for it.
2022-11-30 08:03:13 -07:00
bors
90711a86e5 Auto merge of #99814 - aliemjay:patch-2, r=jackh726
fix universe map in ifcx.instantiate_canonical_*

Previously, `infcx.instantiate_canonical_*` maps the root universe in `canonical` into `ty::UniverseIndex::Root`, I think because it assumes it works with a fresh `infcx` but this is not true for the use cases in mir typeck. Now the root universe is mapped into `infcx.universe()`.

I catched this accidentally while reviewing the code. I'm not sure if this is the right fix or if it is really a bug!
2022-11-30 14:03:36 +00:00
Georg Semmler
42ff718d0f
Add a regression test for #104322 2022-11-30 14:50:32 +01:00
bors
24606deaf4 Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types
2022-11-30 11:13:09 +00:00
bors
a569a88f55 Auto merge of #105080 - matthiaskrgr:rollup-7ffj4oe, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #104697 (Restore control flow on error in EUV)
 - #104811 (feat: implement TcpStream shutdown for wasm32-wasi)
 - #105039 (Fix an ICE parsing a malformed literal in `concat_bytes!`.)
 - #105071 (Add Nicholas Nethercote to `.mailmap`.)
 - #105079 (Add bots to `.mailmap`)

Failed merges:

 - #105074 (Add Nicholas Bishop to `.mailmap`)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-30 07:59:24 +00:00
Matthias Krüger
815b6e5ab8
Rollup merge of #105079 - nnethercote:bots-mailmap, r=jyn514
Add bots to `.mailmap`

r? `@compiler-errors`
2022-11-30 07:00:32 +01:00
Matthias Krüger
bc820ecc34
Rollup merge of #105071 - nnethercote:nnethercote-mailmap, r=compiler-errors
Add Nicholas Nethercote to `.mailmap`.

Before:
```
$ git shortlog -se | grep Nethercote
   517	Nicholas Nethercote <n.nethercote@gmail.com>
     2	Nicholas Nethercote <nnethercote@apple.com>
   560	Nicholas Nethercote <nnethercote@mozilla.com>
```
After
```
$ git shortlog -se | grep Nethercote
  1079	Nicholas Nethercote <n.nethercote@gmail.com>
```
2022-11-30 07:00:32 +01:00
Matthias Krüger
084bbcc2ca
Rollup merge of #105039 - nnethercote:fix-104769, r=petrochenkov
Fix an ICE parsing a malformed literal in `concat_bytes!`.

Fixes #104769.

r? `@petrochenkov`
2022-11-30 07:00:31 +01:00
Matthias Krüger
c752eaa7de
Rollup merge of #104811 - haraldh:feat/wasm32_wasi_shutdown, r=joshtriplett
feat: implement TcpStream shutdown for wasm32-wasi

Signed-off-by: Harald Hoyer <harald@profian.com>
2022-11-30 07:00:31 +01:00
Matthias Krüger
0c14551fe5
Rollup merge of #104697 - dingxiangfei2009:fix-euv-control-flow, r=oli-obk
Restore control flow on error in EUV

cc `@Nilstrieb`

Fix #104649

Since #98574 refactored a piece of scrutinee memory categorization out as a subroutine, there is a subtle change in handling match arms especially when the categorization process faults and bails. In the correct case, it is not supposed to continue to process the arms any more. This PR restores the original control flow in EUV.

I promise to add a compile-fail test to demonstrate that this indeed fixes the issue after coming back from a nap.
2022-11-30 07:00:30 +01:00
Takayuki Maeda
02eaecc767 avoid an unnecessary &str to String conversion 2022-11-30 13:31:35 +09:00
Takayuki Maeda
97f0c58b37 report literal errors when token_lit has errors 2022-11-30 13:31:11 +09:00
bors
8de4b13845 Auto merge of #104679 - dvdhrm:rw/dso, r=petrochenkov
codegen-llvm: never combine DSOLocal and DllImport

Prevent DllImport from being attached to DSOLocal definitions in the LLVM IR. The combination makes no sense, since definitions local to the compilation unit will never be imported from external objects.

Additionally, LLVM will refuse the IR if it encounters the combination (introduced in [1]):

```
  if (GV.hasDLLImportStorageClass())
    Assert(!GV.isDSOLocal(),
           "GlobalValue with DLLImport Storage is dso_local!", &GV);
```

Right now, codegen-llvm will only apply DllImport to constants and rely on call-stubs for functions. Hence, we simply extend the codegen of constants to skip DllImport for any local definitions.

This was discovered when switching the EFI targets to the static relocation model [2]. With this fixed, we can start another attempt at this.

[1] 509132b368
[2] https://github.com/rust-lang/rust/issues/101656
2022-11-30 04:18:15 +00:00
Jakob Degen
5a34dbf193 Improve spans in custom mir 2022-11-29 19:27:26 -08:00
Jakob Degen
52ce1f7697 Support statics in custom mir 2022-11-29 19:27:26 -08:00
Jakob Degen
7578100317 Support most constant kinds in custom mir 2022-11-29 19:26:04 -08:00
Jakob Degen
a98254179b Support arbitrary let statements in custom mir 2022-11-29 19:19:33 -08:00
Nicholas Nethercote
3593a5d74e Add dependabot to .mailmap.
Before:
```
$ git shortlog -se | grep "depend"
    44	dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
     6	dependabot-preview[bot] <dependabot-preview[bot]@users.noreply.github.com>
     4	dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    74	dependabot[bot] <dependabot[bot]@users.noreply.github.com>
    93	dependabot[bot] <support@dependabot.com>
```
After:
```
$ git shortlog -se | grep "depend"
   221  dependabot[bot] <dependabot[bot]@users.noreply.github.com>
```
2022-11-30 13:15:35 +11:00
Nicholas Nethercote
b2e05f6400 Add bors to .mailmap.
Before:
```
$ git shortlog -se | grep "\<bors\>"
 27755	bors <bors@rust-lang.org>
  5729	bors[bot] <26634292+bors[bot]@users.noreply.github.com>
   995	bors[bot] <bors[bot]@users.noreply.github.com>
```
After:
```
$ git shortlog -se | grep "\<bors\>"
 34479	bors <bors@rust-lang.org>
```
2022-11-30 13:09:47 +11:00
Nicholas Nethercote
bf4a62c381 Fix an ICE parsing a malformed literal in concat_bytes!.
Fixes #104769.
2022-11-30 12:19:07 +11:00
bors
d38a99078c Auto merge of #105070 - matthiaskrgr:rollup-9b25khj, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - #103876 (type alias impl trait: add tests showing that hidden type only outlives lifetimes that occur in bounds)
 - #104427 (Explain why `rematch_impl` fails to be infallible)
 - #104436 (Add slice to the stack allocated string comment)
 - #104523 (Don't use periods in target names)
 - #104627 (Print all features with --print target-features)
 - #104911 (Make inferred_outlives_crate return Clause)
 - #105002 (Add `PathBuf::as_mut_os_string` and `Path::as_mut_os_str`)
 - #105023 (Statics used in reachable function's inline asm are reachable)
 - #105045 (`rustc_ast_{passes,pretty}`: remove `ref` patterns)
 - #105049 (Hermit: Minor build fixes)
 - #105051 (Replace a macro with a function)
 - #105062 (rustdoc: use shorthand background for rustdoc toggle CSS)
 - #105066 (move `candidate_from_obligation` out of assembly)
 - #105068 (Run patchelf also on rust-analyzer-proc-macro-srv.)

Failed merges:

 - #105050 (Remove useless borrows and derefs)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-30 00:42:43 +00:00