Don't hardcode the `v1` prelude in diagnostics.
Instead of looking for `std::prelude::v1`, this changes it to look for `std::prelude::<anything>`.
This commit is contained in:
parent
1d6b0f626a
commit
1e4d8042fc
|
@ -324,7 +324,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
.lookup_import_candidates(ident, ns, &self.parent_scope, is_enum_variant)
|
.lookup_import_candidates(ident, ns, &self.parent_scope, is_enum_variant)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|suggestion| import_candidate_to_enum_paths(&suggestion))
|
.map(|suggestion| import_candidate_to_enum_paths(&suggestion))
|
||||||
.filter(|(_, enum_ty_path)| enum_ty_path != "std::prelude::v1")
|
.filter(|(_, enum_ty_path)| !enum_ty_path.starts_with("std::prelude::"))
|
||||||
.collect();
|
.collect();
|
||||||
if !enum_candidates.is_empty() {
|
if !enum_candidates.is_empty() {
|
||||||
if let (PathSource::Type, Some(span)) =
|
if let (PathSource::Type, Some(span)) =
|
||||||
|
|
|
@ -200,7 +200,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
if self.can_coerce(expr_ty, sole_field_ty) {
|
if self.can_coerce(expr_ty, sole_field_ty) {
|
||||||
let variant_path = self.tcx.def_path_str(variant.def_id);
|
let variant_path = self.tcx.def_path_str(variant.def_id);
|
||||||
// FIXME #56861: DRYer prelude filtering
|
// FIXME #56861: DRYer prelude filtering
|
||||||
Some(variant_path.trim_start_matches("std::prelude::v1::").to_string())
|
if let Some(path) = variant_path.strip_prefix("std::prelude::") {
|
||||||
|
if let Some((_, path)) = path.split_once("::") {
|
||||||
|
return Some(path.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(variant_path)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue