Commit Graph

18041 Commits

Author SHA1 Message Date
nils
b00cb04037
Sort target features alphabetically 2022-10-14 22:01:18 +02:00
bors
ee1c3b385b Auto merge of #102529 - colinba:master, r=joshtriplett
Detect and reject out-of-range integers in format string literals

Until now out-of-range integers in format string literals were silently ignored. They wrapped around to zero at usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string literals even cause an 'attempt to add with overflow' panic in rustc.

Fix this by producing an error diagnostic for integers in format string literals which do not fit into usize.

Fixes #102528
2022-10-14 13:41:40 +00:00
Dylan DPC
7cf09c57a2
Rollup merge of #103031 - est31:match_guard_irrefutable_let, r=oli-obk
Suppress irrefutable let patterns lint for prefixes in match guards

In match guards, irrefutable prefixes might use the bindings created by the match pattern. Ideally, we check for this, but we can do the next best thing and just not lint for irrefutable prefixes in match guards.

Fixes #98361
2022-10-14 16:19:16 +05:30
Dylan DPC
77064b7f0a
Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
More dupe word typos

I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14 16:19:15 +05:30
Dylan DPC
8c9ecbb7e3
Rollup merge of #103015 - whentojump:patch, r=compiler-errors
fix a typo
2022-10-14 16:19:15 +05:30
Dylan DPC
b4906acbce
Rollup merge of #102856 - cjgillot:impl-single-check, r=petrochenkov
Only test duplicate inherent impl items in a single place

Based on https://github.com/rust-lang/rust/pull/100387

r? ``@petrochenkov``
2022-10-14 16:19:12 +05:30
Guillaume Gomez
f528414e40 Add missing checks for doc(cfg_hide(...)) attribute 2022-10-14 11:29:54 +02:00
bors
32717603f6 Auto merge of #102695 - compiler-errors:int-and-float-trivial-copy, r=lcnr
Int and float inference variables are trivially copy

Fixes #102645
2022-10-14 07:41:55 +00:00
Michael Goulet
8c7e836abb Address nits, add test for implicit dyn-star coercion without feature gate 2022-10-14 05:47:09 +00:00
Michael Goulet
0cb217d29b Remove CastCheckResult since it's unused 2022-10-14 05:47:09 +00:00
Michael Goulet
a010df9389 float and int vars are trivially copy 2022-10-14 05:26:32 +00:00
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Michael Goulet
feb4244f54 Allow dyn* upcasting 2022-10-14 04:43:56 +00:00
bors
1755c85302 Auto merge of #102684 - JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco
Move `IntoDiagnostic` conformance for `TargetDataLayoutErrors` into `rustc_errors`

Addressed this suggestion https://github.com/rust-lang/rust/pull/101558#issuecomment-1243830009.

This way we comply with the Coherence rule given that `IntoDiagnostic` trait is defined in `rustc_errors`, and almost all other crates depend on it.
2022-10-14 04:35:22 +00:00
Takayuki Maeda
b8418485bc check if the self type is ty::Float before getting second substs 2022-10-14 13:31:15 +09:00
Michael Goulet
76386bd65e Make dyn* cast into a coercion 2022-10-14 04:27:01 +00:00
bors
edabf59ca4 Auto merge of #103026 - matthiaskrgr:rollup-gfmlfkt, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #103000 (Add suggestion to the "missing native library" error)
 - #103006 (rustdoc: don't ICE on `TyKind::Typeof`)
 - #103008 (replace ReErased with fresh region vars in opaque types)
 - #103011 (Improve rustdoc `unsafe-fn` GUI test)
 - #103013 (Add new bootstrap entrypoints to triagebot)
 - #103016 (Ensure enum cast moves)
 - #103021 (Add links to relevant pages to find constraint information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-14 01:28:06 +00:00
