diff options
| author | bors <bors@rust-lang.org> | 2020-02-09 10:20:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-09 10:20:46 +0000 |
| commit | 6dff769e3718c56f78a317df7167426d60895d58 (patch) | |
| tree | 26484dfcfb4f3f1709317f00c90ef60c6da46707 /src/librustc_error_codes/error_codes | |
| parent | 64ea639c12df0594dd891b1ba0b439c8c5eacd83 (diff) | |
| parent | 9dabf80d5517ab87d5985edfd9dc1f66af6eaa16 (diff) | |
Auto merge of #68975 - Dylan-DPC:rollup-jzab8oh, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #68718 (Move `rustc_hir::def_id` to `rustc_span::def_id`) - #68834 (Fix and test implementation of BTreeMap's first/last_entry, pop_first/last) - #68857 (perf: Reduce Vec allocations in normalization by passing &mut Vec) - #68918 (Don't use the word "unwrap" to describe "unwrap" methods) - #68946 (Mark several functions and methods in core::cmp as #[must_use]) - #68958 (Clean up E0277 and E0282 explanations) - #68960 (codegen: misc cleanups around debuginfo scopes and locations.) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0277.md | 4 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0282.md | 18 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/librustc_error_codes/error_codes/E0277.md b/src/librustc_error_codes/error_codes/E0277.md index 2034a5b988c..2e2cd5e01fb 100644 --- a/src/librustc_error_codes/error_codes/E0277.md +++ b/src/librustc_error_codes/error_codes/E0277.md @@ -1,5 +1,7 @@ You tried to use a type which doesn't implement some trait in a place which -expected that trait. Erroneous code example: +expected that trait. + +Erroneous code example: ```compile_fail,E0277 // here we declare the Foo trait with a bar method diff --git a/src/librustc_error_codes/error_codes/E0282.md b/src/librustc_error_codes/error_codes/E0282.md index 54a9de0025a..49d2205f92c 100644 --- a/src/librustc_error_codes/error_codes/E0282.md +++ b/src/librustc_error_codes/error_codes/E0282.md @@ -1,3 +1,11 @@ +The compiler could not infer a type and asked for a type annotation. + +Erroneous code example: + +```compile_fail,E0282 +let x = "hello".chars().rev().collect(); +``` + This error indicates that type inference did not result in one unique possible type, and extra information is required. In most cases this can be provided by adding a type annotation. Sometimes you need to specify a generic type @@ -8,13 +16,9 @@ parameter with a `FromIterator` bound, which for a `char` iterator is implemented by `Vec` and `String` among others. Consider the following snippet that reverses the characters of a string: -```compile_fail,E0282 -let x = "hello".chars().rev().collect(); -``` - -In this case, the compiler cannot infer what the type of `x` should be: -`Vec<char>` and `String` are both suitable candidates. To specify which type to -use, you can use a type annotation on `x`: +In the first code example, the compiler cannot infer what the type of `x` should +be: `Vec<char>` and `String` are both suitable candidates. To specify which type +to use, you can use a type annotation on `x`: ``` let x: Vec<char> = "hello".chars().rev().collect(); |
