]> git.lizzy.rs Git - rust.git/log
rust.git
17 months agoMake sure FFI attrs aren't used on foreign statics
inquisitivecrystal [Tue, 24 Jan 2023 10:54:00 +0000 (02:54 -0800)]
Make sure FFI attrs aren't used on foreign statics

Previously, we verified that FFI attrs were used on foreign items,
but this allowed them on both foreign functions and foreign statics.
This change only allows them on foreign functions.

17 months agoMove FFI attribute validation to `check_attr`
inquisitivecrystal [Tue, 24 Jan 2023 10:19:04 +0000 (02:19 -0800)]
Move FFI attribute validation to `check_attr`

17 months agoAuto merge of #106294 - Nilstrieb:noundef-everything, r=nikic
bors [Tue, 17 Jan 2023 17:39:48 +0000 (17:39 +0000)]
Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikic

Put `noundef` on all scalars that don't allow uninit

Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. After #99182, this function now doesn't return uninit values anymore, making users of it safe from this change.

The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec). This is hopefully rare enough to not break anything.

cc `@nagisa` `@scottmcm` `@nikic`

17 months agoAdd more codegen tests
Nilstrieb [Fri, 30 Dec 2022 20:11:30 +0000 (21:11 +0100)]
Add more codegen tests

17 months agoAuto merge of #106984 - Dylan-DPC:rollup-xce8263, r=Dylan-DPC
bors [Tue, 17 Jan 2023 15:09:12 +0000 (15:09 +0000)]
Auto merge of #106984 - Dylan-DPC:rollup-xce8263, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #101698 (Constify `TypeId` ordering impls)
 - #106148 (Fix unused_parens issue for higher ranked function pointers)
 - #106922 (Avoid unsafe code in `to_ascii_[lower/upper]case()`)
 - #106951 (Remove ineffective run of SimplifyConstCondition)
 - #106962 (Fix use suggestion span)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106962 - compiler-errors:use-sugg-span, r=oli-obk
Dylan DPC [Tue, 17 Jan 2023 15:03:05 +0000 (20:33 +0530)]
Rollup merge of #106962 - compiler-errors:use-sugg-span, r=oli-obk

Fix use suggestion span

Fixes #106954

17 months agoRollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk
Dylan DPC [Tue, 17 Jan 2023 15:03:05 +0000 (20:33 +0530)]
Rollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk

Remove ineffective run of SimplifyConstCondition

There are no constant conditions at this stage.

17 months agoRollup merge of #106922 - ChayimFriedman2:patch-5, r=workingjubilee
Dylan DPC [Tue, 17 Jan 2023 15:03:04 +0000 (20:33 +0530)]
Rollup merge of #106922 - ChayimFriedman2:patch-5, r=workingjubilee

Avoid unsafe code in `to_ascii_[lower/upper]case()`

17 months agoRollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr
Dylan DPC [Tue, 17 Jan 2023 15:03:03 +0000 (20:33 +0530)]
Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr

Fix unused_parens issue for higher ranked function pointers

fixes #105061

r? `@lcnr`

17 months agoRollup merge of #101698 - raldone01:feat/const_cmp_typeid, r=scottmcm
Dylan DPC [Tue, 17 Jan 2023 15:03:03 +0000 (20:33 +0530)]
Rollup merge of #101698 - raldone01:feat/const_cmp_typeid, r=scottmcm

Constify `TypeId` ordering impls

Tracking issue: #101871

Adding const ordering to `TypeId` allows rtti crates to optimize some casting scenarios (without transmuting to `u64`). This would also prevent these crates from breaking if the underlying type is changed from `u64` to something different.

Feature gate: `#![feature(const_cmp_type_id)]`

17 months agoAuto merge of #106612 - JakobDegen:cleanup-wf, r=tmiasko
bors [Tue, 17 Jan 2023 11:34:35 +0000 (11:34 +0000)]
Auto merge of #106612 - JakobDegen:cleanup-wf, r=tmiasko

Document wf constraints on control flow in cleanup blocks

