about summary refs log tree commit diff
path: root/src/librustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2020-05-11bless ui testscsmoe-3/+19
2020-05-10remove try_trait lang itemcsmoe-32/+26
2020-05-10suggest await before try when performing trait selectioncsmoe-0/+91
2020-05-09add regression tests + improve method nameBastian Kauschke-4/+4
2020-05-09Rollup merge of #71555 - cjgillot:nameless, r=matthewjasperRalf Jung-2/+1
Remove ast::{Ident, Name} reexports. The reexport of `Symbol` into `Name` confused me.
2020-05-09Rollup merge of #69406 - jackh726:chalk-upgrade, r=nikomatsakisRalf Jung-14/+296
upgrade chalk and use chalk-solve/chalk-ir/chalk-rust-ir Reintegrate chalk into rustc. r? @nikomatsakis cc. @rust-lang/wg-traits
2020-05-09Rollup merge of #72018 - mark-i-m:canon-chalk, r=mark-i-mDylan DPC-1/+1
Fix canonicalization links
2020-05-08Fix debug assertion in error codeMatthew Jasper-0/+9
2020-05-08fix canonicalization linksmark-1/+1
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-2/+1
2020-05-08checking on either interior or upvarcsmoe-119/+132
2020-05-07Reintegrate chalk using chalk-solveJack Huey-14/+296
2020-05-07perf: Revert accidental inclusion of a part of #69218Markus Westerlind-12/+6
This was accidentally included in #69494 after a rebase and given how much `inflate` and `keccak` stresses the obligation forest seems like a likely culprit to the regression in those benchmarks. (It is necessary in #69218 as obligation forest needs to accurately track the root variables or unifications will get lost)
2020-05-07Rollup merge of #71960 - estebank:fix-E0284, r=davidtwcoDylan DPC-3/+17
Fix E0284 to not use incorrect wording Fix #71584, fix #69683.
2020-05-07Fix E0284 to not use incorrect wordingEsteban Küber-3/+17
Fix #71584, fix #69683.
2020-05-07Auto merge of #55617 - oli-obk:stacker, r=nagisa,oli-obkbors-88/+108
Prevent compiler stack overflow for deeply recursive code I was unable to write a test that 1. runs in under 1s 2. overflows on my machine without this patch The following reproduces the issue, but I don't think it's sensible to include a test that takes 30s to compile. We can now easily squash newly appearing overflows by the strategic insertion of calls to `ensure_sufficient_stack`. ```rust // compile-pass #![recursion_limit="1000000"] macro_rules! chain { (EE $e:expr) => {$e.sin()}; (RECURSE $i:ident $e:expr) => {chain!($i chain!($i chain!($i chain!($i $e))))}; (Z $e:expr) => {chain!(RECURSE EE $e)}; (Y $e:expr) => {chain!(RECURSE Z $e)}; (X $e:expr) => {chain!(RECURSE Y $e)}; (A $e:expr) => {chain!(RECURSE X $e)}; (B $e:expr) => {chain!(RECURSE A $e)}; (C $e:expr) => {chain!(RECURSE B $e)}; // causes overflow on x86_64 linux // less than 1 second until overflow on test machine // after overflow has been fixed, takes 30s to compile :/ (D $e:expr) => {chain!(RECURSE C $e)}; (E $e:expr) => {chain!(RECURSE D $e)}; (F $e:expr) => {chain!(RECURSE E $e)}; // more than 10 seconds (G $e:expr) => {chain!(RECURSE F $e)}; (H $e:expr) => {chain!(RECURSE G $e)}; (I $e:expr) => {chain!(RECURSE H $e)}; (J $e:expr) => {chain!(RECURSE I $e)}; (K $e:expr) => {chain!(RECURSE J $e)}; (L $e:expr) => {chain!(RECURSE L $e)}; } fn main() { let x = chain!(D 42.0_f32); } ``` fixes #55471 fixes #41884 fixes #40161 fixes #34844 fixes #32594 cc @alexcrichton @rust-lang/compiler I looked at all code that checks the recursion limit and inserted stack growth calls where appropriate.
2020-05-06Rollup merge of #70908 - estebank:suggest-add, r=nikomatsakisDylan DPC-184/+6
Provide suggestions for type parameters missing bounds for associated types When implementing the binary operator traits it is easy to forget to restrict the `Output` associated type. `rustc` now accounts for different cases to lead users in the right direction to add the necessary restrictions. The structured suggestions in the following output are new: ``` error: equality constraints are not yet supported in `where` clauses --> $DIR/missing-bounds.rs:37:33 | LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { | ^^^^^^^^^^^^^^^^^^^^^^ not supported | = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information help: if `Output` is an associated type you're trying to set, use the associated type binding syntax | LL | impl<B: Add> Add for E<B> where B: Add<Output = B> { | ^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/missing-bounds.rs:11:11 | 7 | impl<B> Add for A<B> where B: Add { | - this type parameter ... 11 | A(self.0 + rhs.0) | ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type | = note: expected type parameter `B` found associated type `<B as std::ops::Add>::Output` help: consider further restricting this bound | 7 | impl<B> Add for A<B> where B: Add + std::ops::Add<Output = B> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0369]: cannot add `B` to `B` --> $DIR/missing-bounds.rs:31:21 | 31 | Self(self.0 + rhs.0) | ------ ^ ----- B | | | B | help: consider restricting type parameter `B` | 27 | impl<B: std::ops::Add<Output = B>> Add for D<B> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` That output is given for the following cases: ```rust struct A<B>(B); impl<B> Add for A<B> where B: Add { type Output = Self; fn add(self, rhs: Self) -> Self { A(self.0 + rhs.0) //~ ERROR mismatched types } } struct D<B>(B); impl<B> Add for D<B> { type Output = Self; fn add(self, rhs: Self) -> Self { Self(self.0 + rhs.0) //~ ERROR cannot add `B` to `B` } } struct E<B>(B); impl<B: Add> Add for E<B> where <B as Add>::Output = B { type Output = Self; fn add(self, rhs: Self) -> Self { Self(self.0 + rhs.0) } } ```
2020-05-06bless issue-70818 test casecsmoe-10/+7
2020-05-06filter upvars that cause trait obligationcsmoe-120/+134
2020-05-05record upvar into GeneratorInteriorTypeCausecsmoe-17/+18
2020-05-05make yield span optionalcsmoe-7/+9
2020-05-05Rebase and use ena 0.14Markus Westerlind-15/+23
2020-05-05perf: Merge region_obligations snapshotting into the undo logMarkus Westerlind-1/+1
2020-05-05Move projection_cache into the combined undo logMarkus Westerlind-1/+1
2020-05-04Suggest restricting type param when it doesn't satisfy projectionEsteban Küber-184/+6
When encountering a projection that isn't satisfied by a type parameter, suggest constraining the type parameter.
2020-05-04Rollup merge of #71038 - lcnr:dyn_trait_structural_match, r=pnkfelixDylan DPC-0/+5
forbid `dyn Trait` in patterns Do not allow `&dyn Trait` as a generic const parameters. This also changes dyn trait in pattern from ICE to error. closes #63322 closes #70972 r? @eddyb
2020-05-04Auto merge of #71108 - estebank:suggest-proj-type-mismatch-constraint, r=oli-obkbors-0/+7
On type mismatch involving associated type, suggest constraint When an associated type is found when a specific type was expected, if possible provide a structured suggestion constraining the associated type in a bound. ``` error[E0271]: type mismatch resolving `<T as Foo>::Y == i32` --> $DIR/associated-types-multiple-types-one-trait.rs:13:5 | LL | want_y(t); | ^^^^^^ expected `i32`, found associated type ... LL | fn want_y<T:Foo<Y=i32>>(t: &T) { } | ----- required by this bound in `want_y` | = note: expected type `i32` found associated type `<T as Foo>::Y` help: consider constraining the associated type `<T as Foo>::Y` to `i32` | LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T) | ^^^^^^^^^ ``` ``` error[E0308]: mismatched types --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9 | LL | qux(x.func()) | ^^^^^^^^ expected `usize`, found associated type | = note: expected type `usize` found associated type `<impl Trait as Trait>::A` help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize` | LL | fn foo(x: impl Trait<A = usize>) { | ^^^^^^^^^^ ``` Fix #71035. Related to #70908.
2020-05-03Fix tidy checksKevin Per-22/+19
2020-05-03Adding if to prevent borrowing suggestion in structs #71136Kevin Per-6/+46
2020-05-03Rollup merge of #71314 - mibac138:cfg-version, r=petrochenkovDylan DPC-6/+11
Implement RFC 2523, `#[cfg(version(..))]` Hi! This is my first contribution to rust, I hope I didn't miss anything. I tried to implement this feature so that `#[cfg(version(1.44.0))]` works but the parser was printing an error that I wasn't sure how to fix so I just opted for implementing `#[cfg(version("1.44.0"))]` (note the quotes). Tracking issue: #64796
2020-05-02Point at associated types when they have a default typeEsteban Küber-0/+7
Associated types with a default type in a trait can't be relied upon to remain of that default type when in use, so literals of that type can't be used in the trait's items. Point at the associated type and state that information. Reduce verbosity for associated consts of the wrong type.
2020-05-03Implement RFC 2523, `#[cfg(version(..))]`mibac138-6/+11
2020-05-02Rollup merge of #71787 - tshepang:rustdoc-warnings, r=varkorDylan DPC-2/+2
fix rustdoc warnings
2020-05-02Move ensure_sufficient_stack to data_structuresSimonas Kazlauskas-3/+3
We anticipate this to have uses in all sorts of crates and keeping it in `rustc_data_structures` enables access to it from more locations without necessarily pulling in the large `librustc` crate.
2020-05-02Prevent stack overflow for deeply recursive codeOliver Scherer-88/+108
2020-05-02Auto merge of #71795 - RalfJung:rollup-yqxfi5a, r=RalfJungbors-1/+0
Rollup of 6 pull requests Successful merges: - #71712 (Miri: port error backtraces to std::backtrace) - #71736 (bootstrap: also apply unused-attributes hack without deny_warnings) - #71738 (remove AllocId generalization of Pointer) - #71739 (remove obsolete comment) - #71781 (Uncomment test code for failure to use `Box::pin`) - #71782 (Use a non-existent test path instead of clobbering /dev/null) Failed merges: r? @ghost
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-2/+2
2020-05-02Auto merge of #70170 - eddyb:wf-early-exit, r=nikomatsakisbors-43/+45
wf: handle "livelock" checking before reaching `WfPredicates::compute`. For `wf::obligations`'s "livelock" handling, this PR shouldn't cause any behavioral changes, as the check moved to it should be equivalent to the old one in `WfPredicates::compute`. However, it fixes #70168 by making *other* users of `WfPredicates::compute` (that is, `wf::predicate_obligations` and `compute`'s own upvar handling) correct for `ty::Infer`, in that they now get a `WellFormed(ty::Infer(_))` obligation instead of silently ignoring the type. r? @nikomatsakis
2020-05-01remove obsolete commentTshepang Lekhonkhobe-1/+0
Referenced was removed in 9f492fefef8d9a75f6dc27c834561fe977ca70c5
2020-05-01Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasperbors-2/+2
Have the per-query caches store the results on arenas This PR leverages the cache for each query to serve as storage area for the query results. It introduces a new cache `ArenaCache`, which moves the result to an arena, and only stores the reference in the hash map. This allows to remove a sizeable part of the usage of the global `TyCtxt` arena. I only migrated queries that already used arenas before.
2020-04-30wf: {Int,Float}Var can only infer to always-WF ints/floats.Eduard-Mihai Burtescu-2/+8
2020-04-30wf: handle "livelock" checking before reaching `WfPredicates::compute`.Eduard-Mihai Burtescu-42/+38
2020-04-30Rollup merge of #71449 - ecstatic-morse:free-region-cleanup, r=Mark-SimulacrumDylan DPC-1/+1
Move `{Free,}RegionRelations` and `FreeRegionMap` to `rustc_infer` ...and out of `rustc_middle`. This is to further #65031, albeit in a very minor way r? @Mark-Simulacrum
2020-04-29forbid `dyn Trait` in const genericsBastian Kauschke-0/+5
2020-04-28Use the query system to allocate.Camille GILLOT-2/+2
2020-04-27Use `LocalDefId` in `typeck_tables_of` and `used_trait_imports` queriesmarmeladema-1/+1
2020-04-27Auto merge of #71268 - estebank:devectorize, r=eddybbors-114/+91
Remove some `Vec` allocations to improve performance This claws back most of the performance lost in https://github.com/rust-lang/rust/pull/69745. r? @eddyb
2020-04-27Rollup merge of #71409 - estebank:point-at-ret-question-mark-op, r=petrochenkovDylan DPC-14/+37
Point at the return type on `.into()` failure caused by `?` Fix #35946.
2020-04-26Point at the return type on `.into()` failure caused by `?`Esteban Küber-14/+37
Fix #35946.
2020-04-24Remove `Option` from the return type of `def_kind`.Eduard-Mihai Burtescu-1/+1