-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
P-highHigh priorityHigh priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Testcase:
use std::collections::HashMap;
pub fn named_lints<'a>(names: &[&str],
transforms: &'a HashMap<&'static str, u32>)
-> Option<&'a u32> {
transforms.get(&names[0])
}
fn main(){}
<anon>:5:20: 5:29 error: cannot infer an appropriate lifetime due to conflicting requirements [E0495]
<anon>:5 transforms.get(&names[0])
^~~~~~~~~
<anon>:2:1: 6:2 help: consider using an explicit lifetime parameter as shown: fn named_lints<'a>(names: &[&'a str],
transforms: &'a HashMap<&'static str, u32>)
-> Option<&'a u32>
<anon>:2 pub fn named_lints<'a>(names: &[&str],
<anon>:3 transforms: &'a HashMap<&'static str, u32>)
<anon>:4 -> Option<&'a u32> {
<anon>:5 transforms.get(&names[0])
<anon>:6 }
error: aborting due to previous error
playpen: application terminated with error code 101
It looks rather similar to #28839, but I'm not sure whether it's the same thing. Originally reported by @jonas-schievink (#28853 (comment)) .
Metadata
Metadata
Assignees
Labels
P-highHigh priorityHigh priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.