Commit Graph

3125 Commits

Author SHA1 Message Date
bors
cb6ab9516b Auto merge of #113956 - fmease:rustdoc-fix-x-crate-rpitits, r=GuillaumeGomez,compiler-errors
rustdoc: handle cross-crate RPITITs correctly

Filter out the internal associated types synthesized during the desugaring of RPITITs, they really shouldn't show up in the docs.

This also fixes #113929 since we're no longer invoking `is_impossible_associated_item` (renamed from `is_impossible_method`) which cannot handle them (leading to an ICE). I don't think it makes sense to try to make `is_impossible_associated_item` handle this exotic kind of associated type (CC original author `@compiler-errors).`

@ T-rustdoc reviewers, currently I'm throwing out ITIT assoc tys before cleaning assoc tys at each usage-site. I'm thinking about making `clean_middle_assoc_item` return an `Option<_>` instead and doing the check inside of it to prevent any call sites from forgetting the check for ITITs. Since I wasn't sure if you would like that approach, I didn't go through with it. Let me know what you think.

<details><summary>Explanation on why <code>is_impossible_associated_item(itit_assoc_ty)</code> leads to an ICE</summary>

Given the following code:

```rs
pub trait Trait { fn def<T>() -> impl Default {} }
impl Trait for () {}
```

The generated associated type looks something like (simplified):

```rs
type {opaque#0}<T>: Default = impl Default; // the name is actually `kw::Empty` but this is the `def_path_str` repr
```

The query `is_impossible_associated_item` goes through all predicates of the associated item – in this case `<T as Sized>` – to check if they contain any generic parameters from the (generic) associated type itself. For predicates that don't contain any *own* generics, it does further processing, part of which is instantiating the predicate with the generic arguments of the impl block (which is only correct if they truly don't contain any own generics since they wouldn't get instantiated this way leading to an ICE).

It checks if `parent_def_id(T) == assoc_ty_def_id` to get to know if `T` is owned by the assoc ty. Unfortunately this doesn't work for ITIT assoc tys. In this case, the parent of `T` is `Trait::def` (!) which is the associated function (I'm pretty sure this is very intentional) which is of course not equal to the assoc ty `Trait::{opaque#0}`.

</details>

`@rustbot` label A-cross-crate-reexports
2023-07-24 15:19:00 +00:00
Matthias Krüger
af2b370100 more clippy::style fixes:
get_first
single_char_add_str
unnecessary_mut_passed
manual_map
manual_is_ascii_check
2023-07-23 23:39:04 +02:00
Michael Goulet
f3553691a8 Comment stuff in the new solver 2023-07-23 12:30:52 -07:00
Michael Goulet
d1380a1844 Use erased self type when autoderefing for trait error suggestion 2023-07-23 14:13:52 -04:00
Deadbeef
626efab67f fix 2023-07-23 09:58:31 +00:00
Matthias Krüger
b594798ae3 fix clippy::useless_format 2023-07-23 11:14:52 +02:00
Matthias Krüger
adf759bf6a fix couple of clippy findings:
filter_map_identity
iter_kv_map
needless_question_mark
redundant_at_rest_pattern
filter_next
derivable_impls
2023-07-23 10:50:14 +02:00
Matthias Krüger
8f4b81b146
Rollup merge of #113901 - compiler-errors:only-bidi-norm, r=lcnr
Get rid of subst-relate incompleteness in new solver

We shouldn't need subst-relate if we have bidirectional-normalizes-to in the new solver.

The only potential issue may happen if we have an unconstrained projection like `<Wrapper<?0> as Trait>::Assoc == <Wrapper<T> as Trait>::Assoc` where they both normalize to something that doesn't mention any substs, which would possibly prefer `?0 = T` if we fall back to subst-relate. But I'd prefer if we remove incompleteness until we can determine some case where we need them, and the bidirectional-normalizes-to seems better to have in general.

I can update https://github.com/rust-lang/trait-system-refactor-initiative/issues/26 and https://github.com/rust-lang/trait-system-refactor-initiative/issues/25 once this lands.

r? `@lcnr`
2023-07-22 19:57:36 +02:00
Matthias Krüger
0ed5f091a6
Rollup merge of #112508 - compiler-errors:trait-sig-lifetime-sugg-ice, r=cjgillot
Tweak spans for self arg, fix borrow suggestion for signature mismatch

1. Adjust a suggestion message that was annoying me
2. Fix #112503 by recording the right spans for the `self` part of the `&self` 0th argument
3. Remove the suggestion for adjusting a trait signature on type mismatch, bc that's gonna probably break all the other impls of the trait even if it fixes its one usage 😅
2023-07-22 19:57:35 +02:00
Michael Goulet
e32011209d Get rid of subst-relate incompleteness in new solver 2023-07-22 15:33:37 +00:00
León Orell Valerian Liehr
5924043b86
rustdoc: handle cross-crate RPITITs correctly 2023-07-22 12:20:17 +02:00
David Tolnay
5bbf0a8306
Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"
This reverts commit 557359f925, reversing
changes made to 1e6c09a803.
2023-07-21 22:35:57 -07:00
bors
c3c5a5c5f7 Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #113887 (new solver: add a separate cache for coherence)
 - #113910 (Add FnPtr ty to SMIR)
 - #113913 (error/E0691: include alignment in error message)
 - #113914 (rustc_target: drop duplicate code)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-21 16:52:21 +00:00
Oli Scherer
44e21503a8 Double check that hidden types match the expected hidden type 2023-07-21 13:19:36 +00:00
lcnr
303af36be7 new solver: add a separate cache for coherence 2023-07-21 09:34:10 +02:00
Moulins
feb20f2fe7 Track ABI info. in NaiveLayout, and use it for PointerLike checks
THis significantly complicates `NaiveLayout` logic, but is necessary to
ensure that bounds like `NonNull<T>: PointerLike` hold in generic
contexts.

Also implement exact layout computation for structs.
2023-07-21 03:31:46 +02:00
bors
399b068235 Auto merge of #113856 - WaffleLapkin:vtablin', r=oli-obk
Refactor vtable encoding and optimize it for the case of multiple marker traits

