about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2020-01-21Rollup merge of #68297 - Aaron1011:fix/new-const-prop-bounds, r=oli-obkYuki Okushi-34/+10
Filter and test predicates using `normalize_and_test_predicates` for const-prop Fixes #68264 Previously, I attempted to use `substitute_normalize_and_test_predicates` to detect unsatisfiable bounds. Unfortunately, since const-prop runs in a generic environment (we don't have any of the function's generic parameters substituted), this could lead to cycle errors when attempting to normalize predicates. This check is replaced with a more precise check. We now only call `normalize_and_test_predicates` on predicates that have the possibility of being proved unsatisfiable - that is, predicates that don't depend on anything local to the function (e.g. generic parameters). This ensures that we don't hit cycle errors when we normalize said predicates, while still ensuring that we detect unsatisfiable predicates. I haven't been able to come up with a minimization of the Diesel issue - however, I've verified that it compiles successfully.
2020-01-20Add `ConstnessAnd` that implements `ToPredicate`Dylan MacKenzie-43/+66
2020-01-20Add `constness` field to `ty::Predicate::Trait`Dylan MacKenzie-17/+22
2020-01-20Rollup merge of #68353 - Centril:code-liberation, r=petrochenkovDylan DPC-10/+0
Remove `rustc_error_codes` deps except in `rustc_driver` Remove dependencies on `rustc_error_codes` in all crates except for `rustc_driver`. This has some benefits: 1. Adding a new error code when hacking on the compiler only requires rebuilding at most `rustc_error_codes`, `rustc_driver`, and the reflexive & transitive closure of the crate where the new error code is being added and its reverse dependencies. This improves time-to-UI-tests (TTUT). 2. Adding an error description to an error code only requires rebuilding `rustc_error_codes` and `rustc_driver`. This should substantially improve TTUT. r? @petrochenkov cc @rust-lang/wg-diagnostics
2020-01-20Auto merge of #68057 - Aaron1011:fix/marker-trait-selection, r=matthewjasperbors-6/+58
Don't discard marker trait impls when inference variables are present Fixes #61651 Previously, we would unconditionally discard impl candidates for marker traits during trait selection. However, if the predicate had inference variables, this could have the effect of constrainting inference variables (due to a successful trait selection) when we would have otherwise failed due to mutliple applicable impls, This commit prevents marker trait impls from being discarded while the obligation predicate has any inference variables, ensuring that discarding impls will never cause us to incorrectly constraint inference variables.
2020-01-19update test ui for raw-ptr borrow inside generatorcsmoe-1/+1
2020-01-19account temporary borrow by raw-ptrcsmoe-5/+32
2020-01-18remove rustc_error_codes deps except in rustc_driverMazdak Farrokhzad-10/+0
2020-01-17Use named fields for `hir::ItemKind::Impl`Dylan MacKenzie-8/+7
2020-01-17Rollup merge of #68195 - estebank:impl-trait-2000, r=CentrilDylan DPC-2993/+3342
Account for common `impl Trait`/`dyn Trait` return type errors - When all return paths have the same type, suggest `impl Trait`. - When all return paths implement the expected `trait`, suggest `Box<dyn Trait>` and mention using an `enum`. - When multiple different types are returned and `impl Trait` is expected, extend the explanation. - When return type is `impl Trait` and the return paths do not implement `Trait`, point at the returned values. - Split `src/librustc/traits/error_reporting.rs` into multiple files to keep size under control. Fix #68110, cc #66523.
2020-01-16Revert previous attempt at detecting unsatisfiable predicatesAaron Hill-34/+10
2020-01-16review commentsEsteban Küber-26/+23
2020-01-16Account for object safety when suggesting `Box<dyn Trait>`Esteban Küber-1/+3
2020-01-16review commentsEsteban Küber-166/+138
2020-01-16review commentsEsteban Küber-6/+3
2020-01-16review commentsEsteban Küber-122/+137
2020-01-16Split `librustc/traits/error_reporting.rs`Esteban Küber-1531/+1667
2020-01-16fmtEsteban Küber-3/+1
2020-01-16When trait bounds are missing for return values, point at themEsteban Küber-49/+73
2020-01-16Make `impl Trait` suggestion in E0746 `MachineApplicable`Esteban Küber-1/+1
2020-01-16Specific error for unsized `dyn Trait` return typeEsteban Küber-2/+210
Suggest `impl Trait` when possible, and `Box<dyn Trait>` otherwise.
2020-01-16Rollup merge of #68274 - matthiaskrgr:dead_code, r=Dylan-DPCDylan DPC-10/+6
remove dead code The condition `if obligation.recursion_depth >= 0` is always true since `recursion_depth` is `usize`. The else branch is dead code and can be removed. Found by Clippy. Fixes #68251
2020-01-16remove dead codeMatthias Krüger-10/+6
The condition if obligation.recursion_depth >= 0 is always true since recursion_depth is usize. The else branch is dead code and can be removed. Found by Clippy. Fixes #68251
2020-01-16Rollup merge of #68096 - varkor:diagnostic-cleanup, r=CentrilDylan DPC-1/+1
Clean up some diagnostics by making them more consistent In general: - Diagnostic should start with a lowercase letter. - Diagnostics should not end with a full stop. - Ellipses contain three dots. - Backticks should encode Rust code. I also reworded a couple of messages to make them read more clearly. It might be sensible to create a style guide for diagnostics, so these informal conventions are written down somewhere, after which we could audit the existing diagnostics. r? @Centril
2020-01-15Rollup merge of #68212 - csmoe:temp, r=estebankDylan DPC-6/+26
Suggest to shorten temporary lifetime during method call inside generator Closes https://github.com/rust-lang/rust/issues/67376 ![image](https://user-images.githubusercontent.com/35686186/72364752-f6b1e400-3731-11ea-8ec9-8297ba4c6c77.png) r? @estebank cc @tmandry @nikomatsakis
2020-01-15wrap expr id into GeneratorInteriorTypeCausecsmoe-4/+3
2020-01-15update async-await send/sync testcsmoe-19/+19
2020-01-14suggest to limit lifetime of temporary borrow with letcsmoe-1/+1
2020-01-14record generoator interior exprs in typecktablecsmoe-6/+27
2020-01-13Use TraitQueryMode::Canonical when testing predicates in const propAaron Hill-9/+33
2020-01-12Diagnostics should start lowercasevarkor-1/+1
2020-01-12Rollup merge of #68045 - Centril:liberate-lints, r=Mark-SimulacrumMazdak Farrokhzad-8/+10
Move more of `rustc::lint` into `rustc_lint` Based on https://github.com/rust-lang/rust/pull/67806. Here we try to consolidate more of the linting infra into `rustc::lint`. Some high-level notes: - We now store an `Lrc<dyn Any + Send + Sync>` as opposed to `Lrc<LintStore>` in the `GlobalCtxt`. This enables us to avoid referring to the type, breaking a cyclic dependency, and so we can move things from `rustc::lint` to `rustc_lint`. - `in_derive_expansion` is, and needs to, be moved as a method on `Span`. - We reduce the number of ways on `tcx` to emit a lint so that the developer UX is more streamlined. - `LintLevelsBuilder` is moved to `rustc_lint::levels`, leaving behind `LintLevelMap/Set` in a purified form due to current constraints (hopefully fixable in the future after https://github.com/rust-lang/rust/pull/68133). - `struct_lint_level` is moved to `rustc::lint` due to current dependency constraints. - `rustc::lint::context` is moved to `rustc_lint::context`. - The visitors in `rustc::lint` are moved to `rustc_lint::passes`.
2020-01-12Rollup merge of #67867 - matthewjasper:opaque-assoc-lookup, r=oli-obkMazdak Farrokhzad-1/+1
Correctly check for opaque types in `assoc_ty_def` Closes #67856
2020-01-11Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obkbors-3/+11
Promote references to constants instead of statics r? @oli-obk
2020-01-11reduce diversity in linting methodsMazdak Farrokhzad-3/+4
2020-01-11canonicalize some lint importsMazdak Farrokhzad-5/+6
2020-01-10Promote `Ref`s to constants instead of staticSantiago Pastorino-3/+11
2020-01-10nix syntax::errors & prefer rustc_errors over errorsMazdak Farrokhzad-7/+7
2020-01-10Rollup merge of #67922 - Centril:lowering-cleanup, r=petrochenkovMazdak Farrokhzad-2/+1
rustc_ast_lowering: misc cleanup & rustc dep reductions - The first two commits do some code simplification. - The next three do some file splitting (getting `lib.rs` below the 3kloc tidy lint). - The remaining commits reduce the number of `rustc::` imports. This works towards making lowering independent of the `rustc` crate. r? @oli-obk cc @Zoxc
2020-01-10Rollup merge of #66463 - estebank:point-at-closure-and-opaque-types, r=CentrilMazdak Farrokhzad-6/+23
Point at opaque and closure type definitions in type errors Fixes #57266, fixes #67117.
2020-01-09Don't discard marker trait impls when inference variables are presentAaron Hill-6/+58
Fixes #61651 Previously, we would unconditionally discard impl candidates for marker traits during trait selection. However, if the predicate had inference variables, this could have the effect of constrainting inference variables (due to a successful trait selection) when we would have otherwise failed due to mutliple applicable impls, This commit prevents marker trait impls from being discarded while the obligation predicate has any inference variables, ensuring that discarding impls will never cause us to incorrectly constraint inference variables.
2020-01-09refactor 'Output = $ty' & reduce rustc depMazdak Farrokhzad-2/+1
2020-01-08move code to method outside of happy pathEsteban Küber-19/+25
2020-01-08Explain that associated types and consts can't be accessed directly on the ↵Esteban Küber-1/+24
trait's path
2020-01-08reduce code duplicationEsteban Küber-10/+3
2020-01-08Point at the def span of trait refs E0277Esteban Küber-5/+29
2020-01-08- remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}Mazdak Farrokhzad-9/+15
- remove syntax::{help!, span_help!, span_note!} - remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!} - lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints - inline syntax::{struct_span_warn!, diagnostic_used!} - stringify_error_code! -> error_code! & use it more. - find_plugin_registrar: de-fatalize an error - de-fatalize metadata errors - move type_error_struct! to rustc_typeck - struct_span_err! -> rustc_errors
2020-01-07Rename traits::drop -> traits::misc.Camille GILLOT-2/+2
2020-01-07Move magic traits queries to rustc::traits::drop.Camille GILLOT-0/+204
2020-01-07Move required_region_bounds to rustc::infer::opaque_types.Camille GILLOT-2/+3