Nathan Whitaker
709a08ade6 Lower condition directly from AST to HIR 2022-10-13 18:20:39 -07:00
est31
eab41a136a Suppress irrefutable let patterns lint for prefixes in match guards
In match guards, irrefutable prefixes might use the bindings created
by the match pattern. Ideally, we check for this, but we can do the
next best thing and just not lint for irrefutable prefixes in match
guards.
2022-10-14 02:16:40 +02:00
Matthias Krüger
3f12e4bd21
Rollup merge of #103021 - GuillaumeGomez:constraint-pages, r=Amanieu
Add links to relevant pages to find constraint information

I think it can be quite helpful to find this information more quickly.

r? `@Amanieu`
2022-10-14 00:45:20 +02:00
Matthias Krüger
cf675656cb
Rollup merge of #103016 - nbdd0121:enum, r=pnkfelix
Ensure enum cast moves

Fix #102389

r? ``@pnkfelix``
2022-10-14 00:45:19 +02:00
Matthias Krüger
059bbf7ea9
Rollup merge of #103008 - aliemjay:opaque-parent-substs, r=oli-obk
replace ReErased with fresh region vars in opaque types

See inline comments.

Prior art #102943. cc ``@compiler-errors`` ``@oli-obk``

Fixes #100267
Fixes #101940
Fixes #102649
Fixes #102510
2022-10-14 00:45:18 +02:00
Matthias Krüger
c7f048ea00
Rollup merge of #103000 - wesleywiser:suggest_libname, r=compiler-errors
Add suggestion to the "missing native library" error

If we fail to locate a native library that we are linking with, it could be the case the user entered a complete file name like `foo.lib` or `libfoo.a` when we expect them to simply provide `foo`.

In this situation, we now detect that case and suggest the user only provide the library name itself.
2022-10-14 00:45:17 +02:00
bors
60bd3f9677 Auto merge of #102700 - oli-obk:0xDEAD_TAIT, r=compiler-errors
Check hidden types in dead code

fixes #99490

r? `@compiler-errors`

best reviewed commit by commit
2022-10-13 22:39:05 +00:00
Guillaume Gomez
2214748ade Add links to relevant pages to find constraint information 2022-10-13 22:05:49 +02:00
Cameron Steffen
c4068c76a8 Make overlapping_impls non-generic
This improves perf
2022-10-13 14:54:48 -05:00
Camille GILLOT
112ce80726 Report duplicate definition in impls with overlap check. 2022-10-13 16:50:24 +00:00
wtj
5191256400 fix a typo 2022-10-14 00:10:04 +08:00
Ali MJ Al-Nasrawy
d2d3d94332 replace ReErased with fresh region vars in opaque types 2022-10-13 19:06:21 +03:00
Gary Guo
de0396c718 Ensure enum cast moves 2022-10-13 16:44:47 +01:00
Dylan DPC
0f12b40bff
Rollup merge of #102999 - compiler-errors:issue-102985, r=fee1-dead
Delay `is_intrinsic` query until after we've determined the callee is a function

Fixes #102985
2022-10-13 18:19:21 +05:30
Dylan DPC
48f950c527
Rollup merge of #102956 - TaKO8Ki:fix-102946, r=fee1-dead
Use `full_res` instead of `expect_full_res`

Fixes #102946
Fixes #102978
2022-10-13 18:19:21 +05:30
Dylan DPC
42991e551b
Rollup merge of #102947 - compiler-errors:sort-elaborated-existentials, r=cjgillot
Sort elaborated existential predicates in `object_ty_for_trait`

r? `@cjgillot`

I think that #102845 caused #102933. Depending on the order that we elaborate these existential projection predicates, there's no guarantee that they'll be sorted by def id, which is what is failing the assertion in the issue.

Fixes #102933
Fixes #102973
2022-10-13 18:19:20 +05:30
Dylan DPC
dbff6a91c1
Rollup merge of #102904 - compiler-errors:rpitit-verbosely, r=cjgillot
Print return-position `impl Trait` in trait verbosely if `-Zverbose`

Makes the behavior a bit closer to regular `impl Trait` printing
2022-10-13 18:19:20 +05:30
Dylan DPC
ad45dd1722
Rollup merge of #102765 - TaKO8Ki:follow-up-to-102708, r=compiler-errors
Suggest `==` to the first expr which has `ExprKind::Assign` kind

