Commit Graph

1154 Commits

Author SHA1 Message Date
Oli Scherer
9a8e1eea7a Move a field around 2022-11-21 16:35:23 +00:00
Oli Scherer
ae80c764d4 Add an always-ambiguous predicate to make sure that we don't accidentlally allow trait resolution to prove false things during coherence 2022-11-21 16:35:04 +00:00
Oli Scherer
94fe30ff2f Treat different opaque types of the same def id as equal during coherence 2022-11-21 16:06:07 +00:00
bors
1cbc45942d Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104420 (Fix doc example for `wrapping_abs`)
 - #104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`)
 - #104500 (`rustc_ast`: remove `ref` patterns)
 - #104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class)
 - #104595 (Add `PolyExistentialPredicate` type alias)
 - #104605 (deduplicate constant evaluation in cranelift backend)
 - #104628 (Revert "Update CI to use Android NDK r25b")
 - #104662 (Streamline deriving on packed structs.)
 - #104667 (Revert formatting changes of a test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-21 15:22:54 +00:00
Matthias Krüger
844e3fb928
Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
Add `PolyExistentialPredicate` type alias

Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-21 14:11:11 +01:00
bors
7fe6f36224 Auto merge of #103491 - cjgillot:self-rpit, r=oli-obk
Support using `Self` or projections inside an RPIT/async fn

I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait.

The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`.  This PR changes the scheme
```rust
impl<'a> Foo<'a> {
    fn foo<'b, T>() -> impl Into<Self> + 'b { ... }
}

opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b;
impl<'a> Foo<'a> {
    // OLD
    fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... }
                             ^^^^^^^ the `Self` becomes `Foo<'static>`

    // NEW
    fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... }
                             ^^ the `Self` stays `Foo<'a>`
}
```

There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one.

This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more.  The same trick allows to use projections like `T::Assoc` where `Self` is allowed.  The feature is gated behind a `impl_trait_projections` feature gate.

The implementation relies on 2 tweaking rules for opaques in 2 places:
- we only relate substs that correspond to captured lifetimes during TypeRelation;
- we only list captured lifetimes in choice region computation.

For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques.

Impl-trait that do not reference `Self` or projections will have their variances as:
- `o` (invariant) for each parent type or const;
- `*` (bivariant) for each parent lifetime --> will not participate in borrowck;
- `o` (invariant) for each own lifetime.

Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck.  In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`.

r? types
cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-21 12:17:03 +00:00
Dylan DPC
7f35493e99
Rollup merge of #104554 - BoxyUwU:less_unchecked_pls, r=lcnr
Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less

there are only like 3 or 4 call sites left after this but it wasnt obvious to me how to remove them
2022-11-19 11:54:45 +05:30
Dylan DPC
00876c68c4
Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errors
nll: correctly deal with bivariance

fixes #104409

when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions.

r? types cc ``@RalfJung``
2022-11-19 11:54:44 +05:30
Michael Goulet
c36ff28d42 drive-by: PolyExistentialPredicate 2022-11-19 04:04:27 +00:00
Boxy
9ed348376f require an ErrorGuaranteed to taint infcx with errors 2022-11-18 13:25:17 +00:00
Boxy
1c48039a87 rename is_tainted_by_errors 2022-11-18 13:25:17 +00:00
Boxy
9c510048fd InferCtxt::is_tainted_by_errors returns ErrorGuaranteed 2022-11-18 13:25:17 +00:00
Oli Scherer
4f11f3b257 Convert predicates into Predicate in the Obligation constructor 2022-11-16 09:25:19 +00:00
lcnr
6aa611a84c mv utility methods into separate module 2022-11-15 13:50:13 +01:00
lcnr
45f441a7b4 nll: correctly deal with bivariance 2022-11-15 13:34:08 +01:00
Camille GILLOT
3afec247cb Deduplicate visitor. 2022-11-14 18:20:49 +00:00
Camille GILLOT
d470ac9334 Drop relate_opaque_item_substs. 2022-11-14 18:05:14 +00:00
Camille GILLOT
5fc261e9a0 Inherit generics for impl-trait. 2022-11-12 09:59:36 +00:00
Dylan DPC
662df1ec86
Rollup merge of #104206 - compiler-errors:ocx-more-2, r=lcnr
Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more

