Commit Graph

13124 Commits

Author SHA1 Message Date
Matthias Krüger
c5d6f82cb7
Rollup merge of #96769 - Undin:remove-adx_target_feature-from-active, r=joshtriplett
Remove `adx_target_feature` feature from active features list

The feature was stabilized in https://github.com/rust-lang/rust/pull/93745
2022-05-07 22:44:42 +02:00
Camille GILLOT
69e5b2fde0 Do not report overflow error. 2022-05-07 18:18:03 +02:00
flip1995
dd1ff405e3
Track if a where bound comes from a impl Trait desugar
With #93803 `impl Trait` function arguments get desugared to hidden
where bounds. However, Clippy needs to know if a bound was originally a
impl Trait or an actual bound. This adds a field to the
`WhereBoundPredicate` struct to keep track of this information during
HIR lowering.
2022-05-07 17:10:30 +02:00
Guillaume Gomez
27a2bae89c
Rollup merge of #96788 - JakobDegen:checked-binop, r=oli-obk
Improve validator around field projections and checked bin ops

The two commits are unrelated. In both cases, these rules were already documented in MIR docs.
2022-05-07 15:23:47 +02:00
Guillaume Gomez
a644197391
Rollup merge of #96760 - davidtwco:diagnostic-translation-vec, r=oli-obk
diagnostics: port more diagnostics to derive + add support for `Vec` fields

- Port "unconstrained opaque type" diagnostic to using the derive.
- Allow `Vec` fields in diagnostic derive - enables support for diagnostics that have multiple primary spans, or have subdiagnostics repeated at multiple locations. `Vec<..>` fields in the diagnostic derive become loops in the generated code.
- Add `create_{err,warning}` - there wasn't a way to create a diagnostic from a struct and not emit it straight away.
- Port "explicit generic args w/ impl trait" diagnostic to using the derive.

r? `````@oli-obk`````
cc `````@pvdrz`````
2022-05-07 15:23:46 +02:00
Guillaume Gomez
c29f8575ac
Rollup merge of #96581 - RalfJung:debug-size-align, r=oli-obk
make Size and Align debug-printing a bit more compact

In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable).

We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that?

Cc `````@oli-obk`````
2022-05-07 15:23:44 +02:00
SparrowLii
cb7f116c04 optimize promote_consts by cache the validate check 2022-05-07 21:02:25 +08:00
Camille GILLOT
96321ed756 Do not lint on explicit outlives requirements from external macros. 2022-05-07 12:41:15 +02:00
Camille GILLOT
6b348257a1 Cleanup opaque type storage after checking impossible predicates. 2022-05-07 10:25:57 +02:00
Camille GILLOT
8492460fa4 Also check TraitRef with impossible predicates. 2022-05-07 10:24:45 +02:00
bors
574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
bors
36aa7c1436 Auto merge of #96804 - compiler-errors:rollup-1mc6aw3, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #96660 ([bootstrap] Give a better error when trying to run a path with no registered step)
 - #96701 (update `jemallocator` example to use 2018 edition import syntax)
 - #96746 (Fix an ICE on #96738)
 - #96758 (bootstrap: bsd platform flags for split debuginfo)
 - #96778 (Remove closures on `expect_local` to apply `#[track_caller]`)
 - #96781 (Fix an incorrect link in The Unstable Book)
 - #96783 (Link to correct issue in issue-95034 known-bug)
 - #96801 (Add regression test for #96319)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-07 04:15:52 +00:00
Michael Goulet
f799c5d897
Rollup merge of #96778 - JohnTitor:expect-local-track-caller-take-2, r=petrochenkov
Remove closures on `expect_local` to apply `#[track_caller]`

Pointed out in https://github.com/rust-lang/rust/pull/96747#discussion_r866576196
Didn't change `expect_non_local` as I'm not sure if it's also the case.
r? ``@petrochenkov``
2022-05-06 20:49:35 -07:00
Michael Goulet
825dc80d1a
Rollup merge of #96746 - JohnTitor:issue-96738, r=petrochenkov
Fix an ICE on #96738

