Commit Graph

2712 Commits

Author SHA1 Message Date
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
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
Michael Goulet
c4e8a86d9e Don't use outlives type op outside of MIR typeck 2023-05-27 04:13:44 +00:00
Michael Goulet
d7a2fdd4db Uplift complex type ops back into typeck so we can call them locally 2023-05-27 04:13:44 +00:00
Michael Goulet
a25aee1957 Perform MIR type ops locally in new solver 2023-05-27 04:13:44 +00:00
Matthias Krüger
dfdbf1b133
Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwU
do not prefer substs relate during coherence

r? ```@compiler-errors```
2023-05-27 00:24:00 +02:00
lcnr
b6b9611190 remove unnecessary .ok() calls 2023-05-26 11:07:20 +02:00
lcnr
e7fa993d89 do not prefer substs relate during coherence 2023-05-26 11:00:06 +02:00
bors
be72f2587c Auto merge of #111918 - compiler-errors:custom-type-ops-err, r=lcnr
Use `ErrorGuaranteed` more in MIR type ops

Delay bugs more eagerly and pass them through type op infra instead of delaying them at all the usage-sites.

Follow up to: https://github.com/rust-lang/rust/pull/111741#discussion_r1203840588

r? `@lcnr`
2023-05-26 06:20:21 +00:00
clubby789
f97fddab91 Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00