r? ```@lcnr```
2022-11-12 12:02:52 +05:30
bors
11fa0850f0 Auto merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, r=jackh276,davidtwco
Recover from common if let syntax mistakes/typos

Fixes #103587
2022-11-10 05:19:10 +00:00
Michael Goulet
ed6a7cc228 Remove save_and_restore_in_snapshot_flag 2022-11-09 22:58:39 +00:00
bors
cc9b259b5e Auto merge of #103723 - CastilloDel:master, r=jackh726
Remove allow(rustc::potential_query_instability) in rustc_trait_selection

Related to https://github.com/rust-lang/rust/issues/84447

This PR needs to be benchmarked to check for regressions.
2022-11-09 13:45:27 +00:00
bors
bc2504a83c Auto merge of #103171 - jackh726:gen-interior-hrtb-error, r=cjgillot
Better error for HRTB error from generator interior

cc #100013

This is just a first pass at an error. It could be better, and shouldn't really be emitted in the first place. But this is better than what was being emitted before.
2022-11-09 02:02:28 +00:00
CastilloDel
755ca4b9aa Reduce the scope of allow(rustc::potential_query_instability) in rustc_trait_selection
Make InferCtxtExt use a FxIndexMap

This should be faster, because the map is only being used to iterate,
which is supposed to be faster with the IndexMap

Make the user_computed_preds use an IndexMap

It is being used mostly for iteration, so the change shouldn't result in
a perf hit

Make the RegionDeps fields use an IndexMap

This change could be a perf hit. Both `larger` and `smaller` are used
for iteration, but they are also used for insertions.

Make types_without_default_bounds use an IndexMap

It uses extend, but it also iterates and removes items. Not sure if
this will be a perf hit.

Make InferTtxt.reported_trait_errors use an IndexMap

This change brought a lot of other changes. The map seems to have been
mostly used for iteration, so the performance shouldn't suffer.

Add FIXME to change ProvisionalEvaluationCache.map to use an IndexMap

Right now this results in a perf hit. IndexMap doesn't have
the `drain_filter` API, so in `on_completion` we now need to iterate two
times over the map.
2022-11-08 19:41:48 +01:00
yukang
9e7d2287cd use subdiagnostic for sugesting add let 2022-11-08 16:25:37 +08:00
yukang
667b15bb0e fix #103587, Recover from common if let syntax mistakes/typos 2022-11-08 14:10:04 +08:00
Dylan DPC
77a44ab568
Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, r=eholk
Move `fallback_has_occurred` state tracking to `FnCtxt`

Removes a ton of callsites that defaulted to `false`
2022-11-08 11:23:51 +05:30
Jack Huey
3c71fafd6d Add a known that this is a known limitation 2022-11-07 17:52:08 -05:00
Jack Huey
cececca7c7 Get spans for a couple more region types, add some optimizations, and extend test 2022-11-07 17:39:30 -05:00
Jack Huey
00e314d5ed Add an optional Span to BrAnon and use it to print better error for HRTB error from generator interior 2022-11-07 17:39:29 -05:00
bors
ca08a32655 Auto merge of #103218 - CastilloDel:infer, r=jackh726
Remove #![allow(rustc::potential_query_instability)] from rustc_infer

Related to #84447

This PR probably needs to be benchmarked to check for regressions.
2022-11-07 07:38:05 +00:00
Michael Goulet
bc345d7bd0 Move fallback_has_occurred to FnCtxt 2022-11-06 02:40:25 +00:00
bors
a4ab2e0643 Auto merge of #103975 - oli-obk:tracing, r=jackh726
Some tracing and comment cleanups

Pulled out of https://github.com/rust-lang/rust/pull/101900 to see if that is the perf impact
2022-11-06 02:21:34 +00:00
Mateusz
c97fd8183a
Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
Oli Scherer
44d1936d00 Some tracing and comment cleanups 2022-11-04 17:10:07 +00:00
Manish Goregaokar
69e705564d
Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco
Change #[suggestion_*] attributes to use style="..."