This PR does two things
- Refactor `prepare_vtable_segments` (this was motivated by the other change, `prepare_vtable_segments` was quite hard to understand and while trying to edit it I've refactored it)
  - Mostly remove `loop`s labeled `break`s/`continue`s whenever there is a simpler solution
  - Also use `?`
- Make vtable format a bit more efficient wrt to marker traits
  - See the tests for an example

Fixes https://github.com/rust-lang/rust/issues/113840
cc `@crlf0710`

----

Review wise it's probably best to review each commit individually, as then it's more clear why the refactoring is correct.

I can split the last two commits (which change behavior) into a separate PR if it makes reviewing easier
2023-07-20 20:34:06 +00:00
lcnr
5c75bc5317 update doc comments 2023-07-20 12:01:34 +02:00
lcnr
2062f2ca82 review 2023-07-20 12:01:34 +02:00
lcnr
7c97a76b76 re-add comment 2023-07-20 11:05:52 +02:00
lcnr
2d99f40ec5 assembly: only consider blanket impls once 2023-07-20 11:05:52 +02:00
lcnr
fdaec57a28 XSimplifiedType to SimplifiedType::X 2023-07-20 11:05:52 +02:00
Maybe Waffle
1f02c75718 Don't emit useless vptrs for marker traits 2023-07-19 12:06:31 +00:00
Maybe Waffle
f33936c567 Fix comment 2023-07-19 11:53:41 +00:00
Maybe Waffle
d87db8eb3f Simplify last prepare_vtable_segments loop even more 2023-07-19 11:53:41 +00:00
Maybe Waffle
d567f0fc68 Slightly refactor 'exiting_out loop in prepare_vtable_segments
1. Hide the option as an iterator, so it's nicer to work with
2. Replace a loop with `find`
2023-07-19 11:53:31 +00:00
Maybe Waffle
364fc444a5 Refactor 'diving_in loop internals in prepare_vtable_segments
Less explicit loops -- easier to read.
2023-07-19 10:01:48 +00:00
Maybe Waffle
f8f5d7aab2 Replace if let with unwrap in prepare_vtable_segments
Reasoning: if the stack is empty, the loop will be infinite,
so the assumption is that the stack can't be non empty. Unwrap
makes the assumption more clear (and removes an indentation level)
2023-07-19 09:51:35 +00:00
Maybe Waffle
348f26e409 Use ? in prepare_vtable_segments 2023-07-19 09:45:26 +00:00
bors
b657dc555b Auto merge of #113690 - aliemjay:opaque-defined-by-trait, r=compiler-errors
allow opaques to be defined by trait queries, again

This basically reverts #112963.

Moreover, all call-sites of `enter_canonical_trait_query` can now define opaque types, see the ui test `defined-by-user-annotation.rs`.

Fixes #113689

r? `@compiler-errors` `@oli-obk`
2023-07-19 05:40:58 +00:00
Michael Goulet
05f6890b3e Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
Matthias Krüger
eca9c0101c
Rollup merge of #113651 - lcnr:parent-def-id, r=compiler-errors
self type param infer, avoid ICE

fixes #113610, which is caused by 33a2c2487a/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L190-L205)
2023-07-17 12:58:53 +02:00
bors
4c7af429f3 Auto merge of #113336 - compiler-errors:new-solver-iat, r=lcnr
Add support for inherent projections in new solver

Not hard to support these, and it cuts out a really big chunk of failing UI tests with `--compare-mode=next-solver`

r? `@lcnr` (feel free to reassign, anyone can review this)
2023-07-17 01:06:36 +00:00
bors
f1eab64d4f Auto merge of #113769 - matthiaskrgr:rollup-p6i1rco, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113042 (Add Platform Support documentation for MIPS Release 6 targets)
 - #113539 (fixed typo)
 - #113614 (platform-support.md: It's now verified that NetBSD/riscv64 can self-h…)
 - #113750 (Add missing italicization to `sort_unstable_by_key` complexity )
 - #113755 (Normalize lazy type aliases when probing for ADTs)
 - #113756 (fix wrong link)
 - #113762 (Fix typo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-16 23:14:36 +00:00
Matthias Krüger
2b4c194234
Rollup merge of #113539 - agnarrarendelle:master, r=workingjubilee
fixed typo

Hi, I have fixed a few typos in commands. Please review my pr.
2023-07-17 00:14:05 +02:00
bors
0e8e857b11 Auto merge of #113742 - compiler-errors:dont-short-circuit-intercrate-global-preds, r=lcnr
Don't call `predicate_must_hold`-esque functions during fulfillment in intercrate

Fixes #113415

Given that this only happens in `translate_substs`, I don't actually think that this is something that you can weaponize, but it's still sketchy regardless.

r? `@lcnr`
2023-07-16 21:30:37 +00:00
Michael Goulet
c9ce51b5c7 Check GAT, IAT, and weak type where clauses during projection 2023-07-16 21:14:38 +00:00
Michael Goulet
085ae9e8b4 Add support for inherent projections 2023-07-16 21:14:38 +00:00
lcnr
e449daad6c stop mentioning number of applicate implementations 2023-07-16 15:36:19 +02:00
Michael Goulet
8f178d1b0c Don't call predicate_must_hold during fulfillment in intercrate 2023-07-16 01:56:16 +00:00
Matthias Krüger
da18cf8572
Rollup merge of #113625 - compiler-errors:structurally-norm-in-selection, r=lcnr
Structurally normalize in selection

We need to do this because of the fact that we're checking the `Ty::kind` on a type during selection, but goals passed into select are not necessarily normalized.

Right now, we're (kinda) unnecessarily normalizing the RHS of a trait upcasting goal, which is broken for different reasons (#113393). But I'm waiting for this PR to land before discussing that one.

r? `@lcnr`
2023-07-15 19:42:51 +02:00
bors
ad963232d9 Auto merge of #113471 - compiler-errors:new-solver-norm-escaping, r=lcnr
Allow escaping bound vars during `normalize_erasing_regions` in new solver

Add `AllowEscapingBoundVars` to `deeply_normalize`, and use it in the new solver in the `query_normalize` routine.

Ideally, we'd make all `query_normalize` calls handle pass in `AllowEscapingBoundVars` individually, because really the only `query_normalize` call that needs `AllowEscapingBoundVars::Yes` is the one in `try_normalize_generic_arg_after_erasing_regions`, but I think that's kind of overkill. I am happy to be convinced otherwise, though.

r? `@lcnr`
2023-07-14 21:14:30 +00:00
Michael Goulet
7fb27e4717 Structurally normalize in selection 2023-07-14 18:40:18 +00:00
Matthias Krüger
0baf4406da
Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino
Make it clearer that we're just checking for an RPITIT

Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`.

r? `@spastorino`
2023-07-14 19:33:29 +02:00
Michael Goulet
14672eba8b Make it clearer that we're just checking for an RPITIT 2023-07-14 15:18:48 +00:00
Michael Goulet
1ef85d82e0 assertion, comment 2023-07-14 15:03:21 +00:00
Michael Goulet
4bcca3294a Allow escaping bound vars during normalize_erasing_regions in new solver 2023-07-14 15:03:21 +00:00
Ali MJ Al-Nasrawy
281c2271be allow opaques to be defined by trait queries 2023-07-14 12:35:33 +00:00
Mahdi Dibaiee
e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Matthias Krüger
dec104c7ad
Rollup merge of #113536 - lcnr:proof-tree-select, r=BoxyUwU
avoid building proof trees in select

otherwise we ICE because select isn't currently set up to print proof trees.

r? `````@BoxyUwU`````
2023-07-13 22:33:23 +02:00
bors
a161ab00db Auto merge of #113637 - Mark-Simulacrum:bootstrap-bump, r=ozkanonur
Bump bootstrap to 1.72 beta
2023-07-13 18:15:14 +00:00
Matthias Krüger
893a5d2b32
Rollup merge of #113353 - compiler-errors:select-better, r=lcnr
Implement selection for `Unsize` for better coercion behavior

In order for much of coercion to succeed, we need to be able to deal with partial ambiguity of `Unsize` traits during selection. However, I pessimistically implemented selection in the new trait solver to just bail out with ambiguity if it was a built-in impl:
9227ff28af/compiler/rustc_trait_selection/src/solve/eval_ctxt/select.rs (L126)

This implements a proper "rematch" procedure for dealing with built-in `Unsize` goals, so that even if the goal is ambiguous, we are able to get nested obligations which are used in the coercion selection-like loop:
9227ff28af/compiler/rustc_hir_typeck/src/coercion.rs (L702)

Second commit just moves a `resolve_vars_if_possible` call to fix a bug where we weren't detecting a trait upcasting to occur.

r? ``@lcnr``
2023-07-13 12:19:22 +02:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Mark Rousskov
67b0cfc761 Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
agnarrarendelle
dcfcc77282 fixed typos 2023-07-12 01:25:47 +08:00
bors
0a2681cc49 Auto merge of #113470 - compiler-errors:new-solver-structurally-resolve-pat, r=lcnr
Structurally resolve in pattern matching when peeling refs in new solver

Let me know if you want me to commit the minimized test:
```rust
fn test() {}

fn test2() {}

fn main() {
    let tests: &[(_, fn())] = &[
        ("test", test),
        ("test2", test2),
    ];

    for (a, b) in tests {
        todo!();
    }
}
```

In that test above, the match scrutinee is `<std::vec::Iter<(&'static str, fn())> as Iterator>::Item`, which we cannot peel the refs from.

We also need to structurally resolve in the loop, since structural resolve is inherently shallow. I haven't come up with a test where this matters, but I can if you care.

Also,  I removed two other calls to `resolve_vars_with_obligations` in diagnostics code that I'm pretty convinced are not useful.

r? `@lcnr`
2023-07-11 15:29:47 +00:00
Michael Goulet
846d54f16c Structurally resolve in pattern matching when peeling refs in new solver 2023-07-11 02:40:59 +00:00
bors
8ca44ef9ca Auto merge of #112988 - spastorino:new-rpitit-24, r=compiler-errors
Replace RPITIT current impl with new strategy that lowers as a GAT

This PR replaces the current implementation of RPITITs with the new implementation that we had under -Zlower-impl-trait-in-trait-to-assoc-ty flag that lowers the RPIT as a GAT on the trait and on the impls that implement that trait.

Opening this PR as a draft because this goes after #112682, ~#112981~ and ~#112983~.
As soon as those are merged, I can rebase and we should run perf, crater and test a lot.

r? `@compiler-errors`
2023-07-10 19:01:30 +00:00
lcnr
4965caf9be avoid building proof trees in select 2023-07-10 15:17:01 +02:00
Santiago Pastorino
20429af7a3
Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
bors
83964c156d Auto merge of #113491 - matthiaskrgr:rollup-mueqz7h, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113005 (Don't call `query_normalize` when reporting similar impls)
 - #113064 (std: edit [T]::swap docs)
 - #113138 (Add release notes for 1.71.0)
 - #113217 (resolve typerelative ctors to adt)
 - #113254 (Use consistent formatting in Readme)
 - #113482 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-08 20:56:57 +00:00
Matthias Krüger
48a0d038fa
Rollup merge of #113005 - compiler-errors:dont-query-normalize, r=cjgillot
Don't call `query_normalize` when reporting similar impls

Firstly, It's sketchy to be using `query_normalize` at all during HIR typeck -- it's asking for an ICE 😅. Secondly, we're normalizing an impl trait ref that potentially has parameter types in `ty::ParamEnv::empty()`, which is kinda sketchy as well.

The only UI test change from removing this normalization is that we don't evaluate anonymous constants in impls, which end up giving us really ugly suggestions:

```
error[E0277]: the trait bound `[X; 35]: Default` is not satisfied
 --> /home/gh-compiler-errors/test.rs:4:5
  |
4 |     <[X; 35] as Default>::default();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]`
  |
  = help: the following other types implement trait `Default`:
            &[T]
            &mut [T]
            [T; 32]
            [T; core::::array::{impl#30}::{constant#0}]
            [T; core::::array::{impl#31}::{constant#0}]
            [T; core::::array::{impl#32}::{constant#0}]
            [T; core::::array::{impl#33}::{constant#0}]
            [T; core::::array::{impl#34}::{constant#0}]
          and 27 others
```

So just fold the impls with a `BottomUpFolder` that calls `ty::Const::eval`. This doesn't work totally correctly with generic-const-exprs, but it's fine for stable code, and this is error reporting after all.
2023-07-08 20:53:27 +02:00
Matthias Krüger
f3f1b0394d
Rollup merge of #113335 - compiler-errors:reveal-opaques-in-new-solver, r=lcnr
Reveal opaques in new solver

We were testing against the wrong reveal mode 😨

Also a couple of misc commits that I don't want to really put in separate prs

r? ``@lcnr``
2023-07-08 15:49:46 +02:00
bors
ce519c5945 Auto merge of #113474 - compiler-errors:rollup-07x1up7, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #113413 (Add needs-triage to all new issues)
 - #113426 (Don't ICE in `resolve_bound_vars` when associated return-type bounds are in bad positions)
 - #113427 (Remove `variances_of` on RPITIT GATs, remove its one use-case)
 - #113441 (miri: check that assignments do not self-overlap)
 - #113453 (Remove unused from_method from rustc_on_unimplemented)
 - #113456 (Avoid calling report_forbidden_specialization for RPITITs)
 - #113466 (Update cargo)
 - #113467 (Fix comment of `fn_can_unwind`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-08 10:46:29 +00:00
Michael Goulet
37a05d8054
Rollup merge of #113453 - spastorino:new-rpitit-30, r=compiler-errors
Remove unused from_method from rustc_on_unimplemented

Fixes #113439

`on_unimplemented_note` was calling `item_name` for RPITITs and that produced ICEs. I've added a regression test for that but also have removed `from_method` symbol entirely because it wasn't even used and by doing that the `item_name` call was also removed.

r? ``@compiler-errors``
2023-07-07 22:12:17 -07:00
Michael Goulet
77c3cf1bfd Implement selection for unsize for better coercion behavior 2023-07-08 03:41:22 +00:00
bors
d4096e0412 Auto merge of #112652 - oli-obk:tait_only_in_sig, r=compiler-errors
Require TAITs to be mentioned in the signatures of functions that register hidden types for them

r? `@lcnr` `@compiler-errors`

This implements the lang team decision from [the TAIT design meeting](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.202023-05-31.20TAITs/near/362518164).
2023-07-08 03:22:54 +00:00
Santiago Pastorino
3aec8d4227
Remove unused from_method symbol 2023-07-07 15:57:30 -03:00
Michael Goulet
f55b046931 Normalize opaques during codegen in new solver 2023-07-07 16:02:25 +00:00
bors
cb80ff132a Auto merge of #113245 - lukas-code:unsizing-sanity-check, r=the8472
sanity check field offsets in unsizeable structs

As promised in https://github.com/rust-lang/rust/pull/112062#issuecomment-1567494994, this PR extends the layout sanity checks to ensure that structs fields don't move around when unsizing and prevent issues like https://github.com/rust-lang/rust/issues/112048 in the future. Like most other layout sanity checks, this only runs on compilers with debug assertions enabled.

Here is how it looks when it fails:
```text
error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:533:21: unsizing GcNode<std::boxed::Box<i32>> changed field order!
                                Layout { size: Size(32 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes), Size(24 bytes)], memory_index: [0, 1, 2] }, largest_niche: Some(Niche { offset: Size(24 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } }
                                Layout { size: Size(24 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [Size(16 bytes), Size(0 bytes), Size(24 bytes)], memory_index: [1, 0, 2] }, largest_niche: None, variants: Single { index: 0 } }
```

r? `@the8472`
2023-07-07 15:42:29 +00:00
Oli Scherer
4c99872efe Require TAITs to be mentioned in the signatures of functions that register hidden types for them 2023-07-07 13:13:18 +00:00
bors
1a449dcfd2 Auto merge of #113308 - compiler-errors:poly-select, r=lcnr
Split `SelectionContext::select` into fns that take a binder and don't

*most* usages of `SelectionContext::select` don't need to use a binder, but wrap them in a dummy because of the signature. Let's split this out into `SelectionContext::{select,poly_select}` and limit the usages of the latter.

Right now, we only have 3 places where we're calling `poly_select` -- fulfillment, internally within the old solver, and the auto-trait finder.

r? `@lcnr`
2023-07-07 10:32:42 +00:00
Michael Goulet
f1c90985e8
Rollup merge of #113397 - compiler-errors:new-select-prefer-obj, r=lcnr
Prefer object candidates in new selection

`dyn Any` shouldn't be using [this implementation](https://doc.rust-lang.org/std/any/trait.Any.html#impl-Any-for-T) during codegen.

Prefer object candidates over other candidates, except for other object candidates.
2023-07-06 20:11:40 -07:00
Michael Goulet
388c230cf7 Don't call type_of on TAIT in defining scope in new solver 2023-07-06 20:13:22 +00:00
Michael Goulet
3f8919c09b get rid of a bit more calls to poly_select 2023-07-06 16:50:12 +00:00
Michael Goulet
52f7384995 Separate select calls that don't need a binder 2023-07-06 16:50:12 +00:00
Michael Goulet
36453456cb TraitObligation -> PolyTraitObligation 2023-07-06 16:30:11 +00:00
Lukas Markeffsky
7aa5f39d3b add helper methods for accessing struct tail 2023-07-06 13:15:05 +00:00
bors
4b6749b21e Auto merge of #113406 - matthiaskrgr:rollup-0rprs5k, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112295 (Fix the tests-listing-format-json test on Windows)
 - #113246 (fix compiletest crash)
 - #113395 (Dont ICE for `dyn* Trait: Trait` (built-in object) goals during selection in new trait solver)
 - #113402 (Diagnose unsorted CGUs.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-06 10:29:49 +00:00
Oleksandr Babak
944f237d2d
always emit consider AutoImplCandidates for them if they don't also have a ProjectionCandidate 2023-07-06 11:37:21 +02:00
lcnr
b5b3f33940
deal with opaque types without cycling 2023-07-06 11:37:21 +02:00
lcnr
3adedc93a9
update auto trait handling 2023-07-06 11:37:19 +02:00
Michael Goulet
3acaa568c2 Prefer object candidates over impl candidates in new selection 2023-07-06 04:57:17 +00:00
Michael Goulet
cd26d10edf Dont ICE for dyn* Trait: Trait goals during selection in new trait solver 2023-07-06 03:10:11 +00:00
Boxy
12138b8e5e Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
Michael Goulet
c31fe41453
Rollup merge of #113337 - compiler-errors:next-solver-winnow-specializing, r=lcnr
Winnow specialized impls during selection in new solver

We need to be able to winnow impls that are specialized by more specific impls in order for codegen to be able to proceed.

r? ``@lcnr``
2023-07-05 08:45:45 -07:00
Michael Goulet
b2b1a50751
Rollup merge of #113321 - BoxyUwU:move_constkind_to_typeir, r=oli-obk
Move `ty::ConstKind` to `rustc_type_ir`

Needed this in another PR for custom debug impls, and this will also be required to move the new solver into a separate crate that does not use `TyCtxt` so that r-a and friends can depend on the trait solver.

Rebased on top of #113325, only the second and third commits needs reviewing
2023-07-05 08:45:45 -07:00
Michael Goulet
0334b64cbb
Rollup merge of #113320 - oli-obk:eval_obligation_query, r=petrochenkov,BoxyUwU
Add some extra information to opaque type cycle errors

Plus a bunch of cleanups.

This should help users debug query cycles due to auto trait checking. We'll probably want to fix cycle errors in most (or all?) cases by looking at the current item's hidden types (new solver does this), and by delaying the auto trait checks to after typeck.
2023-07-05 08:45:44 -07:00
Michael Goulet
5c7a7d9ed4
Rollup merge of #113319 - lcnr:type-param-def-def-id, r=compiler-errors
`TypeParameterDefinition` always require a `DefId`

the `None` case never actually reaches diagnostics so it feels better for diagnostics to be able to rely on the `DefId` being there, cc #113310
2023-07-05 08:45:43 -07:00
Michael Goulet
a1f8edb5d5
Rollup merge of #113317 - lcnr:sketchy-new-select, r=oli-obk
-Ztrait-solver=next: stop depending on old solver

removes the final dependencies on the old solver when `-Ztrait-solver=next` is enabled.
2023-07-05 08:45:43 -07:00
Boxy
62174bfe72 Deal with fallout 2023-07-05 09:46:30 +01:00
Oli Scherer
307b5ffff3 Make all generics_require_sized_self go through the query to get caching. 2023-07-05 07:46:05 +00:00
Oli Scherer
9e98feb84c Add some extra information to opaque type cycle errors 2023-07-05 07:43:35 +00:00
Oli Scherer
66ae9998d5 Remove redundant delay_span_bug 2023-07-05 07:43:35 +00:00
Oli Scherer
ca581f9161 Don't require associated types with Self: Sized bounds in dyn Trait objects 2023-07-05 07:42:53 +00:00
Michael Goulet
d2a1803d6f Winnow specializing impls 2023-07-05 06:18:48 +00:00
bors
9227ff28af Auto merge of #113329 - lcnr:probe_candidate, r=BoxyUwU
add `ecx.probe_candidate`

Not yet changing the candidate source to an enum because that would be more involved, but this by itself should already be a significant improvement imo

r? `@BoxyUwU`
2023-07-05 03:50:36 +00:00
bors
b7bc6f88ac Auto merge of #113330 - matthiaskrgr:rollup-zm3owin, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113192 (`assemble_candidates_after_normalizing_self_ty` docs)
 - #113251 (Use scoped-tls for SMIR to  map between TyCtxt and SMIR datastructures)
 - #113282 (Update platform-support.md to improve ARM target descriptions)
 - #113296 (add flag for enabling global cache usage for proof trees and printing proof trees on error)
 - #113324 (implement `ConstEvaluatable` goals in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-04 23:51:52 +00:00
Matthias Krüger
7996908c4f
Rollup merge of #113324 - lcnr:const-evaluatable-goal, r=BoxyUwU
implement `ConstEvaluatable` goals in new solver

this only supports stable const generics. `feature(generic_const_exprs)` needs to extend that function is non-trivial ways. Leaving this for someone else or some later date.

r? `@BoxyUwU`
2023-07-04 17:46:28 +02:00
Matthias Krüger
494e67c63c
Rollup merge of #113296 - BoxyUwU:proof_trees_on_error, r=lcnr
add flag for enabling global cache usage for proof trees and printing proof trees on error

This adds a few new things:
- `-Zdump-solver-proof-tree=always/never/on-error`
    - `always`/`never` were previosuly specifiable by whether the flag exists or not, th new flag is `on_error` which reruns obligations of fulfillment and selection errors with proof tree generation enabled and prints them out
- `-Zdump-solver-proof-tree-uses-cache`
    - allows forcing global cache to be used or unused for all generated proof trees, global cache is enabled by default for `always` so that it accurately represents what happend. This flag currently would affect misc uses of `GenerateProofTree::Yes` which will be added in the future for things like diagnostics logic and rustdoc's auto_trait file. We can fix this when we start using proof tree generation for those use cases if it's desirable.

I also changed the output to go straight to stdout instead of going through `debug!` so that `-Zdump-solver-proof-tree` can be adequately used on `nightly` not just a locally built toolchain.

The idea for `on-error` is that it should hopefully make it easier to quickly figure out "why doesnt this code compile"- you just pass in `-Zdump-solver-proof-tree=on-error` and you'll only get proof trees you care about.

---

r? `@lcnr` `@compiler-errors`
2023-07-04 17:46:28 +02:00
Matthias Krüger
6fb790ad1a
Rollup merge of #113192 - lcnr:add-comment, r=compiler-errors
`assemble_candidates_after_normalizing_self_ty` docs

I already explained that in different places a few times, should have added that explanation as a doc comment the first time I did so :3

r? `@BoxyUwU`
2023-07-04 17:46:26 +02:00
lcnr
795c2ef7d9 add ecx.probe_candidate 2023-07-04 17:08:07 +02:00
Boxy
284b61417f reviews 2023-07-04 14:56:09 +01:00
lcnr
abcaf30f9b implement ConstEvaluatable goals in new solver
we don't yet handle `generic_const_exprs`, someone else
can do that :3
2023-07-04 15:54:18 +02:00
Boxy
d30f56dbf2 Replace const_error methods with Const::new_error 2023-07-04 14:46:32 +01:00
Boxy
ddbc774e74 Replace mk_const with Const::new_x methods 2023-07-04 14:26:33 +01:00
lcnr
594cd84a94 TypeParameterDefinition always require a DefId 2023-07-04 11:51:07 +02:00
Boxy
276d628cac move logic for flags into separate function 2023-07-04 10:01:54 +01:00
lcnr
312994243a extend comment 2023-07-04 10:34:27 +02:00
Boxy
adefeb80c3 change flag name 2023-07-04 09:17:41 +01:00
Boxy
2ad00f471a reviews 2023-07-04 09:13:10 +01:00
lcnr
b468bfb361 -Ztrait-solver=next: stop depending on old solver 2023-07-04 10:06:39 +02:00
Michael Goulet
0c73b41cd6 remove TypeWellFormedFromEnv 2023-07-03 21:40:04 +00:00
Michael Goulet
810fbf086d Remove chalk from the compiler 2023-07-03 21:40:04 +00:00
Boxy
040aa58d0a add flag for disabling global cache and printing proof trees on error 2023-07-03 21:00:16 +01:00
Michael Goulet
f3f8793268 Helpers for creating EvalCtxts, some comments 2023-07-03 15:58:33 +00:00
Michael Goulet
298c0d1a62 Implement selection in new trait solver 2023-07-03 15:53:27 +00:00
lcnr
be6a344365 rebase 2023-07-03 09:24:02 +02:00
lcnr
412c6e0b07 review 2023-07-03 09:12:15 +02:00
lcnr
a2dfed6711 deeply_normalize pass in fulfill cx for old solver 2023-07-03 09:12:15 +02:00
lcnr
5378f07d64 use deeply_normalize for assumed_wf_types 2023-07-03 09:12:14 +02:00
lcnr
42067596c2 add deep normalization via the new solver 2023-07-03 09:12:14 +02:00
lcnr
4d42de6d1b add instrument to register_predicate_obligation 2023-07-03 09:12:14 +02:00
bors
7383ab7378 Auto merge of #113154 - lcnr:better-probe-check, r=compiler-errors
change snapshot tracking in fulfillment contexts

use the exact snapshot number to prevent misuse even when created inside of a snapshot
2023-07-01 01:53:10 +00:00
lcnr
01769221bc assemble_candidates_after_normalizing_self_ty docs 2023-06-30 11:56:10 +02:00
bors
a20a04e5d6 Auto merge of #113108 - compiler-errors:normalize-opaques-with-late-bound-vars-again, r=jackh726
Normalize opaques with late-bound vars again

We have a hack in the compiler where if an opaque has escaping late-bound vars, we skip revealing it even though we *could* reveal it from a technical perspective. First of all, this is weird, since we really should be revealing all opaques in `Reveal::All` mode. Second of all, it causes subtle bugs (linked below).

I attempted to fix this in #100980, which was unfortunately reverted due to perf regressions on codebases that used really deeply nested futures in some interesting ways. The worst of which was #103423, which caused the project to hang on build. Another one was #104842, which was just a slow-down, but not a hang. I took some time afterwards to investigate how to rework `normalize_erasing_regions` to take advantage of better caching, but that effort kinda fizzled out (#104133).

However, recently, I was made aware of more bugs whose root cause is not revealing opaques during codegen. That made me want to fix this again -- in the process, interestingly, I took the the minimized example from https://github.com/rust-lang/rust/issues/103423#issuecomment-1292947043, and it doesn't seem to hang any more...

Thinking about this harder, there have been some changes to the way we lower and typecheck async futures that may have reduced the pathologically large number of outlives obligations (see description of #103423) that we were encountering when normalizing opaques with bound vars the last time around:
* #104321 (lower `async { .. }` directly as a generator that implements `Future`, removing the `from_generator` shim)
* #104833 (removing an `identity_future` fn that was wrapping desugared future generators)

... so given that I can see:
* No significant regression on rust perf bot (https://github.com/rust-lang/rust/pull/107620#issuecomment-1600070317)
* No timeouts in crater run I did (https://github.com/rust-lang/rust/pull/107620#issuecomment-1605428952, rechecked failing crates in https://github.com/rust-lang/rust/pull/107620#issuecomment-1605973434)

... and given that this PR:
* Fixes #104601
* Fixes #107557
* Fixes #109464
* Allows us to remove a `DefiningAnchor::Bubble` from codegen (75a8f68183)

I'm inclined to give this another shot at landing this. Best case, it just works -- worst case, we get more examples to study how we need to improve the compiler to make this work.

r? types
2023-06-29 15:37:11 +00:00
lcnr
d04775d739 change snapshot tracking in fulfillment contexts 2023-06-29 10:02:26 +02:00
Michael Goulet
8745ae21f9 convert to fluent, make plurals work 2023-06-28 18:08:21 +00:00
Michael Goulet
d1ab6c2ae3 Do not suggest adjusting trait signature on type mismatch 2023-06-28 17:51:01 +00:00
Michael Goulet
8621285e3b reword message to be less vague 2023-06-28 17:51:01 +00:00
Dylan DPC
fc2c587cd0
Rollup merge of #112867 - compiler-errors:more-impl-source-nits, r=lcnr
More `ImplSource` nits

Even more clean-ups, I'll put this up in parallel with the `select_in_new_trait_solver` PR.

r? ``@lcnr``
2023-06-28 18:28:47 +05:30
Michael Goulet
2c33dfea76 Don't sort strings right after we just sorted by types 2023-06-27 23:31:06 +00:00
Michael Goulet
983f6b9787 Normalize opaques with escaping bound vars 2023-06-27 21:36:15 +00:00
Michael Goulet
374173cd99 TypeWellFormedInEnv 2023-06-26 23:12:04 +00:00
Michael Goulet
fbdef58414 Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
Michael Goulet
28f39862a8 use Const::eval instead of QueryNormalize in error reporting 2023-06-24 18:04:14 +00:00
Michael Goulet
766db8161b
Rollup merge of #112965 - compiler-errors:circular-wf, r=aliemjay
Don't emit same goal as input during `wf::unnormalized_obligations`

r? `@aliemjay` cc `@lcnr`

I accidentally pruned the logic to handle `WF(?0)` when writing `wf::unnormalized_obligations`.

idk if you wanted to construct a test first, but this is an obvious fix. Copied the comment from above.

Fixes rust-lang/trait-system-refactor-initiative#36
2023-06-23 19:47:21 -07:00
Matthias Krüger
4e8983050e
Rollup merge of #112870 - compiler-errors:clause-2, r=oli-obk
Migrate `item_bounds` to `ty::Clause`

Should be simpler than the next PR that's coming up. Last three commits are the relevant ones.

r? ``@oli-obk`` or ``@lcnr``
2023-06-23 19:39:59 +02:00
Michael Goulet
2eb7d69309 Resolve vars when reporting WF error 2023-06-23 16:26:22 +00:00
Michael Goulet
f12695b53b Don't emit same goal as input during wf obligations 2023-06-23 16:23:27 +00:00
Alexander Zhang
48167bd4bd Avoid guessing unknown trait impl in suggestions
When a trait is used without specifying the implementation (e.g. calling
a non-member associated function without fully-qualified syntax) and
there are multiple implementations available, use a placeholder comment
for the implementation type in the suggestion instead of picking a
random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```
2023-06-22 16:37:52 -07:00
Michael Goulet
46a650f4e0 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
bors
04075b3202 Auto merge of #112686 - estebank:sealed-traits, r=petrochenkov
Account for sealed traits in privacy and trait bound errors

On trait bound errors caused by super-traits, identify if the super-trait is publicly accessibly and if not, explain "sealed traits".

```
error[E0277]: the trait bound `S: Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:17:20
   |
LL | impl a::Sealed for S {}
   |                    ^ the trait `Hidden` is not implemented for `S`
   |
note: required by a bound in `Sealed`
  --> $DIR/sealed-trait-local.rs:3:23
   |
LL |     pub trait Sealed: self:🅱️:Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implelement `a:🅱️:Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
```

Deduplicate privacy errors that point to the same path segment even if their deduplication span are different.

When encountering a path that is not reachable due to privacy constraints path segments other than the last, keep metadata for the last path segment's `Res` in order to look for alternative import paths for that item to suggest. If there are none, be explicit that the item is not accessible.

```
error[E0603]: module `b` is private
  --> $DIR/re-exported-trait.rs:11:9
   |
LL | impl a:🅱️:Trait for S {}
   |         ^ private module
   |
note: the module `b` is defined here
  --> $DIR/re-exported-trait.rs:5:5
   |
LL |     mod b {
   |     ^^^^^
help: consider importing this trait through its public re-export instead
   |
LL | impl a::Trait for S {}
   |      ~~~~~~~~
```

```
error[E0603]: module `b` is private
  --> $DIR/private-trait.rs:8:9
   |
LL | impl a:🅱️:Hidden for S {}
   |         ^  ------ trait `b` is not publicly reachable
   |         |
   |         private module
   |
note: the module `b` is defined here
  --> $DIR/private-trait.rs:2:5
   |
LL |     mod b {
   |     ^^^^^
```
2023-06-22 18:23:19 +00:00
Esteban Küber
717c481739 Account for sealed traits in trait bound errors
When implementing a public trait with a private super-trait, we now emit
a note that the missing bound is not going to be able to be satisfied,
and we explain the concept of a sealed trait.
2023-06-22 16:50:21 +00:00
Michael Goulet
5344ed23fa Don't substitute a GAT that has mismatched generics in OpaqueTypeCollector 2023-06-21 16:33:17 +00:00
Nilstrieb
a98c14f3a9
Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21 07:37:01 +02:00
Michael Goulet
7d0a5c31f5 yeet upcast_trait_def_id from ImplSourceObjectData 2023-06-20 23:33:02 +00:00
Michael Goulet
42571c4847 yeet ImplSource::TraitAlias too 2023-06-20 23:33:02 +00:00
Michael Goulet
db235a07f7 Remove unnecessary call to select_from_obligation
The only regression is one ambiguity in the new trait solver, having to
do with two param-env candidates that may apply. I think this is fine,
since the error message already kinda sucks.
2023-06-20 23:33:02 +00:00
bors
46514218f6 Auto merge of #112835 - lcnr:proof-tree-nits, r=BoxyUwU
proof tree nits

r? `@BoxyUwU`
2023-06-20 19:58:46 +00:00
lcnr
e4b171a198 inspect nits 2023-06-20 14:01:03 +02:00
lcnr
f7472aa69e cleanup imports 2023-06-20 12:41:00 +02:00
lcnr
f5438d658f split probe into 2 functions for better readability 2023-06-20 12:40:43 +02:00
bors
6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
Michael Goulet
ca68cf0d46 Merge attrs, better validation 2023-06-20 04:38:55 +00:00
Michael Goulet
657d3f43a9 Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
Michael Goulet
3171c989ef
Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, r=lcnr
Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds

See test for example where we shouldn't consider it possible to alias-relate a TAIT and hidden type.

r? `@lcnr`
2023-06-19 17:53:35 -07:00
Matthias Krüger
68d3e0e3bd
Rollup merge of #112783 - compiler-errors:nlb-fnptr-reject-ice, r=fee1-dead
Don't ICE on bound var in `reject_fn_ptr_impls`

We may try to use an impl like `impl<T: FnPtr> PartialEq {}` to satisfy a predicate like `for<T> T: PartialEq` -- don't ICE in that case.

Fixes #112735
2023-06-19 19:26:28 +02:00
Matthias Krüger
68f2f1e32c
Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obk
Continue folding in query normalizer on weak aliases

Fixes #112752
Fixes #112731 (same root cause, so didn't make a test for it)
fixes #112776

r? ```@oli-obk```
2023-06-19 19:26:27 +02:00
Michael Goulet
21226eefb2 Fully fledged Clause type 2023-06-19 15:46:08 +00:00
Michael Goulet
fca56a8d2c s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
Michael Goulet
2e8af07a8a Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds 2023-06-19 14:49:56 +00:00
Boxy
9af7122b1d create module so that RUSTC_LOG can filter to just proof trees 2023-06-19 09:08:03 +01:00
Boxy
bb743f8635 allow caller to force proof tree generation 2023-06-19 09:08:03 +01:00
Boxy
51090b962f show normalizes-to hack and response instantiation goals 2023-06-19 09:06:16 +01:00
Boxy
e367c04dc6 introduce a separate set of types for finalized proof trees 2023-06-19 09:06:16 +01:00
Boxy
7a3665d016 dont use a trait 2023-06-19 09:01:37 +01:00
Boxy
3587d4ced8 say what kind of cache hit 2023-06-19 09:01:37 +01:00
Boxy
a2050ba12d add -Z flag 2023-06-19 09:01:37 +01:00
Boxy
3009b2c647 initial info dump 2023-06-19 09:01:37 +01:00
Michael Goulet
29c74d5619 Don't ICE on bound var in reject_fn_ptr_impls 2023-06-19 02:52:03 +00:00
Michael Goulet
493b18b653 Continue folding in query normalizer on weak aliases 2023-06-18 20:56:30 +00:00
Michael Goulet
6594c75449 Move ConstEvaluatable to Clause 2023-06-17 21:27:13 +00:00
Michael Goulet
52d3fc93f2 Move WF goal to clause 2023-06-17 21:20:20 +00:00
Michael Goulet
d97d4ebecc Remove even more redundant builtin candidates 2023-06-17 03:32:46 +00:00
Michael Goulet
2835d9d1d3 Simplify even more candidates 2023-06-17 03:32:46 +00:00
Michael Goulet
1311bb56f3 Simplify an ObjectData field 2023-06-17 03:32:45 +00:00
Michael Goulet
9e68b6f505 Simplify some impl source candidates 2023-06-17 03:32:45 +00:00
Michael Goulet
1704481bfa Remove some ImplSource candidates 2023-06-17 03:32:45 +00:00
bors
0cc541e4b2 Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errors
Add `AliasKind::Weak` for type aliases.

`type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a

```rust
trait Identity {
    type Identity;
}
impl<T: Debug> Identity for T {
    type Identity = T;
}
<NotDebug as Identity>::Identity
```

type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer.

Similarly:

* a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes
* rustdoc expands the type alias, even though often times users use them for documentation purposes
* diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about.

For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident.

To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition.

Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds.

As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did.

fixes https://github.com/rust-lang/rust/issues/108617
2023-06-17 00:33:29 +00:00
Michael Goulet
cef94ecedf
Rollup merge of #112665 - compiler-errors:assumption-takes-clause, r=lcnr
Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`

We just use an if-let to match on an optional clause at all the places where we transition from `Predicate` -> `Clause`, but I assume that when things like item-bounds and param-env start to only store `Clause`s then those can just be trivially dropped.

r? ``@lcnr``
2023-06-16 12:53:23 -07:00
Oli Scherer
f3b7dd6388 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
Dylan DPC
64f6c00772
Rollup merge of #112443 - compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr
Opportunistically resolve regions in new solver

Use `opportunistic_resolve_var` during canonicalization to collapse some regions.

We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response...

There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation.

r? ```@lcnr```
2023-06-16 14:46:15 +05:30
bohan
b7921981d5 fix: inline predicate_may_hold_fatal 2023-06-16 11:09:53 +08:00
Michael Goulet
b4ba7c4f93 Make assumption functions in new solver take clause 2023-06-15 16:18:38 +00:00
bors
6ee4265ca6 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
Don't drain-on-drop in DrainFilter impls of various collections.

This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288).

closes #101122

[ACP](https://github.com/rust-lang/libs-team/issues/136)

affected tracking issues
* #43244
* #70530
* #59618

Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-15 00:03:10 +00:00
Matthias Krüger
7240943b28
Rollup merge of #112605 - compiler-errors:negative-docs, r=spastorino
Improve docs/clean up negative overlap functions

Clean up some functions in ways that should not affect behavior, change some names to be clearer (`negative_impl` and `implicit_negative` are not really clear imo), and add some documentation examples.

r? `@spastorino`
2023-06-14 18:10:30 +02:00
bors
7b0eac438a Auto merge of #112400 - WaffleLapkin:vtable_stats, r=compiler-errors
Collect VTable stats & add `-Zprint-vtable-sizes`

This is a bit hacky/buggy, but I'm not entirely sure how to fix it, so I want to ask reviewers for help...

To try this, use either of those:
- `cargo clean && RUSTFLAGS="-Zprint-vtable-sizes" cargo +toolchain b`
- `cargo clean && cargo rustc +toolchain -Zprint-vtable-sizes`
- `rustc +toolchain -Zprint-vtable-sizes ./file.rs`
2023-06-14 11:24:42 +00:00
bors
3ed2a10d17 Auto merge of #110662 - bryangarza:safe-transmute-reference-types, r=compiler-errors
Safe Transmute: Enable handling references

This patch enables support for references in Safe Transmute, by generating nested obligations during trait selection. Specifically, when we call `confirm_transmutability_candidate(...)`, we now recursively traverse the `rustc_transmute::Answer` tree and create obligations for all the `Answer` variants, some of which include multiple nested `Answer`s.
2023-06-14 08:26:22 +00:00
The 8472
18c9a12d13 remove hash_drain_filter feature uses 2023-06-14 09:28:56 +02:00
The 8472
114d5f221c s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
The 8472
c0df1c8c43 remove drain-on-drop behavior from vec::DrainFilter and add #[must_use] 2023-06-14 09:24:51 +02:00
Michael Goulet
9e210522bc Improve docs/clean up negative overlap functions 2023-06-14 02:18:30 +00:00
Michael Goulet
01377e8064 opportunistically resolve regions 2023-06-13 22:10:51 +00:00
Matthias Krüger
b7706e891d
Rollup merge of #111885 - compiler-errors:rust-call-abi-sized, r=eholk
Don't ICE on unsized `extern "rust-call"` call

Conceptually builds on #111864, but doesn't depend on it.
2023-06-13 07:02:28 +02:00
Bryan Garza
f4cf8f65a5 Safe Transmute: Refactor error handling and Answer type
- Create `Answer` type that is not just a type alias of `Result`
- Remove a usage of `map_layouts` to make the code easier to read
- Don't hide errors related to Unknown Layout when computing transmutability
2023-06-12 16:56:21 -07:00
Maybe Waffle
f2545fb225 Collect VTable stats & add -Zprint-vtable-sizes 2023-06-12 15:58:35 +00:00
lcnr
e74d1cd581 update comment 2023-06-12 12:47:09 +02:00
bors
34d64ab7a2 Auto merge of #112466 - lcnr:opaque-type-cleanup, r=compiler-errors
opaque type cleanup

the commits are pretty self-contained.

r? `@compiler-errors` cc `@oli-obk`
2023-06-11 03:42:14 +00:00
lcnr
b62e20d2fd split opaque type handling in new solver
be more explicit in where we only add new hidden types
and where we also have to deal with item bounds.
2023-06-09 16:41:11 +02:00
Michael Goulet
d5e25d40c9 deduplicate identical region constraints 2023-06-08 23:38:07 +00:00
Dylan DPC
0b002eb906
Rollup merge of #112122 - compiler-errors:next-coherence, r=lcnr
Add `-Ztrait-solver=next-coherence`

Flag that conditionally uses the trait solver *only* during coherence, for more testing and/or eventual partial-migration onto the trait solver (in the medium- to long-term).

* This still uses the selection context in some of the coherence methods I think, so it's not "complete". Putting this up for review and/or for further work in-tree.
* I probably need to spend a bit more time making sure that we don't sneakily create any other infcx's during coherence that also need the new solver enabled.

r? `@lcnr`
2023-06-07 18:01:29 +05:30
Dylan DPC
cbe429c7a5
Rollup merge of #112076 - compiler-errors:bidirectional-alias-eq, r=lcnr
Fall back to bidirectional normalizes-to if no subst-relate candidate in alias-relate goal

Sometimes we get into the case where the choice of normalizes-to branch in alias-relate are both valid, but we cannot make a choice of which one to take because they are different -- either returning equivalent but permuted region constraints, or equivalent opaque type definitions but differing modulo normalization.

In this case, we can make progress by considering a fourth candidate where we compute both normalizes-to branches together and canonicalize that as a response. This is essentially the AND intersection of both normalizes-to branches. In an ideal world, we'd be returning something more like the OR intersection of both branches, but we have no way of representing that either for regions (maybe eventually) or opaques (don't see that happening ever).

This is incomplete, so like the subst-relate fallback it's only considered outside of coherence. But it doesn't seem like a dramatic strengthening of inference or anything, and is useful for helping opaque type inference succeed when the hidden type is a projection.

## Example

Consider the goal - `AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter)`.

We have three ways of currently solving this goal:
1. SubstRelate - fails because we can't directly equate the substs of different alias kinds.
2. NormalizesToRhs - `Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter`
    * Ends up infering opaque definition - `Tait := <[i32; 32] as IntoIterator>::IntoIter`
3. NormalizesToLhs - `<[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait`
    * Find impl candidate, substitute the associated type - `std::array::IntoIter<i32, 32>`
    * Equate `std::array::IntoIter<i32, 32>` and `Tait`
        * Ends up infering opaque definition - `Tait := std::array::IntoIter<i32, 32>`

The problem here is that 2 and 3 are essentially both valid, since we have aliases that normalize on both sides, but due to lazy norm, they end up inferring different opaque type definitions that are only equal *after* normalizing them further.

---

r? `@lcnr`
2023-06-07 18:01:28 +05:30
Michael Goulet
b95ea45a60 Note why rust-call abi requires sized obl 2023-06-06 20:57:00 +00:00
Michael Goulet
3ea7c512bd Fall back to bidirectional normalizes-to if no subst-eq in alias-eq goal 2023-06-06 18:44:22 +00:00
Michael Goulet
7a2cdf20e4 Move alias-relate to its own module 2023-06-06 18:44:22 +00:00
Michael Goulet
3d4da98273 Make TraitEngine::new use the right solver, add compare mode 2023-06-06 18:43:20 +00:00
Michael Goulet
b637048a89 Add -Ztrait-solver=next-coherence 2023-06-06 18:43:20 +00:00
Michael Goulet
e0acff796a New trait solver is a property of inference context 2023-06-06 18:43:06 +00:00
Matthias Krüger
38c92cca65
Rollup merge of #112325 - notriddle:notriddle/issue-111932, r=compiler-errors
diagnostics: do not suggest type name tweaks on type-inferred closure args

Fixes #111932
2023-06-06 12:00:34 +02:00
Michael Howell
467bc9ffd5 diagnostics: do not suggest type name tweaks on type-inferred closure args
Fixes #111932
2023-06-05 19:05:15 -07:00
Matthias Krüger
44acf796c7
Rollup merge of #112318 - oli-obk:assoc_ty_sized_bound_for_object_safety, r=compiler-errors
Merge method, type and const object safety checks

cc `@spastorino` and `@compiler-errors` on the first commit. I believe it to be correct, as the field is only `Some` for assoc types, so just checking the field without checking the assoc kind to be `Type` is fine.

The second commit avoids going through all associated items thrice and just goes over all of them once, running the object safety checks per assoc item kind.
2023-06-05 23:48:00 +02:00
Matthias Krüger
ff43249b0e
Rollup merge of #112303 - Nilstrieb:as-deref, r=compiler-errors
Normalize in infcx instead of globally for `Option::as_deref` suggestion

fixes #112293

The projection may contain inference variables. These inference variables are local to the local inference context. Using `tcx.normalize_erasing_regions` doesn't work here because this method is global and does not have access to the inference context. It's therefore unable to deal with the inference variables. We normalize in the local inference context instead, which knowns about the inference variables.

The test looks a little different than the issue example, I made it more minimal and verified that it still ICEs on nightly.

Also contains a drive-by fix to properly compare the types.

r? `@compiler-errors`
2023-06-05 23:47:59 +02:00
Michael Goulet
979379aff7 Resolve vars in result from scrape_region_constraints 2023-06-05 19:40:30 +00:00
Oli Scherer
58972d19e7 Merge method, type and const object safety checks 2023-06-05 16:39:16 +00:00
Oli Scherer
604ffab063 Avoid going through queries if a value of type AssocItem is already available 2023-06-05 14:22:45 +00:00
Nilstrieb
c12575d317 Normalize in infcx instead of globally for Option::as_deref suggestion
The projection may contain inference variables. These inference
variables are local to the local inference context. Using
`tcx.normalize_erasing_regions` doesn't work here because this method is
global and does not have access to the inference context. It's therefore
unable to deal with the inference variables. We normalize in the local
inference context instead, which knowns about the inference variables.
2023-06-05 08:34:06 +00:00
Nilstrieb
896ccb9606 Properly compare types for Option::as_deref suggestion 2023-06-05 08:26:53 +00:00
Matthias Krüger
91f222f931
Rollup merge of #111659 - y21:suggest-as-deref, r=cjgillot
suggest `Option::as_deref(_mut)` on type mismatch in option combinator if it passes typeck

Fixes #106342.
This adds a suggestion to call `.as_deref()` (or `.as_deref_mut()` resp.) if typeck fails due to a type mismatch in the function passed to an `Option` combinator such as `.map()` or `.and_then()`.
For example:
```rs
fn foo(_: &str) {}
Some(String::new()).map(foo);
```
The `.map()` method requires its argument to satisfy `F: FnOnce(String)`, but it received `fn(&str)`, which won't pass. However, placing a `.as_deref()` before the `.map()` call fixes this since `&str == &<String as Deref>::Target`
2023-06-03 20:38:10 +02:00
y21
268b08b01b do not use ty_adt_id from internal trait 2023-06-03 17:17:56 +02:00
Michael Goulet
18763cb464
Rollup merge of #112223 - compiler-errors:new-solver-auto-proj, r=BoxyUwU
Don't ICE in new solver when auto traits have associated types

People can write malformed auto traits, and that shouldn't cause the new solver to ICE
2023-06-02 16:02:07 -07:00
Michael Goulet
84196f3371 Elaborate comment, make sure we do normalizes-to hack eventually for IATs, don't partially support const projection for impls 2023-06-02 22:07:58 +00:00
Michael Goulet
8912015f71 No const equate in new solver 2023-06-02 22:07:57 +00:00
Michael Goulet
2c1473ca70 Normalize anon consts in new solver 2023-06-02 22:07:57 +00:00
Michael Goulet
4fbb43e70f No more TyCtxt::lazy_normalization 2023-06-02 22:07:57 +00:00
Michael Goulet
ecd7809784 Don't ICE in new solver when auto traits have associated types 2023-06-02 19:22:25 +00:00
Matthias Krüger
f121f77d8a
Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errors
Rename `impl_defaultness` to `defaultness`

Since this isn't just about the `impl`.
2023-06-02 18:12:45 +02:00
bors
8ebf04225d Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #111670 (Require that const param tys implement `ConstParamTy`)
 - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…)
 - #112030 (Migrate `item_trait_alias` to Askama)
 - #112150 (Support 128-bit atomics on all x86_64 Apple targets)
 - #112174 (Fix broken link)
 - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.)
 - #112193 (Check tuple elements are `Sized` in `offset_of`)

Failed merges:

 - #112071 (Group rfcs tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-02 07:57:21 +00:00
Michael Goulet
847d50453c Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
Michael Goulet
a9fcb524ff Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too 2023-06-01 18:21:42 +00:00
Michael Goulet
8ab10bacdf remove search_for_adt_const_param_violation 2023-06-01 18:03:59 +00:00
Deadbeef
4f83717cf7 Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
Deadbeef
21bc5cded4 Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
bors
ad8304a0d5 Auto merge of #111076 - notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot
diagnostics: exclude indirect private deps from trait impl suggest

Fixes #88696
2023-05-31 13:47:36 +00:00
Boxy
1e9b69bf3f move hack to normalize_param_env_or_error 2023-05-31 02:14:15 +01:00
bors
f0411ffceb Auto merge of #111881 - lcnr:leak-check, r=nikomatsakis,jackh726
refactor and cleanup the leak check, add it to new solver

ended up being a bit more involved than I wanted but is hopefully still easy enough to review as a single PR, can split it into separate ones otherwise.

this can be reviewed commit by commit:
a473d55cdb9284aa2b01282d1b529a2a4d26547b 31a686646534ca006d906ec757ece4e771d6f973 949039c107852a5e36361c08b62821a0613656f5 242917bf5170d9a723c6c8e23e9d9d0c2fa8dc9d ed2b25a7aa28be3184be9e3022c2796a30eaad87 are all pretty straightforward.

03dd83b4c3f4ff27558f5c8ab859bd9f83db1d04 makes it easier to refactor coherence in a later commit, see the commit description, cc `@oli-obk`

4fe311d807a77b6270f384e41689bf5d58f46aec I don't quite remember what we wanted to test here, this definitely doesn't test that the occurs check doesn't cause incorrect errors in coherence, also cc `@oli-obk` here. I may end up writing a new test for this myself later.

5c200d88a91b75bd0875b973150655bd581ef97a is the main refactor of the leak check, changing it to take the `outer_universe` instead of getting it from a snapshot. Using a snapshot requires us to be in a probe which we aren't in the new solver, it also just feels dirty as snapshots don't really have anything to do with universes.

with all of this cfc230d54188d9c7ed867a9a0d1f51be77b485f9 is now kind of trivial.

r? `@nikomatsakis`
2023-05-30 18:48:12 +00:00
lcnr
0b81f992e9 update universe used by the leak check 2023-05-30 13:04:27 +02:00
lcnr
6f9041bd15 add the leak check to the new solver 2023-05-30 13:03:40 +02:00
lcnr
a0245bb3cb rework the leak_check to take the outer_universe
clean up coherence to not rely on probes anymore
2023-05-30 13:03:38 +02:00
Nilstrieb
e7fdba84e2
Rollup merge of #112060 - lcnr:early-binder, r=jackh726
`EarlyBinder::new` -> `EarlyBinder::bind`

for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR.

r? `@jackh726` `@kylematsuda`
2023-05-30 12:57:40 +02:00
lcnr
200ed9f8cd leak_check: remove unused codepath 2023-05-30 12:40:35 +02:00
Maybe Waffle
e33e20824f Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
lcnr
08d149ca85 EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
Nicholas Nethercote
781111ef35 Use Cow in {D,Subd}iagnosticMessage.
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most
compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl
From<&'static str>`, which involves a bunch of knock-on changes that
require/result in call sites being a little more precise about exactly
what kind of string they use to create errors, and not just `&str`. This
will result in fewer unnecessary allocations, though this will not have
any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to
preserve the existing string imprecision. I could have used `impl
Into<{D,Subd}iagnosticMessage>` in various places as is done in the
compiler, but that would have required changes to *many* call sites
(mostly changing `&format("...")` to `format!("...")`) which didn't seem
worthwhile.
2023-05-29 09:23:43 +10:00
Kyle Matsuda
c40e9cc7ca Make EarlyBinder's inner value private; and fix all of the resulting errors 2023-05-28 10:44:53 -06:00
Kyle Matsuda
03534ac8b7 Replace EarlyBinder(x) with EarlyBinder::new(x) 2023-05-28 10:44:50 -06:00
bors
f59d577838 Auto merge of #112001 - saethlin:enable-matchbranchsimplification, r=cjgillot
Enable MatchBranchSimplification

This pass is one of the small number of benefits from `-Zmir-opt-level=3` that has motivated rustc_codegen_cranelift to use it:

19ed0aade6/compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs (L244-L246)

Cranelift's motivation for this is _runtime_ performance improvements in debug builds. Lifting this pass all the way to `-Zmir-opt-level=1` seems to come without significant perf overhead, so that's what I'm suggesting here.
2023-05-28 09:59:20 +00:00
bors
b9c5fdc888 Auto merge of #111378 - jieyouxu:local-shadows-glob-reexport, r=petrochenkov
Add warn-by-default lint when local binding shadows exported glob re-export item

This PR introduces a warn-by-default rustc lint for when a local binding (a use statement, or a type declaration) produces a name which shadows an exported glob re-export item, causing the name from the exported glob re-export to be hidden (see #111336).

### Unresolved Questions

- [x] ~~Is this approach correct? While it passes the UI tests, I'm not entirely convinced it is correct.~~ Seems to be ok now.
- [x] ~~What should the lint be called / how should it be worded? I don't like calling `use x::*;` or `struct Foo;` a "local binding" but they are `NameBinding`s internally if I'm not mistaken.~~ ~~The lint is called `local_binding_shadows_glob_reexport` for now, unless a better name is suggested.~~ `hidden_glob_reexports`.

Fixes #111336.
2023-05-28 01:18:51 +00:00
Ben Kimock
7e04c93493 Try enabling MatchBranchSimplification 2023-05-27 13:50:13 -04:00
许杰友 Jieyou Xu (Joe)
b9606589c4
Add warn-by-default lint for local binding shadowing exported glob re-export item 2023-05-27 18:49:07 +08:00