follow-up to #102708

[playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4241dc33ed8af02e1ef530d6b14903fd)
2022-10-13 18:19:18 +05:30
Wesley Wiser
097b6d3baf Add suggestion to the "missing native library" error
If we fail to locate a native library that we are linking with, it could
be the case the user entered a complete file name like `foo.lib` or
`libfoo.a` when we expect them to simply provide `foo`.

In this situation, we now detect that case and suggest the user only
provide the library name itself.
2022-10-13 07:35:36 -04:00
Vadim Petrochenkov
f634106591 resolve: Regroup lifetime rib kinds to account for their purpose 2022-10-13 13:32:24 +04:00
Vadim Petrochenkov
e94ec30dc4 resolve: Remove redundant item lifetime ribs
and cleanup lifetime rib walking loops
2022-10-13 13:32:24 +04:00
Vadim Petrochenkov
e8a6e60c5d resolve: Add some asserts for unexpected lifetime rib combinations 2022-10-13 13:32:24 +04:00
Michael Goulet
af3c6f9a03 Delay intrinsic call until after we've determined the callee is a function 2022-10-13 03:10:00 +00:00
Michael Goulet
61f097308b Print RPITIT verbosely if -Zverbose 2022-10-13 02:31:43 +00:00
Michael Goulet
4a8cfe9d14 Sort elaborated existential predicates in object_ty_for_trait 2022-10-13 02:21:15 +00:00
Nathan Whitaker
ad8b242724 Let chains should still drop temporaries
by the end of the condition's execution
2022-10-12 17:57:32 -07:00
Yuki Okushi
0ace46f98c
Rollup merge of #102974 - Rageking8:fix-small-word-dupe-typos, r=JohnTitor
Fix small word dupe typos
2022-10-13 09:41:27 +09:00
Yuki Okushi
f4c9580c65
Rollup merge of #102836 - petrochenkov:jsonspec, r=eholk
rustc_target: Fix json target specs using LLD linker flavors in link args

Fixes https://github.com/rust-lang/rust/pull/101988#issuecomment-1272407248 (a regression introduced by https://github.com/rust-lang/rust/pull/101988).
2022-10-13 09:41:25 +09:00
Yuki Okushi
6755c2a89d
Rollup merge of #102641 - eholk:dyn-star-box, r=compiler-errors
Support casting boxes to dyn*

Boxes have a pointer type at codegen time which LLVM does not allow to be transparently converted to an integer. Work around this by inserting a `ptrtoint` instruction if the argument is a pointer.

r? ``@compiler-errors``

Fixes #102427
2022-10-13 09:41:25 +09:00
Eric Holk
8b2c3ebb86 Add a fixme 2022-10-12 14:26:22 -07:00
bors
0938e1680d Auto merge of #101679 - compiler-errors:rpitit-default-body, r=nikomatsakis
Support default-body trait functions with return-position `impl Trait` in traits

Introduce a new `Trait` candidate kind for the `ImplTraitInTrait` projection candidate, which just projects an RPITIT down to its opaque type form.

This is a hack until we lower RPITITs to regular associated types, after which we will need to rework how these default bodies are type-checked, so comments are left in a few places for us to clean up later.

Fixes #101665
2022-10-12 21:03:47 +00:00
Jhonny Bill Mena
be221573c8 UPDATE - Move IntoDiagnosticArg implementations to diagnostic_impls file 2022-10-12 16:55:28 -04:00
Jhonny Bill Mena
5645cd5b09 ADD - IntoDiagnostic conformance for TargetDataLayoutErrors in rustc_errors
This way we comply with the Coherence rule given that IntoDiagnostic trait is defined in rustc_errors, and almost all other crates depend on it.
2022-10-12 16:54:25 -04:00
bors
c0983a9aac Auto merge of #102975 - Dylan-DPC:rollup-vzuwsh2, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #102623 (translation: eager translation)
 - #102719 (Enforce alphabetical sorting with tidy)
 - #102830 (Unify `tcx.constness` query and param env constness checks)
 - #102883 (Fix stabilization of `feature(half_open_range_patterns)`)
 - #102927 (Fix `let` keyword removal suggestion in structs)
 - #102936 (rustdoc: remove unused CSS `nav.sum`)
 - #102940 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-12 17:48:31 +00:00