As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter.

It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all.

Best reviewed commit-by-commit, there's a bit of noise in there.

cc #100717 `@compiler-errors`
r? `@davidtwco`
2022-11-01 20:00:38 -04:00
bors
e70cbef0c5 Auto merge of #103590 - compiler-errors:ocx-more, r=lcnr
(almost) Always use `ObligationCtxt` when dealing with canonical queries

Hope this is a step in the right direction. cc rust-lang/types-team#50.

r? `@lcnr`
2022-11-01 12:15:10 +00:00
Nicholas Nethercote
c8c25ce5a1 Rename some OwnerId fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
CastilloDel
e9502010b4 Remove #![allow(rustc::potential_query_instability)] from rustc_infer
Change reported_violations to use IndexSet

It is being used to iterate and to insert, without a lot of lookups
so hopefully it won't be a perf hit

Change MiniGraph.nodes to use IndexSet

It is being used to iterate and to insert, without performing lookups
so hopefully it won't be a perf hit

Change RegionConstraintData.givens to a FxIndexSet

This might result in a perf hit. Remove was being used in `givens`,
and `FxIndexSet` doesn't allow calling remove without losing the
fixed iteration order. So it was necessary to change remove to
`shift_remove`, but this method is slower.

Change OpaqueTypesVisitor to use stable sets and maps

This could also be a perf hit.

Make TraitObject visitor use a stable set
2022-10-28 15:32:49 +02:00
Matthias Krüger
84663cee39
Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillot
Don't carry MIR location in `ConstraintCategory::CallArgument`

It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies.

So instead, revert the commit a6b5f95fb0, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in #103220.

Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen.

Fixes #103624
2022-10-28 07:06:43 +02:00
Michael Goulet
dce44faf5b Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"
This reverts commit a6b5f95fb0.
2022-10-27 16:15:11 +00:00
Michael Goulet
d793d80cf7 (almost) Always use ObligationCtxt when dealing with canonical queries 2022-10-27 15:43:33 +00:00
Matthias Krüger
16e74c78a1
Rollup merge of #103255 - oli-obk:opaque_wrong_eq_relation, r=compiler-errors
Clean up hidden type registration

work on https://github.com/rust-lang/rust/issues/101186

Actually passing down the relation and using it instead of `eq` for the hidden type comparison has *no* effect whatsoever and allows for no further improvements at the call sites. I decided the increased complexity was not worth it and thus did not include that change in this PR.

r? `@compiler-errors`
2022-10-27 15:03:55 +02:00
Michael Goulet
901649eeb7 No need to probe when relating opaques in nll_relate 2022-10-26 22:10:12 +00:00
Xiretza
cd621be782 Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]
Using the following command:

find compiler/ -type f -name '*.rs' -exec perl -i -gpe \
    's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \
    '{}' +
2022-10-26 15:04:09 +02:00
Oli Scherer
de5517c3ae Remove unneeded sub-comparison 2022-10-26 12:47:04 +00:00
Dylan DPC
785828744c
Rollup merge of #103416 - compiler-errors:rpit-named, r=cjgillot
Name the `impl Trait` in region bound suggestions

Slightly more descriptive message
2022-10-26 11:29:54 +05:30
Michael Goulet
726bf18d2d Name impl trait in region bound suggestion 2022-10-25 16:37:11 +00:00
Oli Scherer
f3bd222ad9 Bubble the opaque type ordering int opaque type handling 2022-10-25 13:27:58 +00:00
Oli Scherer
14caf7396d Pull opaque type handling out of the type relating delegate 2022-10-25 13:27:04 +00:00
Michael Goulet
1727c00f1a Assert if inference vars are leaking from fully_resolve 2022-10-24 18:53:32 +00:00
bors
e64f1110c0 Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
Flatten diagnostic slug modules

This makes it easier to grep for the slugs in the code.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.

This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.

