about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-06-01Implement custom diagnostic for ConstParamTyMichael Goulet-1/+112
2023-06-01Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait tooMichael Goulet-1/+2
2023-06-01remove search_for_adt_const_param_violationMichael Goulet-55/+19
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-1/+1
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-1/+1
2023-05-31Auto merge of #111076 - ↵bors-0/+1
notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot diagnostics: exclude indirect private deps from trait impl suggest Fixes #88696
2023-05-31move hack to `normalize_param_env_or_error`Boxy-3/+57
2023-05-30Auto merge of #111881 - lcnr:leak-check, r=nikomatsakis,jackh726bors-54/+76
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-30update universe used by the leak checklcnr-1/+3
2023-05-30add the leak check to the new solverlcnr-0/+5
2023-05-30rework the leak_check to take the outer_universelcnr-54/+69
clean up coherence to not rely on probes anymore
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-5/+5
`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-30leak_check: remove unused codepathlcnr-2/+2
2023-05-29Rename `tcx.mk_re_*` => `Region::new_*`Maybe Waffle-6/+7
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-5/+5
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-14/+31
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-28Make EarlyBinder's inner value private; and fix all of the resulting errorsKyle Matsuda-15/+11
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-5/+5
2023-05-28Auto merge of #112001 - saethlin:enable-matchbranchsimplification, r=cjgillotbors-0/+1
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: https://github.com/rust-lang/rust/blob/19ed0aade60e1c1038fe40554bcd9d01b717effa/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-28Auto merge of #111378 - jieyouxu:local-shadows-glob-reexport, r=petrochenkovbors-0/+2
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-27Try enabling MatchBranchSimplificationBen Kimock-0/+1
2023-05-27Add warn-by-default lint for local binding shadowing exported glob re-export ↵许杰友 Jieyou Xu (Joe)-0/+2
item
2023-05-27Don't use outlives type op outside of MIR typeckMichael Goulet-14/+23
2023-05-27Uplift complex type ops back into typeck so we can call them locallyMichael Goulet-17/+558
2023-05-27Perform MIR type ops locally in new solverMichael Goulet-1/+94
2023-05-27Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwUMatthias Krüger-9/+25
do not prefer substs relate during coherence r? ```@compiler-errors```
2023-05-26remove unnecessary `.ok()` callslcnr-6/+14
2023-05-26do not prefer substs relate during coherencelcnr-3/+11
2023-05-25Fallible<_> -> Result<_, NoSolution>Michael Goulet-38/+41
2023-05-25Use ErrorGuaranteed more in MIR type opsMichael Goulet-21/+39
2023-05-25diagnostics: exclude indirect private deps from trait impl suggestMichael Howell-0/+1
Fixes #88696
2023-05-25Match on both reveal and solver mode at the same timeMichael Goulet-41/+38
2023-05-25Add InferCtxt::register_hidden_type_in_new_solverMichael Goulet-40/+24
2023-05-25Strongly prefer alias and param-env boundsMichael Goulet-5/+9
2023-05-25Pre-populate MIR with opaques, prefer subst-relate candidateMichael Goulet-28/+25
2023-05-25Check that opaque is a defining use, prefer pre-defined opaquesMichael Goulet-14/+91
2023-05-25Prepopulate opaques in canonical inputMichael Goulet-77/+170
2023-05-25Move DefiningAnchorMichael Goulet-1/+2
2023-05-25Pull out logic from #111131, plus some new logic in ↵Michael Goulet-6/+60
EvalCtxt::normalize_opaque_type Co-authored-by: lcnr <rust@lcnr.de>
2023-05-24Safe Transmute: Update definition of Condition typeBryan Garza-17/+20
- Change `Condition` to not contain `Answer`s but instead just contain other `Condition`s directly. - Also improve error reporting for `DstHasStricterAlignment`
2023-05-24Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, ↵Manish Goregaokar-7/+7
r=petrochenkov Use `Option::is_some_and` and `Result::is_ok_and` in the compiler `.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable. This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24Safe Transmute: Check mutability before creating dst -> src obligationBryan Garza-5/+15
- Only create dst -> src obligation if Dst is mutable - Add some long comments to explain parts of the transmutability code that were unclear to me when reading - Update/add tests
2023-05-24Safe Transmute: Fix propagation of errorsBryan Garza-3/+3
- Make sure that the most specific Reason is the one that bubbles up when we are folding over the `Answer` tree. `Reason::DstIsBitIncompatible` is the least specific, so that should be used only when there isn't anything else available. - Small fixes where we used the wrong Reason variant. - Tiny cleanups
2023-05-24Safe Transmute: Change Answer type to ResultBryan Garza-23/+23
This patch updates the `Answer` type from `rustc_transmute` so that it just a type alias to `Result`. This makes it so that the standard methods for `Result` can be used to process the `Answer` tree, including being able to make use of the `?` operator on `Answer`s. Also, remove some unused functions
2023-05-24Safe Transmute: Enable handling references, including recursive typesBryan Garza-6/+65
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. Also, to handle recursive types, enable support for coinduction for the Safe Transmute trait (`BikeshedIntrinsicFrom`) by adding the `#[rustc_coinduction]` annotation. Also fix some small logic issues when reducing the `or` and `and` combinations in `rustc_transmute`, so that we don't end up with additional redundant `Answer`s in the tree. Co-authored-by: Jack Wrenn <jack@wrenn.fyi>
2023-05-24Use ObligationCtxt in custom type opsMichael Goulet-27/+27
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-7/+7
2023-05-24Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726Matthias Krüger-10/+16
Don't ICE when computing PointerLike trait when region vars are in param-env Fixes #111877
2023-05-23Don't ICE when computing PointerLike trait when region vars are in param-envMichael Goulet-10/+16
2023-05-23Rollup merge of #111704 - compiler-errors:sized-return-cleanup, r=oli-obkDylan DPC-230/+49
Remove return type sized check hack from hir typeck Remove a bunch of special-cased suggestions when someone returns `-> dyn Trait` that checks for type equality, etc. This was a pretty complex piece of code that also relied on a hack in hir typeck (see changes to `compiler/rustc_hir_typeck/src/check.rs`), and I'm not convinced that it's necessary to maintain, when all we really need to tell the user is that they should return `-> impl Trait` or `-> Box<dyn Trait>`, depending on their specific use-case. This is necessary because we may need to move the "return type is sized" check from hir typeck to wfcheck, which does not have access to typeck results. This is a prerequisite for that, and I'm fairly confident that the diagnostics "regressions" here are not a big deal.