In the block we don't know if the method actually exists thus `expect_local` panics.
Fixes #96738
Fixes #96583
2022-05-06 20:49:32 -07:00
Jack Huey
7d8e10d3c2 Resolve vars before emitting coerce suggestions too 2022-05-06 23:35:44 -04:00
Jack Huey
62d0e4cba9 Resolve vars in note_type_err 2022-05-06 23:35:42 -04:00
bors
f6e5570460 Auto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, r=cjgillot
Remove ItemLikeVisitor impls from rustc_typeck

Issue #95004
cc `@cjgillot`
2022-05-07 01:59:11 +00:00
bors
4799baa70d Auto merge of #96458 - Aaron1011:no-cycle-caching, r=jackh726,cjgillot
Don't cache results of coinductive cycle
2022-05-06 22:41:16 +00:00
Jack Huey
1549576732 Point at closure args too 2022-05-06 16:55:53 -04:00
Jakob Degen
c4168fdb50 Check that field projections have the correct type 2022-05-06 16:43:09 -04:00
bors
77652b9ef3 Auto merge of #96785 - GuillaumeGomez:rollup-rgiwa57, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #96557 (Allow inline consts to reference generic params)
 - #96590 (rustdoc: when running a function-signature search, tweak the tab bar)
 - #96650 (Collect function instance used in `global_asm!` sym operand)
 - #96733 (turn `append_place_to_string` from recursion into iteration)
 - #96748 (Fixes reexports in search)
 - #96752 (Put the incompatible_closure_captures lint messages in alphabetical order)
 - #96754 (rustdoc: ensure HTML/JS side implementors don't have dups)
 - #96772 (Suggest fully qualified path with appropriate params)
 - #96776 (Fix two minor issues in hir.rs)
 - #96782 (a small `mirror_expr` cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-06 20:14:01 +00:00
Jakob Degen
5289bbece3 Expand validator to be more precise on checked binary ops 2022-05-06 15:40:32 -04:00
Guillaume Gomez
a0e2c7e8bb
Rollup merge of #96782 - lcnr:mirror-expr, r=compiler-errors
a small `mirror_expr` cleanup
2022-05-06 20:05:45 +02:00
Guillaume Gomez
a411a32cae
Rollup merge of #96776 - liuw:hir, r=oli-obk
Fix two minor issues in hir.rs

I found these two places in hir.rs which could use a bit of improvements while going through the code.

No functional change.
2022-05-06 20:05:45 +02:00
Guillaume Gomez
6db969ec95
Rollup merge of #96772 - TaKO8Ki:suggest-fully-qualified-path-with-appropriate-params, r=compiler-errors
Suggest fully qualified path with appropriate params

closes #96291
2022-05-06 20:05:44 +02:00
Guillaume Gomez
28d85ab8c4
Rollup merge of #96752 - scottmcm:error-sorting, r=compiler-errors
Put the incompatible_closure_captures lint messages in alphabetical order

Looks like they were in hash order before, which was causing me trouble in #94598, so this PR sorts the errors by trait name.
2022-05-06 20:05:42 +02:00
Guillaume Gomez
c3ddd59f5b
Rollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco
turn `append_place_to_string` from recursion into iteration

This PR fixes the FIXME in the impl of `append_place_to_string` which turns `append_place_to_string` from recursion into iteration, meanwhile simplifying the code relatively.
2022-05-06 20:05:40 +02:00
Guillaume Gomez
c7af4e67c3
Rollup merge of #96650 - tmiasko:global-asm-sym-fn, r=Amanieu
Collect function instance used in `global_asm!` sym operand

The constants used in SymFn operands have FnDef type,
so the type of the constant identifies the function.

Fixes #96623.
2022-05-06 20:05:39 +02:00
Guillaume Gomez
66443a1852
Rollup merge of #96557 - nbdd0121:const, r=oli-obk
Allow inline consts to reference generic params

