Commit Graph

17773 Commits

Author SHA1 Message Date
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
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
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
Michael Goulet
3722ad4c26 Don't lower assoc bindings just to deny them 2022-09-29 22:44:43 +00:00
Michael Goulet
c1c3dacc78 Generate synthetic impl region even in closure body in associated fn 2022-09-29 22:32:28 +00:00
Yiming Lei
523a76a2eb remove the unused :: between trait and type to give user correct diagnostic 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-29 14:24:24 -07:00
Michael Goulet
ee713f3d43 Check generic argument compatibility when projecting assoc ty 2022-09-29 21:22:34 +00:00
bors
9c56d9d6fe Auto merge of #102482 - notriddle:rollup-fjm618g, r=notriddle
Rollup of 7 pull requests

Successful merges:

 - #102214 (Fix span of byte-escaped left format args brace)
 - #102426 (Don't export `__wasm_init_memory` on WebAssembly.)
 - #102437 (rustdoc: cut margin-top from first header in docblock)
 - #102442 (rustdoc: remove bad CSS font-weight on `.impl`, `.method`, etc)
 - #102447 (rustdoc: add method spacing to trait methods)
 - #102468 (tidy: make rustc dependency error less confusing)
 - #102476 (Split out the error reporting logic into a separate function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-29 19:52:48 +00:00
Michael Howell
98075708dd
Rollup merge of #102476 - oli-obk:split_error_path, r=cjgillot
Split out the error reporting logic into a separate function

I was trying to read the function and got distracted by the huge block of code in the middle of it. Turns out it only reports diagnostics and all paths within it end in an error. The main function is now more readable imo.
2022-09-29 10:15:20 -07:00
Michael Howell
3cecc78694
Rollup merge of #102426 - sunfishcode:sunfishcode/no-wasm-init-memory, r=nagisa
Don't export `__wasm_init_memory` on WebAssembly.

Since #72889, the Rust wasm target doesn't use --passive-segments, so remove the `--export=__wasm_init_memory`.

As documented in the [tool-conventions Linking convention], `__wasm_init_memory` is not intended to be exported.

[tool-conventions Linking convention]: 7c064f3048/Linking.md (shared-memory-and-passive-segments)
2022-09-29 10:15:18 -07:00
Michael Howell
0878bee38a
Rollup merge of #102214 - cassaundra:fix-format-args-span, r=cjgillot
Fix span of byte-escaped left format args brace

Fix #102057 (see issue for example).

Previously, the use of escaped left braces (`\x7B`) in format args resulted in an incorrectly offset span. This patch fixes that by considering any escaped characters within the string instead of using a constant offset.
2022-09-29 10:15:17 -07:00
bors
9f1a21ae2b Auto merge of #101893 - oli-obk:lift_derive, r=lcnr
Fix perf regression from TypeVisitor changes

Regression occurred in https://github.com/rust-lang/rust/pull/101858#issuecomment-1248732579

Instead of just reverting, we only fixed part of the regression. The main regression was due to actually correctly visiting a type that contains types and consts and should therefor be visited. This is not actually observable (yet?), but we should still do it correctly instead of risking major bugs in the future.
2022-09-29 17:05:00 +00:00
Oli Scherer
aa3fbf8795 Split out the error reporting logic into a separate function 2022-09-29 14:29:36 +00:00
bors
65445a571c Auto merge of #102471 - Dylan-DPC:rollup-ij3okjt, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #102336 (Fix associated type bindings with anon const in GAT position)
 - #102342 (Add negation methods for signed non-zero integers.)
 - #102385 (Don't export `__heap_base` and `__data_end` on wasm32-wasi.)
 - #102435 (Improve example of Iterator::reduce)
 - #102436 (rustdoc: clean up "normalize.css 8" input override CSS)
 - #102452 (fix minor ungrammatical sentence)
 - #102455 (Use let-chaining in `WhileTrue::check_expr`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-29 13:27:28 +00:00
Dylan DPC
f4e7094ffc
Rollup merge of #102455 - nnethercote:WhileTrue-check_expr, r=lqd
Use let-chaining in `WhileTrue::check_expr`.

This has been bugging me for a while.

r? `@lqd`
2022-09-29 18:13:22 +05:30
Dylan DPC
33553e1a28
Rollup merge of #102385 - sunfishcode:sunfishcode/wasm-no-export-heap-base, r=davidtwco
Don't export `__heap_base` and `__data_end` on wasm32-wasi.

`__heap_base` and `__data_end` are exported for use by wasm-bindgen, which uses the wasm32-unknown-unknown target. On wasm32-wasi, as a step toward implementing the Canonical ABI, and as an aid to building speicalized WASI API polyfill wrappers, don't export `__heap_base` and `__data_end` on wasm32-wasi.
2022-09-29 18:13:20 +05:30
Dylan DPC
1be9ec5443
Rollup merge of #102336 - compiler-errors:issue-102333, r=jackh726
Fix associated type bindings with anon const in GAT position

The first commit formats `type_of.rs`, which is really hard to maintain since it uses a bunch of features like `let`-chains and `if let` match arm bindings. Best if you just review the second two diffs.

Fixes #102333
2022-09-29 18:13:19 +05:30
bors
c5bbf36a31 Auto merge of #102461 - oli-obk:split_collect_rs, r=lcnr
Split collect.rs

This file was way too big (adding a few lines of code caused tidy to trigger)
2022-09-29 10:44:29 +00:00
Oli Scherer
f22f149dbd Some path updates 2022-09-29 09:33:30 +00:00
Oli Scherer
6367e69929 Split collect.rs 2022-09-29 09:31:46 +00:00
bors
8a497b7181 Auto merge of #102328 - cuviper:ibm-stack-probes, r=nagisa
Enable inline stack probes on PowerPC and SystemZ

The LLVM PowerPC and SystemZ targets have both supported `"probe-stack"="inline-asm"` for longer than our current minimum LLVM 13 requirement, so we can turn this on for all `powerpc`, `powerpc64`, `powerpc64le`, and `s390x` targets in Rust. These are all tier-2 or lower, so CI does not run their tests, but I have confirmed that their `linux-gnu` variants do pass on RHEL.

cc #43241
2022-09-29 08:00:54 +00:00
reez12g
e89fbc5872 Fix confliction 2022-09-29 16:50:48 +09:00
reez12g
00612e23cb Mark ignore(illustrative) on docs in compiler/rustc_const_eval/src/interpret/validity.rs 2022-09-29 16:49:23 +09:00
reez12g
73775a96dc Fix docs in compiler/rustc_builtin_macros/src/deriving/generic/mod.rs 2022-09-29 16:49:21 +09:00
reez12g
cc8f98f4f2 Fix docs in compiler/rustc_builtin_macros/src/assert/context.rs 2022-09-29 16:49:20 +09:00
reez12g
213910a8a2 Add feature flag to docs in compiler/rustc_builtin_macros/src/assert/context.rs 2022-09-29 16:49:18 +09:00
reez12g
cf31a29492 Mark ignore on error code docs in compiler/rustc_borrowck/src/region_infer/mod.rs 2022-09-29 16:49:16 +09:00
reez12g
c2ad8d2551 Mark ignore on error code docs in compiler/rustc_borrowck/src/diagnostics/region_errors.rs 2022-09-29 16:49:15 +09:00
reez12g
a1999b76aa Mark ignore(illustrative) on docs in compiler/rustc_ast_lowering/src/expr.rs 2022-09-29 16:49:13 +09:00
reez12g
9a4c5abe45 Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
Yuki Okushi
80e009ceba
Rollup merge of #102416 - lcnr:specialization-fixme, r=compiler-errors
remove FIXME, improve documentation

r? types
2022-09-29 11:42:06 +09:00
Yuki Okushi
039e9e2160
Rollup merge of #102399 - b-naber:binder-print-ice, r=lcnr
Account for use of index-based lifetime names in print of binder

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

r? ```@lcnr```

cc ```@steffahn```
2022-09-29 11:42:06 +09:00
Yuki Okushi
19e84b91e5
Rollup merge of #102351 - Rageking8:improve-E0585, r=wesleywiser
Improve E0585 help
2022-09-29 11:42:04 +09:00
Yuki Okushi
852a152206
Rollup merge of #102085 - chenyukang:code-refactor, r=cjgillot
Code refactoring smart_resolve_report_errors

`smart_resolve_report_errors` 4ecfdfac51/compiler/rustc_resolve/src/late/diagnostics.rs (L143)
is almost 600 lines of code, we should do some code refactoring.
2022-09-29 11:42:03 +09:00
Ellis Hoag
01439c93b8 print <signal> when ranlib failed without an exit code 2022-09-28 19:02:38 -07:00
Nicholas Nethercote
269ff92975 Use let-chaining in WhileTrue::check_expr.
This has been bugging me for a while.
2022-09-29 09:10:57 +10:00
Nicholas Nethercote
f07d4efc45 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
bors
b30c88623c Auto merge of #102384 - camelid:extrainfo, r=GuillaumeGomez
rustdoc: Remove `clean::TraitWithExtraInfo` and queryify `is_notable_trait`

cc `@notriddle` `@GuillaumeGomez`
2022-09-28 22:15:28 +00:00
Dan Gohman
297c908fee Change declare_cfn to use the C visibility for all C ABI functions. 2022-09-28 14:50:58 -07:00
Dan Gohman
bc5443a603 Use the existing set_visibility function. 2022-09-28 14:43:58 -07:00
Nicholas Nethercote
a8d5c00d46 Inline two Ident methods. 2022-09-29 07:05:34 +10:00
Nicholas Nethercote
2aa028d30d Inline <Token as PartialEq<TokenKind>>::eq. 2022-09-29 07:05:34 +10:00
Nicholas Nethercote
5f29a13a5b Change the "dummy self type".
Because this is the only occurrence of a `Res::SelfTy` with `None` and
`None` fields, and the next commit will rely on those not being present.
2022-09-29 06:57:53 +10:00
Cassaundra Smith
e5096d4cba
Fix span of byte-escaped left format args brace
Fix #102057.
2022-09-28 13:47:17 -07:00
bors
ce7f0f1aa0 Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser
Add `#[rustc_safe_intrinsic]`

This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.
2022-09-28 19:07:50 +00:00
Dan Gohman
284c94257f Don't export __wasm_init_memory on WebAssembly.
Since #72889, the Rust wasm target doesn't use --passive-segments, so
remove the `--export=__wasm_init_memory`.

As documented in the [tool-conventions Linking convention],
`__wasm_init_memory` is not intended to be exported.

[tool-conventions Linking convention]: 7c064f3048/Linking.md (shared-memory-and-passive-segments)
2022-09-28 11:13:51 -07:00
Dan Gohman
3c3bf76ce0 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-09-28 10:42:30 -07:00
Rageking8
2ee2ffa9a7 improve E0585 help 2022-09-29 00:34:31 +08:00
lcnr
9ccb851182 update fixme 2022-09-28 17:04:29 +02:00
bors
307dd938d7 Auto merge of #101454 - cjgillot:concat-binders, r=estebank
Do not overwrite lifetime binders for another HirId.

This PR makes higher-ranked bounds in where clauses a bit more principled.
We used to conflate `for<'a> T: Trait` with `(for<'a> T): Trait`.
This PR separates both binders.

This caused issued with fn types, which have their own binder, causing us to overwrite the predicates's binders with `fn`'s binders, ICEing.

Fixes https://github.com/rust-lang/rust/issues/98594
2022-09-28 14:42:55 +00:00
bors
09ae7846a2 Auto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwco
Migrate more of rustc_parse to SessionDiagnostic

Still far from complete, but I thought I'd add a checkpoint here because rebasing was starting to get annoying.
2022-09-28 11:11:42 +00:00
Ding Xiang Fei
4a2c1a12b6
fix unwind drop glue for if-then scopes 2022-09-28 18:45:11 +08:00
b-naber
4fdc78e6bf account for use of index-based lifetime names in print of binder 2022-09-28 12:31:08 +02:00
bors
6201eabde8 Auto merge of #102302 - nnethercote:more-lexer-improvements, r=matklad
More lexer improvements

A follow-up to #99884.

r? `@matklad`
2022-09-28 08:14:04 +00:00
Arthur Cohen
37bf8f888c rustc_safe_intrinsic: Keep list of safe intrinsics within the compiler 2022-09-28 09:40:02 +02:00
bors
837bf370de Auto merge of #102388 - JohnTitor:rollup-mbyw6fl, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #100747 (Add long description and test for E0311)
 - #102232 (Stabilize bench_black_box)
 - #102288 (Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.)
 - #102338 (Deny associated type bindings within associated type bindings)
 - #102347 (Unescaping cleanups)
 - #102348 (Tweak `FulfillProcessor`.)
 - #102378 (Use already resolved `self_ty` in `confirm_fn_pointer_candidate`)
 - #102380 (rustdoc: remove redundant mobile `.source > .sidebar` CSS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-28 04:18:19 +00:00
Yuki Okushi
ae2028817a
Rollup merge of #102378 - compiler-errors:issue-102289, r=jackh726
Use already resolved `self_ty` in `confirm_fn_pointer_candidate`

Fixes #102289
2022-09-28 13:07:20 +09:00
Yuki Okushi
bf54cfe2b2
Rollup merge of #102348 - nnethercote:tweak-FulfillProcessor, r=jackh726
Tweak `FulfillProcessor`.

Avoids some unnecessary references and lifetimes.

r? `@jackh726`
2022-09-28 13:07:19 +09:00
Yuki Okushi
f0daff20ca
Rollup merge of #102347 - nnethercote:unescaping-cleanups, r=matklad
Unescaping cleanups

Some minor improvements.

r? `@matklad`
2022-09-28 13:07:18 +09:00
Yuki Okushi
b263b7e64c
Rollup merge of #102338 - compiler-errors:assoc-ty-binding-in-assoc-ty-binding, r=cjgillot
Deny associated type bindings within associated type bindings

Fixes #102335

This was made worse by #100865, which unified the way we generate substs for GATs and non-generic associated types. However, the issue was not _caused_ by #100865, evidenced by the test I added for GATs:

```rust
trait T {
    type A: S<C<(), i32 = ()> = ()>;
    //~^ ERROR associated type bindings are not allowed here
}

trait Q {}

trait S {
    type C<T>: Q;
}

fn main() {}
```

^ which passes on beta (where GATs are stable) and presumably ever since GATs support was added to `create_substs_for_associated_item` in astconv.
2022-09-28 13:07:18 +09:00
Yuki Okushi
9436ffc226
Rollup merge of #102288 - mejrs:inner, r=compiler-errors
Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.

This suggests various ways to get inside wrapper types if the method cannot be found on the wrapper type, but is present on the wrappee.

For this PR, those wrapper types include `Localkey`, `MaybeUninit`, `RefCell`, `RwLock` and `Mutex`.
2022-09-28 13:07:17 +09:00
Yuki Okushi
07bb2e6527
Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki
Stabilize bench_black_box

This PR stabilize `feature(bench_black_box)`.

```rust
pub fn black_box<T>(dummy: T) -> T;
```

The FCP was completed in https://github.com/rust-lang/rust/issues/64102.

`@rustbot` label +T-libs-api -T-libs
2022-09-28 13:07:17 +09:00
Yuki Okushi
49bc668493
Rollup merge of #100747 - MatthewPeterKelly:mpk/add-long-error-message-for-E0311, r=MatthewPeterKelly
Add long description and test for E0311

Adds a long description and unit test for the E0311 compiler error.

Fixes one line-item in https://github.com/rust-lang/rust/issues/61137.
2022-09-28 13:07:16 +09:00
bors
d6734be398 Auto merge of #100996 - m-ou-se:format-args-2, r=estebank
Rewrite and refactor format_args!() builtin macro.

This is a near complete rewrite of `compiler/rustc_builtin_macros/src/format.rs`.

This gets rid of the massive unmaintanable [`Context` struct](76531befc4/compiler/rustc_builtin_macros/src/format.rs (L176-L263)), and splits the macro expansion into three parts:

1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax, but doesn't parse the template (the literal) itself.
2. Second, `make_format_args` will parse the template, the format options, resolve argument references, produce diagnostics, and turn the whole thing into a `FormatArgs` structure.
3. Finally, `expand_parsed_format_args` will turn that `FormatArgs` structure into the expression that the macro expands to.

In other words, the `format_args` builtin macro used to be a hard-to-maintain 'single pass compiler', which I've split into a three phase compiler with a parser/tokenizer (step 1), semantic analysis (step 2), and backend (step 3). (It's compilers all the way down. ^^)

This can serve as a great starting point for https://github.com/rust-lang/rust/issues/99012, which will only need to change the implementation of 3, while leaving step 1 and 2 unchanged.

It also makes https://github.com/rust-lang/compiler-team/issues/541 easier, which could then upgrade the new `FormatArgs` struct to an `ast` node and remove step 3, moving that step to later in the compilation process.

It also fixes a few diagnostics bugs.

This also [significantly reduces](https://gist.github.com/m-ou-se/b67b2d54172c4837a5ab1b26fa3e5284) the amount of generated code for cases with arguments in non-default order without formatting options, like `"{1} {0}"` or `"{a} {}"`, etc.
2022-09-28 01:36:28 +00:00
Nicholas Nethercote
d0a26acb2a Address review comments. 2022-09-28 11:15:23 +10:00
Noah Lev
4bf789fba7 rustdoc: Queryify is_notable_trait
This might help with #102375.
2022-09-27 17:44:54 -07:00
Dan Gohman
7f06d513fb Don't export __heap_base and __data_end on wasm32-wasi.
`__heap_base` and `__data_end` are exported for use by wasm-bindgen, which
uses the wasm32-unknown-unknown target. On wasm32-wasi, as a step toward
implementing the Canonical ABI, and as an aid to building speicalized WASI
API polyfill wrappers, don't export `__heap_base` and `__data_end` on
wasm32-wasi.
2022-09-27 17:42:33 -07:00
mejrs
4ff83cee95 Deduplicate some logic 2022-09-28 02:36:58 +02:00
Matthew Kelly
c0d32fd2cc review updates 2022-09-27 19:23:59 -04:00
Nicholas Nethercote
94cb5e86ea Small cleanups in unescaping code.
- Rename `unescape_raw_str_or_raw_byte_str` as
  `unescape_raw_str_or_byte_str`, which is more accurate.
- Remove the unused `Mode::in_single_quotes` method.
- Make some assertions more precise, and add a missing one to
  `unescape_char_or_byte`.
- Change all the assertions to `debug_assert!`, because this code is
  reasonably hot, and the assertions aren't required for memory safety,
  and any violations are likely to be sufficiently obvious that normal
  tests will trigger them.
2022-09-28 08:31:24 +10:00
Josh Stone
fb5002d68a 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-27 15:21:31 -07:00
Michael Goulet
e5776c6903 Use already resolved self_ty in confirm_fn_pointer_candidate 2022-09-27 20:00:24 +00:00
Matthias Krüger
3ca0cd0f94
Rollup merge of #102356 - davidtwco:translation-bootstrap-bump-allow-lint, r=lcnr
session: remove now-unnecessary lint `#[allow]`s

In #101230, the internal diagnostic migration lints - `diagnostic_outside_of_impl` and `untranslatable_diagnostic` - were modified so that they wouldn't trigger on functions annotated with `#[rustc_lint_diagnostics]`. However, this change has to make it into the bootstrap compiler before the `#[allow]` annotations that it aims to remove can be removed, which is possible now that #102051 has landed.
2022-09-27 21:42:24 +02:00
Matthias Krüger
e1fb698c44
Rollup merge of #102337 - cuviper:llvm-optional-bool, r=nikic
Avoid LLVM-deprecated `Optional::hasValue`

LLVM 15 added `Optional::has_value`, and LLVM `main` (16) has deprecated
`hasValue`. However, its `explicit operator bool` does the same thing,
and was added long ago, so we can use that across our full LLVM range of
compatibility.
2022-09-27 21:42:24 +02:00
Matthias Krüger
8b635cba1d
Rollup merge of #102284 - compiler-errors:missing-type-in-raw-ptr, r=davidtwco
Structured suggestion for missing `mut`/`const` in raw pointer

Fixes #102261
2022-09-27 21:42:23 +02:00
Matthias Krüger
8d2faa2ae8
Rollup merge of #102281 - RalfJung:invalid-enums, r=cjgillot
make invalid_value lint a bit smarter around enums

Fixes https://github.com/rust-lang/rust/issues/102043
2022-09-27 21:42:22 +02:00
mejrs
f3ac328d58 Address feedback 2022-09-27 21:42:09 +02:00
mejrs
c4c9415132 Wrapper suggestions 2022-09-27 21:42:09 +02:00
Nilstrieb
8a96884981
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.
2022-09-27 20:56:05 +02:00
Xiretza
d7c64574e0 Implement IntoDiagnosticArg for rustc_ast::token::Token(Kind) 2022-09-27 20:29:19 +02:00
Xiretza
37fdcb4b36 Don't unnecessarily stringify paths in diagnostics 2022-09-27 20:29:19 +02:00
Xiretza
caefac034e Document use of Symbol::to_string() 2022-09-27 20:29:19 +02:00
Xiretza
00f95468c4 Migrate even more diagnostics in rustc_parse to diagnostic structs 2022-09-27 20:29:19 +02:00
Xiretza
760c4352d6 Migrate "struct literal body without path" error to diagnostic struct 2022-09-27 20:29:19 +02:00
Xiretza
ba10f2c0f2 Migrate "expected semicolon" diagnostics to diagnostic structs 2022-09-27 20:29:19 +02:00
Xiretza
7507ee29fc Migrate "expected identifier" diagnostics to diagnostic structs 2022-09-27 20:29:19 +02:00
Xiretza
21b5194a3a Rework "inner attribute not permitted" errors 2022-09-27 20:29:19 +02:00
Xiretza
4d0519a4e7 Remove error condition in parse_attribute
This function is only ever called when the `#` has already been
consumed, no need to produce an error message here.
2022-09-27 20:29:19 +02:00
Xiretza
e1b1d7b029 Migrate more rustc_parse diagnostics to diagnostic structs 2022-09-27 20:29:18 +02:00
Xiretza
e56d6a68db Move rustc_parse diagnostic structs to separate module 2022-09-27 20:29:18 +02:00
Xiretza
6ae7a30927 Migrate "invalid literal suffix" diagnostic to diagnostic structs 2022-09-27 20:29:18 +02:00
Xiretza
ab7c7dc7ce Migrate more diagnostics in rustc_parse to diagnostic structs 2022-09-27 20:29:18 +02:00
Xiretza
4d02892acf Allow raw identifiers to be used as fluent arguments 2022-09-27 20:29:18 +02:00
Xiretza
8489a67f0b Implement IntoDiagnosticArg for rustc_ast::Path 2022-09-27 20:29:18 +02:00
Xiretza
495e271883 Migrate rustc_session::expr_parentheses_needed to Subdiagnostic struct 2022-09-27 20:29:18 +02:00
Michael Goulet
92561f43f1 Support bindings with anon consts in generics 2022-09-27 17:42:15 +00:00
Michael Goulet
05267b5a50 Make type_of work correctly for const arg bindings 2022-09-27 17:42:14 +00:00
Michael Goulet
cca48285b8 Format type_of 2022-09-27 17:42:13 +00:00
Michael Goulet
ca2e0bb51a Deny associated type bindings within associated type bindings 2022-09-27 17:41:34 +00:00
Camille GILLOT
337a73da6e Do not overwrite binders for another HirId. 2022-09-27 18:58:37 +02:00
Takayuki Maeda
d7b6bd8f13 improve errors for incomplete functions in struct definitions 2022-09-28 01:03:18 +09:00
Urgau
9ad2f00f6a Stabilize bench_black_box 2022-09-27 17:38:51 +02:00
Ralf Jung
67fd09d3b8 also query type_uninhabited_from 2022-09-27 16:20:23 +02:00
Arthur Cohen
99d57ee23d core: Mark all safe intrinsics with #[rustc_safe_intrinsic] 2022-09-27 15:55:42 +02:00
Arthur Cohen
0ab2c91a2d attributes: Add #[rustc_safe_intrinsic] builtin 2022-09-27 15:55:42 +02:00
Deadbeef
27b280e1b5 Fix ICE in const_trait check code
This fixes #102156.
2022-09-27 13:47:32 +00:00
Mara Bos
20bb600849 Remove confusing drop. 2022-09-27 13:31:52 +02:00
Mara Bos
ba7bf1d8ef Update doc comments. 2022-09-27 13:31:52 +02:00
Mara Bos
cf53fef0d6 Turn format arguments Vec into its own struct.
With efficient lookup through a hash map.
2022-09-27 13:31:52 +02:00
Mara Bos
c1c6e3ae7c Add clarifying comments. 2022-09-27 13:31:51 +02:00
Mara Bos
8d9a5881ea Flatten if-let and match into one. 2022-09-27 13:31:51 +02:00
Mara Bos
15754f5ea1 Move enum definition closer to its usage. 2022-09-27 13:31:51 +02:00
Mara Bos
df7fd119d2 Use if let chain. 2022-09-27 13:31:51 +02:00
Mara Bos
e65c96e4ad Tweak comments. 2022-09-27 13:31:51 +02:00
Mara Bos
ae238efe91 Prefer new_v1_formatted instead of new_v1 with duplicates. 2022-09-27 13:31:51 +02:00
Mara Bos
00074926bb Fix typo. 2022-09-27 13:31:51 +02:00
Mara Bos
8efc383047 Move FormatArgs structure to its own module. 2022-09-27 13:31:51 +02:00
Mara Bos
9bec0de397 Rewrite and refactor format_args!() builtin macro. 2022-09-27 13:13:08 +02:00
bors
57ee5cf5a9 Auto merge of #102306 - lcnr:rustc_hir_analysis, r=compiler-errors
rename rustc_typeck to rustc_hir_analysis

first part of https://github.com/rust-lang/compiler-team/issues/529

r? `@compiler-errors`
2022-09-27 10:45:57 +00:00
David Wood
2286888ef9 session: remove now-unnecessary lint #[allow]s
In #101230, the internal diagnostic migration lints -
`diagnostic_outside_of_impl` and `untranslatable_diagnostic` - were
modified so that they wouldn't trigger on functions annotated with
`#[rustc_lint_diagnostics]`. However, this change has to make it into
the bootstrap compiler before the `#[allow]` annotations that it aims to
remove can be removed, which is possible now that #102051 has landed.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-27 11:01:49 +01:00
lcnr
1fc86a63f4 rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
bors
d9297d22ad Auto merge of #102314 - TaKO8Ki:add-label-to-struct-enum-union-ident, r=estebank
Add a label to struct/enum/union ident name

Based on https://github.com/rust-lang/rust/pull/94996#discussion_r831694150
cc: `@estebank`
2022-09-27 07:30:11 +00:00
Nicholas Nethercote
b69c335327 Tweak FulfillProcessor.
Avoids some unnecessary references and lifetimes.
2022-09-27 16:37:00 +10:00
Nicholas Nethercote
c91c64708b Fix an incorrect comment.
If a `\x` escape occurs in a non-byte literals (e.g. char literal,
string literal), it must be <= 0xff.
2022-09-27 15:25:34 +10:00
bors
de0b511daa Auto merge of #102189 - davidtwco:translation-derive-enums, r=compiler-errors
macros: diagnostic derive on enums

Part of #100717.

Extends `#[derive(Diagnostic)]` to work on enums too where each variant acts like a distinct diagnostic - being able to represent diagnostics this way can be quite a bit simpler for some parts of the compiler.

r? `@compiler-errors`
cc `@Xiretza`
2022-09-27 04:39:25 +00:00
Ellis Hoag
6d01c6d9c8 lint and remove unused diagnostic 2022-09-26 19:57:40 -07:00
Michael Goulet
594134d873 Structured suggestion for missing mut/const in pointer 2022-09-27 02:47:07 +00:00
Nicholas Nethercote
7f7e2165b1 Rename some variables.
These make the delimiter processing clearer.
2022-09-27 12:04:03 +10:00
Takayuki Maeda
4f44dee501 add a label to struct/enum/union ident name 2022-09-27 10:28:50 +09:00
Takayuki Maeda
e123a61297 create a new local var 2022-09-27 10:22:46 +09:00
Matthew Kelly
0d9c01480b remove implied link bound per review
also update .stderr outputs
2022-09-26 20:50:33 -04:00
Matthew Kelly
24aab524cb Merge remote-tracking branch 'origin/master' into mpk/add-long-error-message-for-E0311 2022-09-26 19:59:52 -04:00
Nicholas Nethercote
880ebb657a Minor improvements.
Add some comments, and mark one path as unreachable.
2022-09-27 09:53:04 +10:00
Josh Stone
35adb36779 Avoid LLVM-deprecated Optional::hasValue
LLVM 15 added `Optional::has_value`, and LLVM `main` (16) has deprecated
`hasValue`. However, its `explicit operator bool` does the same thing,
and was added long ago, so we can use that across our full LLVM range of
compatibility.
2022-09-26 16:51:18 -07:00
Josh Stone
ad8f519ed7 Enable inline stack probes on PowerPC and SystemZ 2022-09-26 13:40:24 -07:00
bors
8b705839cd Auto merge of #102324 - matthiaskrgr:rollup-6l70oz3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #101875 (Allow more `!Copy` impls)
 - #101996 (Don't duplicate region names for late-bound regions in print of Binder)
 - #102181 (Add regression test)
 - #102273 (Allow `~const` bounds on non-const functions)
 - #102286 (Recover some items that expect braces and don't take semicolons)

Failed merges:

 - #102314 (Add a label to struct/enum/union ident name)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-26 19:57:51 +00:00
Matthias Krüger
6f5e8c2ed4
Rollup merge of #102286 - compiler-errors:recover-semi-in-block-item, r=davidtwco
Recover some items that expect braces and don't take semicolons

Fixes #102262
2022-09-26 19:19:21 +02:00
Matthias Krüger
e9bec2fdd4
Rollup merge of #102273 - woppopo:relax_const_bound, r=fee1-dead
Allow `~const` bounds on non-const functions

Makes the behavior of bound of trait-associated functions and non-associated functions consistent.
2022-09-26 19:19:21 +02:00
Matthias Krüger
b02062e886
Rollup merge of #101996 - b-naber:binder-print, r=lcnr
Don't duplicate region names for late-bound regions in print of Binder

Fixes https://github.com/rust-lang/rust/issues/101280
2022-09-26 19:19:20 +02:00
Matthias Krüger
4d4a3691e9
Rollup merge of #101875 - fmease:allow-more-negative-copy-impls, r=lcnr
Allow more `!Copy` impls

You can already implement `!Copy` for a lot of types (with `#![feature(negative_impls)]`). However, before this PR you could not implement `!Copy` for ADTs whose fields don't implement `Copy` which didn't make any sense. Further, you couldn't implement `!Copy` for types impl'ing `Drop` (equally nonsensical).

``@rustbot`` label T-types F-negative_impls
Fixes #101836.

r? types
2022-09-26 19:19:19 +02:00
bors
1d1f142660 Auto merge of #102257 - cjgillot:let-else-lint, r=dingxiangfei2009
Fix lint scoping for let-else.

The scoping for let-else is inconsistent with HIR nesting.  This creates cases, in `ui/let-else/let-else-allow-unused.rs` for instance, where an `allow` lint attribute does not apply to the bindings created by `let-else`.

This PR is an attempt to correct this.

As there is no lint that currently relies on this, the test for this behaviour is https://github.com/rust-lang/rust/pull/101500.

cc `@dingxiangfei2009` as you filed https://github.com/rust-lang/rust/pull/101894
2022-09-26 17:17:07 +00:00
bors
e1d7dec558 Auto merge of #102051 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrum
Update bootstrap compiler to 1.65.0

This PR updates the bootstrap compiler to Rust 1.65.0, removing the various `cfg(bootstrap)`s.

r? `@Mark-Simulacrum`
2022-09-26 14:22:43 +00:00
b-naber
6118ee343f address review 2022-09-26 14:21:39 +02:00
bors
84946fe241 Auto merge of #102184 - chenyukang:fix-102087-add-binding-sugg, r=nagisa
Suggest Default::default() when binding isn't initialized

Fixes #102087
2022-09-26 11:41:58 +00:00
b-naber
456f4e8d22 don't duplicate late-bound region names in print of Binder 2022-09-26 13:10:55 +02:00
David Wood
f20c882b8b macros: support diagnostic derive on enums
Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-26 11:59:19 +01:00
lcnr
932f930d27 remove outdated coherence hack 2022-09-26 12:48:28 +02:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
Pietro Albini
d0305b3d00
replace stabilization placeholders 2022-09-26 10:13:44 +02:00
bors
21265dd0d2 Auto merge of #102224 - fee1-dead-contrib:const_trait_impl_specialization, r=oli-obk
Allow specializing on const trait bounds
2022-09-26 08:08:35 +00:00
Ralf Jung
c19daa472b make invalid_value lint a bit smarter around enums 2022-09-26 09:44:10 +02:00
bors
72f4923979 Auto merge of #102297 - fee1-dead-contrib:rollup-2np0cre, r=fee1-dead
Rollup of 5 pull requests

Successful merges:

 - #102143 (Recover from struct nested in struct)
 - #102178 (bootstrap: the backtrace feature is stable, no need to allow it any more)
 - #102197 (Stabilize const `BTree{Map,Set}::new`)
 - #102267 (Don't set RUSTC in the bootstrap build script)
 - #102270 (Remove benches from `rustc_middle`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-26 05:27:43 +00:00
fee1-dead
39c6bdc30d
Rollup merge of #102270 - Nilstrieb:delete-useless-benches, r=TaKO8Ki
Remove benches from `rustc_middle`

These benches benchmark rust langauge features and not the compiler, so they seem to be in the wrong place here. They also all take <1ns, making them pretty useless. Looking at their git history, they just seem to have been carried around for many, many years. This commit ends their journey.
2022-09-26 13:09:43 +08:00
fee1-dead
804c2c1ed9
Rollup merge of #102197 - Nilstrieb:const-new-🌲, r=Mark-Simulacrum
Stabilize const `BTree{Map,Set}::new`

The FCP was completed in #71835.

Since `len` and `is_empty` are not const stable yet, this also creates a new feature for them since they previously used the same `const_btree_new` feature.
2022-09-26 13:09:42 +08:00
fee1-dead
0adf293f87
Rollup merge of #102143 - Rageking8:fix-101540, r=TaKO8Ki
Recover from struct nested in struct

Fixes #101540

r? `@TaKO8Ki`

Not sure If I have done it right.
2022-09-26 13:09:41 +08:00
woppopo
e4b08ab241 Allow ~const bounds on non-const functions 2022-09-26 05:00:31 +00:00
Nicholas Nethercote
fb4dba0a17 Inline and remove cook_lexer_token.
This is a small performance win, alas.
2022-09-26 13:50:13 +10:00
Nicholas Nethercote
da84f0f4c3 Add rustc_lexer::TokenKind::Eof.
For alignment with `rust_ast::TokenKind::Eof`. Plus it's a bit faster,
due to less `Option` manipulation in `StringReader::next_token`.
2022-09-26 13:48:08 +10:00
Nicholas Nethercote
cc0022a363 Rename some things.
`Cursor` keeps track of the position within the current token. But it
uses confusing names that don't make it clear that the "length consumed"
is just within the current token.

This commit renames things to make this clearer.
2022-09-26 13:43:19 +10:00
Nicholas Nethercote
ceb25d125f Use less DRY in cook_lexer_token.
This is a case where a small amount of repetition results in code that
is faster and easier to read.
2022-09-26 13:41:58 +10:00
Nicholas Nethercote
aa6bfaf04b Make rustc_lexer::cursor::Cursor public.
`Cursor` is currently hidden, and the main tokenization path uses
`rustc_lexer::first_token` which involves constructing a new `Cursor`
for every single token, which is weird. Also, `first_token` also can't
handle empty input, so callers have to check for that first.

This commit makes `Cursor` public, so `StringReader` can contain a
`Cursor`, which results in a simpler structure. The commit also changes
`StringReader::advance_token` so it returns an `Option<Token>`,
simplifying the the empty input case.
2022-09-26 13:36:35 +10:00
Nicholas Nethercote
33516ac09a [ui] Rearrange StringReader/TokenTreesReader creation.
`TokenTreesReader` wraps a `StringReader`, but the `into_token_trees`
function obscures this. This commit moves to a more straightforward
control flow.
2022-09-26 13:35:46 +10:00