Auto merge of #65038 - Centril:rollup-m83dpfh, r=Centril
Rollup of 7 pull requests Successful merges: - #63678 (Improve HRTB error span when -Zno-leak-check is used) - #64931 (Reword E0392 slightly) - #64959 (syntax: improve parameter without type suggestions) - #64975 (Implement Clone::clone_from for LinkedList) - #64993 (BacktraceStatus: add Eq impl) - #64998 (Filter out RLS output directories on tidy runs) - #65010 (Compare `primary` with maximum of `children`s' line num instead of dropping it) Failed merges: r? @ghost
This commit is contained in:
commit
c6293e3598
@ -1197,6 +1197,19 @@ impl<T: Clone> Clone for LinkedList<T> {
|
|||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
self.iter().cloned().collect()
|
self.iter().cloned().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clone_from(&mut self, other: &Self) {
|
||||||
|
let mut iter_other = other.iter();
|
||||||
|
if self.len() > other.len() {
|
||||||
|
self.split_off(other.len());
|
||||||
|
}
|
||||||
|
for (elem, elem_other) in self.iter_mut().zip(&mut iter_other) {
|
||||||
|
elem.clone_from(elem_other);
|
||||||
|
}
|
||||||
|
if !iter_other.is_empty() {
|
||||||
|
self.extend(iter_other.cloned());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -110,6 +110,49 @@ fn test_append() {
|
|||||||
check_links(&n);
|
check_links(&n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_clone_from() {
|
||||||
|
// Short cloned from long
|
||||||
|
{
|
||||||
|
let v = vec![1, 2, 3, 4, 5];
|
||||||
|
let u = vec![8, 7, 6, 2, 3, 4, 5];
|
||||||
|
let mut m = list_from(&v);
|
||||||
|
let n = list_from(&u);
|
||||||
|
m.clone_from(&n);
|
||||||
|
check_links(&m);
|
||||||
|
assert_eq!(m, n);
|
||||||
|
for elt in u {
|
||||||
|
assert_eq!(m.pop_front(), Some(elt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Long cloned from short
|
||||||
|
{
|
||||||
|
let v = vec![1, 2, 3, 4, 5];
|
||||||
|
let u = vec![6, 7, 8];
|
||||||
|
let mut m = list_from(&v);
|
||||||
|
let n = list_from(&u);
|
||||||
|
m.clone_from(&n);
|
||||||
|
check_links(&m);
|
||||||
|
assert_eq!(m, n);
|
||||||
|
for elt in u {
|
||||||
|
assert_eq!(m.pop_front(), Some(elt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Two equal length lists
|
||||||
|
{
|
||||||
|
let v = vec![1, 2, 3, 4, 5];
|
||||||
|
let u = vec![9, 8, 1, 2, 3];
|
||||||
|
let mut m = list_from(&v);
|
||||||
|
let n = list_from(&u);
|
||||||
|
m.clone_from(&n);
|
||||||
|
check_links(&m);
|
||||||
|
assert_eq!(m, n);
|
||||||
|
for elt in u {
|
||||||
|
assert_eq!(m.pop_front(), Some(elt))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_insert_prev() {
|
fn test_insert_prev() {
|
||||||
let mut m = list_from(&[0, 2, 4, 6, 8]);
|
let mut m = list_from(&[0, 2, 4, 6, 8]);
|
||||||
|
@ -418,7 +418,19 @@ pub enum NLLRegionVariableOrigin {
|
|||||||
/// from a `for<'a> T` binder). Meant to represent "any region".
|
/// from a `for<'a> T` binder). Meant to represent "any region".
|
||||||
Placeholder(ty::PlaceholderRegion),
|
Placeholder(ty::PlaceholderRegion),
|
||||||
|
|
||||||
Existential,
|
Existential {
|
||||||
|
/// If this is true, then this variable was created to represent a lifetime
|
||||||
|
/// bound in a `for` binder. For example, it might have been created to
|
||||||
|
/// represent the lifetime `'a` in a type like `for<'a> fn(&'a u32)`.
|
||||||
|
/// Such variables are created when we are trying to figure out if there
|
||||||
|
/// is any valid instantiation of `'a` that could fit into some scenario.
|
||||||
|
///
|
||||||
|
/// This is used to inform error reporting: in the case that we are trying to
|
||||||
|
/// determine whether there is any valid instantiation of a `'a` variable that meets
|
||||||
|
/// some constraint C, we want to blame the "source" of that `for` type,
|
||||||
|
/// rather than blaming the source of the constraint C.
|
||||||
|
from_forall: bool
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NLLRegionVariableOrigin {
|
impl NLLRegionVariableOrigin {
|
||||||
@ -426,7 +438,7 @@ impl NLLRegionVariableOrigin {
|
|||||||
match self {
|
match self {
|
||||||
NLLRegionVariableOrigin::FreeRegion => true,
|
NLLRegionVariableOrigin::FreeRegion => true,
|
||||||
NLLRegionVariableOrigin::Placeholder(..) => true,
|
NLLRegionVariableOrigin::Placeholder(..) => true,
|
||||||
NLLRegionVariableOrigin::Existential => false,
|
NLLRegionVariableOrigin::Existential{ .. } => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ pub trait TypeRelatingDelegate<'tcx> {
|
|||||||
/// we will invoke this method to instantiate `'a` with an
|
/// we will invoke this method to instantiate `'a` with an
|
||||||
/// inference variable (though `'b` would be instantiated first,
|
/// inference variable (though `'b` would be instantiated first,
|
||||||
/// as a placeholder).
|
/// as a placeholder).
|
||||||
fn next_existential_region_var(&mut self) -> ty::Region<'tcx>;
|
fn next_existential_region_var(&mut self, was_placeholder: bool) -> ty::Region<'tcx>;
|
||||||
|
|
||||||
/// Creates a new region variable representing a
|
/// Creates a new region variable representing a
|
||||||
/// higher-ranked region that is instantiated universally.
|
/// higher-ranked region that is instantiated universally.
|
||||||
@ -193,7 +193,7 @@ where
|
|||||||
let placeholder = ty::PlaceholderRegion { universe, name: br };
|
let placeholder = ty::PlaceholderRegion { universe, name: br };
|
||||||
delegate.next_placeholder_region(placeholder)
|
delegate.next_placeholder_region(placeholder)
|
||||||
} else {
|
} else {
|
||||||
delegate.next_existential_region_var()
|
delegate.next_existential_region_var(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1026,7 +1026,8 @@ impl EmitterWriter {
|
|||||||
children.iter()
|
children.iter()
|
||||||
.map(|sub| self.get_multispan_max_line_num(&sub.span))
|
.map(|sub| self.get_multispan_max_line_num(&sub.span))
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(primary)
|
.unwrap_or(0)
|
||||||
|
.max(primary)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a left margin to every line but the first, given a padding length and the label being
|
/// Adds a left margin to every line but the first, given a padding length and the label being
|
||||||
|
@ -97,9 +97,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
from_region: RegionVid,
|
from_region: RegionVid,
|
||||||
|
from_region_origin: NLLRegionVariableOrigin,
|
||||||
target_test: impl Fn(RegionVid) -> bool,
|
target_test: impl Fn(RegionVid) -> bool,
|
||||||
) -> (ConstraintCategory, bool, Span) {
|
) -> (ConstraintCategory, bool, Span) {
|
||||||
debug!("best_blame_constraint(from_region={:?})", from_region);
|
debug!("best_blame_constraint(from_region={:?}, from_region_origin={:?})",
|
||||||
|
from_region, from_region_origin);
|
||||||
|
|
||||||
// Find all paths
|
// Find all paths
|
||||||
let (path, target_region) =
|
let (path, target_region) =
|
||||||
@ -152,19 +154,85 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
// we still want to screen for an "interesting" point to
|
// we still want to screen for an "interesting" point to
|
||||||
// highlight (e.g., a call site or something).
|
// highlight (e.g., a call site or something).
|
||||||
let target_scc = self.constraint_sccs.scc(target_region);
|
let target_scc = self.constraint_sccs.scc(target_region);
|
||||||
let best_choice = (0..path.len()).rev().find(|&i| {
|
let mut range = 0..path.len();
|
||||||
let constraint = path[i];
|
|
||||||
|
// As noted above, when reporting an error, there is typically a chain of constraints
|
||||||
|
// leading from some "source" region which must outlive some "target" region.
|
||||||
|
// In most cases, we prefer to "blame" the constraints closer to the target --
|
||||||
|
// but there is one exception. When constraints arise from higher-ranked subtyping,
|
||||||
|
// we generally prefer to blame the source value,
|
||||||
|
// as the "target" in this case tends to be some type annotation that the user gave.
|
||||||
|
// Therefore, if we find that the region origin is some instantiation
|
||||||
|
// of a higher-ranked region, we start our search from the "source" point
|
||||||
|
// rather than the "target", and we also tweak a few other things.
|
||||||
|
//
|
||||||
|
// An example might be this bit of Rust code:
|
||||||
|
//
|
||||||
|
// ```rust
|
||||||
|
// let x: fn(&'static ()) = |_| {};
|
||||||
|
// let y: for<'a> fn(&'a ()) = x;
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// In MIR, this will be converted into a combination of assignments and type ascriptions.
|
||||||
|
// In particular, the 'static is imposed through a type ascription:
|
||||||
|
//
|
||||||
|
// ```rust
|
||||||
|
// x = ...;
|
||||||
|
// AscribeUserType(x, fn(&'static ())
|
||||||
|
// y = x;
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// We wind up ultimately with constraints like
|
||||||
|
//
|
||||||
|
// ```rust
|
||||||
|
// !a: 'temp1 // from the `y = x` statement
|
||||||
|
// 'temp1: 'temp2
|
||||||
|
// 'temp2: 'static // from the AscribeUserType
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// and here we prefer to blame the source (the y = x statement).
|
||||||
|
let blame_source = match from_region_origin {
|
||||||
|
NLLRegionVariableOrigin::FreeRegion
|
||||||
|
| NLLRegionVariableOrigin::Existential { from_forall: false } => {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
NLLRegionVariableOrigin::Placeholder(_)
|
||||||
|
| NLLRegionVariableOrigin::Existential { from_forall: true } => {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let find_region = |i: &usize| {
|
||||||
|
let constraint = path[*i];
|
||||||
|
|
||||||
let constraint_sup_scc = self.constraint_sccs.scc(constraint.sup);
|
let constraint_sup_scc = self.constraint_sccs.scc(constraint.sup);
|
||||||
|
|
||||||
match categorized_path[i].0 {
|
if blame_source {
|
||||||
ConstraintCategory::OpaqueType | ConstraintCategory::Boring |
|
match categorized_path[*i].0 {
|
||||||
ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal => false,
|
ConstraintCategory::OpaqueType | ConstraintCategory::Boring |
|
||||||
ConstraintCategory::TypeAnnotation | ConstraintCategory::Return |
|
ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal => false,
|
||||||
ConstraintCategory::Yield => true,
|
ConstraintCategory::TypeAnnotation | ConstraintCategory::Return |
|
||||||
_ => constraint_sup_scc != target_scc,
|
ConstraintCategory::Yield => true,
|
||||||
|
_ => constraint_sup_scc != target_scc,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match categorized_path[*i].0 {
|
||||||
|
ConstraintCategory::OpaqueType | ConstraintCategory::Boring |
|
||||||
|
ConstraintCategory::BoringNoLocation | ConstraintCategory::Internal => false,
|
||||||
|
_ => true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
let best_choice = if blame_source {
|
||||||
|
range.rev().find(find_region)
|
||||||
|
} else {
|
||||||
|
range.find(find_region)
|
||||||
|
};
|
||||||
|
|
||||||
|
debug!("best_blame_constraint: best_choice={:?} blame_source={}",
|
||||||
|
best_choice, blame_source);
|
||||||
|
|
||||||
if let Some(i) = best_choice {
|
if let Some(i) = best_choice {
|
||||||
if let Some(next) = categorized_path.get(i + 1) {
|
if let Some(next) = categorized_path.get(i + 1) {
|
||||||
if categorized_path[i].0 == ConstraintCategory::Return
|
if categorized_path[i].0 == ConstraintCategory::Return
|
||||||
@ -300,12 +368,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
infcx: &'a InferCtxt<'a, 'tcx>,
|
infcx: &'a InferCtxt<'a, 'tcx>,
|
||||||
mir_def_id: DefId,
|
mir_def_id: DefId,
|
||||||
fr: RegionVid,
|
fr: RegionVid,
|
||||||
|
fr_origin: NLLRegionVariableOrigin,
|
||||||
outlived_fr: RegionVid,
|
outlived_fr: RegionVid,
|
||||||
renctx: &mut RegionErrorNamingCtx,
|
renctx: &mut RegionErrorNamingCtx,
|
||||||
) -> DiagnosticBuilder<'a> {
|
) -> DiagnosticBuilder<'a> {
|
||||||
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
|
debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
|
||||||
|
|
||||||
let (category, _, span) = self.best_blame_constraint(body, fr, |r| {
|
let (category, _, span) = self.best_blame_constraint(body, fr, fr_origin, |r| {
|
||||||
self.provides_universal_region(r, fr, outlived_fr)
|
self.provides_universal_region(r, fr, outlived_fr)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -712,6 +781,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
let (category, from_closure, span) = self.best_blame_constraint(
|
let (category, from_closure, span) = self.best_blame_constraint(
|
||||||
body,
|
body,
|
||||||
borrow_region,
|
borrow_region,
|
||||||
|
NLLRegionVariableOrigin::FreeRegion,
|
||||||
|r| self.provides_universal_region(r, borrow_region, outlived_region)
|
|r| self.provides_universal_region(r, borrow_region, outlived_region)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -771,11 +841,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
fr1: RegionVid,
|
fr1: RegionVid,
|
||||||
|
fr1_origin: NLLRegionVariableOrigin,
|
||||||
fr2: RegionVid,
|
fr2: RegionVid,
|
||||||
) -> (ConstraintCategory, Span) {
|
) -> (ConstraintCategory, Span) {
|
||||||
let (category, _, span) = self.best_blame_constraint(
|
let (category, _, span) = self.best_blame_constraint(
|
||||||
body,
|
body,
|
||||||
fr1,
|
fr1,
|
||||||
|
fr1_origin,
|
||||||
|r| self.provides_universal_region(r, fr1, fr2),
|
|r| self.provides_universal_region(r, fr1, fr2),
|
||||||
);
|
);
|
||||||
(category, span)
|
(category, span)
|
||||||
@ -828,7 +900,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
universe1.cannot_name(placeholder.universe)
|
universe1.cannot_name(placeholder.universe)
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLRegionVariableOrigin::FreeRegion | NLLRegionVariableOrigin::Existential => false,
|
NLLRegionVariableOrigin::FreeRegion | NLLRegionVariableOrigin::Existential { .. } => {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLRegionVariableOrigin::Existential => {
|
NLLRegionVariableOrigin::Existential { .. } => {
|
||||||
// For existential, regions, nothing to do.
|
// For existential, regions, nothing to do.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1348,7 +1348,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
self.check_bound_universal_region(infcx, body, mir_def_id, fr, placeholder);
|
self.check_bound_universal_region(infcx, body, mir_def_id, fr, placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
NLLRegionVariableOrigin::Existential => {
|
NLLRegionVariableOrigin::Existential { .. } => {
|
||||||
// nothing to check here
|
// nothing to check here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1461,7 +1461,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
debug!("check_universal_region: fr_minus={:?}", fr_minus);
|
debug!("check_universal_region: fr_minus={:?}", fr_minus);
|
||||||
|
|
||||||
let blame_span_category =
|
let blame_span_category =
|
||||||
self.find_outlives_blame_span(body, longer_fr, shorter_fr);
|
self.find_outlives_blame_span(body, longer_fr,
|
||||||
|
NLLRegionVariableOrigin::FreeRegion,shorter_fr);
|
||||||
|
|
||||||
// Grow `shorter_fr` until we find some non-local regions. (We
|
// Grow `shorter_fr` until we find some non-local regions. (We
|
||||||
// always will.) We'll call them `shorter_fr+` -- they're ever
|
// always will.) We'll call them `shorter_fr+` -- they're ever
|
||||||
@ -1494,6 +1495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
infcx,
|
infcx,
|
||||||
mir_def_id,
|
mir_def_id,
|
||||||
longer_fr,
|
longer_fr,
|
||||||
|
NLLRegionVariableOrigin::FreeRegion,
|
||||||
shorter_fr,
|
shorter_fr,
|
||||||
region_naming,
|
region_naming,
|
||||||
);
|
);
|
||||||
@ -1547,7 +1549,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
|
// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
|
||||||
let (_, span) = self.find_outlives_blame_span(body, longer_fr, error_region);
|
let (_, span) = self.find_outlives_blame_span(
|
||||||
|
body, longer_fr, NLLRegionVariableOrigin::Placeholder(placeholder), error_region
|
||||||
|
);
|
||||||
|
|
||||||
// Obviously, this error message is far from satisfactory.
|
// Obviously, this error message is far from satisfactory.
|
||||||
// At present, though, it only appears in unit tests --
|
// At present, though, it only appears in unit tests --
|
||||||
@ -1608,7 +1612,7 @@ impl<'tcx> RegionDefinition<'tcx> {
|
|||||||
|
|
||||||
let origin = match rv_origin {
|
let origin = match rv_origin {
|
||||||
RegionVariableOrigin::NLL(origin) => origin,
|
RegionVariableOrigin::NLL(origin) => origin,
|
||||||
_ => NLLRegionVariableOrigin::Existential,
|
_ => NLLRegionVariableOrigin::Existential { from_forall: false },
|
||||||
};
|
};
|
||||||
|
|
||||||
Self { origin, universe, external_name: None }
|
Self { origin, universe, external_name: None }
|
||||||
|
@ -35,7 +35,7 @@ where
|
|||||||
infcx
|
infcx
|
||||||
.tcx
|
.tcx
|
||||||
.fold_regions(value, &mut false, |_region, _depth| {
|
.fold_regions(value, &mut false, |_region, _depth| {
|
||||||
let origin = NLLRegionVariableOrigin::Existential;
|
let origin = NLLRegionVariableOrigin::Existential { from_forall: false };
|
||||||
infcx.next_nll_region_var(origin)
|
infcx.next_nll_region_var(origin)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
|
|||||||
self.infcx.create_next_universe()
|
self.infcx.create_next_universe()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_existential_region_var(&mut self) -> ty::Region<'tcx> {
|
fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
|
||||||
if let Some(_) = &mut self.borrowck_context {
|
if let Some(_) = &mut self.borrowck_context {
|
||||||
let origin = NLLRegionVariableOrigin::Existential;
|
let origin = NLLRegionVariableOrigin::Existential { from_forall };
|
||||||
self.infcx.next_nll_region_var(origin)
|
self.infcx.next_nll_region_var(origin)
|
||||||
} else {
|
} else {
|
||||||
self.infcx.tcx.lifetimes.re_erased
|
self.infcx.tcx.lifetimes.re_erased
|
||||||
@ -88,7 +88,9 @@ impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
|
|||||||
|
|
||||||
fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
|
fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> {
|
||||||
self.infcx
|
self.infcx
|
||||||
.next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential, universe)
|
.next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential {
|
||||||
|
from_forall: false
|
||||||
|
}, universe)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) {
|
fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) {
|
||||||
|
@ -65,7 +65,7 @@ impl TypeRelatingDelegate<'tcx> for &mut ChalkTypeRelatingDelegate<'_, 'tcx> {
|
|||||||
self.infcx.create_next_universe()
|
self.infcx.create_next_universe()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_existential_region_var(&mut self) -> ty::Region<'tcx> {
|
fn next_existential_region_var(&mut self, _was_placeholder: bool) -> ty::Region<'tcx> {
|
||||||
self.infcx.next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP))
|
self.infcx.next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,11 +999,16 @@ fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: ast::Name) {
|
|||||||
|
|
||||||
let suggested_marker_id = tcx.lang_items().phantom_data();
|
let suggested_marker_id = tcx.lang_items().phantom_data();
|
||||||
// Help is available only in presence of lang items.
|
// Help is available only in presence of lang items.
|
||||||
if let Some(def_id) = suggested_marker_id {
|
let msg = if let Some(def_id) = suggested_marker_id {
|
||||||
err.help(&format!("consider removing `{}` or using a marker such as `{}`",
|
format!(
|
||||||
param_name,
|
"consider removing `{}`, refering to it in a field, or using a marker such as `{}`",
|
||||||
tcx.def_path_str(def_id)));
|
param_name,
|
||||||
}
|
tcx.def_path_str(def_id),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!( "consider removing `{}` or refering to it in a field", param_name)
|
||||||
|
};
|
||||||
|
err.help(&msg);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ pub struct Backtrace {
|
|||||||
/// The current status of a backtrace, indicating whether it was captured or
|
/// The current status of a backtrace, indicating whether it was captured or
|
||||||
/// whether it is empty for some other reason.
|
/// whether it is empty for some other reason.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum BacktraceStatus {
|
pub enum BacktraceStatus {
|
||||||
/// Capturing a backtrace is not supported, likely because it's not
|
/// Capturing a backtrace is not supported, likely because it's not
|
||||||
/// implemented for the current platform.
|
/// implemented for the current platform.
|
||||||
|
@ -1220,6 +1220,7 @@ impl<'a> Parser<'a> {
|
|||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
pat: P<ast::Pat>,
|
pat: P<ast::Pat>,
|
||||||
require_name: bool,
|
require_name: bool,
|
||||||
|
is_self_allowed: bool,
|
||||||
is_trait_item: bool,
|
is_trait_item: bool,
|
||||||
) -> Option<Ident> {
|
) -> Option<Ident> {
|
||||||
// If we find a pattern followed by an identifier, it could be an (incorrect)
|
// If we find a pattern followed by an identifier, it could be an (incorrect)
|
||||||
@ -1241,14 +1242,27 @@ impl<'a> Parser<'a> {
|
|||||||
if require_name && (
|
if require_name && (
|
||||||
is_trait_item ||
|
is_trait_item ||
|
||||||
self.token == token::Comma ||
|
self.token == token::Comma ||
|
||||||
|
self.token == token::Lt ||
|
||||||
self.token == token::CloseDelim(token::Paren)
|
self.token == token::CloseDelim(token::Paren)
|
||||||
) { // `fn foo(a, b) {}` or `fn foo(usize, usize) {}`
|
) { // `fn foo(a, b) {}`, `fn foo(a<x>, b<y>) {}` or `fn foo(usize, usize) {}`
|
||||||
err.span_suggestion(
|
if is_self_allowed {
|
||||||
pat.span,
|
err.span_suggestion(
|
||||||
"if this was a parameter name, give it a type",
|
pat.span,
|
||||||
format!("{}: TypeName", ident),
|
"if this is a `self` type, give it a parameter name",
|
||||||
Applicability::HasPlaceholders,
|
format!("self: {}", ident),
|
||||||
);
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Avoid suggesting that `fn foo(HashMap<u32>)` is fixed with a change to
|
||||||
|
// `fn foo(HashMap: TypeName<u32>)`.
|
||||||
|
if self.token != token::Lt {
|
||||||
|
err.span_suggestion(
|
||||||
|
pat.span,
|
||||||
|
"if this was a parameter name, give it a type",
|
||||||
|
format!("{}: TypeName", ident),
|
||||||
|
Applicability::HasPlaceholders,
|
||||||
|
);
|
||||||
|
}
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
pat.span,
|
pat.span,
|
||||||
"if this is a type, explicitly ignore the parameter name",
|
"if this is a type, explicitly ignore the parameter name",
|
||||||
@ -1256,7 +1270,9 @@ impl<'a> Parser<'a> {
|
|||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)");
|
err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)");
|
||||||
return Some(ident);
|
|
||||||
|
// Don't attempt to recover by using the `X` in `X<Y>` as the parameter name.
|
||||||
|
return if self.token == token::Lt { None } else { Some(ident) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -1212,6 +1212,7 @@ impl<'a> Parser<'a> {
|
|||||||
&mut err,
|
&mut err,
|
||||||
pat,
|
pat,
|
||||||
is_name_required,
|
is_name_required,
|
||||||
|
is_self_allowed,
|
||||||
is_trait_item,
|
is_trait_item,
|
||||||
) {
|
) {
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -5,6 +5,10 @@ LL | fn foo(i32);
|
|||||||
| ^ expected one of `:`, `@`, or `|` here
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
|
||||||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a `self` type, give it a parameter name
|
||||||
|
|
|
||||||
|
LL | fn foo(self: i32);
|
||||||
|
| ^^^^^^^^^
|
||||||
help: if this was a parameter name, give it a type
|
help: if this was a parameter name, give it a type
|
||||||
|
|
|
|
||||||
LL | fn foo(i32: TypeName);
|
LL | fn foo(i32: TypeName);
|
||||||
@ -21,6 +25,10 @@ LL | fn bar_with_default_impl(String, String) {}
|
|||||||
| ^ expected one of `:`, `@`, or `|` here
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
|
||||||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a `self` type, give it a parameter name
|
||||||
|
|
|
||||||
|
LL | fn bar_with_default_impl(self: String, String) {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
help: if this was a parameter name, give it a type
|
help: if this was a parameter name, give it a type
|
||||||
|
|
|
|
||||||
LL | fn bar_with_default_impl(String: TypeName, String) {}
|
LL | fn bar_with_default_impl(String: TypeName, String) {}
|
||||||
|
@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | pub struct Dependent<T, const X: T>([(); X]);
|
LL | pub struct Dependent<T, const X: T>([(); X]);
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | enum Foo<T> { Bar }
|
LL | enum Foo<T> { Bar }
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
error: higher-ranked subtype error
|
error: higher-ranked subtype error
|
||||||
--> $DIR/issue-30786.rs:113:18
|
--> $DIR/issue-30786.rs:108:15
|
||||||
|
|
|
||||||
|
LL | let map = source.map(|x: &_| x);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: higher-ranked subtype error
|
||||||
|
--> $DIR/issue-30786.rs:114:18
|
||||||
|
|
|
|
||||||
LL | let filter = map.filter(|x: &_| true);
|
LL | let filter = map.filter(|x: &_| true);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: higher-ranked subtype error
|
error: higher-ranked subtype error
|
||||||
--> $DIR/issue-30786.rs:115:17
|
--> $DIR/issue-30786.rs:116:17
|
||||||
|
|
|
|
||||||
LL | let count = filter.count(); // Assert that we still have a valid stream.
|
LL | let count = filter.count(); // Assert that we still have a valid stream.
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ impl<T> StreamExt for T where for<'a> &'a mut T: Stream { }
|
|||||||
fn main() {
|
fn main() {
|
||||||
let source = Repeat(10);
|
let source = Repeat(10);
|
||||||
let map = source.map(|x: &_| x);
|
let map = source.map(|x: &_| x);
|
||||||
//[migrate]~^ ERROR implementation of `Stream` is not general enough
|
//[nll]~^ ERROR higher-ranked subtype error
|
||||||
|
//[migrate]~^^ ERROR implementation of `Stream` is not general enough
|
||||||
//[migrate]~| NOTE `Stream` would have to be implemented for the type `&'0 mut Map
|
//[migrate]~| NOTE `Stream` would have to be implemented for the type `&'0 mut Map
|
||||||
//[migrate]~| NOTE but `Stream` is actually implemented for the type `&'1
|
//[migrate]~| NOTE but `Stream` is actually implemented for the type `&'1
|
||||||
//[migrate]~| NOTE implementation of `Stream` is not general enough
|
//[migrate]~| NOTE implementation of `Stream` is not general enough
|
||||||
@ -114,4 +115,5 @@ fn main() {
|
|||||||
//[nll]~^ ERROR higher-ranked subtype error
|
//[nll]~^ ERROR higher-ranked subtype error
|
||||||
let count = filter.count(); // Assert that we still have a valid stream.
|
let count = filter.count(); // Assert that we still have a valid stream.
|
||||||
//[nll]~^ ERROR higher-ranked subtype error
|
//[nll]~^ ERROR higher-ranked subtype error
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | enum Bar<T> { What }
|
LL | enum Bar<T> { What }
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | struct Foo<T> where T: Copy;
|
LL | struct Foo<T> where T: Copy;
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | struct NoData<T>;
|
LL | struct NoData<T>;
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
|
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
|
||||||
--> $DIR/issue-20413.rs:8:1
|
--> $DIR/issue-20413.rs:8:1
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | struct Foo<'a, A> {}
|
LL | struct Foo<'a, A> {}
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `A` is never used
|
error[E0392]: parameter `A` is never used
|
||||||
--> $DIR/issue-36299.rs:1:16
|
--> $DIR/issue-36299.rs:1:16
|
||||||
@ -12,7 +12,7 @@ error[E0392]: parameter `A` is never used
|
|||||||
LL | struct Foo<'a, A> {}
|
LL | struct Foo<'a, A> {}
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ error[E0392]: parameter `Self` is never used
|
|||||||
LL | struct Foo<Self>(Self);
|
LL | struct Foo<Self>(Self);
|
||||||
| ^^^^ unused parameter
|
| ^^^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `Self` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | struct Foo<T: ?Hash> { }
|
LL | struct Foo<T: ?Hash> { }
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
10
src/test/ui/nll/relate_tys/fn-subtype.rs
Normal file
10
src/test/ui/nll/relate_tys/fn-subtype.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Test that NLL produces correct spans for higher-ranked subtyping errors.
|
||||||
|
//
|
||||||
|
// compile-flags:-Zno-leak-check
|
||||||
|
|
||||||
|
#![feature(nll)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: fn(&'static ()) = |_| {};
|
||||||
|
let y: for<'a> fn(&'a ()) = x; //~ ERROR higher-ranked subtype error
|
||||||
|
}
|
8
src/test/ui/nll/relate_tys/fn-subtype.stderr
Normal file
8
src/test/ui/nll/relate_tys/fn-subtype.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: higher-ranked subtype error
|
||||||
|
--> $DIR/fn-subtype.rs:9:33
|
||||||
|
|
|
||||||
|
LL | let y: for<'a> fn(&'a ()) = x;
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
16
src/test/ui/nll/relate_tys/trait-hrtb.rs
Normal file
16
src/test/ui/nll/relate_tys/trait-hrtb.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Test that NLL generates proper error spans for trait HRTB errors
|
||||||
|
//
|
||||||
|
// compile-flags:-Zno-leak-check
|
||||||
|
|
||||||
|
#![feature(nll)]
|
||||||
|
|
||||||
|
trait Foo<'a> {}
|
||||||
|
|
||||||
|
fn make_foo<'a>() -> Box<dyn Foo<'a>> {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: Box<dyn Foo<'static>> = make_foo();
|
||||||
|
let y: Box<dyn for<'a> Foo<'a>> = x; //~ ERROR higher-ranked subtype error
|
||||||
|
}
|
8
src/test/ui/nll/relate_tys/trait-hrtb.stderr
Normal file
8
src/test/ui/nll/relate_tys/trait-hrtb.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: higher-ranked subtype error
|
||||||
|
--> $DIR/trait-hrtb.rs:15:39
|
||||||
|
|
|
||||||
|
LL | let y: Box<dyn for<'a> Foo<'a>> = x;
|
||||||
|
| ^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
@ -3,6 +3,12 @@ error: expected one of `:`, `@`, or `|`, found `<`
|
|||||||
|
|
|
|
||||||
LL | fn a(B<) {}
|
LL | fn a(B<) {}
|
||||||
| ^ expected one of `:`, `@`, or `|` here
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
||||||
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a type, explicitly ignore the parameter name
|
||||||
|
|
|
||||||
|
LL | fn a(_: B<) {}
|
||||||
|
| ^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ error[E0392]: parameter `'c` is never used
|
|||||||
LL | struct Foo<'a,'b,'c> {
|
LL | struct Foo<'a,'b,'c> {
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'c` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'c`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@ LL | trait Trait2015 { fn foo(#[allow(C)] i32); }
|
|||||||
| ^ expected one of `:`, `@`, or `|` here
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
|
||||||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a `self` type, give it a parameter name
|
||||||
|
|
|
||||||
|
LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); }
|
||||||
|
| ^^^^^^^^^
|
||||||
help: if this was a parameter name, give it a type
|
help: if this was a parameter name, give it a type
|
||||||
|
|
|
|
||||||
LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); }
|
LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); }
|
||||||
|
@ -76,7 +76,7 @@ error[E0392]: parameter `'Self` is never used
|
|||||||
LL | struct Bar<'Self>;
|
LL | struct Bar<'Self>;
|
||||||
| ^^^^^ unused parameter
|
| ^^^^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'Self` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
@ -3,6 +3,12 @@ error: expected one of `:`, `@`, or `|`, found `<`
|
|||||||
|
|
|
|
||||||
LL | fn foo(Option<i32>, String) {}
|
LL | fn foo(Option<i32>, String) {}
|
||||||
| ^ expected one of `:`, `@`, or `|` here
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
||||||
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a type, explicitly ignore the parameter name
|
||||||
|
|
|
||||||
|
LL | fn foo(_: Option<i32>, String) {}
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: expected one of `:`, `@`, or `|`, found `)`
|
error: expected one of `:`, `@`, or `|`, found `)`
|
||||||
--> $DIR/issue-34264.rs:1:27
|
--> $DIR/issue-34264.rs:1:27
|
||||||
|
14
src/test/ui/suggestions/issue-64252-self-type.rs
Normal file
14
src/test/ui/suggestions/issue-64252-self-type.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// This test checks that a suggestion to add a `self: ` parameter name is provided
|
||||||
|
// to functions where this is applicable.
|
||||||
|
|
||||||
|
pub fn foo(Box<Self>) { }
|
||||||
|
//~^ ERROR expected one of `:`, `@`, or `|`, found `<`
|
||||||
|
|
||||||
|
struct Bar;
|
||||||
|
|
||||||
|
impl Bar {
|
||||||
|
fn bar(Box<Self>) { }
|
||||||
|
//~^ ERROR expected one of `:`, `@`, or `|`, found `<`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() { }
|
30
src/test/ui/suggestions/issue-64252-self-type.stderr
Normal file
30
src/test/ui/suggestions/issue-64252-self-type.stderr
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
error: expected one of `:`, `@`, or `|`, found `<`
|
||||||
|
--> $DIR/issue-64252-self-type.rs:4:15
|
||||||
|
|
|
||||||
|
LL | pub fn foo(Box<Self>) { }
|
||||||
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
||||||
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a type, explicitly ignore the parameter name
|
||||||
|
|
|
||||||
|
LL | pub fn foo(_: Box<Self>) { }
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: expected one of `:`, `@`, or `|`, found `<`
|
||||||
|
--> $DIR/issue-64252-self-type.rs:10:15
|
||||||
|
|
|
||||||
|
LL | fn bar(Box<Self>) { }
|
||||||
|
| ^ expected one of `:`, `@`, or `|` here
|
||||||
|
|
|
||||||
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||||
|
help: if this is a `self` type, give it a parameter name
|
||||||
|
|
|
||||||
|
LL | fn bar(self: Box<Self>) { }
|
||||||
|
| ^^^^^^^^^
|
||||||
|
help: if this is a type, explicitly ignore the parameter name
|
||||||
|
|
|
||||||
|
LL | fn bar(_: Box<Self>) { }
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | struct Bivariant<'a>;
|
LL | struct Bivariant<'a>;
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `'d` is never used
|
error[E0392]: parameter `'d` is never used
|
||||||
--> $DIR/variance-regions-unused-direct.rs:7:19
|
--> $DIR/variance-regions-unused-direct.rs:7:19
|
||||||
@ -12,7 +12,7 @@ error[E0392]: parameter `'d` is never used
|
|||||||
LL | struct Struct<'a, 'd> {
|
LL | struct Struct<'a, 'd> {
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'d` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'d`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | enum Foo<'a> {
|
LL | enum Foo<'a> {
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `'a` is never used
|
error[E0392]: parameter `'a` is never used
|
||||||
--> $DIR/variance-regions-unused-indirect.rs:7:10
|
--> $DIR/variance-regions-unused-indirect.rs:7:10
|
||||||
@ -12,7 +12,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | enum Bar<'a> {
|
LL | enum Bar<'a> {
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | struct SomeStruct<'a> { x: u32 }
|
LL | struct SomeStruct<'a> { x: u32 }
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `'a` is never used
|
error[E0392]: parameter `'a` is never used
|
||||||
--> $DIR/variance-unused-region-param.rs:4:15
|
--> $DIR/variance-unused-region-param.rs:4:15
|
||||||
@ -12,7 +12,7 @@ error[E0392]: parameter `'a` is never used
|
|||||||
LL | enum SomeEnum<'a> { Nothing }
|
LL | enum SomeEnum<'a> { Nothing }
|
||||||
| ^^ unused parameter
|
| ^^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `'a` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ error[E0392]: parameter `A` is never used
|
|||||||
LL | struct SomeStruct<A> { x: u32 }
|
LL | struct SomeStruct<A> { x: u32 }
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `A` is never used
|
error[E0392]: parameter `A` is never used
|
||||||
--> $DIR/variance-unused-type-param.rs:9:15
|
--> $DIR/variance-unused-type-param.rs:9:15
|
||||||
@ -12,7 +12,7 @@ error[E0392]: parameter `A` is never used
|
|||||||
LL | enum SomeEnum<A> { Nothing }
|
LL | enum SomeEnum<A> { Nothing }
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `A` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error[E0392]: parameter `T` is never used
|
error[E0392]: parameter `T` is never used
|
||||||
--> $DIR/variance-unused-type-param.rs:13:15
|
--> $DIR/variance-unused-type-param.rs:13:15
|
||||||
@ -20,7 +20,7 @@ error[E0392]: parameter `T` is never used
|
|||||||
LL | enum ListCell<T> {
|
LL | enum ListCell<T> {
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
|
|
|
||||||
= help: consider removing `T` or using a marker such as `std::marker::PhantomData`
|
= help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ fn filter_dirs(path: &Path) -> bool {
|
|||||||
"src/tools/rls",
|
"src/tools/rls",
|
||||||
"src/tools/rust-installer",
|
"src/tools/rust-installer",
|
||||||
"src/tools/rustfmt",
|
"src/tools/rustfmt",
|
||||||
|
|
||||||
|
// Filter RLS output directories
|
||||||
|
"target/rls",
|
||||||
];
|
];
|
||||||
skip.iter().any(|p| path.ends_with(p))
|
skip.iter().any(|p| path.ends_with(p))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user