- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Using rustc 1.55.0
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=deaf96d3f30f20986ce469e1b49664ff
use std::iter::Sum;
fn main() {
    println!("Hello, world!");
}
fn add<T: 'static + Sum<&T>>(values: &[T]) -> T {
    values.iter().sum()
}The current output is:
❯ cargo run
   Compiling lifetimes v0.1.0 (/Users/josephlyons/Desktop/lifetimes)
error[E0637]: `&` without an explicit lifetime name cannot be used here
  --> src/main.rs:52:25
   |
52 | fn add<T: 'static + Sum<&T>>(values: &[T]) -> T {
   |                         ^ explicit lifetime name needed here
error[E0621]: explicit lifetime required in the type of `values`
  --> src/main.rs:53:19
   |
53 |     values.iter().sum()
   |                   ^^^ lifetime `'static` required
Some errors have detailed explanations: E0621, E0637.
For more information about an error, try `rustc --explain E0621`.
error: could not compile `lifetimes` due to 2 previous errors
Not sure what the proposed output would be, but some sort of help / suggestion could help to make this easier for beginners
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.