Rageking8
d1982bd0af fix small word dupe typos 2022-10-13 00:53:46 +08:00
Dylan DPC
a9a5529eac
Rollup merge of #102927 - compiler-errors:let, r=davidtwco
Fix `let` keyword removal suggestion in structs

(1.) Fixes a bug where, given this code:
```rust
struct Foo {
  let x: i32,
}
```

We were parsing the field name as `let` instead of `x`, which causes issues later on in the type-checking phase.

(2.) Also, suggestions for `let: i32` as a field regressed, displaying this extra `help:` which is removed by this PR

```
help: remove the let, the `let` keyword is not allowed in struct field definitions
  |
2 -     let: i32,
2 +     : i32,
```

(3.) Makes the suggestion text a bit more succinct, since we don't need to re-explain that `let` is not allowed in this position (since it's in a note that follows). This causes the suggestion to render inline as well.

cc `@gimbles,` this addresses a few nits I mentioned in your PR.
2022-10-12 22:13:26 +05:30
Dylan DPC
117a98c5ce
Rollup merge of #102883 - Urgau:fix-stabilization-half_open_range_patterns, r=lcnr
Fix stabilization of `feature(half_open_range_patterns)`

Fixes https://github.com/rust-lang/rust/pull/102275/files#r991292215 by removing the relevant code that was [already partial moved](https://github.com/rust-lang/rust/pull/102275/files#diff-307e0d3a2037c11a3fa16822fbaa0fec08e57ac7d0d6e7354f6005c9482a9e26).

cc `@Undin`
2022-10-12 22:13:25 +05:30
Dylan DPC
c763ebc72f
Rollup merge of #102830 - compiler-errors:constness-parity, r=fee1-dead
Unify `tcx.constness` query and param env constness checks

The checks that we do in the `constness` query seem inconsistent with the checks that we do to determine if an item's param-env is const, so I merged them into the `constness` query and call that from the `param_env` query.

I'm not sure if this totally makes sense -- is there a case where `tcx.param_env()` would return a const param-env for an item whose `tcx.constness()` is `Constness::NotConst`? Because if not, it seems a bit dangerous that these two differ.

Luckily, not many places actually use `tcx.constness()`, and the checks in `tcx.param_env()` seem stricter than the checks in `tcx.constness()` (at least for the types of items we type-check).

Also, due to the way that `tcx.param_env()` is implemented, it _never_ used to return a const param-env for a item coming from a different crate, which also seems dangerous (though also probably not weaponizable currently, because we seldom actually compute the param-env for a non-local item).
2022-10-12 22:13:25 +05:30
Dylan DPC
40deecef03
Rollup merge of #102719 - Nilstrieb:tidy-alphabetical, r=jackh726
Enforce alphabetical sorting with tidy

We have many places where things are supposed to be sorted alphabetically. For the smaller and more recent size assertions, this is mostly upheld, but in other more... alive places it's very messy.

This introduces a new tidy directive to check that a section of code is sorted alphabetically and fixes all places where sorting has gone wrong.
2022-10-12 22:13:24 +05:30
Dylan DPC
dc9f6f3243
Rollup merge of #102623 - davidtwco:translation-eager, r=compiler-errors
translation: eager translation

Part of #100717. See [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/295010720) for additional context.