r? `@davidtwco`
2022-10-23 09:06:39 +00:00
Nilstrieb
c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
Matthias Krüger
ff689a1404
Rollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk
Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes #102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes #103352

r? ```@oli-obk```
2022-10-23 08:14:31 +02:00
Matthias Krüger
b656f5e9a6
Rollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errors
Escape string literals when fixing overlong char literal

Fixes #103323

````@rustbot```` label +A-diagnostics +A-suggestion-diagnostics
2022-10-23 08:14:31 +02:00
Michael Goulet
aa8931c612 Introduce subst_iter and subst_iter_copied on EarlyBinder 2022-10-22 06:52:12 +00:00
clubby789
ed40d46159 Properly escape quotes when suggesting switching between char/string literals 2022-10-22 02:37:15 +01:00
Michael Goulet
419fde7a38 Handle RPITITs properly in register_hidden_type 2022-10-21 14:57:01 +00:00
Dylan DPC
e11511dfa6
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errors
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use

- Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing.
- Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic.
- Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc.

cc #100717
2022-10-21 17:29:58 +05:30
Michael Goulet
a6b5f95fb0 Make ClosureOutlivesRequirement not rely on an unresolved type 2022-10-19 17:10:59 +00:00
bors
a9d1cafa87 Auto merge of #102355 - lcnr:bye-bye-type-traversal, r=oli-obk
remove type traversal for mir constants

r? `@oli-obk` cc `@b-naber`
2022-10-17 14:19:28 +00:00
David Wood
913f597402 infer: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17 09:54:24 +01:00
lcnr
e8150fa60c mir constants: type traversing bye bye 2022-10-17 10:54:01 +02:00
Takayuki Maeda
0b6fa0d418 fix own_substs ICE 2022-10-16 22:24:27 +09:00
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08: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
Rageking8
d1982bd0af fix small word dupe typos 2022-10-13 00:53:46 +08:00
Niko Matsakis
70200ac190
Update compiler/rustc_infer/src/infer/canonical/mod.rs 2022-10-10 16:51:36 -04:00
David Wood
b4ac26289f errors: 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.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
Yuki Okushi
24424d0acb
Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-10 00:09:42 +09:00
Michael Goulet
70f3c79c50 ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
Cameron Steffen
283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Cameron Steffen
349415d1c6 Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
Cameron Steffen
4a68373217 Introduce TypeErrCtxt
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.
2022-10-07 07:06:16 -05:00
Dylan DPC
cec087a202
Rollup merge of #102496 - compiler-errors:into-suggestion, r=davidtwco
Suggest `.into()` when all other coercion suggestions fail

Also removes some bogus suggestions because we now short-circuit when offering coercion suggestions(instead of, for example, suggesting every one that could possibly apply)

Fixes #102415
2022-10-05 17:27:33 +05:30
Takayuki Maeda
45257962d3 stop suggesting adding generic args for turbofish 2022-10-05 16:58:29 +09:00
Michael Goulet
28eda9b18a Suggest .into() when all other coercion suggestions fail 2022-10-05 02:47:31 +00:00
Oli Scherer
c7b6ebdf7c It's not about types or consts, but the lack of regions 2022-10-04 14:10:44 +00:00
Nicholas Nethercote
f07d4efc45 Shrink hir::def::Res.
`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-29 08:44:52 +10:00
lcnr
1fc86a63f4 rustc_typeck to rustc_hir_analysis 2022-09-27 10:37:23 +02:00
Pietro Albini
3975d55d98
remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
bors
f5193a9fcc Auto merge of #95474 - oli-obk:tait_ub, r=jackh726
Neither require nor imply lifetime bounds on opaque type for well formedness

The actual hidden type can live arbitrarily longer than any individual lifetime and arbitrarily shorter than all but one of the lifetimes.

fixes #86218
fixes #84305

This is a **breaking change** but it is a necessary soundness fix
2022-09-25 19:15:26 +00:00
Matthias Krüger
16de1fddee
Rollup merge of #102016 - lcnr:given-OutlivesEnvironment, r=jackh726
implied_bounds: deal with inference vars

fixes #101951

while computing implied bounds for `<<T as ConstructionFirm>::Builder as BuilderFn<'_>>::Output` normalization replaces a projection with an inference var (adding a `Projection` obligation). Until we prove that obligation, this inference var remains unknown, which caused us to miss an implied bound necessary to prove that the unnormalized projection from the trait method signature is wf.