Was recently made aware of [this code](https://github.com/rust-lang/rust/blob/a377893da2cd7124e5a18c7116cbb70e16dd5541/compiler/rustc_codegen_ssa/src/mir/analyze.rs#L247-L368), which has this potential ICE: https://github.com/rust-lang/rust/blob/a377893da2cd7124e5a18c7116cbb70e16dd5541/compiler/rustc_codegen_ssa/src/mir/analyze.rs#L308-L314

Roughly speaking, the code there is attempting to partition the cleanup blocks into funclets that satisfy a "unique successor" property, and the ICE is set off if that's not possible. This PR documents the well-formedness constraints that MIR must satisfy to avoid setting off that ICE.

The constraints documented are slightly stronger than the cases in which the ICE would have been set off in that code. This is necessary though, since whether or not that ICE gets set off can depend on iteration order in some graphs.

This sort of constraint is kind of ugly, but I don't know a better alternative at the moment. It's worth knowing that two important optimizations are still correct:
 - Removing edges in the cfg: Fewer edges => fewer paths => stronger dominance relations => more contractions, and more contractions can't turn a forest into not-a-forest.
 - Contracting an edge u -> v when u only has one successor and v only has one predecessor: u already dominated v, so this contraction was going to happen anyway.

There is definitely a MIR opt somewhere that can run afoul of this, but I don't know where it is. `@saethlin` was able to set it off though, so maybe he'll be able to shed some light on it.

r? `@RalfJung` I suppose, and cc `@tmiasko` who might have insight/opinions on this

17 months agoAuto merge of #106627 - Ezrashaw:no-e0711-without-staged-api, r=Mark-Simulacrum
bors [Tue, 17 Jan 2023 07:20:32 +0000 (07:20 +0000)]
Auto merge of #106627 - Ezrashaw:no-e0711-without-staged-api, r=Mark-Simulacrum

fix: don't emit `E0711` if `staged_api` not enabled

Fixes #106589

Simple fix, added UI test.

As an aside, it seems a lot of features are susceptible to this, `E0711` stands out to me because it's perma-unstable and we are effectively exposing an implementation detail.

17 months agoImprove comments
Nilstrieb [Fri, 30 Dec 2022 20:11:17 +0000 (21:11 +0100)]
Improve comments

17 months agoPut `noundef` on all scalars that don't allow uninit
Nilstrieb [Fri, 30 Dec 2022 14:55:05 +0000 (15:55 +0100)]
Put `noundef` on all scalars that don't allow uninit

Previously, it was only put on scalars with range validity invariants
like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be
undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause
quite a lot of UB in the older parts of the ecosystem. This function now
doesn't return uninit values anymore, making users of it safe from this
change.

The only real sources of UB where people could encounter uninit
primitives are `MaybeUninit::uninit().assume_init()`, which has always
be clear in the docs about being UB and from heap allocations (like
reading from the spare capacity of a vec. This is hopefully rare enough
to not break anything.

17 months agoAuto merge of #106966 - matthiaskrgr:rollup-e34pevi, r=matthiaskrgr
bors [Tue, 17 Jan 2023 04:25:53 +0000 (04:25 +0000)]
Auto merge of #106966 - matthiaskrgr:rollup-e34pevi, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #106591 (suggestion for attempted integer identifier in patterns)
 - #106712 (make error emitted on `impl &Trait` nicer)
 - #106829 (Unify `Opaque`/`Projection` handling in region outlives code)
 - #106869 (rustdoc: remove redundant item kind class from `.item-decl > pre`)
 - #106949 (ConstBlocks are poly if their substs are poly)
 - #106953 (Document `EarlyBinder::subst_identity` and `skip_binder`)
 - #106958 (Don't add A-bootstrap to PRs modifying Cargo.lock)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106958 - jyn514:labels, r=m-ou-se
Matthias Krüger [Tue, 17 Jan 2023 04:25:23 +0000 (05:25 +0100)]
Rollup merge of #106958 - jyn514:labels, r=m-ou-se

Don't add A-bootstrap to PRs modifying Cargo.lock

Changing Cargo.lock is common even when adding dependencies between existing rustc crates.

cc https://github.com/rust-lang/rust/pull/103204#discussion_r1070268737, `@m-ou-se`

17 months agoRollup merge of #106953 - kylematsuda:early-binder-docs, r=jackh726
Matthias Krüger [Tue, 17 Jan 2023 04:25:23 +0000 (05:25 +0100)]
Rollup merge of #106953 - kylematsuda:early-binder-docs, r=jackh726

Document `EarlyBinder::subst_identity` and `skip_binder`

Finishing implementing #105779 will change several commonly used queries to return `EarlyBinder` by default. This PR adds documentation for two of the methods used to access data inside the `EarlyBinder`. I tried to summarize some of the [discussion from the issue](https://github.com/rust-lang/rust/issues/105779#issuecomment-1375512647) in writing this.

r? `@lcnr`

17 months agoRollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
Matthias Krüger [Tue, 17 Jan 2023 04:25:23 +0000 (05:25 +0100)]
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU

ConstBlocks are poly if their substs are poly

r? `@BoxyUwU`

fixes #106926

17 months agoRollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez
Matthias Krüger [Tue, 17 Jan 2023 04:25:22 +0000 (05:25 +0100)]
Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez

rustdoc: remove redundant item kind class from `.item-decl > pre`

This class originated in the very first commit of `rustdoc_ng`, and was used to add a color border around the item decl based on its kind.

https://github.com/rust-lang/rust/blob/4fd061c426902b0904c65e64a3780b21f9ab3afb/src/rustdoc_ng/html/static/main.css#L102-L106

The item decl no longer has a border, and there aren't any kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this PR is updating test cases so that they use `item-decl` to find the `<pre>` tag instead of relying on the fact that the class name had `rust {kind}` in it while other `<pre>` tags only had class `rust`.

17 months agoRollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Matthias Krüger [Tue, 17 Jan 2023 04:25:22 +0000 (05:25 +0100)]
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino

Unify `Opaque`/`Projection` handling in region outlives code

They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias`

r? types

17 months agoRollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank
Matthias Krüger [Tue, 17 Jan 2023 04:25:21 +0000 (05:25 +0100)]
Rollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank

make error emitted on `impl &Trait` nicer

Fixes #106694

Turned out to be simpler than I thought, also added UI test.

Before: ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bda53271ef3a8886793cf427b8cea91))
```text
error: expected one of `:`, ``@`,` or `|`, found `)`
 --> src/main.rs:2:22
  |
2 | fn foo(_: impl &Trait) {}
  |                      ^ expected one of `:`, ``@`,` or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a parameter name, give it a type
  |
2 | fn foo(_: impl Trait: &TypeName) {}
  |                ~~~~~~~~~~~~~~~~
help: if this is a type, explicitly ignore the parameter name
  |
2 | fn foo(_: impl _: &Trait) {}
  |                ++

error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |               -^ expected one of 9 possible tokens
  |               |
  |               help: missing `,`

error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           ^ expected one of 10 possible tokens
```

After:
```text
error: expected a trait, found type
 --> <anon>:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |                -^^^^^
  |                |
  |                help: consider removing the indirection

error: expected a trait, found type
 --> <anon>:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           -^^^^^
  |           |
  |           help: consider removing the indirection
```

17 months agoRollup merge of #106591 - Ezrashaw:attempted-integer-identifer, r=Estebank
Matthias Krüger [Tue, 17 Jan 2023 04:25:21 +0000 (05:25 +0100)]
Rollup merge of #106591 - Ezrashaw:attempted-integer-identifer, r=Estebank

suggestion for attempted integer identifier in patterns

Fixes #106552

Implemented a suggestion on `E0005` that occurs when no bindings are present and the pattern is a literal integer.

17 months agonote -> help
Michael Goulet [Tue, 17 Jan 2023 03:09:49 +0000 (03:09 +0000)]
note -> help

17 months agoFix use suggestion span
Michael Goulet [Tue, 17 Jan 2023 02:35:47 +0000 (02:35 +0000)]
Fix use suggestion span

17 months agoDon't add A-bootstrap to PRs modifying Cargo.lock
jyn [Tue, 17 Jan 2023 00:14:44 +0000 (18:14 -0600)]
Don't add A-bootstrap to PRs modifying Cargo.lock

Changing Cargo.lock is common even when adding dependencies between existing rustc crates.

17 months agoAvoid trivial checks on cleanup control flow in MIR validator
Jakob Degen [Mon, 16 Jan 2023 23:01:16 +0000 (15:01 -0800)]
Avoid trivial checks on cleanup control flow in MIR validator

17 months agoAdd cycle checking to cleanup control flow validation
Jakob Degen [Fri, 13 Jan 2023 16:32:54 +0000 (08:32 -0800)]
Add cycle checking to cleanup control flow validation

17 months agoDocument wf constraints on control flow in cleanup blocks
Jakob Degen [Mon, 9 Jan 2023 02:23:13 +0000 (18:23 -0800)]
Document wf constraints on control flow in cleanup blocks

Also fixes a bug in dominator computation

17 months agodocument EarlyBinder::subst_identity and skip_binder
Kyle Matsuda [Mon, 16 Jan 2023 18:55:27 +0000 (11:55 -0700)]
document EarlyBinder::subst_identity and skip_binder

17 months agoConstify `TypeId` ordering impls
onestacked [Mon, 16 Jan 2023 20:26:03 +0000 (21:26 +0100)]
Constify `TypeId` ordering impls

17 months agoProperly pluralize 'generic constants'
Michael Goulet [Mon, 16 Jan 2023 20:21:29 +0000 (20:21 +0000)]
Properly pluralize 'generic constants'

17 months agoConstBlocks are poly if their substs are poly
Michael Goulet [Mon, 16 Jan 2023 19:55:20 +0000 (19:55 +0000)]
ConstBlocks are poly if their substs are poly

17 months agoAuto merge of #106945 - matthiaskrgr:rollup-c5or8z3, r=matthiaskrgr
bors [Mon, 16 Jan 2023 19:30:08 +0000 (19:30 +0000)]
Auto merge of #106945 - matthiaskrgr:rollup-c5or8z3, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #105954 (Update instrument-coverage.md)
 - #106835 (new trait solver: rebase impl substs for gats correctly)
 - #106912 (check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736))
 - #106940 (Improve a TAIT error and add an error code plus documentation)
 - #106942 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106942 - rustbot:docs-update, r=ehuss
Matthias Krüger [Mon, 16 Jan 2023 19:29:40 +0000 (20:29 +0100)]
Rollup merge of #106942 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/book

1 commits in 2bd5d42c9956369132228da6409f0e68da56c51a..2cd1b5593d26dc6a03c20f8619187ad4b2485552
2023-01-12 14:47:47 UTC to 2023-01-12 14:47:47 UTC

- Typo (rust-lang/book#3457)

## rust-lang/nomicon

2 commits in 8ca261268068d80c0969260fff15199bad87b587..960d610e7f33889a2577f5f17c26f0d5c82b30df
2023-01-06 11:51:41 UTC to 2023-01-05 10:20:31 UTC

- vec/raw: Simplify `RawVec::grow` (rust-lang/nomicon#392)
- borrow-splitting: Use `take` instead of `replace` (rust-lang/nomicon#391)

## rust-lang/reference

4 commits in 3ae62681ff236d5528ef7c8c28ba7c6b2ecc6731..2cb0ed9ba56360949f492f9866afe8c293f9f9da
2023-01-13 03:16:35 UTC to 2023-01-07 00:08:06 UTC

- Update field-expr.md (rust-lang/reference#1318)
- Update documentation for arbitrary_enum_discriminant feature (rust-lang/reference#1055)
- Add links to definitions of terminology ... (rust-lang/reference#1315)
- Enable triagebot shortcuts (rust-lang/reference#1314)

## rust-lang/rust-by-example

2 commits in 8888f9428fe9a48f31de6bd2cef9b9bf80791edc..a9fb7d13eadfcc5f457962731f105b97f9a7474a
2023-01-14 10:25:39 UTC to 2023-01-11 18:25:42 UTC

- get_or_insert example: print my_fruit as intended (rust-lang/rust-by-example#1664)
- Update print.md (rust-lang/rust-by-example#1663)

## rust-lang/rustc-dev-guide

8 commits in b3e2a6e6c8a3aae5b5d950c63046f23bae07096d..7352353ae91c48b136d2ca7d03822e1448165e1e
2023-01-14 20:34:23 UTC to 2023-01-02 23:35:09 UTC

- fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (rust-lang/rustc-dev-guide#1557)
- Update incremental-compilation-in-detail.md (rust-lang/rustc-dev-guide#1553)
- Link to the youtube recording of my talk, not the summary (rust-lang/rustc-dev-guide#1554)
- Change `src/test` to `tests` (rust-lang/rustc-dev-guide#1547)
- add full name for ICE (rust-lang/rustc-dev-guide#1552)
- Fix incorrect links (rust-lang/rustc-dev-guide#1549)
- fix rebase link (rust-lang/rustc-dev-guide#1546)
- Add a section for how to review code more easily (rust-lang/rustc-dev-guide#1538)

17 months agoRollup merge of #106940 - oli-obk:tait_error, r=compiler-errors
Matthias Krüger [Mon, 16 Jan 2023 19:29:39 +0000 (20:29 +0100)]
Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors

Improve a TAIT error and add an error code plus documentation

cc https://github.com/rust-lang/rust/issues/106858

17 months agoRollup merge of #106912 - gftea:pr-106736, r=Nilstrieb
Matthias Krüger [Mon, 16 Jan 2023 19:29:39 +0000 (20:29 +0100)]
Rollup merge of #106912 - gftea:pr-106736, r=Nilstrieb

check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)

PR to solve #106736, r? `@cjgillot`

17 months agoRollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr
Matthias Krüger [Mon, 16 Jan 2023 19:29:38 +0000 (20:29 +0100)]
Rollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr

new trait solver: rebase impl substs for gats correctly

you might've caught this while working on projection code, if so then you can close this pr

r? `@lcnr`

17 months agoRollup merge of #105954 - gftea:patch-1, r=ehuss
Matthias Krüger [Mon, 16 Jan 2023 19:29:37 +0000 (20:29 +0100)]
Rollup merge of #105954 - gftea:patch-1, r=ehuss

Update instrument-coverage.md

explicitly set environment variable LLVM_PROFILE_FILE="default_%m.profraw"  when starting cargo test, otherwise, only one `default.profraw ` is generated and will be overwritten if run unnittests and integration tests at the same time.

17 months agoUpdate books
rustbot [Mon, 16 Jan 2023 17:01:00 +0000 (12:01 -0500)]
Update books

17 months agoImprove a TAIT error and add an error code plus documentation
Oli Scherer [Mon, 16 Jan 2023 15:15:09 +0000 (15:15 +0000)]
Improve a TAIT error and add an error code plus documentation

17 months agoAuto merge of #106853 - TimNN:undo-remap, r=oli-obk
bors [Mon, 16 Jan 2023 15:11:28 +0000 (15:11 +0000)]
Auto merge of #106853 - TimNN:undo-remap, r=oli-obk

Heuristically undo path prefix mappings.

Because the compiler produces better diagnostics if it can find the source of (potentially remapped) dependencies.

The new test fails without the other changes in this PR. Let me know if you have better suggestions for the test directory. I moved the existing remapping test to be in the same location as the new one.

Some more context: I'm exploring running UI tests with remapped paths by default in https://github.com/rust-lang/rust/pull/105924 and this was one of the issues discovered.

This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").

17 months agoUpdate instrument-coverage.md
gftea [Tue, 20 Dec 2022 13:45:19 +0000 (14:45 +0100)]
Update instrument-coverage.md

Document the default for LLVM_PROFILE_FILE and add a recemmondation for setting
it for older versions of Rust which had a different default.

17 months agocomments feedback
yukang [Mon, 16 Jan 2023 12:44:14 +0000 (20:44 +0800)]
comments feedback

17 months agoAuto merge of #106850 - cjgillot:issue-106141, r=oli-obk
bors [Mon, 16 Jan 2023 12:30:49 +0000 (12:30 +0000)]
Auto merge of #106850 - cjgillot:issue-106141, r=oli-obk

Make the inlining destination a Local.

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

17 months agocheck -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)
gftea [Sun, 15 Jan 2023 17:42:04 +0000 (18:42 +0100)]
check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)

17 months agoAuto merge of #106872 - dtolnay:nbsp, r=fee1-dead
bors [Mon, 16 Jan 2023 09:37:08 +0000 (09:37 +0000)]
Auto merge of #106872 - dtolnay:nbsp, r=fee1-dead

Emit only one nbsp error per file

Fixes #106101.

See https://github.com/rust-lang/rust/issues/106098 for an explanation of how someone would end up with a large number of these nbsp characters in their source code, which is why I think rustc needs to handle this specific case in a friendlier way.

17 months agoAuto merge of #106395 - compiler-errors:rework-predicates, r=eholk
bors [Mon, 16 Jan 2023 05:55:59 +0000 (05:55 +0000)]
Auto merge of #106395 - compiler-errors:rework-predicates, r=eholk

Rework some `predicates_of`/`{Generic,Instantiated}Predicates` code

1. Make `instantiate_own` return an iterator, since it's a bit more efficient and easier to work with
2. Remove `bound_{explicit,}_predicates_of` -- these `bound_` methods in particular were a bit awkward to work with since `ty::GenericPredicates` *already* acts kinda like an `EarlyBinder` with its own `instantiate_*` methods, and had only a few call sites anyways.
3. Implement `IntoIterator` for `InstantiatedPredicates`, since it's *very* commonly being `zip`'d together.

17 months agofix dropping diagnostic without emit
Ezra Shaw [Mon, 16 Jan 2023 03:18:56 +0000 (16:18 +1300)]
fix dropping diagnostic without emit

17 months agoAuto merge of #106907 - matthiaskrgr:rustdoc_ref, r=GuillaumeGomez
bors [Mon, 16 Jan 2023 02:43:25 +0000 (02:43 +0000)]
Auto merge of #106907 - matthiaskrgr:rustdoc_ref, r=GuillaumeGomez

rustdoc: simplify some & ref erences

17 months agoRemove ineffective run of SimplifyConstCondition
Tomasz Miąsko [Mon, 16 Jan 2023 00:00:00 +0000 (00:00 +0000)]
Remove ineffective run of SimplifyConstCondition

There are no constant conditions at this stage.

17 months agoAvoid unsafe code in `to_ascii_[lower/upper]case()`
Chayim Refael Friedman [Sun, 15 Jan 2023 23:15:06 +0000 (01:15 +0200)]
Avoid unsafe code in `to_ascii_[lower/upper]case()`

17 months agoAuto merge of #106914 - matthiaskrgr:rollup-yh0x4gq, r=matthiaskrgr
bors [Sun, 15 Jan 2023 21:35:50 +0000 (21:35 +0000)]
Auto merge of #106914 - matthiaskrgr:rollup-yh0x4gq, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #106888 (Add tidy check to ensure that rustdoc GUI tests start with a small description)
 - #106896 (suggest `is_empty` for collections when casting to `bool`)
 - #106900 (Fix regression in `unused_braces` with macros)
 - #106906 (remove redundant clones)
 - #106909 (Only suggest adding type param if path being resolved was a type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 20:17:36 +0000 (21:17 +0100)]
Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank

Only suggest adding type param if path being resolved was a type

17 months agoRollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 20:17:35 +0000 (21:17 +0100)]
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb

remove redundant clones

17 months agoRollup merge of #106900 - clubby789:unused-braces-regression, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 20:17:35 +0000 (21:17 +0100)]
Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebank

Fix regression in `unused_braces` with macros

Fixes #106899

17 months agoRollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 20:17:34 +0000 (21:17 +0100)]
Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors

suggest `is_empty` for collections when casting to `bool`

Fixes #106883

Matches on slices, `String` and `str`. It would be nice to do this with something like `Deref<Target=str>` as well, but AFAIK it's not possible in this part of the compiler.

17 months agoRollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddle
Matthias Krüger [Sun, 15 Jan 2023 20:17:34 +0000 (21:17 +0100)]
Rollup merge of #106888 - GuillaumeGomez:tidy-gui-test, r=notriddle

Add tidy check to ensure that rustdoc GUI tests start with a small description

The first commit comes from https://github.com/rust-lang/rust/pull/106865 to prevent CI to fail.

This PR adds a tidy check to enforce having a small description at the top of the GUI test. Although the format is made to be as easy as possible to read, it's not always obvious what a test is actually checking. I think enforcing this will make it easier for us to come back on these tests if needed.

r? `@notriddle`

17 months agoAuto merge of #106393 - the8472:use-ptr-sub, r=scottmcm
bors [Sun, 15 Jan 2023 18:39:40 +0000 (18:39 +0000)]
Auto merge of #106393 - the8472:use-ptr-sub, r=scottmcm

Simplify manual ptr arithmetic in slice::Iter with ptr_sub

The old code was introduced in #61885, which predates the ptr_sub method and underlying intrinsic. The codegen test still passes.

r? `@scottmcm`

17 months agoreplace manual ptr arithmetic with ptr_sub
The 8472 [Tue, 3 Jan 2023 01:39:13 +0000 (02:39 +0100)]
replace manual ptr arithmetic with ptr_sub

17 months agoOnly suggest adding type param if path being resolved was a type
Michael Goulet [Sun, 15 Jan 2023 16:33:08 +0000 (16:33 +0000)]
Only suggest adding type param if path being resolved was a type

17 months agoRemove bound_{explicit,}_item_bounds
Michael Goulet [Tue, 3 Jan 2023 05:01:17 +0000 (05:01 +0000)]
Remove bound_{explicit,}_item_bounds

17 months agodrive-by: assert when iterating through InstantiatedPredicates
Michael Goulet [Tue, 3 Jan 2023 03:38:06 +0000 (03:38 +0000)]
drive-by: assert when iterating through InstantiatedPredicates

17 months agoMake InstantiatedPredicates impl IntoIterator
Michael Goulet [Tue, 3 Jan 2023 03:32:59 +0000 (03:32 +0000)]
Make InstantiatedPredicates impl IntoIterator

17 months agoinstantiate_own doesn't need to return a pair of vectors
Michael Goulet [Tue, 3 Jan 2023 02:49:31 +0000 (02:49 +0000)]
instantiate_own doesn't need to return a pair of vectors

17 months agoAuto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr
bors [Sun, 15 Jan 2023 15:07:27 +0000 (15:07 +0000)]
Auto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr

Implement some FIXME methods in the new trait solver

Implement just enough of the solver's response logic to make it not ICE.

Also, fix a bug with `no_bound_vars` call failing due to canonical bound vars.

r? `@lcnr`

17 months agorustdoc: simplify some & ref erences
Matthias Krüger [Sun, 15 Jan 2023 14:23:30 +0000 (15:23 +0100)]
rustdoc: simplify some & ref erences

17 months agoremove redundant clones
Matthias Krüger [Sun, 15 Jan 2023 14:02:02 +0000 (15:02 +0100)]
remove redundant clones

17 months agoAuto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank...
bors [Sun, 15 Jan 2023 12:10:36 +0000 (12:10 +0000)]
Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank,lcnr

Consolidate two almost duplicated fn info extraction routines

Moves `extract_callable_info` up to trait selection, because it was being (almost) duplicated fully there for similar diagnostic purposes. This also generalizes the diagnostics we can give slightly (see UI test).

17 months agoAdd small description to GUI test
Guillaume Gomez [Sat, 14 Jan 2023 21:18:56 +0000 (22:18 +0100)]
Add small description to GUI test

17 months agoAdd tidy check to ensure that rustdoc GUI tests start with a small description
Guillaume Gomez [Sat, 14 Jan 2023 21:17:06 +0000 (22:17 +0100)]
Add tidy check to ensure that rustdoc GUI tests start with a small description

17 months agosuggest `is_empty` for collections when casting to `bool`
Ezra Shaw [Sun, 15 Jan 2023 02:51:52 +0000 (15:51 +1300)]
suggest `is_empty` for collections when casting to `bool`

17 months agoAuto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum
bors [Sun, 15 Jan 2023 08:59:55 +0000 (08:59 +0000)]
Auto merge of #105851 - dtolnay:peekmutleak, r=Mark-Simulacrum

Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met

In the libs-api team's discussion around #104210, some of the team had hesitations around exposing malformed BinaryHeaps of an element type whose Ord and Drop impls are trusted, and which does not contain interior mutability.

For example in the context of this kind of code:

```rust
use std::collections::BinaryHeap;
use std::ops::Range;
use std::slice;

fn main() {
    let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    let cut_points = BinaryHeap::from(vec![4, 2, 7]);
    println!("{:?}", chop(slice, cut_points));
}

// This is a souped up slice::split_at_mut to split in arbitrary many places.
//
// usize's Ord impl is trusted, so 1 single bounds check guarantees all those
// output slices are non-overlapping and in-bounds
fn chop<T>(slice: &mut [T], mut cut_points: BinaryHeap<usize>) -> Vec<&mut [T]> {
    let mut vec = Vec::with_capacity(cut_points.len() + 1);
    let max = match cut_points.pop() {
        Some(max) => max,
        None => {
            vec.push(slice);
            return vec;
        }
    };

    assert!(max <= slice.len());

    let len = slice.len();
    let ptr: *mut T = slice.as_mut_ptr();
    let get_unchecked_mut = unsafe {
        |range: Range<usize>| &mut *slice::from_raw_parts_mut(ptr.add(range.start), range.len())
    };

    vec.push(get_unchecked_mut(max..len));
    let mut end = max;
    while let Some(start) = cut_points.pop() {
        vec.push(get_unchecked_mut(start..end));
        end = start;
    }
    vec.push(get_unchecked_mut(0..end));
    vec
}
```

```console
[['7', '8', '9'], ['4', '5', '6'], ['2', '3'], ['0', '1']]
```

In the current BinaryHeap API, `peek_mut()` is the only thing that makes the above function unsound.

```rust
let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let mut cut_points = BinaryHeap::from(vec![4, 2, 7]);
{
    let mut max = cut_points.peek_mut().unwrap();
    *max = 0;
    std::mem::forget(max);
}
println!("{:?}", chop(slice, cut_points));
```

```console
[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], [], ['2', '3'], ['0', '1']]
```

Or worse:

```rust
let slice = &mut ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let mut cut_points = BinaryHeap::from(vec![100, 100]);
{
    let mut max = cut_points.peek_mut().unwrap();
    *max = 0;
    std::mem::forget(max);
}
println!("{:?}", chop(slice, cut_points));
```

```console
[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], [], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u{1}', '\0', '?', '翾', '?', '翾', '\0', '\0', '?', '翾', '?', '翾', '?', '啿', '?', '啿', '?', '啿', '?', '啿', '?', '啿', '?', '翾', '\0', '\0', '񤬐', '啿', '\u{5}', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\u{8}', '\0', '`@',` '\0', '\u{1}', '\0', '?', '翾', '?', '翾', '?', '翾', '
thread 'main' panicked at 'index out of bounds: the len is 33 but the index is 33', library/core/src/unicode/unicode_data.rs:319:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

---

This PR makes `peek_mut()` use leak amplification (https://doc.rust-lang.org/1.66.0/nomicon/leaking.html#drain) to preserve the heap's invariant even in the situation that `PeekMut` gets leaked.

I'll also follow up in the tracking issue of unstable `drain_sorted()` (#59278) and `retain()` (#71503).

17 months agoFix regression in `unused_braces` with macros
clubby789 [Sun, 15 Jan 2023 05:06:33 +0000 (05:06 +0000)]
Fix regression in `unused_braces` with macros

17 months agoAuto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgr
bors [Sun, 15 Jan 2023 00:16:09 +0000 (00:16 +0000)]
Auto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #106072 (fix: misleading "add dyn keyword before derive macro" suggestion)
 - #106859 (Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal)
 - #106863 (Remove various double spaces in compiler source comments.)
 - #106865 (Add explanation comment for GUI test)
 - #106867 (Fix the stability attributes for `std::os::fd`.)
 - #106878 (Add regression test for #92157)
 - #106879 (Add regression test for #42114)
 - #106880 (doc: fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoRollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper
Matthias Krüger [Sun, 15 Jan 2023 00:01:39 +0000 (01:01 +0100)]
Rollup merge of #106880 - tspiteri:borrowing-sub-typo, r=cuviper

doc: fix typo

17 months agoRollup merge of #106879 - JohnTitor:issue-42114, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 00:01:39 +0000 (01:01 +0100)]
Rollup merge of #106879 - JohnTitor:issue-42114, r=compiler-errors

Add regression test for #42114

Closes #42114
r? compiler-errors
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoRollup merge of #106878 - JohnTitor:issue-92157, r=compiler-errors
Matthias Krüger [Sun, 15 Jan 2023 00:01:38 +0000 (01:01 +0100)]
Rollup merge of #106878 - JohnTitor:issue-92157, r=compiler-errors

Add regression test for #92157

Closes #92157
r? compiler-errors
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoRollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se
Matthias Krüger [Sun, 15 Jan 2023 00:01:38 +0000 (01:01 +0100)]
Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, r=m-ou-se

Fix the stability attributes for `std::os::fd`.

As `@bjorn3` pointed out [here], I used the wrong stability attribute in #98368 when making `std::os::fd` public. I set it to Rust 1.63, which was when io-safety was stabilized, but it should be Rust 1.66, which was when `std::os::fd` was stabilized.

[here]: https://github.com/rust-lang/rust/pull/98368#discussion_r1063721420

17 months agoRollup merge of #106865 - GuillaumeGomez:add-gui-test-explanation, r=notriddle
Matthias Krüger [Sun, 15 Jan 2023 00:01:37 +0000 (01:01 +0100)]
Rollup merge of #106865 - GuillaumeGomez:add-gui-test-explanation, r=notriddle

Add explanation comment for GUI test

r? `@notriddle`

17 months agoRollup merge of #106863 - anden3:compiler-double-spaces, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 00:01:37 +0000 (01:01 +0100)]
Rollup merge of #106863 - anden3:compiler-double-spaces, r=Nilstrieb

Remove various double spaces in compiler source comments.

Was asked to do it by `@Nilstrieb`

17 months agoRollup merge of #106859 - tialaramex:master, r=Nilstrieb
Matthias Krüger [Sun, 15 Jan 2023 00:01:36 +0000 (01:01 +0100)]
Rollup merge of #106859 - tialaramex:master, r=Nilstrieb

Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal

Today Rust just points out that we have a char and we need a u8, but if I wrote 'A' then I could fix this by just writing b'A' instead. This code should detect the case where we're about to report a type mismatch of this kind, and the programmer wrote a char literal, and the char they wrote is ASCII, so therefore just prefixing b to make a byte literal will do what they meant.

I have definitely written this mistake more than once, it's not difficult to figure out what to do, but the compiler might as well tell us anyway.

I provided a test with two simple examples where the suggestion is appropriate, and one where it is not because the char literal is not ASCII, showing that the suggestion is only triggered in the former cases.

I have contributed only a small typo doc fix before, so this is my first substantive rustc change.

17 months agoRollup merge of #106072 - eopb:dyn-derive, r=estebank
Matthias Krüger [Sun, 15 Jan 2023 00:01:36 +0000 (01:01 +0100)]
Rollup merge of #106072 - eopb:dyn-derive, r=estebank

fix: misleading "add dyn keyword before derive macro" suggestion

Fixes #106071

17 months agomake error emitted on `impl &Trait` nicer
Ezra Shaw [Sat, 14 Jan 2023 08:20:20 +0000 (21:20 +1300)]
make error emitted on `impl &Trait` nicer

17 months agoDocument guarantees about BinaryHeap invariant
David Tolnay [Thu, 5 Jan 2023 08:04:59 +0000 (00:04 -0800)]
Document guarantees about BinaryHeap invariant

17 months agoLeak amplification for peek_mut() to ensure BinaryHeap's invariant is always met
David Tolnay [Sun, 18 Dec 2022 17:40:36 +0000 (09:40 -0800)]
Leak amplification for peek_mut() to ensure BinaryHeap's invariant is always met

17 months agoAdd test of leaking a binary_heap PeekMut
David Tolnay [Sun, 18 Dec 2022 17:40:23 +0000 (09:40 -0800)]
Add test of leaking a binary_heap PeekMut

17 months agoImprove E0308: suggest user meant to use byte literal, w/ tests and fix
Nick Lamb [Sat, 14 Jan 2023 14:51:17 +0000 (14:51 +0000)]
Improve E0308: suggest user meant to use byte literal, w/ tests and fix
suggested by Nilstrieb

Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
17 months agodoc: fix typo
Trevor Spiteri [Sat, 14 Jan 2023 21:09:14 +0000 (22:09 +0100)]
doc: fix typo

17 months agoAuto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr
bors [Sat, 14 Jan 2023 20:53:37 +0000 (20:53 +0000)]
Auto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #105526 (libcore: make result of iter::from_generator Clone)
 - #106563 (Fix `unused_braces` on generic const expr macro call)
 - #106661 (Stop probing for statx unless necessary)
 - #106820 (Deprioritize fulfillment errors that come from expansions.)
 - #106828 (rustdoc: remove `docblock` class from notable trait popover)
 - #106849 (Allocate one less vec while parsing arrays)
 - #106855 (rustdoc: few small cleanups)
 - #106860 (Remove various double spaces in the libraries.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

17 months agoAdd regression test for #42114
Yuki Okushi [Sat, 14 Jan 2023 20:52:22 +0000 (05:52 +0900)]
Add regression test for #42114

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoAdd regression test for #92157
Yuki Okushi [Sat, 14 Jan 2023 20:47:24 +0000 (05:47 +0900)]
Add regression test for #92157

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
17 months agoEmit only one nbsp error per file
David Tolnay [Sat, 14 Jan 2023 18:34:06 +0000 (10:34 -0800)]
Emit only one nbsp error per file

17 months agoAdd more nbsp to unicode-chars test
David Tolnay [Sat, 14 Jan 2023 19:02:14 +0000 (11:02 -0800)]
Add more nbsp to unicode-chars test

17 months agorustdoc: remove redundant item kind class from `.item-decl > pre`
Michael Howell [Sat, 14 Jan 2023 17:58:55 +0000 (10:58 -0700)]
rustdoc: remove redundant item kind class from `.item-decl > pre`

This class originated in the very first commit of `rustdoc_ng`, and was used
to add a color border around the item decl based on its kind.

https://github.com/rust-lang/rust/blob/4fd061c426902b0904c65e64a3780b21f9ab3afb/src/rustdoc_ng/html/static/main.css#L102-L106

The item decl no longer has a border, and there aren't any
kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this commit is updating test cases so that they use `item-decl` to
find the `<pre>` tag instead of relying on the fact that the class name
had `rust {kind}` in it while other `<pre>` tags only had class `rust`.

17 months agoFix the stability attributes for `std::os::fd`.
Dan Gohman [Sat, 14 Jan 2023 17:35:42 +0000 (09:35 -0800)]
Fix the stability attributes for `std::os::fd`.

As @bjorn3 pointed out [here], I used the wrong stability attribute in #98368
when making `std::os::fd` public. I set it to Rust 1.63, which was when
io-safety was stabilized, but it should be Rust 1.66, which was when
`std::os::fd` was stabilized.

[here]: https://github.com/rust-lang/rust/pull/98368#discussion_r1063721420

17 months agoRollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC
Matthias Krüger [Sat, 14 Jan 2023 17:45:29 +0000 (18:45 +0100)]
Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPC

Remove various double spaces in the libraries.

I was just pretty bothered by this when reading the source for a function, and was suggested to check if this happened elsewhere.

17 months agoRollup merge of #106855 - klensy:rd-s, r=notriddle
Matthias Krüger [Sat, 14 Jan 2023 17:45:28 +0000 (18:45 +0100)]
Rollup merge of #106855 - klensy:rd-s, r=notriddle

rustdoc: few small cleanups

17 months agoRollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb
Matthias Krüger [Sat, 14 Jan 2023 17:45:28 +0000 (18:45 +0100)]
Rollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb

Allocate one less vec while parsing arrays

Probably does not matter, but imo a little bit nicer.

17 months agoRollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, r=GuillaumeGomez
Matthias Krüger [Sat, 14 Jan 2023 17:45:27 +0000 (18:45 +0100)]
Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, r=GuillaumeGomez

rustdoc: remove `docblock` class from notable trait popover

This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl.

Fixes #92974

17 months agoRollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebank
Matthias Krüger [Sat, 14 Jan 2023 17:45:27 +0000 (18:45 +0100)]
Rollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebank

Deprioritize fulfillment errors that come from expansions.

Fixes (part of?) #69455