Tracking issue: #76001

The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well.

However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have:
```rust
fn foo<T>() {
    let x = [4i32; std::mem::size_of::<T>()];   // NOT ALLOWED (for now)
    let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR!
    let x = [4i32; const { std::mem::size_of::<T>() }];   // NOT ALLOWED (for now)
}
```

This would make inline consts super useful for compile-time checks and assertions:
```rust
fn assert_zst<T>() {
    const { assert!(std::mem::size_of::<T>() == 0) };
}
```

This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do:
```rust
fn assert_zst<T>() {
    struct F<T>(T);
    impl<T> F<T> {
        const V: () = assert!(std::mem::size_of::<T>() == 0);
    }
    let _ = F::<T>::V;
}
```

It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either:
```rust
fn foo<T>() -> usize {
    let (_, size): (PhantomData<T>, usize) = const {
        const fn my_size_of<T>() -> (PhantomData<T>, usize) {
            (PhantomData, std::mem::size_of::<T>())
        }
        my_size_of()
    };
    size
}
```

```@rustbot``` label: F-inline_const
2022-05-06 20:05:37 +02:00
bors
d60b4f52c9 Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser
Fixing #95444 by only displaying passes that take more than 5 millise…

As discussed in #95444, I have added the code to test and only display prints that are greater than 5 milliseconds.

r? `@jyn514`
2022-05-06 17:52:47 +00:00
lcnr
a87fa6314f mirror_expr cleanup 2022-05-06 19:00:37 +02:00
Yuki Okushi
7b773e890e
Remove closures on expect_local to apply #[track_caller] 2022-05-07 01:11:32 +09:00
Miguel Guarniz
91ef3ba71d remove all usages of hir().def_kind
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:05 -04:00
Miguel Guarniz
3afc5ea201 use def_span and def_kind queries instead of calling tcx.hir() methods
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:05 -04:00
Miguel Guarniz
ef1d112095 pass ItemId to check_item_type instead of Item
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:05 -04:00
Miguel Guarniz
1b07c4af81 remove ImplWfCheck
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:05 -04:00
Miguel Guarniz
dfe07461f4 remove CheckItemTypesVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:04 -04:00
Miguel Guarniz
d88dfd2522 use hir_module_items in check_mod_item_types query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:04 -04:00
Miguel Guarniz
422dd3b8dc use hir_module_items instead of visit_all_item_likes in check_mod_impl_wf query
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:04 -04:00
Miguel Guarniz
f47f39b95f remove UnsafetyChecker
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:04 -04:00
Miguel Guarniz
7c3c588988 remove ItemLikeVisitor impl for InherentOverlapChecker
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:11:04 -04:00
Miguel Guarniz
63849b6ecf remove ItemLikeVisitor impl for InherentCollect
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 12:10:59 -04:00
Miguel Guarniz
c27f30835c remove OutlivesTest
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 11:55:15 -04:00
Miguel Guarniz
9c111dd209 remove VarianceTest
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 11:55:15 -04:00
Miguel Guarniz
03e955d812 use DefKind::Fn instead of DefKind::AsscFn for foreign items
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 11:55:15 -04:00
Miguel Guarniz
a7225275e5 remove ItemLikeVisitor impl for TermsContext
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 11:55:15 -04:00
Miguel Guarniz
7064033bf6 remove ItemLikeVisitor impl for ContraintContext
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06 11:55:15 -04:00
Yuki Okushi
35d77c1710
Also suggest calling constructors for external DefIds 2022-05-07 00:43:50 +09:00
Wei Liu
fcb385cfb1 Use matches! for YieldSource::is_await 2022-05-06 15:00:48 +00:00
Wei Liu
85e688e4c3 Fix comment for async closure variant 2022-05-06 14:59:40 +00:00
Takayuki Maeda
857eb02abe suggest fully qualified path with appropriate params 2022-05-06 23:14:11 +09:00
bors
9a251644fa Auto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint, r=nikomatsakis
Remove mutable_borrow_reservation_conflict lint and allow the code pattern

