about summary refs log tree commit diff
path: root/src/librustc/infer
AgeCommit message (Collapse)AuthorLines
2018-02-18Generate documentation for auto-trait implsAaron Hill-5/+18
A new section is added to both both struct and trait doc pages. On struct/enum pages, a new 'Auto Trait Implementations' section displays any synthetic implementations for auto traits. Currently, this is only done for Send and Sync. On trait pages, a new 'Auto Implementors' section displays all types which automatically implement the trait. Effectively, this is a list of all public types in the standard library. Synthesized impls for a particular auto trait ('synthetic impls') take into account generic bounds. For example, a type 'struct Foo<T>(T)' will have 'impl<T> Send for Foo<T> where T: Send' generated for it. Manual implementations of auto traits are also taken into account. If we have the following types: 'struct Foo<T>(T)' 'struct Wrapper<T>(Foo<T>)' 'unsafe impl<T> Send for Wrapper<T>' // pretend that Wrapper<T> makes this sound somehow Then Wrapper will have the following impl generated: 'impl<T> Send for Wrapper<T>' reflecting the fact that 'T: Send' need not hold for 'Wrapper<T>: Send' to hold Lifetimes, HRTBS, and projections (e.g. '<T as Iterator>::Item') are taken into account by synthetic impls However, if a type can *never* implement a particular auto trait (e.g. 'struct MyStruct<T>(*const T)'), then a negative impl will be generated (in this case, 'impl<T> !Send for MyStruct<T>') All of this means that a user should be able to copy-paste a synthetic impl into their code, without any observable changes in behavior (assuming the rest of the program remains unchanged).
2018-02-17fix more typos found by codespell.Matthias Krüger-4/+4
2018-02-03Auto merge of #47791 - estebank:mismatched-trait-impl, r=nikomatsakisbors-29/+52
Tweak presentation on lifetime trait mismatch - On trait/impl method discrepancy, add label pointing at trait signature. - Point only at method definition when referring to named lifetimes on lifetime mismatch. - When the sub and sup expectations are the same, tweak the output to avoid repeated spans. Fix #30790, CC #18759.
2018-01-28Point only at method signatures and point at traitEsteban Küber-3/+3
- On mismatch between impl and trait method, point at the trait signature. - Point only at the method signature instead of the whole body on trait/impl mismatch errors.
2018-01-28For named lifetimes point only at method signatureEsteban Küber-20/+45
When refering to named lifetime conflict, point only at the method's signature span instead of the entire method. When the expected and found sup and sub traces are the same, avoid redundant text.
2018-01-27end_point handling multibyte characters correctly.David Wood-1/+2
2018-01-26Tweak presentation on lifetime trait mismatchEsteban Küber-6/+4
2018-01-25Rollup merge of #47529 - nikomatsakis:impl-trait-issue-38064, r=cramertjAlex Crichton-1/+1
track recursion limit when expanding existential impl trait r? @cramertj
2018-01-23Adds support for immovable generators. Move checking of invalid borrows ↵John Kåre Alsaker-1/+2
across suspension points to borrowck. Fixes #44197, #45259 and #45093.
2018-01-22Auto merge of #47144 - estebank:moved-closure-arg, r=nikomatsakisbors-13/+156
Custom error when moving arg outside of its closure When given the following code: ```rust fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { f(&()); } fn main() { let mut x = None; give_any(|y| x = Some(y)); } ``` provide a custom error: ``` error: borrowed data cannot be moved outside of its closure --> file.rs:7:27 | 6 | let mut x = None; | ----- borrowed data cannot be moved into here... 7 | give_any(|y| x = Some(y)); | --- ^ cannot be moved outside of its closure | | | ...because it cannot outlive this closure ``` instead of the generic lifetime error: ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:14... --> file.rs:7:14 | 7 | give_any(|y| x = Some(y)); | ^^^^^^^^^^^^^^^ note: ...so that expression is assignable (expected &(), found &()) --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ note: but, the lifetime must be valid for the block suffix following statement 0 at 6:5... --> file.rs:6:5 | 6 | / let mut x = None; 7 | | give_any(|y| x = Some(y)); 8 | | } | |_^ note: ...so that variable is valid at time of its declaration --> file.rs:6:9 | 6 | let mut x = None; | ^^^^^ ``` Fix #45983.
2018-01-19Tweak wording and spans of closure lifetime errorsEsteban Küber-3/+33
2018-01-17track recursion limit when expanding existential impl traitNiko Matsakis-1/+1
2018-01-15Move diagnostic logic to its own moduleEsteban Küber-50/+126
- Move specialized borrow checker diagnostic for bindings escaping its closure to its own module. - Move affected tests to `ui`.
2018-01-15Handle case of moving into vec with uninferred lifetimeEsteban Küber-7/+15
2018-01-15Generalize cases where specific move error ocurrsEsteban Küber-2/+1
Trigger new diagnostic in `compile-fail/regions-escape-bound-fn.rs` test, and not only in `compile-fail/regions-escape-bound-fn-2.rs`.
2018-01-15Reword diagnosticEsteban Küber-10/+6
2018-01-15Custom error when moving arg outside of its closureEsteban Küber-1/+35
When given the following code: ```rust fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { f(&()); } fn main() { let mut x = None; give_any(|y| x = Some(y)); } ``` provide a custom error: ``` error: borrowed data cannot be moved outside of its closure --> file.rs:7:27 | 6 | let mut x = None; | ----- binding declared outside of closure 7 | give_any(|y| x = Some(y)); | --- ^ cannot be assigned to binding outside of its closure | | | closure you can't escape ``` instead of the generic lifetime error: ``` error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:14... --> file.rs:7:14 | 7 | give_any(|y| x = Some(y)); | ^^^^^^^^^^^^^^^ note: ...so that expression is assignable (expected &(), found &()) --> file.rs:7:27 | 7 | give_any(|y| x = Some(y)); | ^ note: but, the lifetime must be valid for the block suffix following statement 0 at 6:5... --> file.rs:6:5 | 6 | / let mut x = None; 7 | | give_any(|y| x = Some(y)); 8 | | } | |_^ note: ...so that variable is valid at time of its declaration --> file.rs:6:9 | 6 | let mut x = None; | ^^^^^ ```
2018-01-15Auto merge of #47329 - davidtwco:issue-46983, r=nikomatsakisbors-12/+13
NLL: bad error message when converting anonymous lifetime to `'static` Fixes #46983. r? @nikomatsakis
2018-01-10Fixes #46983. Fixes bad error message when converting anonymous lifetime to ↵David Wood-12/+13
`'static`
2018-01-08Use different DefIndex representation that is better suited for variable ↵Michael Woerister-3/+2
length integer encodings.
2018-01-01Fix docs for future pulldown migrationMalo Jaffré-17/+31
2017-12-25"incompatible arm" diagnostic span tweakEsteban Küber-2/+12
Use span label instead of span note for single line spans in "incompatible arm" diagnostic.
2017-12-20improve comment about instantiating anon typesNiko Matsakis-6/+34
2017-12-20when using feature(nll), don't warn about AST-based region errorsNiko Matsakis-7/+51
Also, keep reporting AST-based region errors that are not occuring in a fn body.
2017-12-20Add nll feature and make nll imply nll_dump_causeSantiago Pastorino-1/+1
2017-12-20refactor `report_generic_bound_failure` to be usable by NLL codeNiko Matsakis-13/+22
2017-12-20connect NLL machinery to the `NiceRegionError` codeNiko Matsakis-1/+1
2017-12-20give precedence to `try_report_named_anon_conflict` methodNiko Matsakis-2/+2
2017-12-20use `Option<ErrorReported>` instead of `bool`Niko Matsakis-34/+25
Also allows us to replace `or_false` with `?`. No functional change
2017-12-20introduce a `NiceRegionError` type and define methods on thatNiko Matsakis-82/+137
This is more convenient, and allows us to be more independent from infcx, particularly with respect to `in_progress_tables` field. No functional change.
2017-12-20nice_region_error: rustfmtNiko Matsakis-83/+98
2017-12-20extract `find_anon_type` into its own moduleNiko Matsakis-263/+296
2017-12-20make `util` fns private to nice_region_errorNiko Matsakis-8/+8
2017-12-20move nice-region-error reporting into its own moduleNiko Matsakis-5/+16
2017-12-20connect NLL type checker to the impl trait codeNiko Matsakis-5/+42
We now add the suitable `impl Trait` constraints.
2017-12-20extract the writeback code for anon types into InferCtxtNiko Matsakis-1/+102
No functional change.
2017-12-20extract `constrain_anon_types` to the `InferCtxt`Niko Matsakis-15/+284
No funtional change.
2017-12-20extract `instantiate_anon_types` to the `InferCtxt`Niko Matsakis-0/+201
No functional change.
2017-12-15add a new RegionKind variant: ReClosureBoundNiko Matsakis-1/+29
This is needed to allow the `ClosureRegionRequirements` to capture types that include regions.
2017-12-13Add more debug logsSantiago Pastorino-1/+15
2017-12-13Check Repeat RvalueSantiago Pastorino-0/+4
2017-12-10infer: Fix typo in README.Emilio Cobos Álvarez-1/+1
Was just reading through it and found this, not a big deal but...
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+2
2017-12-07replace `InferCtxt::fn_sig` with `closure_sig`Niko Matsakis-32/+12
2017-12-07mir-borrowck returns closure requirements, mir-typeck enforcesNiko Matsakis-0/+5
2017-12-04outlives/env: fix comment, say must and not shouldNiko Matsakis-1/+1
2017-12-04outlives/env: Fix comment that lost surrounding context.Niko Matsakis-3/+2
2017-12-04free_region_map: Fix typo in comment: r_a <= r_bNiko Matsakis-1/+1
2017-12-04rename `greater_than` to `reachable_from`Niko Matsakis-13/+0
2017-12-04rename `implied_bounds` module to `bounds`Niko Matsakis-3/+3