Skip to content

Commit 5bc82c0

Browse files
committedJun 15, 2022
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
·
1.90.01.63.0
2 parents b31f9cc + 4ab704e commit 5bc82c0

26 files changed

+697
-143
lines changed
 

‎compiler/rustc_ast_lowering/src/path.rs‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
196196
ParenthesizedGenericArgs::Err => {
197197
let mut err = struct_span_err!(self.sess, data.span, E0214, "{}", msg);
198198
err.span_label(data.span, "only `Fn` traits may use parentheses");
199-
if let Ok(snippet) = self.sess.source_map().span_to_snippet(data.span) {
200-
// Do not suggest going from `Trait()` to `Trait<>`
201-
if !data.inputs.is_empty() {
202-
// Suggest replacing `(` and `)` with `<` and `>`
203-
// The snippet may be missing the closing `)`, skip that case
204-
if snippet.ends_with(')') {
205-
if let Some(split) = snippet.find('(') {
206-
let trait_name = &snippet[0..split];
207-
let args = &snippet[split + 1..snippet.len() - 1];
208-
err.span_suggestion(
209-
data.span,
210-
"use angle brackets instead",
211-
format!("{}<{}>", trait_name, args),
212-
Applicability::MaybeIncorrect,
213-
);
214-
}
215-
}
216-
}
217-
};
199+
// Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
200+
if !data.inputs.is_empty() {
201+
// Start of the span to the 1st character of 1st argument
202+
let open_param = data.inputs_span.shrink_to_lo().to(data
203+
.inputs
204+
.first()
205+
.unwrap()
206+
.span
207+
.shrink_to_lo());
208+
// Last character position of last argument to the end of the span
209+
let close_param = data
210+
.inputs
211+
.last()
212+
.unwrap()
213+
.span
214+
.shrink_to_hi()
215+
.to(data.inputs_span.shrink_to_hi());
216+
err.multipart_suggestion(
217+
&format!("use angle brackets instead",),
218+
vec![
219+
(open_param, String::from("<")),
220+
(close_param, String::from(">")),
221+
],
222+
Applicability::MaybeIncorrect,
223+
);
224+
}
218225
err.emit();
219226
(
220227
self.lower_angle_bracketed_parameter_data(

‎compiler/rustc_typeck/src/check/pat.rs‎

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -649,39 +649,41 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
649649
}
650650
}
651651

652-
fn borrow_pat_suggestion(
653-
&self,
654-
err: &mut Diagnostic,
655-
pat: &Pat<'_>,
656-
inner: &Pat<'_>,
657-
expected: Ty<'tcx>,
658-
) {
652+
// Precondition: pat is a Ref(_) pattern
653+
fn borrow_pat_suggestion(&self, err: &mut Diagnostic, pat: &Pat<'_>) {
659654
let tcx = self.tcx;
660-
if let PatKind::Binding(..) = inner.kind {
655+
if let PatKind::Ref(inner, mutbl) = pat.kind
656+
&& let PatKind::Binding(_, _, binding, ..) = inner.kind {
661657
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id);
662658
let binding_parent = tcx.hir().get(binding_parent_id);
663-
debug!("inner {:?} pat {:?} parent {:?}", inner, pat, binding_parent);
659+
debug!(?inner, ?pat, ?binding_parent);
660+
661+
let mutability = match mutbl {
662+
ast::Mutability::Mut => "mut",
663+
ast::Mutability::Not => "",
664+
};
665+
664666
match binding_parent {
665-
hir::Node::Param(hir::Param { span, .. })
666-
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) =>
667-
{
668-
err.span_suggestion(
669-
*span,
670-
&format!("did you mean `{snippet}`"),
671-
format!(" &{expected}"),
672-
Applicability::MachineApplicable,
667+
// Check that there is explicit type (ie this is not a closure param with inferred type)
668+
// so we don't suggest moving something to the type that does not exist
669+
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span != *ty_span => {
670+
err.multipart_suggestion_verbose(
671+
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
672+
vec![
673+
(pat.span.until(inner.span), "".to_owned()),
674+
(ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())),
675+
],
676+
Applicability::MachineApplicable
673677
);
674678
}
675-
hir::Node::Arm(_) | hir::Node::Pat(_) => {
679+
hir::Node::Param(_) | hir::Node::Arm(_) | hir::Node::Pat(_) => {
676680
// rely on match ergonomics or it might be nested `&&pat`
677-
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) {
678-
err.span_suggestion(
679-
pat.span,
680-
"you can probably remove the explicit borrow",
681-
snippet,
682-
Applicability::MaybeIncorrect,
683-
);
684-
}
681+
err.span_suggestion_verbose(
682+
pat.span.until(inner.span),
683+
format!("consider removing `&{mutability}` from the pattern"),
684+
"",
685+
Applicability::MaybeIncorrect,
686+
);
685687
}
686688
_ => {} // don't provide suggestions in other cases #55175
687689
}
@@ -1836,6 +1838,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18361838
box_ty
18371839
}
18381840

1841+
// Precondition: Pat is Ref(inner)
18391842
fn check_pat_ref(
18401843
&self,
18411844
pat: &'tcx Pat<'tcx>,
@@ -1853,7 +1856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18531856

18541857
// Take region, inner-type from expected type if we can,
18551858
// to avoid creating needless variables. This also helps with
1856-
// the bad interactions of the given hack detailed in (note_1).
1859+
// the bad interactions of the given hack detailed in (note_1).
18571860
debug!("check_pat_ref: expected={:?}", expected);
18581861
match *expected.kind() {
18591862
ty::Ref(_, r_ty, r_mutbl) if r_mutbl == mutbl => (expected, r_ty),
@@ -1869,7 +1872,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18691872
// Look for a case like `fn foo(&foo: u32)` and suggest
18701873
// `fn foo(foo: &u32)`
18711874
if let Some(mut err) = err {
1872-
self.borrow_pat_suggestion(&mut err, pat, inner, expected);
1875+
self.borrow_pat_suggestion(&mut err, pat);
18731876
err.emit();
18741877
}
18751878
(rptr_ty, inner_ty)

‎library/core/src/intrinsics.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,7 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
23632363
#[rustc_const_unstable(feature = "const_eval_select", issue = "none")]
23642364
#[lang = "const_eval_select"]
23652365
#[rustc_do_not_const_check]
2366+
#[inline]
23662367
pub const unsafe fn const_eval_select<ARG, F, G, RET>(
23672368
arg: ARG,
23682369
_called_in_const: F,

‎library/std/src/ffi/os_str.rs‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
4545
/// values, encoded in a less-strict variant of UTF-8. This is useful to
4646
/// understand when handling capacity and length values.
4747
///
48+
/// # Capacity of `OsString`
49+
///
50+
/// Capacity uses units of UTF-8 bytes for OS strings which were created from valid unicode, and
51+
/// uses units of bytes in an unspecified encoding for other contents. On a given target, all
52+
/// `OsString` and `OsStr` values use the same units for capacity, so the following will work:
53+
/// ```
54+
/// use std::ffi::{OsStr, OsString};
55+
///
56+
/// fn concat_os_strings(a: &OsStr, b: &OsStr) -> OsString {
57+
/// let mut ret = OsString::with_capacity(a.len() + b.len()); // This will allocate
58+
/// ret.push(a); // This will not allocate further
59+
/// ret.push(b); // This will not allocate further
60+
/// ret
61+
/// }
62+
/// ```
63+
///
4864
/// # Creating an `OsString`
4965
///
5066
/// **From a Rust string**: `OsString` implements
@@ -186,7 +202,7 @@ impl OsString {
186202
/// OS strings without reallocating. If `capacity` is 0, the string will not
187203
/// allocate.
188204
///
189-
/// See main `OsString` documentation information about encoding.
205+
/// See the main `OsString` documentation information about encoding and capacity units.
190206
///
191207
/// # Examples
192208
///
@@ -229,7 +245,7 @@ impl OsString {
229245

230246
/// Returns the capacity this `OsString` can hold without reallocating.
231247
///
232-
/// See `OsString` introduction for information about encoding.
248+
/// See the main `OsString` documentation information about encoding and capacity units.
233249
///
234250
/// # Examples
235251
///
@@ -251,6 +267,8 @@ impl OsString {
251267
///
252268
/// The collection may reserve more space to avoid frequent reallocations.
253269
///
270+
/// See the main `OsString` documentation information about encoding and capacity units.
271+
///
254272
/// # Examples
255273
///
256274
/// ```
@@ -272,6 +290,8 @@ impl OsString {
272290
/// greater than or equal to `self.len() + additional`. Does nothing if
273291
/// capacity is already sufficient.
274292
///
293+
/// See the main `OsString` documentation information about encoding and capacity units.
294+
///
275295
/// # Errors
276296
///
277297
/// If the capacity overflows, or the allocator reports a failure, then an error
@@ -313,6 +333,8 @@ impl OsString {
313333
///
314334
/// [`reserve`]: OsString::reserve
315335
///
336+
/// See the main `OsString` documentation information about encoding and capacity units.
337+
///
316338
/// # Examples
317339
///
318340
/// ```
@@ -340,6 +362,8 @@ impl OsString {
340362
///
341363
/// [`try_reserve`]: OsString::try_reserve
342364
///
365+
/// See the main `OsString` documentation information about encoding and capacity units.
366+
///
343367
/// # Errors
344368
///
345369
/// If the capacity overflows, or the allocator reports a failure, then an error
@@ -373,6 +397,8 @@ impl OsString {
373397

374398
/// Shrinks the capacity of the `OsString` to match its length.
375399
///
400+
/// See the main `OsString` documentation information about encoding and capacity units.
401+
///
376402
/// # Examples
377403
///
378404
/// ```
@@ -399,6 +425,8 @@ impl OsString {
399425
///
400426
/// If the current capacity is less than the lower limit, this is a no-op.
401427
///
428+
/// See the main `OsString` documentation information about encoding and capacity units.
429+
///
402430
/// # Examples
403431
///
404432
/// ```
@@ -773,6 +801,8 @@ impl OsStr {
773801
/// This number is simply useful for passing to other methods, like
774802
/// [`OsString::with_capacity`] to avoid reallocations.
775803
///
804+
/// See the main `OsString` documentation information about encoding and capacity units.
805+
///
776806
/// # Examples
777807
///
778808
/// ```

‎src/librustdoc/html/static/js/source-script.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
3232
fullPath += elem["name"] + "/";
3333

3434
name.onclick = () => {
35-
if (hasClass(this, "expand")) {
36-
removeClass(this, "expand");
35+
if (hasClass(name, "expand")) {
36+
removeClass(name, "expand");
3737
} else {
38-
addClass(this, "expand");
38+
addClass(name, "expand");
3939
}
4040
};
4141
name.innerText = elem["name"];

‎src/librustdoc/json/mod.rs‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,44 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
181181
let name = item.name;
182182
let item_id = item.item_id;
183183
if let Some(mut new_item) = self.convert_item(item) {
184-
if let types::ItemEnum::Trait(ref mut t) = new_item.inner {
185-
t.implementations = self.get_trait_implementors(item_id.expect_def_id())
186-
} else if let types::ItemEnum::Struct(ref mut s) = new_item.inner {
187-
s.impls = self.get_impls(item_id.expect_def_id())
188-
} else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
189-
e.impls = self.get_impls(item_id.expect_def_id())
190-
} else if let types::ItemEnum::Union(ref mut u) = new_item.inner {
191-
u.impls = self.get_impls(item_id.expect_def_id())
192-
}
184+
let can_be_ignored = match new_item.inner {
185+
types::ItemEnum::Trait(ref mut t) => {
186+
t.implementations = self.get_trait_implementors(item_id.expect_def_id());
187+
false
188+
}
189+
types::ItemEnum::Struct(ref mut s) => {
190+
s.impls = self.get_impls(item_id.expect_def_id());
191+
false
192+
}
193+
types::ItemEnum::Enum(ref mut e) => {
194+
e.impls = self.get_impls(item_id.expect_def_id());
195+
false
196+
}
197+
types::ItemEnum::Union(ref mut u) => {
198+
u.impls = self.get_impls(item_id.expect_def_id());
199+
false
200+
}
201+
202+
types::ItemEnum::Method(_)
203+
| types::ItemEnum::AssocConst { .. }
204+
| types::ItemEnum::AssocType { .. } => true,
205+
types::ItemEnum::Module(_)
206+
| types::ItemEnum::ExternCrate { .. }
207+
| types::ItemEnum::Import(_)
208+
| types::ItemEnum::StructField(_)
209+
| types::ItemEnum::Variant(_)
210+
| types::ItemEnum::Function(_)
211+
| types::ItemEnum::TraitAlias(_)
212+
| types::ItemEnum::Impl(_)
213+
| types::ItemEnum::Typedef(_)
214+
| types::ItemEnum::OpaqueTy(_)
215+
| types::ItemEnum::Constant(_)
216+
| types::ItemEnum::Static(_)
217+
| types::ItemEnum::ForeignType
218+
| types::ItemEnum::Macro(_)
219+
| types::ItemEnum::ProcMacro(_)
220+
| types::ItemEnum::PrimitiveType(_) => false,
221+
};
193222
let removed = self
194223
.index
195224
.borrow_mut()
@@ -199,7 +228,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
199228
// to make sure the items are unique. The main place this happens is when an item, is
200229
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
201230
if let Some(old_item) = removed {
202-
assert_eq!(old_item, new_item);
231+
// In case of generic implementations (like `impl<T> Trait for T {}`), all the
232+
// inner items will be duplicated so we can ignore if they are slightly different.
233+
if !can_be_ignored {
234+
assert_eq!(old_item, new_item);
235+
}
203236
}
204237
}
205238

‎src/test/rustdoc-gui/source-code-page.goml‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Checks that the interactions with the source code pages are workined as expected.
1+
// Checks that the interactions with the source code pages are working as expected.
22
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
33
// Check that we can click on the line number.
44
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})
2727
// We click on the left of the "1" span but still in the "line-number" `<pre>`.
2828
click: (103, 103)
2929
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
30+
31+
// Checking the source code sidebar.
32+
33+
// First we "open" it.
34+
click: "#sidebar-toggle"
35+
assert: ".sidebar.expanded"
36+
37+
// We check that the first entry of the sidebar is collapsed (which, for whatever reason,
38+
// is number 2 and not 1...).
39+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
40+
assert-text: ("#source-sidebar .name:nth-child(2)", "implementors")
41+
// We also check its children are hidden too.
42+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
43+
// We now click on it.
44+
click: "#source-sidebar .name:nth-child(2)"
45+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name expand"})
46+
// Checking that its children are displayed as well.
47+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "block"})
48+
49+
// And now we collapse it again.
50+
click: "#source-sidebar .name:nth-child(2)"
51+
assert-attribute: ("#source-sidebar .name:nth-child(2)", {"class": "name"})
52+
assert-css: ("#source-sidebar .name:nth-child(2) + .children", {"display": "none"})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/97986>.
2+
3+
// @has generic_impl.json
4+
// @has - "$.index[*][?(@.name=='f')]"
5+
// @has - "$.index[*][?(@.name=='AssocTy')]"
6+
// @has - "$.index[*][?(@.name=='AssocConst')]"
7+
8+
pub mod m {
9+
pub struct S;
10+
}
11+
12+
pub trait F {
13+
type AssocTy;
14+
const AssocConst: usize;
15+
fn f() -> m::S;
16+
}
17+
18+
impl<T> F for T {
19+
type AssocTy = u32;
20+
const AssocConst: usize = 0;
21+
fn f() -> m::S {
22+
m::S
23+
}
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// build-pass
2+
// ignore-tidy-linelength
3+
4+
// Regression for #93775, needs build-pass to test it.
5+
6+
#![recursion_limit = "1000"]
7+
8+
use std::marker::PhantomData;
9+
10+
struct Z;
11+
struct S<T>(PhantomData<T>);
12+
13+
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<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derr‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ LL | let &&x = &1isize as &dyn T;
2323
| ^^ ----------------- this expression has type `&dyn T`
2424
| |
2525
| expected trait object `dyn T`, found reference
26-
| help: you can probably remove the explicit borrow: `x`
2726
|
2827
= note: expected trait object `dyn T`
2928
found reference `&_`
29+
help: consider removing `&` from the pattern
30+
|
31+
LL - let &&x = &1isize as &dyn T;
32+
LL + let &x = &1isize as &dyn T;
33+
|
3034

3135
error[E0308]: mismatched types
3236
--> $DIR/destructure-trait-ref.rs:36:11
@@ -35,10 +39,14 @@ LL | let &&&x = &(&1isize as &dyn T);
3539
| ^^ -------------------- this expression has type `&&dyn T`
3640
| |
3741
| expected trait object `dyn T`, found reference
38-
| help: you can probably remove the explicit borrow: `x`
3942
|
4043
= note: expected trait object `dyn T`
4144
found reference `&_`
45+
help: consider removing `&` from the pattern
46+
|
47+
LL - let &&&x = &(&1isize as &dyn T);
48+
LL + let &&x = &(&1isize as &dyn T);
49+
|
4250

4351
error[E0308]: mismatched types
4452
--> $DIR/destructure-trait-ref.rs:40:13

‎src/test/ui/error-codes/E0214.stderr‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
22
--> $DIR/E0214.rs:2:12
33
|
44
LL | let v: Vec(&str) = vec!["foo"];
5-
| ^^^^^^^^^
6-
| |
7-
| only `Fn` traits may use parentheses
8-
| help: use angle brackets instead: `Vec<&str>`
5+
| ^^^^^^^^^ only `Fn` traits may use parentheses
6+
|
7+
help: use angle brackets instead
8+
|
9+
LL | let v: Vec<&str> = vec!["foo"];
10+
| ~ ~
911

1012
error: aborting due to previous error
1113

‎src/test/ui/issues/issue-23589.stderr‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
22
--> $DIR/issue-23589.rs:2:12
33
|
44
LL | let v: Vec(&str) = vec!['1', '2'];
5-
| ^^^^^^^^^
6-
| |
7-
| only `Fn` traits may use parentheses
8-
| help: use angle brackets instead: `Vec<&str>`
5+
| ^^^^^^^^^ only `Fn` traits may use parentheses
6+
|
7+
help: use angle brackets instead
8+
|
9+
LL | let v: Vec<&str> = vec!['1', '2'];
10+
| ~ ~
911

1012
error[E0308]: mismatched types
1113
--> $DIR/issue-23589.rs:2:29
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn ugh(&[bar]: &u32) {} //~ ERROR expected an array or slice
2+
3+
fn bgh(&&bar: u32) {} //~ ERROR mismatched types
4+
5+
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0529]: expected an array or slice, found `u32`
2+
--> $DIR/issue-38371-unfixable.rs:1:9
3+
|
4+
LL | fn ugh(&[bar]: &u32) {}
5+
| ^^^^^ pattern cannot match with input type `u32`
6+
7+
error[E0308]: mismatched types
8+
--> $DIR/issue-38371-unfixable.rs:3:8
9+
|
10+
LL | fn bgh(&&bar: u32) {}
11+
| ^^^^^ --- expected due to this
12+
| |
13+
| expected `u32`, found reference
14+
|
15+
= note: expected type `u32`
16+
found reference `&_`
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors have detailed explanations: E0308, E0529.
21+
For more information about an error, try `rustc --explain E0308`.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-rustfix
2+
// see also issue-38371-unfixable.rs
3+
#![allow(dead_code)]
4+
5+
#[derive(Copy, Clone)]
6+
struct Foo {}
7+
8+
fn foo(_a: &Foo) {} //~ ERROR mismatched types
9+
10+
fn bar(_a: Foo) {}
11+
12+
fn qux(_a: &Foo) {}
13+
14+
fn zar(&_a: &Foo) {}
15+
16+
fn agh(&_a: &u32) {} //~ ERROR mismatched types
17+
18+
fn main() {}
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
struct Foo {
2-
}
1+
// run-rustfix
2+
// see also issue-38371-unfixable.rs
3+
#![allow(dead_code)]
34

4-
fn foo(&foo: Foo) { //~ ERROR mismatched types
5-
}
5+
#[derive(Copy, Clone)]
6+
struct Foo {}
67

7-
fn bar(foo: Foo) {
8-
}
8+
fn foo(&_a: Foo) {} //~ ERROR mismatched types
99

10-
fn qux(foo: &Foo) {
11-
}
10+
fn bar(_a: Foo) {}
1211

13-
fn zar(&foo: &Foo) {
14-
}
12+
fn qux(_a: &Foo) {}
1513

16-
// The somewhat unexpected help message in this case is courtesy of
17-
// match_default_bindings.
18-
fn agh(&&bar: &u32) { //~ ERROR mismatched types
19-
}
14+
fn zar(&_a: &Foo) {}
2015

21-
fn bgh(&&bar: u32) { //~ ERROR mismatched types
22-
}
23-
24-
fn ugh(&[bar]: &u32) { //~ ERROR expected an array or slice
25-
}
16+
fn agh(&&_a: &u32) {} //~ ERROR mismatched types
2617

2718
fn main() {}
Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,35 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-38371.rs:4:8
2+
--> $DIR/issue-38371.rs:8:8
33
|
4-
LL | fn foo(&foo: Foo) {
5-
| ^^^^-----
6-
| | |
7-
| | expected due to this
4+
LL | fn foo(&_a: Foo) {}
5+
| ^^^ --- expected due to this
6+
| |
87
| expected struct `Foo`, found reference
9-
| help: did you mean `foo`: `&Foo`
108
|
119
= note: expected struct `Foo`
1210
found reference `&_`
11+
help: to take parameter `_a` by reference, move `&` to the type
12+
|
13+
LL - fn foo(&_a: Foo) {}
14+
LL + fn foo(_a: &Foo) {}
15+
|
1316

1417
error[E0308]: mismatched types
15-
--> $DIR/issue-38371.rs:18:9
18+
--> $DIR/issue-38371.rs:16:9
1619
|
17-
LL | fn agh(&&bar: &u32) {
18-
| ^^^^ ---- expected due to this
20+
LL | fn agh(&&_a: &u32) {}
21+
| ^^^ ---- expected due to this
1922
| |
2023
| expected `u32`, found reference
21-
| help: you can probably remove the explicit borrow: `bar`
22-
|
23-
= note: expected type `u32`
24-
found reference `&_`
25-
26-
error[E0308]: mismatched types
27-
--> $DIR/issue-38371.rs:21:8
28-
|
29-
LL | fn bgh(&&bar: u32) {
30-
| ^^^^^ --- expected due to this
31-
| |
32-
| expected `u32`, found reference
3324
|
3425
= note: expected type `u32`
3526
found reference `&_`
36-
37-
error[E0529]: expected an array or slice, found `u32`
38-
--> $DIR/issue-38371.rs:24:9
27+
help: consider removing `&` from the pattern
3928
|
40-
LL | fn ugh(&[bar]: &u32) {
41-
| ^^^^^ pattern cannot match with input type `u32`
29+
LL - fn agh(&&_a: &u32) {}
30+
LL + fn agh(&_a: &u32) {}
31+
|
4232

43-
error: aborting due to 4 previous errors
33+
error: aborting due to 2 previous errors
4434

45-
Some errors have detailed explanations: E0308, E0529.
46-
For more information about an error, try `rustc --explain E0308`.
35+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// run-rustfix
2+
3+
fn _f0(_a: &u32) {} //~ ERROR mismatched types
4+
fn _f1(_a: &mut u32) {} //~ ERROR mismatched types
5+
fn _f2(&_a: &u32) {} //~ ERROR mismatched types
6+
fn _f3(&mut _a: &mut u32) {} //~ ERROR mismatched types
7+
fn _f4(&_a: &u32) {} //~ ERROR mismatched types
8+
fn _f5(&mut _a: &mut u32) {} //~ ERROR mismatched types
9+
10+
fn main() {
11+
let _: fn(u32) = |_a| (); //~ ERROR mismatched types
12+
let _: fn(u32) = |_a| (); //~ ERROR mismatched types
13+
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types
14+
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types
15+
let _: fn(&u32) = |&_a| (); //~ ERROR mismatched types
16+
let _: fn(&mut u32) = |&mut _a| (); //~ ERROR mismatched types
17+
18+
let _ = |_a: &u32| (); //~ ERROR mismatched types
19+
let _ = |_a: &mut u32| (); //~ ERROR mismatched types
20+
let _ = |&_a: &u32| (); //~ ERROR mismatched types
21+
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types
22+
let _ = |&_a: &u32| (); //~ ERROR mismatched types
23+
let _ = |&mut _a: &mut u32| (); //~ ERROR mismatched types
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// run-rustfix
2+
3+
fn _f0(&_a: u32) {} //~ ERROR mismatched types
4+
fn _f1(&mut _a: u32) {} //~ ERROR mismatched types
5+
fn _f2(&&_a: &u32) {} //~ ERROR mismatched types
6+
fn _f3(&mut &_a: &mut u32) {} //~ ERROR mismatched types
7+
fn _f4(&&mut _a: &u32) {} //~ ERROR mismatched types
8+
fn _f5(&mut &mut _a: &mut u32) {} //~ ERROR mismatched types
9+
10+
fn main() {
11+
let _: fn(u32) = |&_a| (); //~ ERROR mismatched types
12+
let _: fn(u32) = |&mut _a| (); //~ ERROR mismatched types
13+
let _: fn(&u32) = |&&_a| (); //~ ERROR mismatched types
14+
let _: fn(&mut u32) = |&mut &_a| (); //~ ERROR mismatched types
15+
let _: fn(&u32) = |&&mut _a| (); //~ ERROR mismatched types
16+
let _: fn(&mut u32) = |&mut &mut _a| (); //~ ERROR mismatched types
17+
18+
let _ = |&_a: u32| (); //~ ERROR mismatched types
19+
let _ = |&mut _a: u32| (); //~ ERROR mismatched types
20+
let _ = |&&_a: &u32| (); //~ ERROR mismatched types
21+
let _ = |&mut &_a: &mut u32| (); //~ ERROR mismatched types
22+
let _ = |&&mut _a: &u32| (); //~ ERROR mismatched types
23+
let _ = |&mut &mut _a: &mut u32| (); //~ ERROR mismatched types
24+
}
Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/ref-pat-suggestions.rs:3:8
3+
|
4+
LL | fn _f0(&_a: u32) {}
5+
| ^^^ --- expected due to this
6+
| |
7+
| expected `u32`, found reference
8+
|
9+
= note: expected type `u32`
10+
found reference `&_`
11+
help: to take parameter `_a` by reference, move `&` to the type
12+
|
13+
LL - fn _f0(&_a: u32) {}
14+
LL + fn _f0(_a: &u32) {}
15+
|
16+
17+
error[E0308]: mismatched types
18+
--> $DIR/ref-pat-suggestions.rs:4:8
19+
|
20+
LL | fn _f1(&mut _a: u32) {}
21+
| ^^^^^^^ --- expected due to this
22+
| |
23+
| expected `u32`, found `&mut _`
24+
|
25+
= note: expected type `u32`
26+
found mutable reference `&mut _`
27+
help: to take parameter `_a` by reference, move `&mut` to the type
28+
|
29+
LL - fn _f1(&mut _a: u32) {}
30+
LL + fn _f1(_a: &mut u32) {}
31+
|
32+
33+
error[E0308]: mismatched types
34+
--> $DIR/ref-pat-suggestions.rs:5:9
35+
|
36+
LL | fn _f2(&&_a: &u32) {}
37+
| ^^^ ---- expected due to this
38+
| |
39+
| expected `u32`, found reference
40+
|
41+
= note: expected type `u32`
42+
found reference `&_`
43+
help: consider removing `&` from the pattern
44+
|
45+
LL - fn _f2(&&_a: &u32) {}
46+
LL + fn _f2(&_a: &u32) {}
47+
|
48+
49+
error[E0308]: mismatched types
50+
--> $DIR/ref-pat-suggestions.rs:6:13
51+
|
52+
LL | fn _f3(&mut &_a: &mut u32) {}
53+
| ^^^ -------- expected due to this
54+
| |
55+
| expected `u32`, found reference
56+
|
57+
= note: expected type `u32`
58+
found reference `&_`
59+
help: consider removing `&` from the pattern
60+
|
61+
LL - fn _f3(&mut &_a: &mut u32) {}
62+
LL + fn _f3(&mut _a: &mut u32) {}
63+
|
64+
65+
error[E0308]: mismatched types
66+
--> $DIR/ref-pat-suggestions.rs:7:9
67+
|
68+
LL | fn _f4(&&mut _a: &u32) {}
69+
| ^^^^^^^ ---- expected due to this
70+
| |
71+
| expected `u32`, found `&mut _`
72+
|
73+
= note: expected type `u32`
74+
found mutable reference `&mut _`
75+
help: consider removing `&mut` from the pattern
76+
|
77+
LL - fn _f4(&&mut _a: &u32) {}
78+
LL + fn _f4(&_a: &u32) {}
79+
|
80+
81+
error[E0308]: mismatched types
82+
--> $DIR/ref-pat-suggestions.rs:8:13
83+
|
84+
LL | fn _f5(&mut &mut _a: &mut u32) {}
85+
| ^^^^^^^ -------- expected due to this
86+
| |
87+
| expected `u32`, found `&mut _`
88+
|
89+
= note: expected type `u32`
90+
found mutable reference `&mut _`
91+
help: consider removing `&mut` from the pattern
92+
|
93+
LL - fn _f5(&mut &mut _a: &mut u32) {}
94+
LL + fn _f5(&mut _a: &mut u32) {}
95+
|
96+
97+
error[E0308]: mismatched types
98+
--> $DIR/ref-pat-suggestions.rs:11:23
99+
|
100+
LL | let _: fn(u32) = |&_a| ();
101+
| ^--
102+
| ||
103+
| |expected due to this
104+
| expected `u32`, found reference
105+
|
106+
= note: expected type `u32`
107+
found reference `&_`
108+
help: consider removing `&` from the pattern
109+
|
110+
LL - let _: fn(u32) = |&_a| ();
111+
LL + let _: fn(u32) = |_a| ();
112+
|
113+
114+
error[E0308]: mismatched types
115+
--> $DIR/ref-pat-suggestions.rs:12:23
116+
|
117+
LL | let _: fn(u32) = |&mut _a| ();
118+
| ^^^^^--
119+
| | |
120+
| | expected due to this
121+
| expected `u32`, found `&mut _`
122+
|
123+
= note: expected type `u32`
124+
found mutable reference `&mut _`
125+
help: consider removing `&mut` from the pattern
126+
|
127+
LL - let _: fn(u32) = |&mut _a| ();
128+
LL + let _: fn(u32) = |_a| ();
129+
|
130+
131+
error[E0308]: mismatched types
132+
--> $DIR/ref-pat-suggestions.rs:13:25
133+
|
134+
LL | let _: fn(&u32) = |&&_a| ();
135+
| ^--
136+
| ||
137+
| |expected due to this
138+
| expected `u32`, found reference
139+
|
140+
= note: expected type `u32`
141+
found reference `&_`
142+
help: consider removing `&` from the pattern
143+
|
144+
LL - let _: fn(&u32) = |&&_a| ();
145+
LL + let _: fn(&u32) = |&_a| ();
146+
|
147+
148+
error[E0308]: mismatched types
149+
--> $DIR/ref-pat-suggestions.rs:14:33
150+
|
151+
LL | let _: fn(&mut u32) = |&mut &_a| ();
152+
| ^--
153+
| ||
154+
| |expected due to this
155+
| expected `u32`, found reference
156+
|
157+
= note: expected type `u32`
158+
found reference `&_`
159+
help: consider removing `&` from the pattern
160+
|
161+
LL - let _: fn(&mut u32) = |&mut &_a| ();
162+
LL + let _: fn(&mut u32) = |&mut _a| ();
163+
|
164+
165+
error[E0308]: mismatched types
166+
--> $DIR/ref-pat-suggestions.rs:15:25
167+
|
168+
LL | let _: fn(&u32) = |&&mut _a| ();
169+
| ^^^^^--
170+
| | |
171+
| | expected due to this
172+
| expected `u32`, found `&mut _`
173+
|
174+
= note: expected type `u32`
175+
found mutable reference `&mut _`
176+
help: consider removing `&mut` from the pattern
177+
|
178+
LL - let _: fn(&u32) = |&&mut _a| ();
179+
LL + let _: fn(&u32) = |&_a| ();
180+
|
181+
182+
error[E0308]: mismatched types
183+
--> $DIR/ref-pat-suggestions.rs:16:33
184+
|
185+
LL | let _: fn(&mut u32) = |&mut &mut _a| ();
186+
| ^^^^^--
187+
| | |
188+
| | expected due to this
189+
| expected `u32`, found `&mut _`
190+
|
191+
= note: expected type `u32`
192+
found mutable reference `&mut _`
193+
help: consider removing `&mut` from the pattern
194+
|
195+
LL - let _: fn(&mut u32) = |&mut &mut _a| ();
196+
LL + let _: fn(&mut u32) = |&mut _a| ();
197+
|
198+
199+
error[E0308]: mismatched types
200+
--> $DIR/ref-pat-suggestions.rs:18:14
201+
|
202+
LL | let _ = |&_a: u32| ();
203+
| ^^^ --- expected due to this
204+
| |
205+
| expected `u32`, found reference
206+
|
207+
= note: expected type `u32`
208+
found reference `&_`
209+
help: to take parameter `_a` by reference, move `&` to the type
210+
|
211+
LL - let _ = |&_a: u32| ();
212+
LL + let _ = |_a: &u32| ();
213+
|
214+
215+
error[E0308]: mismatched types
216+
--> $DIR/ref-pat-suggestions.rs:19:14
217+
|
218+
LL | let _ = |&mut _a: u32| ();
219+
| ^^^^^^^ --- expected due to this
220+
| |
221+
| expected `u32`, found `&mut _`
222+
|
223+
= note: expected type `u32`
224+
found mutable reference `&mut _`
225+
help: to take parameter `_a` by reference, move `&mut` to the type
226+
|
227+
LL - let _ = |&mut _a: u32| ();
228+
LL + let _ = |_a: &mut u32| ();
229+
|
230+
231+
error[E0308]: mismatched types
232+
--> $DIR/ref-pat-suggestions.rs:20:15
233+
|
234+
LL | let _ = |&&_a: &u32| ();
235+
| ^^^ ---- expected due to this
236+
| |
237+
| expected `u32`, found reference
238+
|
239+
= note: expected type `u32`
240+
found reference `&_`
241+
help: consider removing `&` from the pattern
242+
|
243+
LL - let _ = |&&_a: &u32| ();
244+
LL + let _ = |&_a: &u32| ();
245+
|
246+
247+
error[E0308]: mismatched types
248+
--> $DIR/ref-pat-suggestions.rs:21:19
249+
|
250+
LL | let _ = |&mut &_a: &mut u32| ();
251+
| ^^^ -------- expected due to this
252+
| |
253+
| expected `u32`, found reference
254+
|
255+
= note: expected type `u32`
256+
found reference `&_`
257+
help: consider removing `&` from the pattern
258+
|
259+
LL - let _ = |&mut &_a: &mut u32| ();
260+
LL + let _ = |&mut _a: &mut u32| ();
261+
|
262+
263+
error[E0308]: mismatched types
264+
--> $DIR/ref-pat-suggestions.rs:22:15
265+
|
266+
LL | let _ = |&&mut _a: &u32| ();
267+
| ^^^^^^^ ---- expected due to this
268+
| |
269+
| expected `u32`, found `&mut _`
270+
|
271+
= note: expected type `u32`
272+
found mutable reference `&mut _`
273+
help: consider removing `&mut` from the pattern
274+
|
275+
LL - let _ = |&&mut _a: &u32| ();
276+
LL + let _ = |&_a: &u32| ();
277+
|
278+
279+
error[E0308]: mismatched types
280+
--> $DIR/ref-pat-suggestions.rs:23:19
281+
|
282+
LL | let _ = |&mut &mut _a: &mut u32| ();
283+
| ^^^^^^^ -------- expected due to this
284+
| |
285+
| expected `u32`, found `&mut _`
286+
|
287+
= note: expected type `u32`
288+
found mutable reference `&mut _`
289+
help: consider removing `&mut` from the pattern
290+
|
291+
LL - let _ = |&mut &mut _a: &mut u32| ();
292+
LL + let _ = |&mut _a: &mut u32| ();
293+
|
294+
295+
error: aborting due to 18 previous errors
296+
297+
For more information about this error, try `rustc --explain E0308`.

‎src/test/ui/pattern/for-loop-bad-item.stderr‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ LL | for ((_, _), (&mut c, _)) in &mut map {
55
| ^^^^^^ -------- this is an iterator with items of type `(&(char, char), &mut (char, char))`
66
| |
77
| expected `char`, found `&mut _`
8-
| help: you can probably remove the explicit borrow: `c`
98
|
109
= note: expected type `char`
1110
found mutable reference `&mut _`
11+
help: consider removing `&mut` from the pattern
12+
|
13+
LL - for ((_, _), (&mut c, _)) in &mut map {
14+
LL + for ((_, _), (c, _)) in &mut map {
15+
|
1216

1317
error[E0308]: mismatched types
1418
--> $DIR/for-loop-bad-item.rs:14:14

‎src/test/ui/proc-macro/issue-66286.stderr‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
22
--> $DIR/issue-66286.rs:8:22
33
|
44
LL | pub extern fn foo(_: Vec(u32)) -> u32 {
5-
| ^^^^^^^^
6-
| |
7-
| only `Fn` traits may use parentheses
8-
| help: use angle brackets instead: `Vec<u32>`
5+
| ^^^^^^^^ only `Fn` traits may use parentheses
6+
|
7+
help: use angle brackets instead
8+
|
9+
LL | pub extern fn foo(_: Vec<u32>) -> u32 {
10+
| ~ ~
911

1012
error: aborting due to previous error
1113

‎src/test/ui/suggestions/let-binding-init-expr-as-ty.stderr‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
1010
--> $DIR/let-binding-init-expr-as-ty.rs:2:19
1111
|
1212
LL | let foo: i32::from_be(num);
13-
| ^^^^^^^^^^^^
14-
| |
15-
| only `Fn` traits may use parentheses
16-
| help: use angle brackets instead: `from_be<num>`
13+
| ^^^^^^^^^^^^ only `Fn` traits may use parentheses
14+
|
15+
help: use angle brackets instead
16+
|
17+
LL | let foo: i32::from_be<num>;
18+
| ~ ~
1719

1820
error[E0223]: ambiguous associated type
1921
--> $DIR/let-binding-init-expr-as-ty.rs:2:14

‎src/test/ui/suggestions/match-ergonomics.stderr‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ error[E0308]: mismatched types
44
LL | match &x[..] {
55
| ------ this expression has type `&[i32]`
66
LL | [&v] => {},
7-
| ^^
8-
| |
9-
| expected `i32`, found reference
10-
| help: you can probably remove the explicit borrow: `v`
7+
| ^^ expected `i32`, found reference
118
|
129
= note: expected type `i32`
1310
found reference `&_`
11+
help: consider removing `&` from the pattern
12+
|
13+
LL - [&v] => {},
14+
LL + [v] => {},
15+
|
1416

1517
error[E0529]: expected an array or slice, found `Vec<i32>`
1618
--> $DIR/match-ergonomics.rs:8:9
@@ -34,13 +36,15 @@ error[E0308]: mismatched types
3436
LL | match y {
3537
| - this expression has type `i32`
3638
LL | &v => {},
37-
| ^^
38-
| |
39-
| expected `i32`, found reference
40-
| help: you can probably remove the explicit borrow: `v`
39+
| ^^ expected `i32`, found reference
4140
|
4241
= note: expected type `i32`
4342
found reference `&_`
43+
help: consider removing `&` from the pattern
44+
|
45+
LL - &v => {},
46+
LL + v => {},
47+
|
4448

4549
error[E0308]: mismatched types
4650
--> $DIR/match-ergonomics.rs:40:13
@@ -49,10 +53,14 @@ LL | if let [&v] = &x[..] {}
4953
| ^^ ------ this expression has type `&[i32]`
5054
| |
5155
| expected `i32`, found reference
52-
| help: you can probably remove the explicit borrow: `v`
5356
|
5457
= note: expected type `i32`
5558
found reference `&_`
59+
help: consider removing `&` from the pattern
60+
|
61+
LL - if let [&v] = &x[..] {}
62+
LL + if let [v] = &x[..] {}
63+
|
5664

5765
error: aborting due to 5 previous errors
5866

‎src/test/ui/type/issue-91268.stderr‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
2929
|
3030
LL | 0: u8(ţ
3131
| ^^^^ only `Fn` traits may use parentheses
32+
|
33+
help: use angle brackets instead
34+
|
35+
LL | 0: u8<ţ>
36+
| ~ +
3237

3338
error[E0109]: type arguments are not allowed on this type
3439
--> $DIR/issue-91268.rs:9:11

‎src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
22
--> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:13
33
|
44
LL | let b = Bar::(isize, usize)::new(); // OK too (for the parser)
5-
| ^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| only `Fn` traits may use parentheses
8-
| help: use angle brackets instead: `Bar::<isize, usize>`
5+
| ^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
6+
|
7+
help: use angle brackets instead
8+
|
9+
LL | let b = Bar::<isize, usize>::new(); // OK too (for the parser)
10+
| ~ ~
911

1012
error: aborting due to previous error
1113

0 commit comments

Comments
 (0)
Please sign in to comment.