This was the only breaking issue with the NLL stabilization PR. Lang team decided to go ahead and allow this.

r? `@nikomatsakis`
Closes #59159
Closes #56254
2022-05-06 12:32:44 +00:00
Ellen
e4b8ed5aff move closure down 2022-05-06 11:40:18 +01:00
Ellen
2819b2d8c9 wording tweaks 2022-05-06 11:37:22 +01:00
Arseniy Pendryak
02ac4a4e02 Remove adx_target_feature feature from active features list
The feature was stabilized in https://github.com/rust-lang/rust/pull/93745
2022-05-06 13:12:45 +03:00
bors
8c4fc9d9a4 Auto merge of #94598 - scottmcm:prefix-free-hasher-methods, r=Amanieu
Add a dedicated length-prefixing method to `Hasher`

This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.

Fixes #94026

r? rust-lang/libs

---

The core of this change is the following two new methods on `Hasher`:

```rust
pub trait Hasher {
    /// Writes a length prefix into this hasher, as part of being prefix-free.
    ///
    /// If you're implementing [`Hash`] for a custom collection, call this before
    /// writing its contents to this `Hasher`.  That way
    /// `(collection![1, 2, 3], collection![4, 5])` and
    /// `(collection![1, 2], collection![3, 4, 5])` will provide different
    /// sequences of values to the `Hasher`
    ///
    /// The `impl<T> Hash for [T]` includes a call to this method, so if you're
    /// hashing a slice (or array or vector) via its `Hash::hash` method,
    /// you should **not** call this yourself.
    ///
    /// This method is only for providing domain separation.  If you want to
    /// hash a `usize` that represents part of the *data*, then it's important
    /// that you pass it to [`Hasher::write_usize`] instead of to this method.
    ///
    /// # Examples
    ///
    /// ```
    /// #![feature(hasher_prefixfree_extras)]
    /// # // Stubs to make the `impl` below pass the compiler
    /// # struct MyCollection<T>(Option<T>);
    /// # impl<T> MyCollection<T> {
    /// #     fn len(&self) -> usize { todo!() }
    /// # }
    /// # impl<'a, T> IntoIterator for &'a MyCollection<T> {
    /// #     type Item = T;
    /// #     type IntoIter = std::iter::Empty<T>;
    /// #     fn into_iter(self) -> Self::IntoIter { todo!() }
    /// # }
    ///
    /// use std:#️⃣:{Hash, Hasher};
    /// impl<T: Hash> Hash for MyCollection<T> {
    ///     fn hash<H: Hasher>(&self, state: &mut H) {
    ///         state.write_length_prefix(self.len());
    ///         for elt in self {
    ///             elt.hash(state);
    ///         }
    ///     }
    /// }
    /// ```
    ///
    /// # Note to Implementers
    ///
    /// If you've decided that your `Hasher` is willing to be susceptible to
    /// Hash-DoS attacks, then you might consider skipping hashing some or all
    /// of the `len` provided in the name of increased performance.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_length_prefix(&mut self, len: usize) {
        self.write_usize(len);
    }

    /// Writes a single `str` into this hasher.
    ///
    /// If you're implementing [`Hash`], you generally do not need to call this,
    /// as the `impl Hash for str` does, so you can just use that.
    ///
    /// This includes the domain separator for prefix-freedom, so you should
    /// **not** call `Self::write_length_prefix` before calling this.
    ///
    /// # Note to Implementers
    ///
    /// The default implementation of this method includes a call to
    /// [`Self::write_length_prefix`], so if your implementation of `Hasher`
    /// doesn't care about prefix-freedom and you've thus overridden
    /// that method to do nothing, there's no need to override this one.
    ///
    /// This method is available to be overridden separately from the others
    /// as `str` being UTF-8 means that it never contains `0xFF` bytes, which
    /// can be used to provide prefix-freedom cheaper than hashing a length.
    ///
    /// For example, if your `Hasher` works byte-by-byte (perhaps by accumulating
    /// them into a buffer), then you can hash the bytes of the `str` followed
    /// by a single `0xFF` byte.
    ///
    /// If your `Hasher` works in chunks, you can also do this by being careful
    /// about how you pad partial chunks.  If the chunks are padded with `0x00`
    /// bytes then just hashing an extra `0xFF` byte doesn't necessarily
    /// provide prefix-freedom, as `"ab"` and `"ab\u{0}"` would likely hash
    /// the same sequence of chunks.  But if you pad with `0xFF` bytes instead,
    /// ensuring at least one padding byte, then it can often provide
    /// prefix-freedom cheaper than hashing the length would.
    #[inline]
    #[unstable(feature = "hasher_prefixfree_extras", issue = "88888888")]
    fn write_str(&mut self, s: &str) {
        self.write_length_prefix(s.len());
        self.write(s.as_bytes());
    }
}
```

With updates to the `Hash` implementations for slices and containers to call `write_length_prefix` instead of `write_usize`.

`write_str` defaults to using `write_length_prefix` since, as was pointed out in the issue, the `write_u8(0xFF)` approach is insufficient for hashers that work in chunks, as those would hash `"a\u{0}"` and `"a"` to the same thing.  But since `SipHash` works byte-wise (there's an internal buffer to accumulate bytes until a full chunk is available) it overrides `write_str` to continue to use the add-non-UTF-8-byte approach.

---

Compatibility:

Because the default implementation of `write_length_prefix` calls `write_usize`, the changed hash implementation for slices will do the same thing the old one did on existing `Hasher`s.
2022-05-06 09:43:57 +00:00
Ralf Jung
22cc6c3482 don't debug-print ConstValue in MIR pretty-printer 2022-05-06 10:57:03 +02:00
Ralf Jung
bd31ba045d make Size and Align debug-printing a bit more compact 2022-05-06 10:57:03 +02:00
Elliot Roberts
647d0b6dd3 fix unmatched braces 2022-05-06 00:17:02 -07:00
Scott McMurray
98054377ee Add a dedicated length-prefixing method to Hasher
This accomplishes two main goals:
- Make it clear who is responsible for prefix-freedom, including how they should do it
- Make it feasible for a `Hasher` that *doesn't* care about Hash-DoS resistance to get better performance by not hashing lengths

This does not change rustc-hash, since that's in an external crate, but that could potentially use it in future.
2022-05-06 00:03:38 -07:00
SparrowLii
8ff01894a0 turn append_place_to_string from recursion into iteration 2022-05-06 12:11:42 +08:00
David Wood
af47257c0d typeck: port "explicit generic args w/ impl trait"
Port the "explicit generic arguments with impl trait" diagnostic to
using the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-06 03:46:12 +01:00
David Wood
3f413d2abb sess: add create_{err,warning}
Currently, the only API for creating errors from a diagnostic derive
will emit it immediately. This makes it difficult to add subdiagnostics
to diagnostics from the derive, so add `create_{err,warning}` functions
that return the diagnostic without emitting it.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-06 03:44:41 +01:00
David Wood
859079ff12 macros: allow Vec fields in diagnostic derive
Diagnostics can have multiple primary spans, or have subdiagnostics
repeated at multiple locations, so support `Vec<..>` fields in the
diagnostic derive which become loops in the generated code.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-06 03:43:30 +01:00
Michael Goulet
b8c829b64f
Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors
Add `track_caller` to `DefId::expect_local()`

Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888.
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
2022-05-05 19:34:27 -07:00
David Wood
3dac70fcc0 typeck: port "unconstrained opaque type" diag
Port the "unconstrained opaque type" diagnostic to using the diagnostic
derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-06 03:04:30 +01:00
Scott McMurray
30309db972 Put the 2229 migration errors in alphabetical order
Looks like they were in FxHash order before, so it might just be luck that this used to be consistent across different word lengths.
2022-05-05 17:41:02 -07:00
Peh
e79ba76ec4 Fixing #95444 by only displaying passes that take more than 5 milliseconds
95444: Adding passes that include memory increase

Fix95444: Change the substraction with the abs_diff() method

Fix95444: Change the substraction with abs_diff() method
2022-05-05 23:56:40 +00:00
bors
74cea9fdb9 Auto merge of #96520 - lcnr:general-incoherent-impls, r=petrochenkov
generalize "incoherent impls" impl for user defined types

To allow the move of `trait Error` into core.

continues the work from #94963, finishes https://github.com/rust-lang/compiler-team/issues/487

r? `@petrochenkov` cc `@yaahc`
2022-05-05 23:24:36 +00:00
Yuki Okushi
2ed38cdbdd
Add track_caller to DefId::expect_local() 2022-05-06 07:28:06 +09:00
Yuki Okushi
436c0e129c
Fix an ICE on #96738 2022-05-06 07:15:35 +09:00
Aaron Hill
40c6d838cd
Don't cache results of coinductive cycle
Fixes #96319

The logic around handling co-inductive cycles in the evaluation cache
is confusing and error prone. Fortunately, a perf run showed that it
doesn't actually appear to improve performance, so we can simplify
this code (and eliminate a source of ICEs) by just skipping caching
the evaluation results for co-inductive cycle participants.

This commit makes no changes to any of the other logic around
co-inductive cycle handling. Thus, while this commit could
potentially expose latent bugs that were being hidden by
caching, it should not introduce any new bugs.
2022-05-05 14:01:35 -04:00
bors
50cf76c24b Auto merge of #96734 - matthiaskrgr:rollup-hng33tb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #95359 (Update `int_roundings` methods from feedback)
 - #95843 (Improve Rc::new_cyclic and Arc::new_cyclic documentation)
 - #96507 (Suggest calling `Self::associated_function()`)
 - #96635 (Use "strict" mode in JS scripts)
 - #96673 (Report that opaque types are not allowed in impls even in the presence of other errors)
 - #96682 (Show invisible delimeters (within comments) when pretty printing.)
 - #96714 (interpret/validity: debug-check ScalarPair layout information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-05 16:59:54 +00:00
Ellen
fea1d76503 make compare_generic_param_kinds errors consistent 2022-05-05 17:45:39 +01:00
Matthias Krüger
68048199c9
Rollup merge of #96714 - RalfJung:scalar-pair-debug, r=oli-obk
interpret/validity: debug-check ScalarPair layout information

This would have caught https://github.com/rust-lang/rust/issues/96158.
I ran the Miri test suite and it still passes.

r? `@oli-obk`
2022-05-05 15:43:07 +02:00
Matthias Krüger
7a915dd80d
Rollup merge of #96682 - nnethercote:show-invisible-delims, r=petrochenkov
Show invisible delimeters (within comments) when pretty printing.

Because invisible syntax is really hard to work with!

r? `@petrochenkov`
2022-05-05 15:43:05 +02:00
Matthias Krüger
5f8a2f6080
Rollup merge of #96673 - oli-obk:tait_impl_diagnostic, r=petrochenkov
Report that opaque types are not allowed in impls even in the presence of other errors

fixes  #96569

before this PR those useful errors were hidden because either `unused parameter` or `only traits defined in the current crate can be implemented for arbitrary types` got emitted first.
2022-05-05 15:43:05 +02:00
Matthias Krüger
34bf620ac9
Rollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnr
Suggest calling `Self::associated_function()`

closes #96453
2022-05-05 15:43:03 +02:00
lcnr
321162b259 update error messages and explicitly mention them in tests 2022-05-05 14:29:24 +02:00
bors
a7d6768e3b Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoerister
Add a new Rust attribute to support embedding debugger visualizers

Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB.

Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies.

RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-05 12:26:38 +00:00
Ellen
4208c53ed6 exit out of compare_number_of_generics early 2022-05-05 12:41:43 +01:00
Ellen
6225e980bf handle mismatched generic parameter kinds 2022-05-05 12:24:05 +01:00
lcnr
ba0ecbdcd4 forbid empty impls for types with incoherent impls 2022-05-05 10:54:47 +02:00
lcnr
dc184b4e17 remove unnecessary check 2022-05-05 10:53:00 +02:00
lcnr
209dd2cb0a generalize "incoherent impls" impl for custom types 2022-05-05 10:53:00 +02:00
Ralf Jung
e47d6c7a6b give it a scary name 2022-05-05 09:55:38 +02:00
Takayuki Maeda
df25189552 suggest calling Self::associated_function()
do not suggest when trait_ref is some

Update compiler/rustc_resolve/src/late/diagnostics.rs

Co-authored-by: lcnr <rust@lcnr.de>

use helper struct

add a test for functions with some params

refactor debug log
2022-05-05 16:44:09 +09:00
bors
7d3e03666a Auto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #96603 (Enable full revision in const generics ui tests)
 - #96616 (Relax memory ordering used in `min_stack`)
 - #96619 (Relax memory ordering used in SameMutexCheck)
 - #96628 (Stabilize `bool::then_some`)
 - #96658 (Move callback to the () => {} syntax.)
 - #96677 (Add more tests for label-break-value)
 - #96697 (Enable tracing for all queries)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-05 02:49:16 +00:00
Yuki Okushi
ade123275d
Rollup merge of #96697 - oli-obk:trace_queries, r=michaelwoerister
Enable tracing for all queries

This allows you to log everything within a specific query, e.g.

```
env RUSTC_LOG=[mir_borrowck]
```

dumping all borrowck queries may be a bit verbose, so you can also restrict it to just an item of your choice:

```
env RUSTC_LOG=[mir_borrowck{key=\.\*name_of_item\.\*}]
```

the regex `.*` in the key name are because the key is a debug printed DefId, so you'd get all kinds of things like hashes in there. The tracing logs will show you the key, so you can restrict it further if you want.
2022-05-05 10:20:38 +09:00
Yuki Okushi
da57b3a832
Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-se
Stabilize `bool::then_some`

FCP completed in https://github.com/rust-lang/rust/issues/80967
2022-05-05 10:20:35 +09:00
bors
bdcb6a99e8 Auto merge of #96593 - jackh726:issue-93262, r=compiler-errors
Revert "Prefer projection candidates instead of param_env candidates for Sized predicates"

Fixes #93262
Reopens #89352

This was a hack that seemed to have no negative side-effects at the time. Given that the latter has a workaround and likely less common than the former, it makes sense to revert this change.

r? `@compiler-errors`
2022-05-05 00:24:48 +00:00
ridwanabdillahi
791bef5455 Cleanup broken doc links. 2022-05-04 17:17:57 -07:00
bors
4c60a0ea5b Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`
2022-05-04 21:16:28 +00:00
Nicholas Nethercote
baa18c027a Add a comment on TokenKind::Interpolated. 2022-05-05 07:06:57 +10:00
Nicholas Nethercote
99f5945f85 Overhaul MacArgs::Eq.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
2022-05-05 07:06:12 +10:00
Camille GILLOT
1d43b4d59c Exit before fetching bounds on associated items. 2022-05-04 22:59:16 +02:00
Camille GILLOT
cca981661a Only keep predicates on Self when checking dyn TraitAlias. 2022-05-04 22:59:15 +02:00
Ralf Jung
5b20da8180 interpret: debug-check ScalarPair layout information 2022-05-04 22:52:02 +02:00
Camille GILLOT
bb6b433958 Add debug statements. 2022-05-04 22:46:24 +02:00
Oli Scherer
0d5a738b8b Enable tracing for all queryies 2022-05-04 16:15:26 +00:00