]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoerror::Error: rename the Demand arguments from req to demand
Nick Cameron [Wed, 24 Aug 2022 14:17:17 +0000 (15:17 +0100)]
error::Error: rename the Demand arguments from req to demand

Signed-off-by: Nick Cameron <nrc@ncameron.org>
22 months agoerror::Error: rename the chain method to sources
Nick Cameron [Wed, 24 Aug 2022 14:14:51 +0000 (15:14 +0100)]
error::Error: rename the chain method to sources

Signed-off-by: Nick Cameron <nrc@ncameron.org>
22 months agoAuto merge of #100942 - ehuss:update-cargo, r=ehuss
bors [Wed, 24 Aug 2022 05:34:43 +0000 (05:34 +0000)]
Auto merge of #100942 - ehuss:update-cargo, r=ehuss

Update cargo

7 commits in 9809f8ff33c2b998919fd0432c626f0f7323697a..6da726708a4406f31f996d813790818dce837161
2022-08-16 22:10:06 +0000 to 2022-08-23 21:39:56 +0000
- Update non-ASCII crate name warning message (rust-lang/cargo#11017)
- Add more tests for aggressive or precise update (rust-lang/cargo#11011)
- Ignore broken but excluded file during traversing (rust-lang/cargo#11008)
- Improve error message for wrong target names (rust-lang/cargo#10999)
- Bump snapbox to 0.3 (rust-lang/cargo#11005)
- remove missed reference to workspace inheritance in unstable.md (rust-lang/cargo#11001)
- Warning when precise or aggressive without -p flag (rust-lang/cargo#10988)

22 months agoUpdate cargo
Eric Huss [Wed, 24 Aug 2022 03:58:12 +0000 (20:58 -0700)]
Update cargo

22 months agoAuto merge of #96869 - sunfishcode:main, r=joshtriplett
bors [Wed, 24 Aug 2022 01:17:52 +0000 (01:17 +0000)]
Auto merge of #96869 - sunfishcode:main, r=joshtriplett

Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8.

Add a `is_known_utf8` flag to `Wtf8Buf`, which tracks whether the
string is known to contain UTF-8. This is efficiently computed in many
common situations, such as when a `Wtf8Buf` is constructed from a `String`
or `&str`, or with `Wtf8Buf::from_wide` which is already doing UTF-16
decoding and already checking for surrogates.

This makes `OsString::into_string` O(1) rather than O(N) on Windows in
common cases.

And, it eliminates the need to scan through the string for surrogates in
`Args::next` and `Vars::next`, because the strings are already being
translated with `Wtf8Buf::from_wide`.

Many things on Windows construct `OsString`s with `Wtf8Buf::from_wide`,
such as `DirEntry::file_name` and `fs::read_link`, so with this patch,
users of those functions can subsequently call `.into_string()` without
paying for an extra scan through the string for surrogates.

r? `@ghost`

22 months agoAuto merge of #100675 - Xiretza:fluent-mandate-crate-prefix, r=davidtwco
bors [Tue, 23 Aug 2022 22:30:07 +0000 (22:30 +0000)]
Auto merge of #100675 - Xiretza:fluent-mandate-crate-prefix, r=davidtwco

fluent: mandate slug names to be prefixed by crate name

This is currently only convention, but not actively checked for.

Additionally, improve error messages to highlight the path of the offending fluent file rather than the identifier preceding it.

This will conflict with #100671, so I'll leave it as draft until that's merged.

22 months agoAuto merge of #99917 - yaahc:error-in-core-move, r=thomcc
bors [Tue, 23 Aug 2022 19:48:55 +0000 (19:48 +0000)]
Auto merge of #99917 - yaahc:error-in-core-move, r=thomcc

Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of https://github.com/rust-lang/rust/pull/90328 using new compiler features that have been added to support error in core.

22 months agoAuto merge of #100920 - Dylan-DPC:rollup-vlcw3sr, r=Dylan-DPC
bors [Tue, 23 Aug 2022 15:12:09 +0000 (15:12 +0000)]
Auto merge of #100920 - Dylan-DPC:rollup-vlcw3sr, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #99249 (Do not re-parse function signatures to suggest generics)
 - #100309 (Extend comma suggestion to cases where fields arent missing)
 - #100368 (InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed>)
 - #100768 (Migrate `rustc_plugin_impl` to `SessionDiagnostic`)
 - #100835 (net listen backlog update, follow-up from #97963.)
 - #100851 (Fix rustc_parse_format precision & width spans)
 - #100857 (Refactor query modifier parsing)
 - #100907 (Fix typo in UnreachableProp)
 - #100909 (Minor `ast::LitKind` improvements)

Failed merges:

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

22 months agoRollup merge of #100909 - nnethercote:minor-ast-LitKind-improvement, r=petrochenkov
Dylan DPC [Tue, 23 Aug 2022 15:10:09 +0000 (20:40 +0530)]
Rollup merge of #100909 - nnethercote:minor-ast-LitKind-improvement, r=petrochenkov

Minor `ast::LitKind` improvements

r? `@petrochenkov`

22 months agoRollup merge of #100907 - Nilstrieb:unrachable-typo-lol, r=Dylan-DPC
Dylan DPC [Tue, 23 Aug 2022 15:10:08 +0000 (20:40 +0530)]
Rollup merge of #100907 - Nilstrieb:unrachable-typo-lol, r=Dylan-DPC

Fix typo in UnreachableProp

r? ``@Dylan-DPC``

22 months agoRollup merge of #100857 - camsteffen:query-parse-refactor, r=davidtwco
Dylan DPC [Tue, 23 Aug 2022 15:10:07 +0000 (20:40 +0530)]
Rollup merge of #100857 - camsteffen:query-parse-refactor, r=davidtwco

Refactor query modifier parsing

Reduce redundancy and improve error spans.

22 months agoRollup merge of #100851 - Alexendoo:rpf-width-prec-spans, r=fee1-dead
Dylan DPC [Tue, 23 Aug 2022 15:10:06 +0000 (20:40 +0530)]
Rollup merge of #100851 - Alexendoo:rpf-width-prec-spans, r=fee1-dead

Fix rustc_parse_format precision & width spans

When a `precision`/`width` was `CountIsName - {:name$}` or `CountIs - {:10}` the `precision_span`/`width_span` was set to `None`

For `width` the name span in `CountIsName(_, name_span)` had its `.start` off by one

r? ``@fee1-dead`` / cc ``@PrestonFrom`` since this is similar to #99987

22 months agoRollup merge of #100835 - devnexen:listener_followups, r=devnexen
Dylan DPC [Tue, 23 Aug 2022 15:10:05 +0000 (20:40 +0530)]
Rollup merge of #100835 - devnexen:listener_followups, r=devnexen

net listen backlog update, follow-up from #97963.

FreeBSD and using system limit instead for others.

22 months agoRollup merge of #100768 - Facel3ss1:plugin-impl-translation, r=davidtwco
Dylan DPC [Tue, 23 Aug 2022 15:10:04 +0000 (20:40 +0530)]
Rollup merge of #100768 - Facel3ss1:plugin-impl-translation, r=davidtwco

Migrate `rustc_plugin_impl` to `SessionDiagnostic`

Migration of the `rustc_plugin_impl` crate.
~Draft PR because it is blocked on #100694 for `#[fatal(...)]` support~ (this has been merged, and I've changed over to `#[diag(...)]` now too), but I would also like to know if what I did with `LoadPluginError` is okay, because all it does is display the error message from `libloading` ([See conversation on zulip](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.23100717.20diagnostic.20translation/near/294327843)). This crate is apparently for a deprecated feature which is used by servo, so I don't know how much this matters anyway.

22 months agoRollup merge of #100368 - chenyukang:fix-100321, r=lcnr
Dylan DPC [Tue, 23 Aug 2022 15:10:03 +0000 (20:40 +0530)]
Rollup merge of #100368 - chenyukang:fix-100321, r=lcnr

InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed>

Fixes #100321.
Use Cell<Option<ErrorGuaranteed>> to guarantee that we emit an error when that flag is set.

22 months agoRollup merge of #100309 - compiler-errors:issue-100300, r=sanxiyn
Dylan DPC [Tue, 23 Aug 2022 15:10:02 +0000 (20:40 +0530)]
Rollup merge of #100309 - compiler-errors:issue-100300, r=sanxiyn

Extend comma suggestion to cases where fields arent missing

Fixes #100300

22 months agoRollup merge of #99249 - cjgillot:no-reparse-fn, r=fee1-dead
Dylan DPC [Tue, 23 Aug 2022 15:10:01 +0000 (20:40 +0530)]
Rollup merge of #99249 - cjgillot:no-reparse-fn, r=fee1-dead

Do not re-parse function signatures to suggest generics

This PR uses the existing resolution rib infrastructure to channel the correct span information to suggest generic parameters.  This allows to avoid re-parsing a function's source code.

Drive-by cleanup: this removes useless `FnItemRibKind` from late resolution ribs.  All the use cases are already covered by `ItemRibKind` and `AssocItemRibKind` which have more precise semantics.

22 months agoAuto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum
bors [Tue, 23 Aug 2022 08:09:19 +0000 (08:09 +0000)]
Auto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum

Align android `sigaddset` impl with the reference impl from Bionic

In https://github.com/rust-lang/rust/pull/100737 I noticed we were treating the sigset_t as an array of bytes, while referencing code from android (https://github.com/aosp-mirror/platform_bionic/blob/ad8dcd6023294b646e5a8288c0ed431b0845da49/libc/include/android/legacy_signal_inlines.h) which treats it as an array of unsigned long.

That said, the behavior difference is so subtle here that it's not hard to see why nobody noticed. This fixes the implementation to be equivalent to the one in bionic.

22 months agoRemove the symbol from `ast::LitKind::Err`.
Nicholas Nethercote [Mon, 22 Aug 2022 03:27:52 +0000 (13:27 +1000)]
Remove the symbol from `ast::LitKind::Err`.

Because it's never used meaningfully.

22 months agoAdd some useful comments to `LitKind`.
Nicholas Nethercote [Mon, 22 Aug 2022 03:38:19 +0000 (13:38 +1000)]
Add some useful comments to `LitKind`.

22 months agoFix typo in UnreachableProp
nils [Tue, 23 Aug 2022 06:18:18 +0000 (08:18 +0200)]
Fix typo in UnreachableProp

22 months agoAuto merge of #100904 - matthiaskrgr:rollup-z3yzivj, r=matthiaskrgr
bors [Tue, 23 Aug 2022 05:22:05 +0000 (05:22 +0000)]
Auto merge of #100904 - matthiaskrgr:rollup-z3yzivj, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #100382 (Make the GATS self outlives error take into GATs in the inputs)
 - #100565 (Suggest adding a missing semicolon before an item)
 - #100641 (Add the armv4t-none-eabi target to the supported_targets)
 - #100789 (Use separate infcx to solve obligations during negative coherence)
 - #100832 (Some small bootstrap cleanup)
 - #100861 (fix ICE with extra-const-ub-checks)
 - #100862 (tidy: remove crossbeam-utils)
 - #100887 (Refactor part of codegen_call_terminator)
 - #100893 (Remove out-of-context comment in `mem::MaybeUninit` documentation)

Failed merges:

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

22 months agoRollup merge of #100893 - thinety:master, r=scottmcm
Matthias Krüger [Tue, 23 Aug 2022 04:55:31 +0000 (06:55 +0200)]
Rollup merge of #100893 - thinety:master, r=scottmcm

Remove out-of-context comment in `mem::MaybeUninit` documentation

Reverted the comment to an earlier version to avoid confusion: neither raw pointer assignment nor `ptr::write` is used inside the for loop.

22 months agoRollup merge of #100887 - eholk:codegen_call_terminator-cleanup, r=fee1-dead
Matthias Krüger [Tue, 23 Aug 2022 04:55:30 +0000 (06:55 +0200)]
Rollup merge of #100887 - eholk:codegen_call_terminator-cleanup, r=fee1-dead

Refactor part of codegen_call_terminator

I was reading through this code and found the chain of `if let` and a nested match on the same value that was matched in the `if let` to be kind of hard to follow. This PR cleans it up by flattening the `if let` chain and nested match into a single `match` expression.

22 months agoRollup merge of #100862 - ehuss:tidy-crossbeam, r=Mark-Simulacrum
Matthias Krüger [Tue, 23 Aug 2022 04:55:29 +0000 (06:55 +0200)]
Rollup merge of #100862 - ehuss:tidy-crossbeam, r=Mark-Simulacrum

tidy: remove crossbeam-utils

crossbeam-utils is no longer needed now that scoped threads are available in 1.63.

22 months agoRollup merge of #100861 - RalfJung:const-ice, r=oli-obk
Matthias Krüger [Tue, 23 Aug 2022 04:55:28 +0000 (06:55 +0200)]
Rollup merge of #100861 - RalfJung:const-ice, r=oli-obk

fix ICE with extra-const-ub-checks

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

22 months agoRollup merge of #100832 - ehuss:bootstrap-cleanup, r=jyn514
Matthias Krüger [Tue, 23 Aug 2022 04:55:27 +0000 (06:55 +0200)]
Rollup merge of #100832 - ehuss:bootstrap-cleanup, r=jyn514

Some small bootstrap cleanup

This is a collection of a few small cleanups. See commits for more details.

* Remove some unused fields from the tool_extended macro.
* Remove rustfmt from publish_toolstate.
* Remove Steve from toolstate failure notices.
* Don't allow rustfmt to fail on dist.

22 months agoRollup merge of #100789 - compiler-errors:issue-99662, r=spastorino
Matthias Krüger [Tue, 23 Aug 2022 04:55:26 +0000 (06:55 +0200)]
Rollup merge of #100789 - compiler-errors:issue-99662, r=spastorino

Use separate infcx to solve obligations during negative coherence

I feel like I fixed this already but I may have fixed it then forgot to push the branch...

Also fixes up some redundant param-envs being passed around (since they're already passed around in the `Obligation`)

Fixes #99662

r? ``@spastorino``

22 months agoRollup merge of #100641 - corwinkuiper:add-armv4t-target, r=oli-obk
Matthias Krüger [Tue, 23 Aug 2022 04:55:25 +0000 (06:55 +0200)]
Rollup merge of #100641 - corwinkuiper:add-armv4t-target, r=oli-obk

Add the armv4t-none-eabi target to the supported_targets

This target was added in #100244 but forgot to add it to the macro in the `mod.rs` file.

``@Lokathor``

22 months agoRollup merge of #100565 - TaKO8Ki:suggest-adding-missing-semicolon-before-item, r...
Matthias Krüger [Tue, 23 Aug 2022 04:55:24 +0000 (06:55 +0200)]
Rollup merge of #100565 - TaKO8Ki:suggest-adding-missing-semicolon-before-item, r=compiler-errors

Suggest adding a missing semicolon before an item

fixes #100533

22 months agoRollup merge of #100382 - jackh726:gat-self-outlives-input, r=compiler-errors
Matthias Krüger [Tue, 23 Aug 2022 04:55:23 +0000 (06:55 +0200)]
Rollup merge of #100382 - jackh726:gat-self-outlives-input, r=compiler-errors

Make the GATS self outlives error take into GATs in the inputs

Before, the reasoning was that outlives should factor in to the outlives error, because that value is produced and inputs aren't. However, this is potentially confusing, and we can just require this for now and relax it later if we need. GATs in where clauses still don't count for the self outlives error, and I've added a test for that.

This now errors:
```rust
trait Input {
    type Item<'a>;
    //~^ missing required
    fn takes_item<'a>(&'a self, item: Self::Item<'a>);
}
```

I've also added a test that this does not:
```rust
trait WhereClause {
    type Item<'a>;
    fn takes_item<'a>(&'a self) where Self::Item<'a>: ;
}
```

r? ``@compiler-errors``

22 months agoAuto merge of #100678 - GuillaumeGomez:improve-rustdoc-json-tests, r=aDotInTheVoid
bors [Tue, 23 Aug 2022 02:40:52 +0000 (02:40 +0000)]
Auto merge of #100678 - GuillaumeGomez:improve-rustdoc-json-tests, r=aDotInTheVoid

Improve rustdoc json tests

Fixes #100588.

r? `@aDotInTheVoid`

22 months agoAuto merge of #99963 - cjgillot:iter-submodule, r=compiler-errors
bors [Mon, 22 Aug 2022 23:09:35 +0000 (23:09 +0000)]
Auto merge of #99963 - cjgillot:iter-submodule, r=compiler-errors

Simplify implementation for par_for_each_module

22 months agoRemove out-of-context comment in `mem::MaybeUninit` documentation
Thiago Trannin [Mon, 22 Aug 2022 23:03:53 +0000 (20:03 -0300)]
Remove out-of-context comment in `mem::MaybeUninit` documentation

22 months agoMark suggestion as MaybeIncorrect.
Camille GILLOT [Mon, 22 Aug 2022 22:09:58 +0000 (00:09 +0200)]
Mark suggestion as MaybeIncorrect.

22 months agoRemove FnItemRibKind.
Camille GILLOT [Thu, 14 Jul 2022 15:40:43 +0000 (17:40 +0200)]
Remove FnItemRibKind.

22 months agoRemove generate_fn_name_span and generate_local_type_param_snippet.
Camille GILLOT [Thu, 14 Jul 2022 15:28:34 +0000 (17:28 +0200)]
Remove generate_fn_name_span and generate_local_type_param_snippet.

22 months agoDo not call generate_fn_name_span in typeck.
Camille GILLOT [Thu, 14 Jul 2022 15:27:49 +0000 (17:27 +0200)]
Do not call generate_fn_name_span in typeck.

22 months agoImprove local generic parameter suggestions.
Camille GILLOT [Thu, 14 Jul 2022 13:09:30 +0000 (15:09 +0200)]
Improve local generic parameter suggestions.

22 months agoCreate specific ConstantHasGenerics for ConstantItemRibKind.
Camille GILLOT [Thu, 14 Jul 2022 12:54:53 +0000 (14:54 +0200)]
Create specific ConstantHasGenerics for ConstantItemRibKind.

22 months agoMove error trait into core
Jane Losare-Lusby [Fri, 29 Jul 2022 18:54:47 +0000 (18:54 +0000)]
Move error trait into core

22 months agoAuto merge of #99762 - Nilstrieb:unreachable-prop, r=oli-obk
bors [Mon, 22 Aug 2022 20:28:16 +0000 (20:28 +0000)]
Auto merge of #99762 - Nilstrieb:unreachable-prop, r=oli-obk

UnreachableProp: Preserve unreachable branches for multiple targets

Before, UnreachablePropagation removed all unreachable branches. This was a pessimization, as it removed information about reachability that was used later in the optimization pipeline.

For example, this code
```rust
pub enum Two { A, B }
pub fn identity(x: Two) -> Two {
    match x {
        Two::A => Two::A,
        Two::B => Two::B,
    }
}
```

basically has `switchInt() -> [0: 0, 1: 1, otherwise: unreachable]` for the match. This allows it to be transformed into a simple `x`. If we remove the unreachable branch, the transformation becomes illegal.

This was the problem keeping `UnreachablePropagation` from being enabled, so we can enable it now.

Something similar already happened in #77800, but it did not show a perf improvement there. Let's try it again anyways!

Fixes #68105, although that issue has been fixed for a long time (see #77680).

22 months agoRefactor part of codegen_call_terminator
Eric Holk [Mon, 22 Aug 2022 18:25:56 +0000 (11:25 -0700)]
Refactor part of codegen_call_terminator

22 months agoAuto merge of #100881 - Dylan-DPC:rollup-q9rr658, r=Dylan-DPC
bors [Mon, 22 Aug 2022 17:46:57 +0000 (17:46 +0000)]
Auto merge of #100881 - Dylan-DPC:rollup-q9rr658, r=Dylan-DPC

Rollup of 8 pull requests

Successful merges:

 - #98200 (Expand potential inner `Or` pattern for THIR)
 - #99770 (Make some const prop mir-opt tests `unit-test`s)
 - #99957 (Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase)
 - #100331 (Guarantee `try_reserve` preserves the contents on error)
 - #100336 (Fix two const_trait_impl issues)
 - #100713 (Convert diagnostics in parser/expr to SessionDiagnostic)
 - #100820 (Use pointer `is_aligned*` methods)
 - #100872 (Add guarantee that Vec::default() does not alloc)

Failed merges:

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

22 months agoMigrate rustc_plugin_impl to SessionDiagnostic
Peter Medus [Fri, 19 Aug 2022 17:29:33 +0000 (18:29 +0100)]
Migrate rustc_plugin_impl to SessionDiagnostic

22 months agonet listen backlog update, follow-up from #97963.
David CARLIER [Sun, 21 Aug 2022 05:58:51 +0000 (06:58 +0100)]
net listen backlog update, follow-up from #97963.

FreeBSD and using system limit instead for others.

22 months agoRollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead
Dylan DPC [Mon, 22 Aug 2022 15:04:16 +0000 (20:34 +0530)]
Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead

Add guarantee that Vec::default() does not alloc

Currently `Vec::new()` is guaranteed to not allocate until elements are pushed onto the `Vec`, but such a guarantee is missing for `Vec`'s implementation of `Default::default`.

This adds such a guarantee for `Vec::default()` to the API reference.

See also [this discussion on URLO](https://users.rust-lang.org/t/guarantee-that-vec-default-does-not-allocate/79903).

22 months agoRollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=scottmcm
Dylan DPC [Mon, 22 Aug 2022 15:04:15 +0000 (20:34 +0530)]
Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=scottmcm

Use pointer `is_aligned*` methods

This PR replaces some manual alignment checks with calls to `pointer::{is_aligned, is_aligned_to}` and removes a useless pointer cast.

r? `@scottmcm`

_split off from #100746_

22 months agoRollup merge of #100713 - Xiretza:parser-expr-session-diagnostics, r=estebank
Dylan DPC [Mon, 22 Aug 2022 15:04:14 +0000 (20:34 +0530)]
Rollup merge of #100713 - Xiretza:parser-expr-session-diagnostics, r=estebank

Convert diagnostics in parser/expr to SessionDiagnostic

This migrates all the easy cases in `rustc_parse::parser::expr` to `SessionDiagnostic`s, I've left things such as `multipart_suggestion`s out for now in the hopes of a derive API being developed soon.

22 months agoRollup merge of #100336 - fee1-dead-contrib:fix-wf-const-trait, r=oli-obk
Dylan DPC [Mon, 22 Aug 2022 15:04:13 +0000 (20:34 +0530)]
Rollup merge of #100336 - fee1-dead-contrib:fix-wf-const-trait, r=oli-obk

Fix two const_trait_impl issues

r? ``@oli-obk``

Fixes #100222.
Fixes #100543.

22 months agoRollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=thomcc
Dylan DPC [Mon, 22 Aug 2022 15:04:12 +0000 (20:34 +0530)]
Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=thomcc

Guarantee `try_reserve` preserves the contents on error

Update doc comments to make the guarantee explicit. However, some
implementations does not have the statement though.

* `HashMap`, `HashSet`: require guarantees on hashbrown side.
* `PathBuf`: simply redirecting to `OsString`.

Fixes #99606.

22 months agoRollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mark-Simulacrum
Dylan DPC [Mon, 22 Aug 2022 15:04:10 +0000 (20:34 +0530)]
Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mark-Simulacrum

Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase

Rebasing of pull request #86634 off of master to try and get the feature "ip" stabilized.

I also found a test failure in the rebase that is_global was considering the benchmark space to be globally reachable.

This is related to my other rebasing pull request #99947

22 months agoRollup merge of #99770 - Nilstrieb:mir-pass-unit-test, r=oli-obk
Dylan DPC [Mon, 22 Aug 2022 15:04:09 +0000 (20:34 +0530)]
Rollup merge of #99770 - Nilstrieb:mir-pass-unit-test, r=oli-obk

Make some const prop mir-opt tests `unit-test`s

Most of these have no or only tiny diffs beyond line numbers being changed (would it make sense to not have line numbers in mir-opt tests?). Some things changed a bit, but I think it should all be fine, not sure though.

22 months agoRollup merge of #98200 - ouz-a:issue-98177, r=oli-obk
Dylan DPC [Mon, 22 Aug 2022 15:04:08 +0000 (20:34 +0530)]
Rollup merge of #98200 - ouz-a:issue-98177, r=oli-obk

Expand potential inner `Or` pattern for THIR

Code assumed there wouldn't be a deeper `Or` pattern inside expanded `PatStack` this fixes it by looking for the `Or` pattern inside expanded `PatStack`.

A more ideal solution would be recursively doing this but I haven't found a good way to do that.
_fixes #97898_

22 months agoAuto merge of #99908 - Nilstrieb:mir-opt-span, r=oli-obk
bors [Mon, 22 Aug 2022 14:59:21 +0000 (14:59 +0000)]
Auto merge of #99908 - Nilstrieb:mir-opt-span, r=oli-obk

Show absolute line numbers if span is outside relative span

In the MIR pretty printing, it can sometimes happen that the span of the statement is outside the span of the body (for example through inlining). In this case, don't display a relative span but an absolute span. This will make the mir-opt-tests a little more prone to diffs again, but the impact should be small.

Fixes #99854

r? `@oli-obk`

22 months agoremove hack fix since we don't have no overflow diagnostic
yukang [Mon, 22 Aug 2022 14:22:15 +0000 (22:22 +0800)]
remove hack fix since we don't have no overflow diagnostic

22 months agoInferCtxt emit error when incorrectly tainted by errors
yukang [Wed, 10 Aug 2022 14:21:34 +0000 (22:21 +0800)]
InferCtxt emit error when incorrectly tainted by errors

22 months agobless mir-opt tests
Nilstrieb [Fri, 29 Jul 2022 16:52:38 +0000 (18:52 +0200)]
bless mir-opt tests

22 months agobless ui tests
Nilstrieb [Fri, 29 Jul 2022 16:52:04 +0000 (18:52 +0200)]
bless ui tests

22 months agoFix span for consts in mir builder
Nilstrieb [Fri, 29 Jul 2022 16:49:27 +0000 (18:49 +0200)]
Fix span for consts in mir builder

22 months agoShow absolute line numbers if span is outside relative span
Nilstrieb [Fri, 29 Jul 2022 14:34:06 +0000 (16:34 +0200)]
Show absolute line numbers if span is outside relative span

In the MIR pretty printing, it can sometimes happen that the span of the
statement is outside the span of the body (for example through
inlining). In this case, don't display a relative span but an absolute
span. This will make the mir-opt-tests a little more prone to diffs
again, but the impact should be small.

22 months agofix tidy
Deadbeef [Mon, 22 Aug 2022 11:41:38 +0000 (11:41 +0000)]
fix tidy

22 months agoAuto merge of #99702 - SparrowLii:transtive_relation, r=oli-obk
bors [Mon, 22 Aug 2022 11:39:53 +0000 (11:39 +0000)]
Auto merge of #99702 - SparrowLii:transtive_relation, r=oli-obk

get rid of `RefCell` in `TransitiveRelation`

This is one of the jobs in `Pending refactorings` in #48685. The parallel-compiler's work has been suspended for quite some time, but I think I can pick it up gradually. I think this PR should be a start.

Regarding the refactoring of `TransitiveRelation`, `@nikomatsakis`  has proposed [two(three?) schemes](https://github.com/rust-lang/rust/pull/48587#issuecomment-369336651). In order to satisfy both compilation efficiency and robustness, I think adding the `freeze` method may be the best solution, although it requires relatively more code changes.

22 months agoOverhaul 100222 test; wf always remap to nonconst
Deadbeef [Mon, 22 Aug 2022 11:28:01 +0000 (11:28 +0000)]
Overhaul 100222 test; wf always remap to nonconst

22 months agoremove stray comment
Deadbeef [Mon, 22 Aug 2022 11:06:07 +0000 (11:06 +0000)]
remove stray comment

22 months agoFix wf check on `#[const_trait]` return types
Deadbeef [Tue, 9 Aug 2022 17:41:49 +0000 (17:41 +0000)]
Fix wf check on `#[const_trait]` return types

22 months agoAdd guarantee that Vec::default() does not alloc
Jan Behrens [Mon, 22 Aug 2022 10:36:44 +0000 (12:36 +0200)]
Add guarantee that Vec::default() does not alloc

Currently `Vec::new()` is guaranteed to not allocate until elements are
pushed onto the `Vec`, but such a guarantee is missing for `Vec`'s
implementation of `Default::default`. This adds such a guarantee for
`Vec::default()` to the API reference.

22 months agore-base and use `OutlivesEnvironment::with_bounds`
SparrowLii [Mon, 22 Aug 2022 10:36:02 +0000 (18:36 +0800)]
re-base and use `OutlivesEnvironment::with_bounds`

22 months agouse type alias impl trait in `outlives_bounds::InferCtxtExt`
SparrowLii [Mon, 1 Aug 2022 02:23:09 +0000 (10:23 +0800)]
use type alias impl trait in `outlives_bounds::InferCtxtExt`

22 months agoadd `with_bounds` to `OutlivesEnvironment` and `implied_bounds_tys` to `outlives_boun...
SparrowLii [Fri, 29 Jul 2022 07:08:50 +0000 (15:08 +0800)]
add `with_bounds` to `OutlivesEnvironment` and `implied_bounds_tys` to `outlives_bounds::InferCtxtExt`

22 months agoget rid of `RefCell` in `TransitiveRelation`
SparrowLii [Mon, 25 Jul 2022 03:06:22 +0000 (11:06 +0800)]
get rid of `RefCell` in `TransitiveRelation`

22 months agoAuto merge of #100868 - Dylan-DPC:rollup-a1hfi1r, r=Dylan-DPC
bors [Mon, 22 Aug 2022 08:32:41 +0000 (08:32 +0000)]
Auto merge of #100868 - Dylan-DPC:rollup-a1hfi1r, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93162 (Std module docs improvements)
 - #99386 (Add tests that check `Vec::retain` predicate execution order.)
 - #99915 (Recover keywords in trait bounds)
 - #100694 (Migrate rustc_ast_passes diagnostics to `SessionDiagnostic` and translatable messages (first part))
 - #100757 (Catch overflow early)

Failed merges:

 - #99917 (Move Error trait into core)

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

22 months agofluent: update tests
Xiretza [Wed, 17 Aug 2022 11:05:13 +0000 (13:05 +0200)]
fluent: update tests

22 months agofluent: point to path containing error instead of module name
Xiretza [Wed, 17 Aug 2022 10:12:59 +0000 (12:12 +0200)]
fluent: point to path containing error instead of module name

Example error before:

error: name `generic_does_not_live_long_enough` does not start with the crate name
  --> compiler/rustc_error_messages/src/lib.rs:33:17
   |
33 |     borrowck => "../locales/en-US/borrowck.ftl",
   |     ^^^^^^^^
   |
   = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough`

after:

error: name `generic_does_not_live_long_enough` does not start with the crate name
  --> compiler/rustc_error_messages/src/lib.rs:33:17
   |
33 |     borrowck => "../locales/en-US/borrowck.ftl",
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: prepend `borrowck_` to the slug name: `borrowck_generic_does_not_live_long_enough`

22 months agofluent: mandate slug names to be prefixed by crate name
Xiretza [Wed, 17 Aug 2022 10:09:06 +0000 (12:09 +0200)]
fluent: mandate slug names to be prefixed by crate name

22 months agoRollup merge of #100757 - ouz-a:issue-95134, r=jackh726
Dylan DPC [Mon, 22 Aug 2022 06:15:45 +0000 (11:45 +0530)]
Rollup merge of #100757 - ouz-a:issue-95134, r=jackh726

Catch overflow early

Although this code should raise an overflow error, it didn't because [check_recursion_limit](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/select/struct.SelectionContext.html#method.check_recursion_limit) it checks for `depth = 128` but not for `129` which should have triggered the overflow error. Anyways this catches that error early.

Fixes #95134

22 months agoRollup merge of #100694 - finalchild:ast-passes-diag, r=TaKO8Ki
Dylan DPC [Mon, 22 Aug 2022 06:15:44 +0000 (11:45 +0530)]
Rollup merge of #100694 - finalchild:ast-passes-diag, r=TaKO8Ki

Migrate rustc_ast_passes diagnostics to `SessionDiagnostic` and translatable messages (first part)

Doing a full migration of the `rustc_ast_passes` crate.
Making a draft here since there's not yet a tracking issue for the migrations going on.

`@rustbot` label +A-translation

22 months agoRollup merge of #99915 - WaffleLapkin:recover_keyword_bounds, r=compiler-errors
Dylan DPC [Mon, 22 Aug 2022 06:15:42 +0000 (11:45 +0530)]
Rollup merge of #99915 - WaffleLapkin:recover_keyword_bounds, r=compiler-errors

Recover keywords in trait bounds

(_this pr was inspired by [this tweet](https://twitter.com/Azumanga/status/1552982326409367561)_)

Recover keywords in trait bound, motivational example:
```rust
fn f(_: impl fn()) {} // mistyped, meant `Fn`
```

<details><summary>Current nightly (3 needless and confusing errors!)</summary>
<p>

```text
error: expected identifier, found keyword `fn`
 --> ./t.rs:1:15
  |
1 | fn _f(_: impl fn()) {}
  |               ^^ expected identifier, found keyword
  |
help: escape `fn` to use it as an identifier
  |
1 | fn _f(_: impl r#fn()) {}
  |               ++

error: expected one of `:` or `|`, found `)`
 --> ./t.rs:1:19
  |
1 | fn _f(_: impl fn()) {}
  |                   ^ expected one of `:` or `|`

error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found keyword `fn`
 --> ./t.rs:1:15
  |
1 | fn _f(_: impl fn()) {}
  |              -^^ expected one of 9 possible tokens
  |              |
  |              help: missing `,`

error: at least one trait must be specified
 --> ./t.rs:1:10
  |
1 | fn _f(_: impl fn()) {}
  |          ^^^^
```

</p>
</details>

This PR:
```text
error: expected identifier, found keyword `fn`
 --> ./t.rs:1:15
  |
1 | fn _f(_: impl fn()) {}
  |               ^^ expected identifier, found keyword
  |
help: escape `fn` to use it as an identifier
  |
1 | fn _f(_: impl r#fn()) {}
  |               ++

error[E0405]: cannot find trait `r#fn` in this scope
  --> ./t.rs:1:15
   |
1  | fn _f(_: impl fn()) {}
   |               ^^ help: a trait with a similar name exists (notice the capitalization): `Fn`
   |
  ::: /home/waffle/projects/repos/rust/library/core/src/ops/function.rs:74:1
   |
74 | pub trait Fn<Args>: FnMut<Args> {
   | ------------------------------- similarly named trait `Fn` defined here
```

It would be nice to have suggestion in the first error like "have you meant `Fn` trait", instead of a separate error, but the recovery is deep inside ident parsing, which makes it a lot harder to do.

r? `@compiler-errors`

22 months agoRollup merge of #99386 - AngelicosPhosphoros:add_retain_test_maybeuninit, r=JohnTitor
Dylan DPC [Mon, 22 Aug 2022 06:15:41 +0000 (11:45 +0530)]
Rollup merge of #99386 - AngelicosPhosphoros:add_retain_test_maybeuninit, r=JohnTitor

Add tests that check `Vec::retain` predicate execution order.

This behaviour is documented for `Vec::retain` which means that there is code that rely on that but there weren't tests about that.

22 months agoRollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum
Dylan DPC [Mon, 22 Aug 2022 06:15:40 +0000 (11:45 +0530)]
Rollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum

Std module docs improvements

My primary goal is to create a cleaner separation between primitive types and primitive type helper modules (fixes #92777). I also changed a few header lines in other top-level std modules (seen at https://doc.rust-lang.org/std/) for consistency.

Some conventions used/established:

 * "The \`Box\<T>` type for heap allocation." - if a module mainly provides a single type, name it and summarize its purpose in the module header
 * "Utilities for the _ primitive type." - this wording is used for the header of helper modules
 * Documentation for primitive types themselves are removed from helper modules
 * provided-by-core functionality of primitive types is documented in the primitive type instead of the helper module (such as the "Iteration" section in the slice docs)

I wonder if some content in `std::ptr` should be in `pointer` but I did not address this.

22 months agoAuto merge of #100676 - lcnr:implied-bounds-yay, r=nikomatsakis
bors [Mon, 22 Aug 2022 06:10:26 +0000 (06:10 +0000)]
Auto merge of #100676 - lcnr:implied-bounds-yay, r=nikomatsakis

implied bounds: explicitly state which types are assumed to be wf

Adds a new query which maps each definition to the types which that definition assumes to be well formed. The intent is to make it easier to reason about implied bounds.

This change should not influence the user-facing behavior of rustc. Notably, `borrowck` still only assumes that the function signature of associated functions is well formed while `wfcheck` assumes that the both the function signature and the impl trait ref is well formed. Not sure if that by itself can trigger UB or whether it's just annoying.

As a next step, we can add `WellFormed` predicates to `predicates_of` of these items and can stop adding the wf bounds at each place which uses them. I also intend to move the computation from `assumed_wf_types` to `implied_bounds` into the `param_env` computation. This requires me to take a deeper look at `compare_predicate_entailment` which is currently somewhat weird wrt implied bounds so I am not touching this here.

r? `@nikomatsakis`

22 months agoAuto merge of #100671 - Xiretza:tidy-fluent-files, r=davidtwco
bors [Mon, 22 Aug 2022 03:02:50 +0000 (03:02 +0000)]
Auto merge of #100671 - Xiretza:tidy-fluent-files, r=davidtwco

tidy: check fluent files for style

Inspired by https://github.com/rust-lang/rust/pull/100651#discussion_r947600576

There were a lot of line length violations, so I've excepted that lint - I'm not sure if fluent files can be formatted to avoid long lines at all.

22 months agoRefactor query modifier parsing
Cameron Steffen [Sun, 21 Aug 2022 22:44:39 +0000 (17:44 -0500)]
Refactor query modifier parsing

22 months agoAuto merge of #100668 - nnethercote:use-AttrVec-more, r=spastorino
bors [Mon, 22 Aug 2022 00:34:02 +0000 (00:34 +0000)]
Auto merge of #100668 - nnethercote:use-AttrVec-more, r=spastorino

Use `AttrVec` more

In some places we use `Vec<Attribute>` and some places we use
`ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points
where we have to convert between `Vec` and `ThinVec`.

This commit changes the places that use `Vec<Attribute>` to use
`AttrVec`. A lot of this is mechanical and boring, but there are
some interesting parts:
- It adds a few new methods to `ThinVec`.
- It implements `MapInPlace` for `ThinVec`, and introduces a macro to
  avoid the repetition of this trait for `Vec`, `SmallVec`, and
  `ThinVec`.

Overall, it makes the code a little nicer, and has little effect on
performance. But it is a precursor to removing
`rustc_data_structures::ThinVec` and replacing it with
`thin_vec::ThinVec`, which is implemented more efficiently.

r? `@spastorino`

22 months agotidy: remove crossbeam-utils
Eric Huss [Mon, 22 Aug 2022 00:11:51 +0000 (17:11 -0700)]
tidy: remove crossbeam-utils

22 months agofix ICE with extra-const-ub-checks
Ralf Jung [Mon, 22 Aug 2022 00:00:38 +0000 (20:00 -0400)]
fix ICE with extra-const-ub-checks

22 months agoAuto merge of #100654 - compiler-errors:rework-point-at-arg, r=estebank
bors [Sun, 21 Aug 2022 21:52:56 +0000 (21:52 +0000)]
Auto merge of #100654 - compiler-errors:rework-point-at-arg, r=estebank

Rework "point at arg" suggestions to be more accurate

Fixes #100560

Introduce a new set of `ObligationCauseCode`s which have additional bookeeping for what expression caused the obligation, and which predicate caused the obligation. This allows us to look at the _unsubstituted_ signature to find out which parameter or generic type argument caused an obligaton to fail.

This means that (in most cases) we significantly improve the likelihood of pointing out the right argument that causes a fulfillment error. Also, since this logic isn't happening in just the `select_where_possible_and_mutate_fulfillment()` calls in the argument checking code, but instead during all trait selection in `FnCtxt`, we are also able to point out the correct argument even if inference means that we don't know whether an obligation has failed until well after a call expression has been checked.

r? `@ghost`

22 months agoUse `AttrVec` in more places.
Nicholas Nethercote [Wed, 17 Aug 2022 02:34:33 +0000 (12:34 +1000)]
Use `AttrVec` in more places.

In some places we use `Vec<Attribute>` and some places we use
`ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points
where we have to convert between `Vec` and `ThinVec`.

This commit changes the places that use `Vec<Attribute>` to use
`AttrVec`. A lot of this is mechanical and boring, but there are
some interesting parts:
- It adds a few new methods to `ThinVec`.
- It implements `MapInPlace` for `ThinVec`, and introduces a macro to
  avoid the repetition of this trait for `Vec`, `SmallVec`, and
  `ThinVec`.

Overall, it makes the code a little nicer, and has little effect on
performance. But it is a precursor to removing
`rustc_data_structures::thin_vec::ThinVec` and replacing it with
`thin_vec::ThinVec`, which is implemented more efficiently.

22 months agoFix rustc_parse_format precision & width spans
Alex Macleod [Sun, 21 Aug 2022 16:19:48 +0000 (16:19 +0000)]
Fix rustc_parse_format precision & width spans

22 months agobless mir-opt tests
Nilstrieb [Tue, 26 Jul 2022 13:17:02 +0000 (15:17 +0200)]
bless mir-opt tests

22 months agoEnable UnreachablePropagation under mir-opt-level >= 2
Nilstrieb [Tue, 26 Jul 2022 13:15:07 +0000 (15:15 +0200)]
Enable UnreachablePropagation under mir-opt-level >= 2

It was disabled because of pathological behaviour of LLVM in some
benchmarks. As of #77680, this has been fixed. The problem there was
that it caused pessimizations in some cases. These have now been fixed
as well.

22 months agoUnreachableProp: Preserve unreachable branches for multiple targets
Nilstrieb [Tue, 26 Jul 2022 13:11:12 +0000 (15:11 +0200)]
UnreachableProp: Preserve unreachable branches for multiple targets

Before, UnreachablePropagation removed all unreachable branches.
This was a pessimization, as it removed information about
reachability that was used later in the optimization pipeline.

For example, this code
```rust
pub enum Two { A, B }
pub fn identity(x: Two) -> Two {
    match x {
        Two::A => Two::A,
        Two::B => Two::B,
    }
}
```

basically has `switchInt() -> [0: 0, 1: 1, otherwise: unreachable]` for the match.
This allows it to be transformed into a simple `x`. If we remove the
unreachable branch, the transformation becomes illegal.

22 months agoAuto merge of #100847 - matthiaskrgr:rollup-0ga531s, r=matthiaskrgr
bors [Sun, 21 Aug 2022 19:05:18 +0000 (19:05 +0000)]
Auto merge of #100847 - matthiaskrgr:rollup-0ga531s, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #100556 (Clamp Function for f32 and f64)
 - #100663 (Make slice::reverse const)
 - #100697 ( Minor syntax and formatting update to doc comment on `find_vtable_types_for_unsizing`)
 - #100760 (update test for LLVM change)
 - #100761 (some general mir typeck cleanup)
 - #100775 (rustdoc: Merge source code pages HTML elements together v2)
 - #100813 (Add `/build-rust-analyzer/` to .gitignore)
 - #100821 (Make some docs nicer wrt pointer offsets)
 - #100822 (Replace most uses of `pointer::offset` with `add` and `sub`)
 - #100839 (Make doc for stdin field of process consistent)
 - #100842 (Add diagnostics lints to `rustc_transmute` module (zero diags))

Failed merges:

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

22 months agoAuto merge of #100645 - notriddle:notriddle/rustdoc-diet-plan, r=GuillaumeGomez
bors [Sun, 21 Aug 2022 16:40:26 +0000 (16:40 +0000)]
Auto merge of #100645 - notriddle:notriddle/rustdoc-diet-plan, r=GuillaumeGomez

rustdoc: strategic boxing to reduce the size of ItemKind and Type

The `Type` change redesigns `QPath` to box the entire data structure instead of boxing `self_type` and the `trait_`.

This reduces the size of several `ItemKind` variants, leaving `Impl` as the biggest variant. The `ItemKind` change boxes that variant's payload.

22 months agoReplace #[error(..)] etc. to #[diag(..)]
finalchild [Sun, 21 Aug 2022 16:24:47 +0000 (01:24 +0900)]
Replace #[error(..)] etc. to #[diag(..)]

22 months agoFix incorrect return type of emit_fatal
Park Jaeon [파차] [Sat, 20 Aug 2022 17:22:05 +0000 (02:22 +0900)]
Fix incorrect return type of emit_fatal

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
22 months agoRemove redundant clone
finalchild [Thu, 18 Aug 2022 18:36:43 +0000 (03:36 +0900)]
Remove redundant clone

22 months agoMigrate forbidden_default and *_without_body
finalchild [Thu, 18 Aug 2022 17:43:01 +0000 (02:43 +0900)]
Migrate forbidden_default and *_without_body

22 months agoFix `build_format` not unescaping braces properly
finalchild [Thu, 18 Aug 2022 17:21:35 +0000 (02:21 +0900)]
Fix `build_format` not unescaping braces properly

Co-authored-by: RanolP <public.ranolp@gmail.com>
22 months agoSupport #[fatal(..)]
finalchild [Thu, 18 Aug 2022 12:20:50 +0000 (21:20 +0900)]
Support #[fatal(..)]