- **Store diagnostic arguments in a `HashMap`**: Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`.
- **Add `AddToDiagnostic::add_to_diagnostic_with`**: `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure.
- **Add `DiagnosticMessage::Eager`**: Add variant of `DiagnosticMessage` for eagerly translated messages
(messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation.
- **Support `#[subdiagnostic(eager)]`**: Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`.
- **Finish migrating `rustc_query_system`**: Using eager translation, migrate the remaining repeated cycle stack diagnostic.
- **Split formatting initialization and use in diagnostic derives**: Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move.

  This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg`
anyway.

  However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as:

      let diag = { /* create diagnostic */ };

      diag.span_suggestion_with_style(
          span,
          fluent::crate::slug,
          format!("{}", __binding_0),
          Applicability::Unknown,
          SuggestionStyle::ShowAlways
      );
      /* + other subdiagnostic additions */

      diag.set_arg("foo", __binding_0);
      /* + other `set_arg` calls */

      diag.emit();

  For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first.

  Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition.

  By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added.

      let diag = { /* create diagnostic */ };

      let __code_0 = format!("{}", __binding_0);
      /* + other formatting */

      diag.set_arg("foo", __binding_0);
      /* + other `set_arg` calls */

      diag.span_suggestion_with_style(
          span,
          fluent::crate::slug,
          __code_0,
          Applicability::Unknown,
          SuggestionStyle::ShowAlways
      );
      /* + other subdiagnostic additions */

      diag.emit();

- **Remove field ordering logic in diagnostic derive:** Following the approach taken in earlier commits to separate formatting initialization from use in the subdiagnostic derive, simplify the diagnostic derive by removing the field-ordering logic that previously solved this problem.

r? ```@compiler-errors```
2022-10-12 22:13:23 +05:30
bors
538f118da1 Auto merge of #102732 - RalfJung:assert_unsafe_precondition2, r=bjorn3
nicer errors from assert_unsafe_precondition

This makes the errors shown by cargo-careful nicer, and since `panic_no_unwind` is `nounwind noreturn` it hopefully doesn't have bad codegen impact. Thanks to `@bjorn3` for the hint!

Would be nice if we could somehow supply our own (static) message to print, currently it always prints `panic in a function that cannot unwind`. But still, this is better than before.
2022-10-12 14:39:43 +00:00
Maybe Waffle
c5de3ecec3 link lint function with decorate function param to struct_lint_level 2022-10-12 14:16:24 +00:00
Waffle Maybe
b1c3e78661
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-10-12 16:39:11 +04:00
Nilstrieb
7bfef19844 Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30
Takayuki Maeda
b11dddd1c1 fix #102946 2022-10-12 19:03:46 +09:00
Maybe Waffle
f1ac7b5a65 Improve docs for struct_lint_level function. 2022-10-12 09:28:11 +00:00
bors
e6ce5627a9 Auto merge of #102948 - Dylan-DPC:rollup-j8h74rb, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #102110 (Migrate rustc_passes diagnostics)
 - #102187 (Use correct location for type tests in promoted constants)
 - #102239 (Move style guide to rust-lang/rust)
 - #102578 (Panic for invalid arguments of `{integer primitive}::ilog{,2,10}` in all modes)
 - #102811 (Use memset to initialize readbuf)
 - #102890 (Check representability in adt_sized_constraint)
 - #102913 (unify `IsPattern` and `IsImport` enum in `show_candidates`)
 - #102924 (rustdoc: remove unused classes from sidebar links)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-12 06:57:24 +00:00
Dylan DPC
252ce10bb0
Rollup merge of #102913 - SparrowLii:import-candidate, r=compiler-errors
unify `IsPattern` and `IsImport` enum in `show_candidates`

Follow-up of #102876
A binding cannot appear in both pattern and import at the same time, so it makes sense to unify them
r? `@compiler-errors`
2022-10-12 11:11:26 +05:30
Dylan DPC
c8a8e7d116
Rollup merge of #102890 - camsteffen:adt-sized-representability, r=cjgillot
Check representability in adt_sized_constraint

Now that representability is a query, we can use it to preemptively avoid a cycle in `adt_sized_constraint`.

I moved the representability check into `check_mod_type_wf` to avoid a scenario where rustc quits before checking all the types for representability. This also removes the check from rustdoc, which is alright AFAIK.

r? ``@cjgillot``
2022-10-12 11:11:26 +05:30
Dylan DPC
5e04567ac7
Rollup merge of #102187 - b-naber:inline-const-source-info, r=eholk
Use correct location for type tests in promoted constants

Previously we forgot to remap the location in a type test collected when visiting the body of a promoted constant back to the usage location, causing an ICE when trying to get span information for that type test.

Fixes https://github.com/rust-lang/rust/issues/102117
2022-10-12 11:11:24 +05:30
Dylan DPC
32471a7035
Rollup merge of #102110 - CleanCut:migrate_rustc_passes_diagnostics, r=davidtwco
Migrate rustc_passes diagnostics

Picks up abandoned work from https://github.com/rust-lang/rust/pull/100870

I would like to do this collaboratively, as there is a lot of work! Here's the process:

- Comment below that you are willing to help and I will add you as a collaborator to my `rust` fork (that gives you write access)
- Indicate which file/task you would like to work on (so we don't duplicate work) from the list below
- Do the work, push up a commit, comment that you're done with that file/task
- Repeat until done 😄

### Files to Migrate (in `compiler/rustc_passes/src/`)

- [x] check_attr.rs ``@CleanCut``
- [x] check_const.rs ``@CleanCut``
- [x] dead.rs ``@CleanCut``
- [x] debugger_visualizer.rs ``@CleanCut``
- [x] diagnostic_items.rs ``@CleanCut``
- [x] entry.rs ``@CleanCut``
- [x] lang_items.rs ``@CleanCut``
- [x] layout_test.rs ``@CleanCut``
- [x] lib_features.rs ``@CleanCut``
- [x] ~liveness.rs~ ``@CleanCut`` Nothing to do
- [x] loops.rs ``@CleanCut``
- [x] naked_functions.rs ``@CleanCut``
- [x] stability.rs ``@CleanCut``
- [x] weak_lang_items.rs ``@CleanCut``

### Tasks

- [x] Rebase on current `master` ``@CleanCut``
- [x] Review work from [the earlier PR](https://github.com/rust-lang/rust/pull/100870) and make sure it all looks good
  - [x] compiler/rustc_error_messages/locales/en-US/passes.ftl ``@CleanCut``
  - [x] compiler/rustc_passes/src/check_attr.rs ``@CleanCut``
  - [x] compiler/rustc_passes/src/errors.rs ``@CleanCut``
  - [x] compiler/rustc_passes/src/lang_items.rs ``@CleanCut``
  - [x] compiler/rustc_passes/src/lib.rs ``@CleanCut``
  - [x] compiler/rustc_passes/src/weak_lang_items.rs ``@CleanCut``
2022-10-12 11:11:23 +05:30
Michael Goulet
bef8681a18 TyAlias needs encoded constness too, for layout computation in rustdoc 2022-10-12 04:17:21 +00:00
Michael Goulet
3021598fdb Do not register placeholder region outlives when considering_regions is false 2022-10-12 04:04:55 +00:00
Michael Goulet
c646c4d403 Unify tcx.constness and param env constness checks 2022-10-12 04:04:09 +00:00
bors
2b91cbe2d4 Auto merge of #102692 - nnethercote:TokenStreamBuilder, r=Aaron1011
Remove `TokenStreamBuilder`

`TokenStreamBuilder` is used to combine multiple token streams. It can be removed, leaving the code a little simpler and a little faster.

r? `@Aaron1011`
2022-10-12 03:46:16 +00:00
SparrowLii
a7f58af9fe unify IsPattern and IsImport enum 2022-10-12 08:46:52 +08:00
Ralf Jung
66282cb47d add panic_fmt_nounwind for panicing without unwinding, and use it for panic_no_unwind 2022-10-11 22:47:31 +02:00
Ralf Jung
2b50cd1877 rename rustc_allocator_nounwind to rustc_nounwind 2022-10-11 22:47:31 +02:00
Michael Goulet
f9d3c83526 Fix let removal suggestion in struct 2022-10-11 17:35:50 +00:00
Matthias Krüger
a13c7da23e
Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwco
Fix ICE #102878

Fixes #102878
2022-10-11 18:59:50 +02:00
Matthias Krüger
cb67283392
Rollup merge of #102889 - petrochenkov:partres, r=cjgillot
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
2022-10-11 18:59:50 +02:00
Matthias Krüger
24722e8d5b
Rollup merge of #102612 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs, r=davidtwco
Migrate `codegen_ssa` to diagnostics structs - [Part 1]

Initial migration of `codegen_ssa`. Going to split this crate migration in at least two PRs in order to avoid a huge PR and to quick off some questions around:

1. Translating messages from "external" crates.
2. Interfacing with OS messages.
3. Adding UI tests while migrating diagnostics.

_See comments below._
2022-10-11 18:59:48 +02:00
Matthias Krüger
cadb37a8c7
Rollup merge of #101727 - est31:stabilize_map_first_last, r=m-ou-se
Stabilize map_first_last

Stabilizes the following functions:

```Rust
impl<T> BTreeSet<T> {
    pub fn first(&self) -> Option<&T> where T: Ord;
    pub fn last(&self) -> Option<&T> where T: Ord;
    pub fn pop_first(&mut self) -> Option<T> where T: Ord;
    pub fn pop_last(&mut self) -> Option<T> where T: Ord;
}

impl<K, V> BTreeMap<K, V> {
    pub fn first_key_value(&self) -> Option<(&K, &V)> where K: Ord;
    pub fn last_key_value(&self) -> Option<(&K, &V)> where K: Ord;
    pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
    pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V>> where K: Ord;
    pub fn pop_first(&mut self) -> Option<(K, V)> where K: Ord;
    pub fn pop_last(&mut self) -> Option<(K, V)> where K: Ord;
}
```

Closes #62924

~~Blocked on the [FCP](https://github.com/rust-lang/rust/issues/62924#issuecomment-1179489929) finishing.~~ Edit: It finished!
2022-10-11 18:59:46 +02:00
Matthias Krüger
6d58ff7fe6
Rollup merge of #100387 - cjgillot:hygiene-trait-impl, r=petrochenkov
Check uniqueness of impl items by trait item when applicable.

When checking uniqueness of item names in impl blocks, we currently use the same definition of hygiene as for toplevel items.  This means that a plain item and one generated by a macro 2.0 do not collide.

This hygiene rule does not match with how impl items resolve to associated trait items. As a consequence, we misdiagnose the trait impls.

This PR proposes to consider that trait impl items are uses of the corresponding trait items during resolution, instead of checking for duplicates later. An error is emitted when a trait impl item is used twice.

There should be no stable breakage, since macros 2.0 are still unstable.

r? ``@petrochenkov``
cc ``@RalfJung``

Fixes https://github.com/rust-lang/rust/issues/71614.
2022-10-11 18:59:45 +02:00
Yuki Okushi
98764c0c72
Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Move lifetime resolution module to rustc_hir_analysis.

Now that lifetime resolution has been removed from it, this file has nothing to do in `rustc_resolve`.  It's purpose is to compute Debruijn indices for lifetimes, so let's put it in type collection.
2022-10-11 18:37:55 +09:00
Camille GILLOT
152cd63226 Report duplicate definitions in trait impls during resolution. 2022-10-11 06:24:51 +00:00
Vadim Petrochenkov
1a8f177772 rustc_hir: Less error-prone methods for accessing PartialRes resolution 2022-10-11 09:04:52 +04:00
bors
518263d889 Auto merge of #102896 - matthiaskrgr:rollup-jg5xawz, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #101360 (Point out incompatible closure bounds)
 - #101789 (`let`'s not needed in struct field definitions)
 - #102846 (update to syn-1.0.102)
 - #102871 (rustdoc: clean up overly complex `.trait-impl` CSS selectors)
 - #102876 (suggest candidates for unresolved import)
 - #102888 (Improve rustdoc-gui search-color test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-11 00:36:26 +00:00
Cameron Steffen
d933092dc5 Check representability in adt_sized_constraint 2022-10-10 14:36:12 -05:00
Matthias Krüger
0bd1cba98b
Rollup merge of #102876 - SparrowLii:import-candidate, r=fee1-dead
suggest candidates for unresolved import

Currently we prompt suggestion of candidates(help notes of `use xxx::yyy`) for names which cannot be resolved, but we don't do that for import statements themselves that couldn't be resolved. It seems reasonable to add candidate help information for these statements as well.
Fixes #102711
2022-10-10 20:47:34 +02:00
Matthias Krüger
01a2246000
Rollup merge of #101789 - gimbles:let, r=estebank
`let`'s not needed in struct field definitions

Fixes #101683
2022-10-10 20:47:32 +02:00
Matthias Krüger
d8d01e3216
Rollup merge of #101360 - compiler-errors:multiple-closure-bounds, r=petrochenkov
Point out incompatible closure bounds

Fixes #100295
2022-10-10 20:47:31 +02:00
Takayuki Maeda
68260289b5 fix #102878 2022-10-11 02:43:36 +09:00
Camille GILLOT
a474ec50b7 Move lifetime resolution module to rustc_hir_analysis. 2022-10-10 17:40:52 +00:00
Guillaume Gomez
adc24d1b5e Fix compiler docs 2022-10-10 18:28:29 +02:00
Guillaume Gomez
3416fa1882 Fix doc lint error 2022-10-10 18:28:29 +02:00
Nathan Stocks
5ef1c03bd8 make up your mind, rustfmt 2022-10-10 10:06:52 -06:00
Nathan Stocks
50e2795624 remove out-of-date fixme 2022-10-10 09:52:53 -06:00
Urgau
d17a69e453 Fix stabilization of feature(half_open_range_patterns) 2022-10-10 15:45:57 +02:00
David Wood
fbac1f288b macros: simplify field ordering in diag derive
Following the approach taken in earlier commits to separate formatting
initialization from use in the subdiagnostic derive, simplify the
diagnostic derive by removing the field-ordering logic that previously
solved this problem.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
David Wood
7e20929e55 macros: separate suggestion fmt'ing and emission
Diagnostic derives have previously had to take special care when
ordering the generated code so that fields were not used after a move.

This is unlikely for most fields because a field is either annotated
with a subdiagnostic attribute and is thus likely a `Span` and copiable,
or is a argument, in which case it is only used once by `set_arg`
anyway.

However, format strings for code in suggestions can result in fields
being used after being moved if not ordered carefully. As a result, the
derive currently puts `set_arg` calls last (just before emission), such
as:

```rust
let diag = { /* create diagnostic */ };

diag.span_suggestion_with_style(
    span,
    fluent::crate::slug,
    format!("{}", __binding_0),
    Applicability::Unknown,
    SuggestionStyle::ShowAlways
);
/* + other subdiagnostic additions */

diag.set_arg("foo", __binding_0);
/* + other `set_arg` calls */

diag.emit();
```

For eager translation, this doesn't work, as the message being
translated eagerly can assume that all arguments are available - so
arguments _must_ be set first.

Format strings for suggestion code are now separated into two parts - an
initialization line that performs the formatting into a variable, and a
usage in the subdiagnostic addition.

By separating these parts, the initialization can happen before
arguments are set, preserving the desired order so that code compiles,
while still enabling arguments to be set before subdiagnostics are
added.

```rust
let diag = { /* create diagnostic */ };

let __code_0 = format!("{}", __binding_0);
/* + other formatting */

diag.set_arg("foo", __binding_0);
/* + other `set_arg` calls */

diag.span_suggestion_with_style(
    span,
    fluent::crate::slug,
    __code_0,
    Applicability::Unknown,
    SuggestionStyle::ShowAlways
);
/* + other subdiagnostic additions */

diag.emit();
```

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
David Wood
113e94369c query_system: finish migration
Using eager translation, migrate the remaining repeated cycle stack
diagnostic.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
David Wood
291a4736d9 macros: #[subdiagnostic(eager)]
Add support for `eager` argument to the `subdiagnostic` attribute which
generates a call to `eager_subdiagnostic`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00