r? types
2022-09-25 09:32:07 +02:00
Takayuki Maeda
8fe936099a separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
bors
9a963e3bad Auto merge of #102056 - b-naber:unevaluated, r=lcnr
Introduce mir::Unevaluated

Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that.

r? `@lcnr`
2022-09-23 13:39:11 +00:00
b-naber
a705e65605 rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
bors
4d44e09cb1 Auto merge of #102165 - matthiaskrgr:rollup-n5oquhe, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #100734 (Split out async_fn_in_trait into a separate feature)
 - #101664 (Note if mismatched types have a similar name)
 - #101815 (Migrated the rustc_passes annotation without effect diagnostic infrastructure)
 - #102042 (Distribute rust-docs-json via rustup.)
 - #102066 (rustdoc: remove unnecessary `max-width` on headers)
 - #102095 (Deduplicate two functions that would soon have been three)
 - #102104 (Set 'exec-env:RUST_BACKTRACE=0' in const-eval-select tests)
 - #102112 (Allow full relro on powerpc64-unknown-linux-gnu)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-23 09:33:23 +00:00
Oli Scherer
59e285ff34 Report diagnostics at the actually actionable site 2022-09-23 08:00:02 +00:00
Matthias Krüger
c2d2535b84
Rollup merge of #101664 - mejrs:similarity, r=fee1-dead
Note if mismatched types have a similar name

If users get a type error between similarly named types, it will point out that these are actually different types, and where they were defined.
2022-09-23 04:29:16 +02:00
Matthias Krüger
b93c9a7d37
Rollup merge of #102128 - oli-obk:const_unification, r=lcnr
Const unification is already infallible, remove the error handling logic

r? `@lcnr`

is this expected to be used in the future? Right now it is dead code.
2022-09-22 21:34:53 +02:00
bors
89e4e1f1b3 Auto merge of #102139 - Dylan-DPC:rollup-ljlipt8, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #101598 (Update rustc's information on Android's sanitizers)
 - #102036 (Remove use of `io::ErrorKind::Other` in std)
 - #102037 (Make cycle errors recoverable)
 - #102069 (Skip `Equate` relation in `handle_opaque_type`)
 - #102076 (rustc_transmute: fix big-endian discriminants)
 - #102107 (Add missing space between notable trait tooltip and where clause)
 - #102119 (Fix a typo “pararmeter” in error message)
 - #102131 (Added which number is computed in compute_float.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-22 15:18:35 +00:00
Dylan DPC
8bf533593d
Rollup merge of #102069 - compiler-errors:no-eq-in-register-opaque, r=oli-obk
Skip `Equate` relation in `handle_opaque_type`

r? ``@oli-obk``
2022-09-22 18:25:54 +05:30
Dylan DPC
d5ae6737bf
Rollup merge of #102037 - jyn514:normalize-docs, r=lcnr
Make cycle errors recoverable

In particular, this allows rustdoc to recover from cycle errors when normalizing associated types for documentation.

In the past, ```@jackh726``` has said we need to be careful about overflow errors: https://github.com/rust-lang/rust/pull/91430#issuecomment-983997013

> Off the top of my head, we definitely should be careful about treating overflow errors the same as
"not implemented for some reason" errors. Otherwise, you could end up with behavior that is
different depending on recursion depth. But, that might be context-dependent.

But cycle errors should be safe to unconditionally report; they don't depend on the recursion depth, they will always be an error whenever they're encountered.

Helps with https://github.com/rust-lang/rust/issues/81091.

r? ```@lcnr``` cc ```@matthewjasper```
2022-09-22 18:25:53 +05:30
bors
8ab71ab59f Auto merge of #100980 - compiler-errors:normalize-opaque-w-bound-vars, r=lcnr
Normalize opaques w/ bound vars

