Auto merge of #98152 - JohnTitor:rollup-osr17j6, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #97202 (os str capacity documentation) - #97964 (Fix suggestions for `&a: T` parameters) - #98053 (Fix generic impl rustdoc json output) - #98059 (Inline `const_eval_select`) - #98092 (Fix sidebar items expand collapse) - #98119 (Refactor path segment parameter error) - #98135 (Add regression test for #93775) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
5bc82c0b94
26 changed files with 697 additions and 143 deletions
|
@ -196,25 +196,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
ParenthesizedGenericArgs::Err => {
|
ParenthesizedGenericArgs::Err => {
|
||||||
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
|
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
|
||||||
err.span_label(data.span, "only `Fn` traits may use parentheses");
|
err.span_label(data.span, "only `Fn` traits may use parentheses");
|
||||||
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
|
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
|
||||||
// Do not suggest going from `Trait()` to `Trait<>`
|
if !data.inputs.is_empty() {
|
||||||
if !data.inputs.is_empty() {
|
// Start of the span to the 1st character of 1st argument
|
||||||
// Suggest replacing `(` and `)` with `<` and `>`
|
let open_param = data.inputs_span.shrink_to_lo().to(data
|
||||||
// The snippet may be missing the closing `)`, skip that case
|
.inputs
|
||||||
if snippet.ends_with(')') {
|
.first()
|
||||||
if let Some(split) = snippet.find('(') {
|
.unwrap()
|
||||||
let trait_name = &snippet[0..split];
|
.span
|
||||||
let args = &snippet[split + 1..snippet.len() - 1];
|
.shrink_to_lo());
|
||||||
err.span_suggestion(
|
// Last character position of last argument to the end of the span
|
||||||
data.span,
|
let close_param = data
|
||||||
"use angle brackets instead",
|
.inputs
|
||||||
format!("{}<{}>", trait_name, args),
|
.last()
|
||||||
Applicability::MaybeIncorrect,
|
.unwrap()
|
||||||
);
|
.span
|
||||||
}
|
.shrink_to_hi()
|
||||||
}
|
.to(data.inputs_span.shrink_to_hi());
|
||||||
}
|
err.multipart_suggestion(
|
||||||
};
|
&format!("use angle brackets instead",),
|
||||||
|
vec![
|
||||||
|
(open_param, String::from("<")),
|
||||||
|
(close_param, String::from(">")),
|
||||||
|
],
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
(
|
(
|
||||||
self.lower_angle_bracketed_parameter_data(
|
self.lower_angle_bracketed_parameter_data(
|
||||||
|
|
|
@ -649,39 +649,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow_pat_suggestion(
|
// Precondition: pat is a Ref(_) pattern
|
||||||
&self,
|
fn borrow_pat_suggestion(&self, err: &mut Diagnostic, pat: &Pat<'_>) {
|
||||||
err: &mut Diagnostic,
|
|
||||||
pat: &Pat<'_>,
|
|
||||||
inner: &Pat<'_>,
|
|
||||||
expected: Ty<'tcx>,
|
|
||||||
) {
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
if let PatKind::Binding(..) = inner.kind {
|
if let PatKind::Ref(inner, mutbl) = pat.kind
|
||||||
|
&& let PatKind::Binding(_, _, binding, ..) = inner.kind {
|
||||||
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id);
|
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id);
|
||||||
let binding_parent = tcx.hir().get(binding_parent_id);
|
let binding_parent = tcx.hir().get(binding_parent_id);
|
||||||
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, binding_parent);
|
debug!(?inner, ?pat, ?binding_parent);
|
||||||
|
|
||||||
|
let mutability = match mutbl {
|
||||||
|
ast::Mutability::Mut => "mut",
|
||||||
|
ast::Mutability::Not => "",
|
||||||
|
};
|
||||||
|
|
||||||
match binding_parent {
|
match binding_parent {
|
||||||
hir::Node::Param(hir::Param { span, .. })
|
// Check that there is explicit type (ie this is not a closure param with inferred type)
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) =>
|
// so we don't suggest moving something to the type that does not exist
|
||||||
{
|
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span != *ty_span => {
|
||||||
err.span_suggestion(
|
err.multipart_suggestion_verbose(
|
||||||
*span,
|
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
|
||||||
&format!("did you mean `{snippet}`"),
|
vec![
|
||||||
format!(" &{expected}"),
|
(pat.span.until(inner.span), "".to_owned()),
|
||||||
Applicability::MachineApplicable,
|
(ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())),
|
||||||
|
],
|
||||||
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
hir::Node::Arm(_) | hir::Node::Pat(_) => {
|
hir::Node::Param(_) | hir::Node::Arm(_) | hir::Node::Pat(_) => {
|
||||||
// rely on match ergonomics or it might be nested `&&pat`
|
// rely on match ergonomics or it might be nested `&&pat`
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) {
|
err.span_suggestion_verbose(
|
||||||
err.span_suggestion(
|
pat.span.until(inner.span),
|
||||||
pat.span,
|
format!("consider removing `&{mutability}` from the pattern"),
|
||||||
"you can probably remove the explicit borrow",
|
"",
|
||||||
snippet,
|
Applicability::MaybeIncorrect,
|
||||||
Applicability::MaybeIncorrect,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {} // don't provide suggestions in other cases #55175
|
_ => {} // don't provide suggestions in other cases #55175
|
||||||
}
|
}
|
||||||
|
@ -1836,6 +1838,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
box_ty
|
box_ty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Precondition: Pat is Ref(inner)
|
||||||
fn check_pat_ref(
|
fn check_pat_ref(
|
||||||
&self,
|
&self,
|
||||||
pat: &'tcx Pat<'tcx>,
|
pat: &'tcx Pat<'tcx>,
|
||||||
|
@ -1853,7 +1856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
// Take region, inner-type from expected type if we can,
|
// Take region, inner-type from expected type if we can,
|
||||||
// to avoid creating needless variables. This also helps with
|
// to avoid creating needless variables. This also helps with
|
||||||
// the bad interactions of the given hack detailed in (note_1).
|
// the bad interactions of the given hack detailed in (note_1).
|
||||||
debug!("check_pat_ref: expected={:?}", expected);
|
debug!("check_pat_ref: expected={:?}", expected);
|
||||||
match *expected.kind() {
|
match *expected.kind() {
|
||||||
ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty),
|
ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty),
|
||||||
|
@ -1869,7 +1872,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Look for a case like `fn foo(&foo: u32)` and suggest
|
// Look for a case like `fn foo(&foo: u32)` and suggest
|
||||||
// `fn foo(foo: &u32)`
|
// `fn foo(foo: &u32)`
|
||||||
if let Some(mut err) = err {
|
if let Some(mut err) = err {
|
||||||
self.borrow_pat_suggestion(&mut err, pat, inner, expected);
|
self.borrow_pat_suggestion(&mut err, pat);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
(rptr_ty, inner_ty)
|
(rptr_ty, inner_ty)
|
||||||
|
|
|
@ -2363,6 +2363,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
|
||||||
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
|
||||||
#[lang = "const_eval_select"]
|
#[lang = "const_eval_select"]
|
||||||
#[rustc_do_not_const_check]
|
#[rustc_do_not_const_check]
|
||||||
|
#[inline]
|
||||||
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
|
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
|
||||||
arg: ARG,
|
arg: ARG,
|
||||||
_called_in_const: F,
|
_called_in_const: F,
|
||||||
|
|
|
@ -45,6 +45,22 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
|
||||||
/// values, encoded in a less-strict variant of UTF-8. This is useful to
|
/// values, encoded in a less-strict variant of UTF-8. This is useful to
|
||||||
/// understand when handling capacity and length values.
|
/// understand when handling capacity and length values.
|
||||||
///
|
///
|
||||||
|
/// # Capacity of `OsString`
|
||||||
|
///
|
||||||
|
/// Capacity uses units of UTF-8 bytes for OS strings which were created from valid unicode, and
|
||||||
|
/// uses units of bytes in an unspecified encoding for other contents. On a given target, all
|
||||||
|
/// `OsString` and `OsStr` values use the same units for capacity, so the following will work:
|
||||||
|
/// ```
|
||||||
|
/// use std::ffi::{OsStr, OsString};
|
||||||
|
///
|
||||||
|
/// fn concat_os_strings(a: &OsStr, b: &OsStr) -> OsString {
|
||||||
|
/// let mut ret = OsString::with_capacity(a.len() + b.len()); // This will allocate
|
||||||
|
/// ret.push(a); // This will not allocate further
|
||||||
|
/// ret.push(b); // This will not allocate further
|
||||||
|
/// ret
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// # Creating an `OsString`
|
/// # Creating an `OsString`
|
||||||
///
|
///
|
||||||
/// **From a Rust string**: `OsString` implements
|
/// **From a Rust string**: `OsString` implements
|
||||||
|
@ -186,7 +202,7 @@ impl OsString {
|
||||||
/// OS strings without reallocating. If `capacity` is 0, the string will not
|
/// OS strings without reallocating. If `capacity` is 0, the string will not
|
||||||
/// allocate.
|
/// allocate.
|
||||||
///
|
///
|
||||||
/// See main `OsString` documentation information about encoding.
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -229,7 +245,7 @@ impl OsString {
|
||||||
|
|
||||||
/// Returns the capacity this `OsString` can hold without reallocating.
|
/// Returns the capacity this `OsString` can hold without reallocating.
|
||||||
///
|
///
|
||||||
/// See `OsString` introduction for information about encoding.
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -251,6 +267,8 @@ impl OsString {
|
||||||
///
|
///
|
||||||
/// The collection may reserve more space to avoid frequent reallocations.
|
/// The collection may reserve more space to avoid frequent reallocations.
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -272,6 +290,8 @@ impl OsString {
|
||||||
/// greater than or equal to `self.len() + additional`. Does nothing if
|
/// greater than or equal to `self.len() + additional`. Does nothing if
|
||||||
/// capacity is already sufficient.
|
/// capacity is already sufficient.
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// If the capacity overflows, or the allocator reports a failure, then an error
|
/// If the capacity overflows, or the allocator reports a failure, then an error
|
||||||
|
@ -313,6 +333,8 @@ impl OsString {
|
||||||
///
|
///
|
||||||
/// [`reserve`]: OsString::reserve
|
/// [`reserve`]: OsString::reserve
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -340,6 +362,8 @@ impl OsString {
|
||||||
///
|
///
|
||||||
/// [`try_reserve`]: OsString::try_reserve
|
/// [`try_reserve`]: OsString::try_reserve
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// If the capacity overflows, or the allocator reports a failure, then an error
|
/// If the capacity overflows, or the allocator reports a failure, then an error
|
||||||
|
@ -373,6 +397,8 @@ impl OsString {
|
||||||
|
|
||||||
/// Shrinks the capacity of the `OsString` to match its length.
|
/// Shrinks the capacity of the `OsString` to match its length.
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -399,6 +425,8 @@ impl OsString {
|
||||||
///
|
///
|
||||||
/// If the current capacity is less than the lower limit, this is a no-op.
|
/// If the current capacity is less than the lower limit, this is a no-op.
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -773,6 +801,8 @@ impl OsStr {
|
||||||
/// This number is simply useful for passing to other methods, like
|
/// This number is simply useful for passing to other methods, like
|
||||||
/// [`OsString::with_capacity`] to avoid reallocations.
|
/// [`OsString::with_capacity`] to avoid reallocations.
|
||||||
///
|
///
|
||||||
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -32,10 +32,10 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
|
||||||
fullPath += elem["name"] + "/";
|
fullPath += elem["name"] + "/";
|
||||||
|
|
||||||
name.onclick = () => {
|
name.onclick = () => {
|
||||||
if (hasClass(this, "expand")) {
|
if (hasClass(name, "expand")) {
|
||||||
removeClass(this, "expand");
|
removeClass(name, "expand");
|
||||||
} else {
|
} else {
|
||||||
addClass(this, "expand");
|
addClass(name, "expand");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
name.innerText = elem["name"];
|
name.innerText = elem["name"];
|
||||||
|
|
|
@ -181,15 +181,44 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
let name = item.name;
|
let name = item.name;
|
||||||
let item_id = item.item_id;
|
let item_id = item.item_id;
|
||||||
if let Some(mut new_item) = self.convert_item(item) {
|
if let Some(mut new_item) = self.convert_item(item) {
|
||||||
if let types::ItemEnum::Trait(ref mut t) = new_item.inner {
|
let can_be_ignored = match new_item.inner {
|
||||||
t.implementations = self.get_trait_implementors(item_id.expect_def_id())
|
types::ItemEnum::Trait(ref mut t) => {
|
||||||
} else if let types::ItemEnum::Struct(ref mut s) = new_item.inner {
|
t.implementations = self.get_trait_implementors(item_id.expect_def_id());
|
||||||
s.impls = self.get_impls(item_id.expect_def_id())
|
false
|
||||||
} else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
|
}
|
||||||
e.impls = self.get_impls(item_id.expect_def_id())
|
types::ItemEnum::Struct(ref mut s) => {
|
||||||
} else if let types::ItemEnum::Union(ref mut u) = new_item.inner {
|
s.impls = self.get_impls(item_id.expect_def_id());
|
||||||
u.impls = self.get_impls(item_id.expect_def_id())
|
false
|
||||||
}
|
}
|
||||||
|
types::ItemEnum::Enum(ref mut e) => {
|
||||||
|
e.impls = self.get_impls(item_id.expect_def_id());
|
||||||
|
false
|
||||||
|
}
|
||||||
|
types::ItemEnum::Union(ref mut u) => {
|
||||||
|
u.impls = self.get_impls(item_id.expect_def_id());
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
types::ItemEnum::Method(_)
|
||||||
|
| types::ItemEnum::AssocConst { .. }
|
||||||
|
| types::ItemEnum::AssocType { .. } => true,
|
||||||
|
types::ItemEnum::Module(_)
|
||||||
|
| types::ItemEnum::ExternCrate { .. }
|
||||||
|
| types::ItemEnum::Import(_)
|
||||||
|
| types::ItemEnum::StructField(_)
|
||||||
|
| types::ItemEnum::Variant(_)
|
||||||
|
| types::ItemEnum::Function(_)
|
||||||
|
| types::ItemEnum::TraitAlias(_)
|
||||||
|
| types::ItemEnum::Impl(_)
|
||||||
|
| types::ItemEnum::Typedef(_)
|
||||||
|
| types::ItemEnum::OpaqueTy(_)
|
||||||
|
| types::ItemEnum::Constant(_)
|
||||||
|
| types::ItemEnum::Static(_)
|
||||||
|
| types::ItemEnum::ForeignType
|
||||||
|
| types::ItemEnum::Macro(_)
|
||||||
|
| types::ItemEnum::ProcMacro(_)
|
||||||
|
| types::ItemEnum::PrimitiveType(_) => false,
|
||||||
|
};
|
||||||
let removed = self
|
let removed = self
|
||||||
.index
|
.index
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
@ -199,7 +228,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
// to make sure the items are unique. The main place this happens is when an item, is
|
// to make sure the items are unique. The main place this happens is when an item, is
|
||||||
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
|
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
|
||||||
if let Some(old_item) = removed {
|
if let Some(old_item) = removed {
|
||||||
assert_eq!(old_item, new_item);
|
// In case of generic implementations (like `impl<T> Trait for T {}`), all the
|
||||||
|
// inner items will be duplicated so we can ignore if they are slightly different.
|
||||||
|
if !can_be_ignored {
|
||||||
|
assert_eq!(old_item, new_item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Checks that the interactions with the source code pages are workined as expected.
|
// Checks that the interactions with the source code pages are working as expected.
|
||||||
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
|
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
|
||||||
// Check that we can click on the line number.
|
// Check that we can click on the line number.
|
||||||
click: ".line-numbers > span:nth-child(4)" // This is the span for line 4.
|
click: ".line-numbers > span:nth-child(4)" // This is the span for line 4.
|
||||||
|
@ -27,3 +27,26 @@ assert-position: ("//*[@id='1']", {"x": 104, "y": 103})
|
||||||
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
|
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
|
||||||
click: (103, 103)
|
click: (103, 103)
|
||||||
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
|
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
|
||||||
|
|
||||||
|
// Checking the source code sidebar.
|
||||||
|
|
||||||
|
// First we "open" it.
|
||||||
|
click: "#sidebar-toggle"
|
||||||
|
assert: ".sidebar.expanded"
|
||||||
|
|
||||||
|
// We check that the first entry of the sidebar is collapsed (which, for whatever reason,
|
||||||
|
// is number 2 and not 1...).
|
||||||
|
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
|
||||||
|
assert-text: ("#source-sidebar .name:nth-child(2)", "implementors")
|
||||||
|
// We also check its children are hidden too.
|
||||||
|
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
|
||||||
|
// We now click on it.
|
||||||
|
click: "#source-sidebar .name:nth-child(2)"
|
||||||
|
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name expand"})
|
||||||
|
// Checking that its children are displayed as well.
|
||||||
|
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "block"})
|
||||||
|
|
||||||
|
// And now we collapse it again.
|
||||||
|
click: "#source-sidebar .name:nth-child(2)"
|
||||||
|
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
|
||||||
|
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
|
||||||
|
|
24
src/test/rustdoc-json/generic_impl.rs
Normal file
24
src/test/rustdoc-json/generic_impl.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/97986>.
|
||||||
|
|
||||||
|
// @has generic_impl.json
|
||||||
|
// @has - "$.index[*][?(@.name=='f')]"
|
||||||
|
// @has - "$.index[*][?(@.name=='AssocTy')]"
|
||||||
|
// @has - "$.index[*][?(@.name=='AssocConst')]"
|
||||||
|
|
||||||
|
pub mod m {
|
||||||
|
pub struct S;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait F {
|
||||||
|
type AssocTy;
|
||||||
|
const AssocConst: usize;
|
||||||
|
fn f() -> m::S;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> F for T {
|
||||||
|
type AssocTy = u32;
|
||||||
|
const AssocConst: usize = 0;
|
||||||
|
fn f() -> m::S {
|
||||||
|
m::S
|
||||||
|
}
|
||||||
|
}
|
29
src/test/ui/associated-consts/issue-93775.rs
Normal file
29
src/test/ui/associated-consts/issue-93775.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
// build-pass
|
||||||
|
// ignore-tidy-linelength
|
||||||
|
|
||||||
|
// Regression for #93775, needs build-pass to test it.
|
||||||
|
|
||||||
|
#![recursion_limit = "1000"]
|
||||||
|
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
struct Z;
|
||||||
|
struct S<T>(PhantomData<T>);
|
||||||
|
|
||||||
|
type Nested = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<Z>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
||||||
|
|
||||||
|
trait AsNum {
|
||||||
|
const NUM: u32;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsNum for Z {
|
||||||
|
const NUM: u32 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: AsNum> AsNum for S<T> {
|
||||||
|
const NUM: u32 = T::NUM + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = Nested::NUM;
|
||||||
|
}
|
|
@ -23,10 +23,14 @@ LL | let &&x = &1isize as &dyn T;
|
||||||
| ^^ ----------------- this expression has type `&dyn T`
|
| ^^ ----------------- this expression has type `&dyn T`
|
||||||
| |
|
| |
|
||||||
| expected trait object `dyn T`, found reference
|
| expected trait object `dyn T`, found reference
|
||||||
| help: you can probably remove the explicit borrow: `x`
|
|
||||||
|
|
|
|
||||||
= note: expected trait object `dyn T`
|
= note: expected trait object `dyn T`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let &&x = &1isize as &dyn T;
|
||||||
|
LL + let &x = &1isize as &dyn T;
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/destructure-trait-ref.rs:36:11
|
--> $DIR/destructure-trait-ref.rs:36:11
|
||||||
|
@ -35,10 +39,14 @@ LL | let &&&x = &(&1isize as &dyn T);
|
||||||
| ^^ -------------------- this expression has type `&&dyn T`
|
| ^^ -------------------- this expression has type `&&dyn T`
|
||||||
| |
|
| |
|
||||||
| expected trait object `dyn T`, found reference
|
| expected trait object `dyn T`, found reference
|
||||||
| help: you can probably remove the explicit borrow: `x`
|
|
||||||
|
|
|
|
||||||
= note: expected trait object `dyn T`
|
= note: expected trait object `dyn T`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let &&&x = &(&1isize as &dyn T);
|
||||||
|
LL + let &&x = &(&1isize as &dyn T);
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/destructure-trait-ref.rs:40:13
|
--> $DIR/destructure-trait-ref.rs:40:13
|
||||||
|
|
|
@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
--> $DIR/E0214.rs:2:12
|
--> $DIR/E0214.rs:2:12
|
||||||
|
|
|
|
||||||
LL | let v: Vec(&str) = vec!["foo"];
|
LL | let v: Vec(&str) = vec!["foo"];
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ only `Fn` traits may use parentheses
|
||||||
| |
|
|
|
||||||
| only `Fn` traits may use parentheses
|
help: use angle brackets instead
|
||||||
| help: use angle brackets instead: `Vec<&str>`
|
|
|
||||||
|
LL | let v: Vec<&str> = vec!["foo"];
|
||||||
|
| ~ ~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
--> $DIR/issue-23589.rs:2:12
|
--> $DIR/issue-23589.rs:2:12
|
||||||
|
|
|
|
||||||
LL | let v: Vec(&str) = vec!['1', '2'];
|
LL | let v: Vec(&str) = vec!['1', '2'];
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ only `Fn` traits may use parentheses
|
||||||
| |
|
|
|
||||||
| only `Fn` traits may use parentheses
|
help: use angle brackets instead
|
||||||
| help: use angle brackets instead: `Vec<&str>`
|
|
|
||||||
|
LL | let v: Vec<&str> = vec!['1', '2'];
|
||||||
|
| ~ ~
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-23589.rs:2:29
|
--> $DIR/issue-23589.rs:2:29
|
||||||
|
|
5
src/test/ui/mismatched_types/issue-38371-unfixable.rs
Normal file
5
src/test/ui/mismatched_types/issue-38371-unfixable.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
fn ugh(&[bar]: &u32) {} //~ ERROR expected an array or slice
|
||||||
|
|
||||||
|
fn bgh(&&bar: u32) {} //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn main() {}
|
21
src/test/ui/mismatched_types/issue-38371-unfixable.stderr
Normal file
21
src/test/ui/mismatched_types/issue-38371-unfixable.stderr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
error[E0529]: expected an array or slice, found `u32`
|
||||||
|
--> $DIR/issue-38371-unfixable.rs:1:9
|
||||||
|
|
|
||||||
|
LL | fn ugh(&[bar]: &u32) {}
|
||||||
|
| ^^^^^ pattern cannot match with input type `u32`
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/issue-38371-unfixable.rs:3:8
|
||||||
|
|
|
||||||
|
LL | fn bgh(&&bar: u32) {}
|
||||||
|
| ^^^^^ --- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0308, E0529.
|
||||||
|
For more information about an error, try `rustc --explain E0308`.
|
18
src/test/ui/mismatched_types/issue-38371.fixed
Normal file
18
src/test/ui/mismatched_types/issue-38371.fixed
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
// run-rustfix
|
||||||
|
// see also issue-38371-unfixable.rs
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
struct Foo {}
|
||||||
|
|
||||||
|
fn foo(_a: &Foo) {} //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn bar(_a: Foo) {}
|
||||||
|
|
||||||
|
fn qux(_a: &Foo) {}
|
||||||
|
|
||||||
|
fn zar(&_a: &Foo) {}
|
||||||
|
|
||||||
|
fn agh(&_a: &u32) {} //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,27 +1,18 @@
|
||||||
struct Foo {
|
// run-rustfix
|
||||||
}
|
// see also issue-38371-unfixable.rs
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
fn foo(&foo: Foo) { //~ ERROR mismatched types
|
#[derive(Copy, Clone)]
|
||||||
}
|
struct Foo {}
|
||||||
|
|
||||||
fn bar(foo: Foo) {
|
fn foo(&_a: Foo) {} //~ ERROR mismatched types
|
||||||
}
|
|
||||||
|
|
||||||
fn qux(foo: &Foo) {
|
fn bar(_a: Foo) {}
|
||||||
}
|
|
||||||
|
|
||||||
fn zar(&foo: &Foo) {
|
fn qux(_a: &Foo) {}
|
||||||
}
|
|
||||||
|
|
||||||
// The somewhat unexpected help message in this case is courtesy of
|
fn zar(&_a: &Foo) {}
|
||||||
// match_default_bindings.
|
|
||||||
fn agh(&&bar: &u32) { //~ ERROR mismatched types
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bgh(&&bar: u32) { //~ ERROR mismatched types
|
fn agh(&&_a: &u32) {} //~ ERROR mismatched types
|
||||||
}
|
|
||||||
|
|
||||||
fn ugh(&[bar]: &u32) { //~ ERROR expected an array or slice
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,46 +1,35 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-38371.rs:4:8
|
--> $DIR/issue-38371.rs:8:8
|
||||||
|
|
|
|
||||||
LL | fn foo(&foo: Foo) {
|
LL | fn foo(&_a: Foo) {}
|
||||||
| ^^^^-----
|
| ^^^ --- expected due to this
|
||||||
| | |
|
| |
|
||||||
| | expected due to this
|
|
||||||
| expected struct `Foo`, found reference
|
| expected struct `Foo`, found reference
|
||||||
| help: did you mean `foo`: `&Foo`
|
|
||||||
|
|
|
|
||||||
= note: expected struct `Foo`
|
= note: expected struct `Foo`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: to take parameter `_a` by reference, move `&` to the type
|
||||||
|
|
|
||||||
|
LL - fn foo(&_a: Foo) {}
|
||||||
|
LL + fn foo(_a: &Foo) {}
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-38371.rs:18:9
|
--> $DIR/issue-38371.rs:16:9
|
||||||
|
|
|
|
||||||
LL | fn agh(&&bar: &u32) {
|
LL | fn agh(&&_a: &u32) {}
|
||||||
| ^^^^ ---- expected due to this
|
| ^^^ ---- expected due to this
|
||||||
| |
|
| |
|
||||||
| expected `u32`, found reference
|
| expected `u32`, found reference
|
||||||
| help: you can probably remove the explicit borrow: `bar`
|
|
||||||
|
|
|
|
||||||
= note: expected type `u32`
|
= note: expected type `u32`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
error[E0308]: mismatched types
|
|
||||||
--> $DIR/issue-38371.rs:21:8
|
|
||||||
|
|
|
|
||||||
LL | fn bgh(&&bar: u32) {
|
LL - fn agh(&&_a: &u32) {}
|
||||||
| ^^^^^ --- expected due to this
|
LL + fn agh(&_a: &u32) {}
|
||||||
| |
|
|
|
||||||
| expected `u32`, found reference
|
|
||||||
|
|
|
||||||
= note: expected type `u32`
|
|
||||||
found reference `&_`
|
|
||||||
|
|
||||||
error[E0529]: expected an array or slice, found `u32`
|
error: aborting due to 2 previous errors
|
||||||
--> $DIR/issue-38371.rs:24:9
|
|
||||||
|
|
|
||||||
LL | fn ugh(&[bar]: &u32) {
|
|
||||||
| ^^^^^ pattern cannot match with input type `u32`
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0308, E0529.
|
|
||||||
For more information about an error, try `rustc --explain E0308`.
|
|
||||||
|
|
24
src/test/ui/mismatched_types/ref-pat-suggestions.fixed
Normal file
24
src/test/ui/mismatched_types/ref-pat-suggestions.fixed
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
fn _f0(_a: &u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f1(_a: &mut u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f2(&_a: &u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f3(&mut _a: &mut u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f4(&_a: &u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f5(&mut _a: &mut u32) {} //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: fn(u32) = |_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(u32) = |_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types
|
||||||
|
|
||||||
|
let _ = |_a: &u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |_a: &mut u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&_a: &u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&_a: &u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types
|
||||||
|
}
|
24
src/test/ui/mismatched_types/ref-pat-suggestions.rs
Normal file
24
src/test/ui/mismatched_types/ref-pat-suggestions.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
fn _f0(&_a: u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f1(&mut _a: u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f2(&&_a: &u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f3(&mut &_a: &mut u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f4(&&mut _a: &u32) {} //~ ERROR mismatched types
|
||||||
|
fn _f5(&mut &mut _a: &mut u32) {} //~ ERROR mismatched types
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: fn(u32) = |&_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(u32) = |&mut _a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&u32) = |&&_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&mut u32) = |&mut &_a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&u32) = |&&mut _a| (); //~ ERROR mismatched types
|
||||||
|
let _: fn(&mut u32) = |&mut &mut _a| (); //~ ERROR mismatched types
|
||||||
|
|
||||||
|
let _ = |&_a: u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&mut _a: u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&&_a: &u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&mut &_a: &mut u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&&mut _a: &u32| (); //~ ERROR mismatched types
|
||||||
|
let _ = |&mut &mut _a: &mut u32| (); //~ ERROR mismatched types
|
||||||
|
}
|
297
src/test/ui/mismatched_types/ref-pat-suggestions.stderr
Normal file
297
src/test/ui/mismatched_types/ref-pat-suggestions.stderr
Normal file
|
@ -0,0 +1,297 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:3:8
|
||||||
|
|
|
||||||
|
LL | fn _f0(&_a: u32) {}
|
||||||
|
| ^^^ --- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: to take parameter `_a` by reference, move `&` to the type
|
||||||
|
|
|
||||||
|
LL - fn _f0(&_a: u32) {}
|
||||||
|
LL + fn _f0(_a: &u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:4:8
|
||||||
|
|
|
||||||
|
LL | fn _f1(&mut _a: u32) {}
|
||||||
|
| ^^^^^^^ --- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: to take parameter `_a` by reference, move `&mut` to the type
|
||||||
|
|
|
||||||
|
LL - fn _f1(&mut _a: u32) {}
|
||||||
|
LL + fn _f1(_a: &mut u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:5:9
|
||||||
|
|
|
||||||
|
LL | fn _f2(&&_a: &u32) {}
|
||||||
|
| ^^^ ---- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - fn _f2(&&_a: &u32) {}
|
||||||
|
LL + fn _f2(&_a: &u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:6:13
|
||||||
|
|
|
||||||
|
LL | fn _f3(&mut &_a: &mut u32) {}
|
||||||
|
| ^^^ -------- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - fn _f3(&mut &_a: &mut u32) {}
|
||||||
|
LL + fn _f3(&mut _a: &mut u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:7:9
|
||||||
|
|
|
||||||
|
LL | fn _f4(&&mut _a: &u32) {}
|
||||||
|
| ^^^^^^^ ---- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - fn _f4(&&mut _a: &u32) {}
|
||||||
|
LL + fn _f4(&_a: &u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:8:13
|
||||||
|
|
|
||||||
|
LL | fn _f5(&mut &mut _a: &mut u32) {}
|
||||||
|
| ^^^^^^^ -------- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - fn _f5(&mut &mut _a: &mut u32) {}
|
||||||
|
LL + fn _f5(&mut _a: &mut u32) {}
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:11:23
|
||||||
|
|
|
||||||
|
LL | let _: fn(u32) = |&_a| ();
|
||||||
|
| ^--
|
||||||
|
| ||
|
||||||
|
| |expected due to this
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(u32) = |&_a| ();
|
||||||
|
LL + let _: fn(u32) = |_a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:12:23
|
||||||
|
|
|
||||||
|
LL | let _: fn(u32) = |&mut _a| ();
|
||||||
|
| ^^^^^--
|
||||||
|
| | |
|
||||||
|
| | expected due to this
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(u32) = |&mut _a| ();
|
||||||
|
LL + let _: fn(u32) = |_a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:13:25
|
||||||
|
|
|
||||||
|
LL | let _: fn(&u32) = |&&_a| ();
|
||||||
|
| ^--
|
||||||
|
| ||
|
||||||
|
| |expected due to this
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(&u32) = |&&_a| ();
|
||||||
|
LL + let _: fn(&u32) = |&_a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:14:33
|
||||||
|
|
|
||||||
|
LL | let _: fn(&mut u32) = |&mut &_a| ();
|
||||||
|
| ^--
|
||||||
|
| ||
|
||||||
|
| |expected due to this
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(&mut u32) = |&mut &_a| ();
|
||||||
|
LL + let _: fn(&mut u32) = |&mut _a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:15:25
|
||||||
|
|
|
||||||
|
LL | let _: fn(&u32) = |&&mut _a| ();
|
||||||
|
| ^^^^^--
|
||||||
|
| | |
|
||||||
|
| | expected due to this
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(&u32) = |&&mut _a| ();
|
||||||
|
LL + let _: fn(&u32) = |&_a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:16:33
|
||||||
|
|
|
||||||
|
LL | let _: fn(&mut u32) = |&mut &mut _a| ();
|
||||||
|
| ^^^^^--
|
||||||
|
| | |
|
||||||
|
| | expected due to this
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _: fn(&mut u32) = |&mut &mut _a| ();
|
||||||
|
LL + let _: fn(&mut u32) = |&mut _a| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:18:14
|
||||||
|
|
|
||||||
|
LL | let _ = |&_a: u32| ();
|
||||||
|
| ^^^ --- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: to take parameter `_a` by reference, move `&` to the type
|
||||||
|
|
|
||||||
|
LL - let _ = |&_a: u32| ();
|
||||||
|
LL + let _ = |_a: &u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:19:14
|
||||||
|
|
|
||||||
|
LL | let _ = |&mut _a: u32| ();
|
||||||
|
| ^^^^^^^ --- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: to take parameter `_a` by reference, move `&mut` to the type
|
||||||
|
|
|
||||||
|
LL - let _ = |&mut _a: u32| ();
|
||||||
|
LL + let _ = |_a: &mut u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:20:15
|
||||||
|
|
|
||||||
|
LL | let _ = |&&_a: &u32| ();
|
||||||
|
| ^^^ ---- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _ = |&&_a: &u32| ();
|
||||||
|
LL + let _ = |&_a: &u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:21:19
|
||||||
|
|
|
||||||
|
LL | let _ = |&mut &_a: &mut u32| ();
|
||||||
|
| ^^^ -------- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found reference
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _ = |&mut &_a: &mut u32| ();
|
||||||
|
LL + let _ = |&mut _a: &mut u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:22:15
|
||||||
|
|
|
||||||
|
LL | let _ = |&&mut _a: &u32| ();
|
||||||
|
| ^^^^^^^ ---- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _ = |&&mut _a: &u32| ();
|
||||||
|
LL + let _ = |&_a: &u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/ref-pat-suggestions.rs:23:19
|
||||||
|
|
|
||||||
|
LL | let _ = |&mut &mut _a: &mut u32| ();
|
||||||
|
| ^^^^^^^ -------- expected due to this
|
||||||
|
| |
|
||||||
|
| expected `u32`, found `&mut _`
|
||||||
|
|
|
||||||
|
= note: expected type `u32`
|
||||||
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - let _ = |&mut &mut _a: &mut u32| ();
|
||||||
|
LL + let _ = |&mut _a: &mut u32| ();
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to 18 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
|
@ -5,10 +5,14 @@ LL | for ((_, _), (&mut c, _)) in &mut map {
|
||||||
| ^^^^^^ -------- this is an iterator with items of type `(&(char, char), &mut (char, char))`
|
| ^^^^^^ -------- this is an iterator with items of type `(&(char, char), &mut (char, char))`
|
||||||
| |
|
| |
|
||||||
| expected `char`, found `&mut _`
|
| expected `char`, found `&mut _`
|
||||||
| help: you can probably remove the explicit borrow: `c`
|
|
||||||
|
|
|
|
||||||
= note: expected type `char`
|
= note: expected type `char`
|
||||||
found mutable reference `&mut _`
|
found mutable reference `&mut _`
|
||||||
|
help: consider removing `&mut` from the pattern
|
||||||
|
|
|
||||||
|
LL - for ((_, _), (&mut c, _)) in &mut map {
|
||||||
|
LL + for ((_, _), (c, _)) in &mut map {
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/for-loop-bad-item.rs:14:14
|
--> $DIR/for-loop-bad-item.rs:14:14
|
||||||
|
|
|
@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
--> $DIR/issue-66286.rs:8:22
|
--> $DIR/issue-66286.rs:8:22
|
||||||
|
|
|
|
||||||
LL | pub extern fn foo(_: Vec(u32)) -> u32 {
|
LL | pub extern fn foo(_: Vec(u32)) -> u32 {
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ only `Fn` traits may use parentheses
|
||||||
| |
|
|
|
||||||
| only `Fn` traits may use parentheses
|
help: use angle brackets instead
|
||||||
| help: use angle brackets instead: `Vec<u32>`
|
|
|
||||||
|
LL | pub extern fn foo(_: Vec<u32>) -> u32 {
|
||||||
|
| ~ ~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
--> $DIR/let-binding-init-expr-as-ty.rs:2:19
|
--> $DIR/let-binding-init-expr-as-ty.rs:2:19
|
||||||
|
|
|
|
||||||
LL | let foo: i32::from_be(num);
|
LL | let foo: i32::from_be(num);
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^ only `Fn` traits may use parentheses
|
||||||
| |
|
|
|
||||||
| only `Fn` traits may use parentheses
|
help: use angle brackets instead
|
||||||
| help: use angle brackets instead: `from_be<num>`
|
|
|
||||||
|
LL | let foo: i32::from_be<num>;
|
||||||
|
| ~ ~
|
||||||
|
|
||||||
error[E0223]: ambiguous associated type
|
error[E0223]: ambiguous associated type
|
||||||
--> $DIR/let-binding-init-expr-as-ty.rs:2:14
|
--> $DIR/let-binding-init-expr-as-ty.rs:2:14
|
||||||
|
|
|
@ -4,13 +4,15 @@ error[E0308]: mismatched types
|
||||||
LL | match &x[..] {
|
LL | match &x[..] {
|
||||||
| ------ this expression has type `&[i32]`
|
| ------ this expression has type `&[i32]`
|
||||||
LL | [&v] => {},
|
LL | [&v] => {},
|
||||||
| ^^
|
| ^^ expected `i32`, found reference
|
||||||
| |
|
|
||||||
| expected `i32`, found reference
|
|
||||||
| help: you can probably remove the explicit borrow: `v`
|
|
||||||
|
|
|
|
||||||
= note: expected type `i32`
|
= note: expected type `i32`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - [&v] => {},
|
||||||
|
LL + [v] => {},
|
||||||
|
|
|
||||||
|
|
||||||
error[E0529]: expected an array or slice, found `Vec<i32>`
|
error[E0529]: expected an array or slice, found `Vec<i32>`
|
||||||
--> $DIR/match-ergonomics.rs:8:9
|
--> $DIR/match-ergonomics.rs:8:9
|
||||||
|
@ -34,13 +36,15 @@ error[E0308]: mismatched types
|
||||||
LL | match y {
|
LL | match y {
|
||||||
| - this expression has type `i32`
|
| - this expression has type `i32`
|
||||||
LL | &v => {},
|
LL | &v => {},
|
||||||
| ^^
|
| ^^ expected `i32`, found reference
|
||||||
| |
|
|
||||||
| expected `i32`, found reference
|
|
||||||
| help: you can probably remove the explicit borrow: `v`
|
|
||||||
|
|
|
|
||||||
= note: expected type `i32`
|
= note: expected type `i32`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - &v => {},
|
||||||
|
LL + v => {},
|
||||||
|
|
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/match-ergonomics.rs:40:13
|
--> $DIR/match-ergonomics.rs:40:13
|
||||||
|
@ -49,10 +53,14 @@ LL | if let [&v] = &x[..] {}
|
||||||
| ^^ ------ this expression has type `&[i32]`
|
| ^^ ------ this expression has type `&[i32]`
|
||||||
| |
|
| |
|
||||||
| expected `i32`, found reference
|
| expected `i32`, found reference
|
||||||
| help: you can probably remove the explicit borrow: `v`
|
|
||||||
|
|
|
|
||||||
= note: expected type `i32`
|
= note: expected type `i32`
|
||||||
found reference `&_`
|
found reference `&_`
|
||||||
|
help: consider removing `&` from the pattern
|
||||||
|
|
|
||||||
|
LL - if let [&v] = &x[..] {}
|
||||||
|
LL + if let [v] = &x[..] {}
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
|
|
|
|
||||||
LL | 0: u8(ţ
|
LL | 0: u8(ţ
|
||||||
| ^^^^ only `Fn` traits may use parentheses
|
| ^^^^ only `Fn` traits may use parentheses
|
||||||
|
|
|
||||||
|
help: use angle brackets instead
|
||||||
|
|
|
||||||
|
LL | 0: u8<ţ>
|
||||||
|
| ~ +
|
||||||
|
|
||||||
error[E0109]: type arguments are not allowed on this type
|
error[E0109]: type arguments are not allowed on this type
|
||||||
--> $DIR/issue-91268.rs:9:11
|
--> $DIR/issue-91268.rs:9:11
|
||||||
|
|
|
@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
|
||||||
--> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:13
|
--> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let b = Bar::(isize, usize)::new(); // OK too (for the parser)
|
LL | let b = Bar::(isize, usize)::new(); // OK too (for the parser)
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
|
||||||
| |
|
|
|
||||||
| only `Fn` traits may use parentheses
|
help: use angle brackets instead
|
||||||
| help: use angle brackets instead: `Bar::<isize, usize>`
|
|
|
||||||
|
LL | let b = Bar::<isize, usize>::new(); // OK too (for the parser)
|
||||||
|
| ~ ~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue