Commit Graph

242049 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
5f56465621
Make feature negative_bounds internal 2023-12-28 00:43:35 +01:00
bors
88d69b72b4 Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-dead
Introduce `const Trait` (always-const trait bounds)

Feature `const_trait_impl` currently lacks a way to express “always const” trait bounds. This makes it impossible to define generic items like fns or structs which contain types that depend on const method calls (\*). While the final design and esp. the syntax of effects / keyword generics isn't set in stone, some version of “always const” trait bounds will very likely form a part of it. Further, their implementation is trivial thanks to the `effects` backbone.

Not sure if this needs t-lang sign-off though.

(\*):

```rs
#![feature(const_trait_impl, effects, generic_const_exprs)]

fn compute<T: const Trait>() -> Type<{ T::generate() }> { /*…*/ }

struct Store<T: const Trait>
where
    Type<{ T::generate() }>:,
{
    field: Type<{ T::generate() }>,
}
```

Lastly, “always const” trait bounds are a perfect fit for `generic_const_items`.

```rs
#![feature(const_trait_impl, effects, generic_const_items)]

const DEFAULT<T: const Default>: T = T::default();
```

Previously, we (oli, fee1-dead and I) wanted to reinterpret `~const Trait` as `const Trait` in generic const items which would've been quite surprising and not very generalizable.
Supersedes #117530.

---

cc `@oli-obk`

As discussed
r? fee1-dead (or compiler)
2023-12-27 19:24:31 +00:00
bors
a861c8965e Auto merge of #117303 - sjwang05:issue-117245, r=estebank
Suggest `=>` --> `>=` in comparisons

Fixes #117245
2023-12-27 17:26:12 +00:00
bors
15755f38cd Auto merge of #119302 - Mark-Simulacrum:relative-spans, r=WaffleLapkin
Support encoding spans with relative offsets

The relative offset is often smaller than the absolute offset, and with
the LEB128 encoding, this ends up cutting the overall metadata size
considerably (~1.5 megabytes on libcore). We can support both relative
and absolute encodings essentially for free since we already take a full
byte to differentiate between direct and indirect encodings (so an extra
variant is quite cheap).
2023-12-27 14:55:18 +00:00
Mark Rousskov
9c5293c27b Support relative offsets when encoding spans
The relative offset is often smaller than the absolute offset, and with
the LEB128 encoding, this ends up cutting the overall metadata size
considerably (~1.5 megabytes on libcore). We can support both relative
and absolute encodings essentially for free since we already take a full
byte to differentiate between direct and indirect encodings (so an extra
variant is quite cheap).
2023-12-27 07:31:38 -05:00
León Orell Valerian Liehr
3eb48a35c8
Introduce const Trait (always-const trait bounds) 2023-12-27 12:51:32 +01:00
bors
ca9ff83f1b Auto merge of #119327 - notriddle:notriddle/plusencoding, r=GuillaumeGomez
rustdoc: treat query string `+` as space

Fixes #119219
2023-12-27 11:47:24 +00:00
bors
df5d53585a Auto merge of #119343 - matthiaskrgr:rollup-vkt8lst, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #119175 (fix: diagnostic for casting reference to slice)
 - #119337 (Remove dead codes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-27 09:46:51 +00:00
Matthias Krüger
f05e16a70d
Rollup merge of #119337 - mu001999:dead_code/clean, r=WaffleLapkin
Remove dead codes

Detected by #118257
2023-12-27 09:11:36 +01:00
Matthias Krüger
d6382c785f
Rollup merge of #119175 - veera-sivarajan:fix-cast-to-slice, r=WaffleLapkin
fix: diagnostic for casting reference to slice

fixes:  #118790

Removes `if self.cast_ty.is_trait()` to produce the same diagnostic for cast to slice and trait.
2023-12-27 09:11:35 +01:00
bors
9da44323c9 Auto merge of #119233 - Nadrieril:keep-whole-pat-around, r=compiler-errors
Exhaustiveness: keep the original `thir::Pat` around

This PR makes it possible for exhaustiveness to look at the original `thir::Pat`, which I'll need at least for the [`small_gaps`](https://github.com/rust-lang/rust/pull/118879) lint (without that we can't distinguish inclusive and exclusive ranges within exhaustiveness). This PR is almost entirely lifetime-wrangling.
2023-12-27 07:48:29 +00:00
r01and
33867834bc
Remove dead codes 2023-12-27 07:33:43 +00:00
sjwang05
97cf1c87bd
Suggest => --> >= in conditions 2023-12-26 20:59:14 -08:00
bors
625c2c401f Auto merge of #119334 - weihanglo:update-cargo, r=weihanglo
Update cargo

7 commits in 363a2d11320faf531f6aacd1ea067c6bc08343b9..ac6bbb33293d8d424c17ecdb42af3aac25fb7295
2023-12-22 03:12:42 +0000 to 2023-12-26 23:22:08 +0000
- docs: fix link to nightly doc of cargo-util-schemas (rust-lang/cargo#13209)
- doc: improve word usage (rust-lang/cargo#13206)
- fix: clarify `--path` is the installation source not destination (rust-lang/cargo#13205)
- refactor: give some better examples for package ID spec (rust-lang/cargo#13202)
- chore: fix a typo (rust-lang/cargo#13201)
- Extend the build directive syntax with `cargo::` (rust-lang/cargo#12201)
- Rework `--check-cfg` generation comment (rust-lang/cargo#13195)

r? ghost
2023-12-27 03:04:03 +00:00
Weihang Lo
eb84788b67
Update cargo 2023-12-26 21:04:15 -05:00
bors
eee93d8396 Auto merge of #119328 - estebank:might_coerce_eq_typo, r=compiler-errors
Suggest `=` to `==` in more cases, even in the face of reference mismatch

Given `foo: &String` and `bar: str`, suggest `==` when given `if foo = bar {}`:

```
error[E0308]: mismatched types
  --> $DIR/assignment-expected-bool.rs:37:8
   |
LL |     if foo = bar {}
   |        ^^^^^^^^^ expected `bool`, found `()`
   |
help: you might have meant to compare for equality
   |
LL |     if foo == bar {}
   |             +
```
2023-12-27 00:22:27 +00:00
Esteban Küber
dc30eb1967 Suggest = to == in more cases, even in the face of reference mismatch
Given `foo: &String` and `bar: str`, suggest `==` when given `if foo = bar {}`:

```
error[E0308]: mismatched types
  --> $DIR/assignment-expected-bool.rs:37:8
   |
LL |     if foo = bar {}
   |        ^^^^^^^^^ expected `bool`, found `()`
   |
help: you might have meant to compare for equality
   |
LL |     if foo == bar {}
   |             +
```
2023-12-26 23:48:55 +00:00
Nadrieril
fc0be3c921 Keep reference to the original Pat in DeconstructedPat 2023-12-26 23:14:23 +01:00
bors
2df6406b88 Auto merge of #118431 - sjwang05:issue-44695, r=estebank
Emit better suggestions for `&T == T` and `T == &T`

Fixes #40660
Fixes #44695
2023-12-26 21:34:24 +00:00
Michael Howell
624885d242 rustdoc: treat query string + as space
Fixes #119219
2023-12-26 14:14:28 -07:00
bors
deace71034 Auto merge of #119324 - compiler-errors:rollup-c6eqcg9, r=compiler-errors
Rollup of 5 pull requests

Successful merges:

 - #119235 (Add missing feature gate for sanitizer CFI cfgs)
 - #119240 (Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s)
 - #119297 (Pass DeadItem and lint as consistent group in dead-code.)
 - #119307 (Clean up some lifetimes in `rustc_pattern_analysis`)
 - #119323 (add test for coercing never to infinite type)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-26 19:28:49 +00:00
Michael Goulet
a5b3d139b3
Rollup merge of #119323 - lukas-code:test-never-to-infinite, r=compiler-errors
add test for coercing never to infinite type

Closes https://github.com/rust-lang/rust/issues/113197.

This was fixed in https://github.com/rust-lang/rust/pull/118308, probably 1978168c13.
2023-12-26 13:29:14 -05:00
Michael Goulet
e1be642b41
Rollup merge of #119307 - compiler-errors:pat-lifetimes, r=Nadrieril
Clean up some lifetimes in `rustc_pattern_analysis`

This PR removes some redundant lifetimes. I figured out that we were shortening the lifetime of an arena-allocated `&'p DeconstructedPat<'p>` to `'a DeconstructedPat<'p>`, which forced us to carry both lifetimes when we could otherwise carry just one.

This PR also removes and elides some unnecessary lifetimes.

I also cherry-picked 0292eb9bb9b897f5c0926c6a8530877f67e7cc9b, and then simplified more lifetimes in `MatchVisitor`, which should make #119233 a very simple PR!

r? Nadrieril
2023-12-26 13:29:14 -05:00
Michael Goulet
65aaece6c0
Rollup merge of #119297 - cjgillot:issue-119267, r=petrochenkov
Pass DeadItem and lint as consistent group in dead-code.

Fixes https://github.com/rust-lang/rust/issues/119267
2023-12-26 13:29:13 -05:00
Michael Goulet
e7bd402a38
Rollup merge of #119240 - compiler-errors:lang-item-more, r=petrochenkov
Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s

The rest of 'em affect diagnostics, so leave them alone... for now.

cc #115178
2023-12-26 13:29:13 -05:00
Michael Goulet
50e380c8f3
Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, r=Nilstrieb
Add missing feature gate for sanitizer CFI cfgs

Found during the review of https://github.com/rust-lang/rust/pull/118494 in https://github.com/rust-lang/rust/pull/118494#discussion_r1416079288.

cc `@rcvalle`
2023-12-26 13:29:13 -05:00
bors
a75fed74b6 Auto merge of #119042 - bvanjoi:fix-118697-2, r=compiler-errors
fallback `default` to `None` during ast-lowering for lifetime binder

Fixes #118697

This is another attempt. It has a fallback, setting `default` to `None` and emit an error for non-lifetime binders during ast lowering.

r? `@compiler-errors`
2023-12-26 17:30:42 +00:00
Lukas Markeffsky
29036045c3 add test for coercing never to infinite type 2023-12-26 17:57:33 +01:00
Lukas Markeffsky
cb2fc0967f rename tests 2023-12-26 17:50:30 +01:00
bors
e1fadb2c35 Auto merge of #119133 - scottmcm:assert-unchecked, r=thomcc
Add `hint::assert_unchecked`

Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430

I think that means this is good for nightly, since we can always rename it before stabilization.

Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-26 15:31:44 +00:00
bors
2fe50cd72c Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank
rework `-Zverbose`

implements the changes described in https://github.com/rust-lang/compiler-team/issues/706

the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics.

possible follow up work:
- `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200
- `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`.

r? `@compiler-errors` cc `@estebank`
2023-12-26 12:27:29 +00:00
bors
ea7ef7b6c2 Auto merge of #119315 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2023-12-26 10:29:03 +00:00
bors
a815c3b69c Auto merge of #119313 - matthiaskrgr:rollup-41x48j6, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #119287 (Fix doc typo for read_exact_at)
 - #119294 (fix `./configure --set change-id`)
 - #119303 (Update sysinfo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-26 08:22:57 +00:00
bohan
e16efbd23a fallback default to None during ast-loweing for lifetime binder 2023-12-26 16:10:29 +08:00
Matthias Krüger
f7dc91f25f
Rollup merge of #119303 - GuillaumeGomez:update-sysinfo, r=onur-ozkan
Update sysinfo

A small bugfix was released for sysinfo so updating once again.

r? ``@onur-ozkan``
2023-12-26 08:48:34 +01:00
Matthias Krüger
c59de6b117
Rollup merge of #119294 - jyn514:configure-change-id, r=onur-ozkan
fix `./configure --set change-id`

the logic for this is kinda hacky and treats whitespace as significant d1e26401bc/src/bootstrap/configure.py (L485-L491)

r? ``@onur-ozkan``
2023-12-26 08:48:33 +01:00
Matthias Krüger
e1b3f45178
Rollup merge of #119287 - AlexBuz:patch-1, r=the8472
Fix doc typo for read_exact_at

This adds an "s" at the end of "byte" to make it plural, as it should be here.
2023-12-26 08:48:33 +01:00
bors
4658d3816c Auto merge of #3241 - rust-lang:rustup-2023-12-26, r=RalfJung
Automatic Rustup
2023-12-26 07:22:44 +00:00
bors
f6456285dd Auto merge of #119285 - lch361:split-no-panic, r=the8472
Removed redundant bounds checking at Split's next and next_back methods

Since these methods are using `Iterator::rposition`, which always returns a valid index, then there is no point in regular indexing with bounds checking
2023-12-26 06:24:22 +00:00
The Miri Conjob Bot
236ae9905a Merge from rustc 2023-12-26 05:00:54 +00:00
The Miri Conjob Bot
f2407d98de Preparing for merge from rustc 2023-12-26 04:54:17 +00:00
bors
1ab783112a Auto merge of #119258 - compiler-errors:closure-kind, r=eholk
Make closures carry their own ClosureKind

Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant.

This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine".

r? eholk
2023-12-26 04:25:53 +00:00
Michael Goulet
7e00e9736d Make some non-diagnostic-affecting QPath::LangItem into regular qpaths 2023-12-26 04:07:38 +00:00
Michael Goulet
48d089a800 Merge 'thir and 'p 2023-12-26 03:15:41 +00:00
Nadrieril
2b4f84f2b2 thir::Visitor only needs to visit &'thir data 2023-12-26 03:15:18 +00:00
bors
2271c26e4a Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, r=compiler-errors
Remove `DiagCtxt` API duplication

`DiagCtxt` defines the internal API for creating and emitting diagnostics: methods like `struct_err`, `struct_span_warn`, `note`, `create_fatal`, `emit_bug`. There are over 50 methods.

Some of these methods are then duplicated across several other types: `Session`, `ParseSess`, `Parser`, `ExtCtxt`, and `MirBorrowckCtxt`. `Session` duplicates the most, though half the ones it does are unused. Each duplicated method just calls forward to the corresponding method in `DiagCtxt`. So this duplication exists to (in the best case) shorten chains like `ecx.tcx.sess.parse_sess.dcx.emit_err()` to `ecx.emit_err()`.

This API duplication is ugly and has been bugging me for a while. And it's inconsistent: there's no real logic about which methods are duplicated, and the use of `#[rustc_lint_diagnostic]` and `#[track_caller]` attributes vary across the duplicates.

This PR removes the duplicated API methods and makes all diagnostic creation and emission go through `DiagCtxt`. It also adds `dcx` getter methods to several types to shorten chains. This approach scales *much* better than API duplication; indeed, the PR adds `dcx()` to numerous types that didn't have API duplication: `TyCtxt`, `LoweringCtxt`, `ConstCx`, `FnCtxt`, `TypeErrCtxt`, `InferCtxt`, `CrateLoader`, `CheckAttrVisitor`, and `Resolver`. These result in a lot of changes from `foo.tcx.sess.emit_err()` to `foo.dcx().emit_err()`. (You could do this with more types, but it gets into diminishing returns territory for types that don't emit many diagnostics.)

After all these changes, some call sites are more verbose, some are less verbose, and many are the same. The total number of lines is reduced, mostly because of the removed API duplication. And consistency is increased, because calls to `emit_err` and friends are always preceded with `.dcx()` or `.dcx`.

r? `@compiler-errors`
2023-12-26 02:24:39 +00:00
Michael Goulet
4ae024c754 Elide more lifetimes 2023-12-26 02:12:33 +00:00
Michael Goulet
ae40f6a7ff Clean up more lifetimes 2023-12-26 02:06:39 +00:00
Michael Goulet
b91a98ba10 Even more 2023-12-26 02:02:01 +00:00
Michael Goulet
eebb2abe0b Yeet some lifetimes 2023-12-26 01:59:18 +00:00