First, we reenable normalization of opaque types with escaping late bound regions to fix rust-lang/miri#2433. This essentially reverts #89285.

Second, we mitigate the perf regression found in #88862 by simplifying the way that we relate (sub and eq) GeneratorWitness types.

This relies on the fact that we construct these GeneratorWitness types somewhat particularly (with all free regions found in the witness types replaced with late bound regions) -- but those bound regions really should be treated as existential regions, not universal ones. Those two facts leads me to believe that we do not need to use the full `higher_ranked_sub` machinery to relate two generator witnesses. I'm pretty confident that this is correct, but I'm glad to discuss this further.
2022-09-22 12:47:31 +00:00
b-naber
9f3784df89 introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
Oli Scherer
13438ee29c Const unification is already infallible, remove the error handling logic 2022-09-22 08:20:13 +00:00
bors
7a8636c843 Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk
Require `#[const_trait]` on `Trait` for `impl const Trait`

r? `@oli-obk`
2022-09-22 04:22:24 +00:00
Michael Goulet
02ad984d74 Comment, and bail early if bound vars list differs 2022-09-22 02:17:39 +00:00
Michael Goulet
d018144761 Optimize subtyping and equation of GeneratorWitness 2022-09-22 02:17:39 +00:00
bors
9062b780b3 Auto merge of #101558 - JhonnyBillM:session-diagnostic-to-diagnostic-handler-refactor, r=davidtwco
Move and rename `SessionDiagnostic` & `SessionSubdiagnostic` traits and macros

After PR #101434, we want to:
- [x] Move `SessionDiagnostic` to `rustc_errors`.
- [x] Add `emit_` methods that accept `impl SessionDiagnostic` to `Handler`.
- [x] _(optional)_ Rename trait `SessionDiagnostic` to `DiagnosticHandler`.
- [x] _(optional)_ Rename macro `SessionDiagnostic` to `DiagnosticHandler`.
- [x] Update Rustc Dev Guide and Docs to reflect these changes. https://github.com/rust-lang/rustc-dev-guide/pull/1460

Now I am having build issues getting the compiler to build when trying to rename the macro.

<details>
  <summary>See diagnostics errors and context when building.</summary>

```
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
  --> compiler/rustc_attr/src/session_diagnostics.rs:13:10
   |
13 |   #[derive(DiagnosticHandler)]
   |            ^^^^^^^^^^^^^^^^^ in this derive macro expansion
   |
  ::: /Users/jhonny/.cargo/registry/src/github.com-1ecc6299db9ec823/synstructure-0.12.6/src/macros.rs:94:9
   |
94 | /         pub fn $derives(
95 | |             i: $crate::macros::TokenStream
96 | |         ) -> $crate::macros::TokenStream {
   | |________________________________________- in this expansion of `#[derive(DiagnosticHandler)]`
   |
note: the lint level is defined here
  --> compiler/rustc_attr/src/lib.rs:10:9
   |
10 | #![deny(rustc::diagnostic_outside_of_impl)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

```

And also this one:

```
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_attr/src/session_diagnostics.rs:213:32
    |
213 |         let mut diag = handler.struct_span_err_with_code(
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
```

> **Note**
> Can't find where this message is coming from, because you can see in [this experimental branch](https://github.com/JhonnyBillM/rust/tree/experimental/trying-to-rename-session-diagnostic-macro)  that I updated all errors and diags to say:
> error: diagnostics should only be created in **`DiagnosticHandler`**/`AddSubdiagnostic` impls
> and not:
> error: diagnostics should only be created in **`SessionDiagnostic`**/`AddSubdiagnostic` impls

</details>

I tried building the compiler in different ways (playing with the stages etc), but nothing worked.

## Question

**Do we need to build or do something different when renaming a macro and identifiers?**

For context, see experimental commit f2193a98b4 where the macro and symbols are renamed, but it doesn't compile.
2022-09-21 19:58:39 +00:00