1
Fork 0

Auto merge of #136248 - matthiaskrgr:rollup-leaxgfd, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #133382 (Suggest considering casting fn item as fn pointer in more cases)
 - #136092 (Test pipes also when not running on Windows and Linux simultaneously)
 - #136190 (Remove duplicated code in RISC-V asm bad-reg test)
 - #136192 (ci: remove unused windows runner)
 - #136205 (Properly check that array length is valid type during built-in unsizing in index)
 - #136211 (Update mdbook to 0.4.44)
 - #136212 (Tweak `&mut self` suggestion span)
 - #136214 (Make crate AST mutation accessible for driver callback)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-29 16:18:29 +00:00
commit 0cc4f4f7b8
44 changed files with 321 additions and 206 deletions

View file

@ -1140,10 +1140,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let amp_mut_sugg = match *local_decl.local_info() {
LocalInfo::User(mir::BindingForm::ImplicitSelf(_)) => {
let suggestion = suggest_ampmut_self(self.infcx.tcx, decl_span);
let additional =
local_trait.map(|span| (span, suggest_ampmut_self(self.infcx.tcx, span)));
Some(AmpMutSugg { has_sugg: true, span: decl_span, suggestion, additional })
let (span, suggestion) = suggest_ampmut_self(self.infcx.tcx, decl_span);
let additional = local_trait.map(|span| suggest_ampmut_self(self.infcx.tcx, span));
Some(AmpMutSugg { has_sugg: true, span, suggestion, additional })
}
LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm {
@ -1202,10 +1201,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
opt_ty_info: None,
..
})) => {
let sugg = suggest_ampmut_self(self.infcx.tcx, decl_span);
let (span, sugg) =
suggest_ampmut_self(self.infcx.tcx, decl_span);
Some(AmpMutSugg {
has_sugg: true,
span: decl_span,
span,
suggestion: sugg,
additional: None,
})
@ -1461,17 +1461,12 @@ fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option<Symb
}
}
fn suggest_ampmut_self<'tcx>(tcx: TyCtxt<'tcx>, span: Span) -> String {
fn suggest_ampmut_self(tcx: TyCtxt<'_>, span: Span) -> (Span, String) {
match tcx.sess.source_map().span_to_snippet(span) {
Ok(snippet) => {
let lt_pos = snippet.find('\'');
if let Some(lt_pos) = lt_pos {
format!("&{}mut self", &snippet[lt_pos..snippet.len() - 4])
} else {
"&mut self".to_string()
Ok(snippet) if snippet.ends_with("self") => {
(span.with_hi(span.hi() - BytePos(4)).shrink_to_hi(), "mut ".to_string())
}
}
_ => "&mut self".to_string(),
_ => (span, "&mut self".to_string()),
}
}

View file

@ -160,7 +160,7 @@ pub trait Callbacks {
fn after_crate_root_parsing(
&mut self,
_compiler: &interface::Compiler,
_queries: &ast::Crate,
_krate: &mut ast::Crate,
) -> Compilation {
Compilation::Continue
}
@ -311,7 +311,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
// Parse the crate root source code (doesn't parse submodules yet)
// Everything else is parsed during macro expansion.
let krate = passes::parse(sess);
let mut krate = passes::parse(sess);
// If pretty printing is requested: Figure out the representation, print it and exit
if let Some(pp_mode) = sess.opts.pretty {
@ -328,7 +328,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
return early_exit();
}
if callbacks.after_crate_root_parsing(compiler, &krate) == Compilation::Stop {
if callbacks.after_crate_root_parsing(compiler, &mut krate) == Compilation::Stop {
return early_exit();
}

View file

@ -1,6 +1,7 @@
use rustc_errors::Applicability;
use rustc_hir_analysis::autoderef::Autoderef;
use rustc_infer::infer::InferOk;
use rustc_infer::traits::{Obligation, ObligationCauseCode};
use rustc_middle::span_bug;
use rustc_middle::ty::adjustment::{
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, OverloadedDeref,
@ -136,8 +137,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut self_ty = adjusted_ty;
if unsize {
// We only unsize arrays here.
if let ty::Array(element_ty, _) = adjusted_ty.kind() {
self_ty = Ty::new_slice(self.tcx, *element_ty);
if let ty::Array(element_ty, ct) = *adjusted_ty.kind() {
self.register_predicate(Obligation::new(
self.tcx,
self.cause(base_expr.span, ObligationCauseCode::ArrayLen(adjusted_ty)),
self.param_env,
ty::ClauseKind::ConstArgHasType(ct, self.tcx.types.usize),
));
self_ty = Ty::new_slice(self.tcx, element_ty);
} else {
continue;
}

View file

@ -194,6 +194,9 @@ pub enum ObligationCauseCode<'tcx> {
/// A slice or array is WF only if `T: Sized`.
SliceOrArrayElem,
/// An array `[T; N]` can only be indexed (and is only well-formed if) `N` has type usize.
ArrayLen(Ty<'tcx>),
/// A tuple is WF only if its middle elements are `Sized`.
TupleElem,

View file

@ -165,6 +165,8 @@ trait_selection_explicit_lifetime_required_with_param_type = explicit lifetime r
trait_selection_fn_consider_casting = consider casting the fn item to a fn pointer: `{$casting}`
trait_selection_fn_consider_casting_both = consider casting both fn items to fn pointers using `as {$sig}`
trait_selection_fn_uniq_types = different fn items have unique types, even if their signatures are the same
trait_selection_fps_cast = consider casting to a fn pointer
trait_selection_fps_cast_both = consider casting both fn items to fn pointers using `as {$expected_sig}`

View file

@ -1844,7 +1844,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.suggest_tuple_pattern(cause, &exp_found, diag);
self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
self.suggest_function_pointers(cause, span, &exp_found, diag);
self.suggest_function_pointers(cause, span, &exp_found, terr, diag);
self.suggest_turning_stmt_into_expr(cause, &exp_found, diag);
}
}

View file

@ -12,6 +12,7 @@ use rustc_middle::traits::{
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
StatementAsExpression,
};
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self as ty, GenericArgKind, IsSuggestable, Ty, TypeVisitableExt};
use rustc_span::{Span, sym};
@ -20,7 +21,7 @@ use tracing::debug;
use crate::error_reporting::TypeErrCtxt;
use crate::error_reporting::infer::hir::Path;
use crate::errors::{
ConsiderAddingAwait, FnConsiderCasting, FnItemsAreDistinct, FnUniqTypes,
ConsiderAddingAwait, FnConsiderCasting, FnConsiderCastingBoth, FnItemsAreDistinct, FnUniqTypes,
FunctionPointerSuggestion, SuggestAccessingField, SuggestRemoveSemiOrReturnBinding,
SuggestTuplePatternMany, SuggestTuplePatternOne, TypeErrorAdditionalDiags,
};
@ -381,14 +382,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}
pub(super) fn suggest_function_pointers(
pub fn suggest_function_pointers_impl(
&self,
cause: &ObligationCause<'tcx>,
span: Span,
span: Option<Span>,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
diag: &mut Diag<'_>,
) {
debug!("suggest_function_pointers(cause={:?}, exp_found={:?})", cause, exp_found);
let ty::error::ExpectedFound { expected, found } = exp_found;
let expected_inner = expected.peel_refs();
let found_inner = found.peel_refs();
@ -411,6 +410,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
return;
}
let Some(span) = span else {
let casting = format!("{fn_name} as {sig}");
diag.subdiagnostic(FnItemsAreDistinct);
diag.subdiagnostic(FnConsiderCasting { casting });
return;
};
let sugg = match (expected.is_ref(), found.is_ref()) {
(true, false) => FunctionPointerSuggestion::UseRef { span, fn_name },
(false, true) => FunctionPointerSuggestion::RemoveRef { span, fn_name },
@ -445,6 +451,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
let fn_name = self.tcx.def_path_str_with_args(*did2, args2);
let Some(span) = span else {
diag.subdiagnostic(FnConsiderCastingBoth { sig: *expected_sig });
return;
};
let sug = if found.is_ref() {
FunctionPointerSuggestion::CastBothRef {
span,
@ -488,6 +500,23 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
};
}
pub(super) fn suggest_function_pointers(
&self,
cause: &ObligationCause<'tcx>,
span: Span,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
terr: TypeError<'tcx>,
diag: &mut Diag<'_>,
) {
debug!("suggest_function_pointers(cause={:?}, exp_found={:?})", cause, exp_found);
if exp_found.expected.peel_refs().is_fn() && exp_found.found.peel_refs().is_fn() {
self.suggest_function_pointers_impl(Some(span), exp_found, diag);
} else if let TypeError::Sorts(exp_found) = terr {
self.suggest_function_pointers_impl(None, &exp_found, diag);
}
}
pub fn should_suggest_as_ref_kind(
&self,
expected: Ty<'tcx>,

View file

@ -1969,6 +1969,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
StringPart::highlighted(exp_found.found.to_string()),
StringPart::normal("`"),
]);
self.suggest_function_pointers_impl(None, &exp_found, err);
}
true

View file

@ -2769,6 +2769,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
ObligationCauseCode::SliceOrArrayElem => {
err.note("slice and array elements must have `Sized` type");
}
ObligationCauseCode::ArrayLen(array_ty) => {
err.note(format!("the length of array `{array_ty}` must be type `usize`"));
}
ObligationCauseCode::TupleElem => {
err.note("only the last element of a tuple may have a dynamically sized type");
}

View file

@ -1496,6 +1496,12 @@ pub struct FnConsiderCasting {
pub casting: String,
}
#[derive(Subdiagnostic)]
#[help(trait_selection_fn_consider_casting_both)]
pub struct FnConsiderCastingBoth<'a> {
pub sig: Binder<'a, FnSig<'a>>,
}
#[derive(Subdiagnostic)]
pub enum SuggestAccessingField<'a> {
#[suggestion(

View file

@ -689,7 +689,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
self.require_sized(subty, ObligationCauseCode::SliceOrArrayElem);
// Note that the len being WF is implicitly checked while visiting.
// Here we just check that it's of type usize.
let cause = self.cause(ObligationCauseCode::Misc);
let cause = self.cause(ObligationCauseCode::ArrayLen(t));
self.out.push(traits::Obligation::with_depth(
tcx,
cause,

View file

@ -1,7 +1,7 @@
use crate::io::{Read, Write, pipe};
#[test]
#[cfg(all(windows, unix, not(miri)))]
#[cfg(all(any(unix, windows), not(miri)))]
fn pipe_creation_clone_and_rw() {
let (rx, tx) = pipe().unwrap();

View file

@ -43,10 +43,6 @@ runners:
os: windows-2022-8core-32gb
<<: *base-job
- &job-windows-16c
os: windows-2022-16core-64gb
<<: *base-job
- &job-aarch64-linux
# Free some disk space to avoid running out of space during the build.
free_disk: true

View file

@ -58,7 +58,7 @@ impl rustc_driver::Callbacks for MyCallbacks {
fn after_crate_root_parsing(
&mut self,
_compiler: &Compiler,
krate: &rustc_ast::Crate,
krate: &mut rustc_ast::Crate,
) -> Compilation {
for item in &krate.items {
println!("{}", item_to_string(&item));

View file

@ -58,7 +58,7 @@ impl rustc_driver::Callbacks for MyCallbacks {
fn after_crate_root_parsing(
&mut self,
_compiler: &Compiler,
krate: &rustc_ast::Crate,
krate: &mut rustc_ast::Crate,
) -> Compilation {
for item in &krate.items {
println!("{}", item_to_string(&item));

View file

@ -150,9 +150,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.16.0"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]]
name = "byteorder"
@ -191,9 +191,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.5.26"
version = "4.5.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783"
checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796"
dependencies = [
"clap_builder",
"clap_derive",
@ -201,9 +201,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.26"
version = "4.5.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121"
checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7"
dependencies = [
"anstream",
"anstyle",
@ -214,9 +214,9 @@ dependencies = [
[[package]]
name = "clap_complete"
version = "4.5.42"
version = "4.5.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33a7e468e750fa4b6be660e8b5651ad47372e8fb114030b594c2d75d48c5ffd0"
checksum = "0952013545c9c6dca60f491602655b795c6c062ab180c9cb0bccb83135461861"
dependencies = [
"clap",
]
@ -253,9 +253,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "cpufeatures"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3"
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
dependencies = [
"libc",
]
@ -750,9 +750,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.7.0"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652"
dependencies = [
"equivalent",
"hashbrown",
@ -867,9 +867,9 @@ dependencies = [
[[package]]
name = "mdbook"
version = "0.4.43"
version = "0.4.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe1f98b8d66e537d2f0ba06e7dec4f44001deec539a2d18bfc102d6a86189148"
checksum = "f9da1e54401fe5d45a664c57e112e70f18e8c5a73e268c179305b932ee864574"
dependencies = [
"ammonia",
"anyhow",
@ -1372,9 +1372,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.43"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.8.0",
"errno",
@ -1391,9 +1391,9 @@ checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
[[package]]
name = "ryu"
version = "1.0.18"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd"
[[package]]
name = "same-file"
@ -1412,9 +1412,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "semver"
version = "1.0.24"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
[[package]]
name = "serde"
@ -1438,9 +1438,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.135"
version = "1.0.138"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
dependencies = [
"itoa",
"memchr",
@ -1732,9 +1732,9 @@ checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
[[package]]
name = "unicode-ident"
version = "1.0.14"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
[[package]]
name = "unicode-width"
@ -1972,9 +1972,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winnow"
version = "0.6.24"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a"
checksum = "ad699df48212c6cc6eb4435f35500ac6fd3b9913324f938aea302022ce19d310"
dependencies = [
"memchr",
]

View file

@ -14,6 +14,6 @@ mdbook-i18n-helpers = "0.3.3"
mdbook-spec = { path = "../../doc/reference/mdbook-spec" }
[dependencies.mdbook]
version = "0.4.37"
version = "0.4.44"
default-features = false
features = ["search"]

View file

@ -1,6 +0,0 @@
//@ known-bug: #131103
struct Struct<const N: i128>(pub [u8; N]);
pub fn function(value: Struct<3>) -> u8 {
value.0[0]
}

View file

@ -22,170 +22,164 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: cannot use register `x16`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:48:18
--> $DIR/bad-reg.rs:46:18
|
LL | asm!("", out("x16") _);
| ^^^^^^^^^^^^
error: cannot use register `x17`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:50:18
--> $DIR/bad-reg.rs:48:18
|
LL | asm!("", out("x17") _);
| ^^^^^^^^^^^^
error: cannot use register `x18`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:52:18
--> $DIR/bad-reg.rs:50:18
|
LL | asm!("", out("x18") _);
| ^^^^^^^^^^^^
error: cannot use register `x19`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:54:18
--> $DIR/bad-reg.rs:52:18
|
LL | asm!("", out("x19") _);
| ^^^^^^^^^^^^
error: cannot use register `x20`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:56:18
--> $DIR/bad-reg.rs:54:18
|
LL | asm!("", out("x20") _);
| ^^^^^^^^^^^^
error: cannot use register `x21`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:58:18
--> $DIR/bad-reg.rs:56:18
|
LL | asm!("", out("x21") _);
| ^^^^^^^^^^^^
error: cannot use register `x22`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:60:18
--> $DIR/bad-reg.rs:58:18
|
LL | asm!("", out("x22") _);
| ^^^^^^^^^^^^
error: cannot use register `x23`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:62:18
--> $DIR/bad-reg.rs:60:18
|
LL | asm!("", out("x23") _);
| ^^^^^^^^^^^^
error: cannot use register `x24`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:64:18
--> $DIR/bad-reg.rs:62:18
|
LL | asm!("", out("x24") _);
| ^^^^^^^^^^^^
error: cannot use register `x25`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:66:18
--> $DIR/bad-reg.rs:64:18
|
LL | asm!("", out("x25") _);
| ^^^^^^^^^^^^
error: cannot use register `x26`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:68:18
--> $DIR/bad-reg.rs:66:18
|
LL | asm!("", out("x26") _);
| ^^^^^^^^^^^^
error: cannot use register `x27`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:70:18
--> $DIR/bad-reg.rs:68:18
|
LL | asm!("", out("x27") _);
| ^^^^^^^^^^^^
error: cannot use register `x28`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:72:18
--> $DIR/bad-reg.rs:70:18
|
LL | asm!("", out("x28") _);
| ^^^^^^^^^^^^
error: cannot use register `x29`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:74:18
--> $DIR/bad-reg.rs:72:18
|
LL | asm!("", out("x29") _);
| ^^^^^^^^^^^^
error: cannot use register `x30`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:76:18
--> $DIR/bad-reg.rs:74:18
|
LL | asm!("", out("x30") _);
| ^^^^^^^^^^^^
error: cannot use register `x31`: register can't be used with the `e` target feature
--> $DIR/bad-reg.rs:78:18
--> $DIR/bad-reg.rs:76:18
|
LL | asm!("", out("x31") _);
| ^^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:82:26
--> $DIR/bad-reg.rs:80:26
|
LL | asm!("/* {} */", in(freg) f);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:84:26
--> $DIR/bad-reg.rs:82:26
|
LL | asm!("/* {} */", out(freg) _);
| ^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:86:26
--> $DIR/bad-reg.rs:84:26
|
LL | asm!("/* {} */", in(freg) d);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:89:26
--> $DIR/bad-reg.rs:87:26
|
LL | asm!("/* {} */", out(freg) d);
| ^^^^^^^^^^^
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -193,7 +187,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -201,12 +195,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 34 previous errors
error: aborting due to 33 previous errors

View file

@ -22,50 +22,44 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -73,7 +67,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -81,12 +75,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 14 previous errors
error: aborting due to 13 previous errors

View file

@ -22,74 +22,68 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:82:26
--> $DIR/bad-reg.rs:80:26
|
LL | asm!("/* {} */", in(freg) f);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:84:26
--> $DIR/bad-reg.rs:82:26
|
LL | asm!("/* {} */", out(freg) _);
| ^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:86:26
--> $DIR/bad-reg.rs:84:26
|
LL | asm!("/* {} */", in(freg) d);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:89:26
--> $DIR/bad-reg.rs:87:26
|
LL | asm!("/* {} */", out(freg) d);
| ^^^^^^^^^^^
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -97,7 +91,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -105,12 +99,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 18 previous errors
error: aborting due to 17 previous errors

View file

@ -22,50 +22,44 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: `d` target feature is not enabled
--> $DIR/bad-reg.rs:86:35
--> $DIR/bad-reg.rs:84:35
|
LL | asm!("/* {} */", in(freg) d);
| ^
@ -73,7 +67,7 @@ LL | asm!("/* {} */", in(freg) d);
= note: this is required to use type `f64` with register class `freg`
error: `d` target feature is not enabled
--> $DIR/bad-reg.rs:89:36
--> $DIR/bad-reg.rs:87:36
|
LL | asm!("/* {} */", out(freg) d);
| ^
@ -81,7 +75,7 @@ LL | asm!("/* {} */", out(freg) d);
= note: this is required to use type `f64` with register class `freg`
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -89,7 +83,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -97,12 +91,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 16 previous errors
error: aborting due to 15 previous errors

View file

@ -22,50 +22,44 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -73,7 +67,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -81,12 +75,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 14 previous errors
error: aborting due to 13 previous errors

View file

@ -22,74 +22,68 @@ error: invalid register `gp`: the global pointer cannot be used as an operand fo
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `gp`: the global pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("gp") _);
| ^^^^^^^^^^^
error: invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:43:18
--> $DIR/bad-reg.rs:41:18
|
LL | asm!("", out("tp") _);
| ^^^^^^^^^^^
error: invalid register `zero`: the zero register cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", out("zero") _);
| ^^^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:96:18
--> $DIR/bad-reg.rs:94:18
|
LL | asm!("", in("v0") x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:99:18
--> $DIR/bad-reg.rs:97:18
|
LL | asm!("", out("v0") x);
| ^^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:102:26
--> $DIR/bad-reg.rs:100:26
|
LL | asm!("/* {} */", in(vreg) x);
| ^^^^^^^^^^
error: register class `vreg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:105:26
--> $DIR/bad-reg.rs:103:26
|
LL | asm!("/* {} */", out(vreg) _);
| ^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:82:26
--> $DIR/bad-reg.rs:80:26
|
LL | asm!("/* {} */", in(freg) f);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:84:26
--> $DIR/bad-reg.rs:82:26
|
LL | asm!("/* {} */", out(freg) _);
| ^^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:86:26
--> $DIR/bad-reg.rs:84:26
|
LL | asm!("/* {} */", in(freg) d);
| ^^^^^^^^^^
error: register class `freg` requires at least one of the following target features: d, f
--> $DIR/bad-reg.rs:89:26
--> $DIR/bad-reg.rs:87:26
|
LL | asm!("/* {} */", out(freg) d);
| ^^^^^^^^^^^
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:96:27
--> $DIR/bad-reg.rs:94:27
|
LL | asm!("", in("v0") x);
| ^
@ -97,7 +91,7 @@ LL | asm!("", in("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:99:28
--> $DIR/bad-reg.rs:97:28
|
LL | asm!("", out("v0") x);
| ^
@ -105,12 +99,12 @@ LL | asm!("", out("v0") x);
= note: register class `vreg` supports these types:
error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:102:35
--> $DIR/bad-reg.rs:100:35
|
LL | asm!("/* {} */", in(vreg) x);
| ^
|
= note: register class `vreg` supports these types:
error: aborting due to 18 previous errors
error: aborting due to 17 previous errors

View file

@ -38,8 +38,6 @@ fn f() {
//~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand for inline asm
asm!("", out("gp") _);
//~^ ERROR invalid register `gp`: the global pointer cannot be used as an operand for inline asm
asm!("", out("gp") _);
//~^ ERROR invalid register `gp`: the global pointer cannot be used as an operand for inline asm
asm!("", out("tp") _);
//~^ ERROR invalid register `tp`: the thread pointer cannot be used as an operand for inline asm
asm!("", out("zero") _);

View file

@ -4,7 +4,7 @@ struct S {
}
impl S {
async fn bar(&self) { //~ HELP consider changing this to be a mutable reference
//~| SUGGESTION &mut self
//~| SUGGESTION mut
self.foo += 1; //~ ERROR cannot assign to `self.foo`, which is behind a `&` reference [E0594]
}
}

View file

@ -7,7 +7,7 @@ LL | self.foo += 1;
help: consider changing this to be a mutable reference
|
LL | async fn bar(&mut self) {
| ~~~~~~~~~
| +++
error: aborting due to 1 previous error

View file

@ -41,7 +41,7 @@ LL | let a16 = self.read_word() as u16;
help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition
|
LL | extern "C" fn read_dword(&'_ mut self) -> u16 {
| ~~~~~~~~~~~~
| +++
error[E0596]: cannot borrow `*self` as mutable, as it is behind a `&` reference
--> $DIR/trait-impl-argument-difference-ice.rs:18:19
@ -52,7 +52,7 @@ LL | let b16 = self.read_word() as u16;
help: consider changing this to be a mutable reference in the `impl` method and the `trait` definition
|
LL | extern "C" fn read_dword(&'_ mut self) -> u16 {
| ~~~~~~~~~~~~
| +++
error: aborting due to 5 previous errors; 1 warning emitted

View file

@ -3,6 +3,8 @@ error: the constant `N` is not of type `usize`
|
LL | impl<const N: u64> Q for [u8; N] {
| ^^^^^^^ expected `usize`, found `u64`
|
= note: the length of array `[u8; N]` must be type `usize`
error: the constant `13` is not of type `u64`
--> $DIR/bad-subst-const-kind.rs:13:24

View file

@ -3,6 +3,8 @@ error: the constant `N` is not of type `usize`
|
LL | impl<const N: u64> Q for [u8; N] {}
| ^^^^^^^ expected `usize`, found `u64`
|
= note: the length of array `[u8; N]` must be type `usize`
error[E0046]: not all trait items implemented, missing: `ASSOC`
--> $DIR/type_mismatch.rs:8:1

View file

@ -0,0 +1,13 @@
struct Struct<const N: i128>(pub [u8; N]);
//~^ ERROR the constant `N` is not of type `usize`
pub fn function(value: Struct<3>) -> u8 {
value.0[0]
//~^ ERROR the constant `3` is not of type `usize`
// FIXME(const_generics): Ideally we wouldn't report the above error
// b/c `Struct<_>` is never well formed, but I'd rather report too many
// errors rather than ICE the compiler.
}
fn main() {}

View file

@ -0,0 +1,18 @@
error: the constant `N` is not of type `usize`
--> $DIR/index_array_bad_type.rs:1:34
|
LL | struct Struct<const N: i128>(pub [u8; N]);
| ^^^^^^^ expected `usize`, found `i128`
|
= note: the length of array `[u8; N]` must be type `usize`
error: the constant `3` is not of type `usize`
--> $DIR/index_array_bad_type.rs:5:5
|
LL | value.0[0]
| ^^^^^^^ expected `usize`, found `i128`
|
= note: the length of array `[u8; 3]` must be type `usize`
error: aborting due to 2 previous errors

View file

@ -3,6 +3,8 @@ error: the constant `W` is not of type `usize`
|
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
| ^^^^^^^^^^^^^ expected `usize`, found `bool`
|
= note: the length of array `[[u32; H]; W]` must be type `usize`
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:11:9
@ -18,6 +20,8 @@ error: the constant `W` is not of type `usize`
|
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool`
|
= note: the length of array `[[u32; H]; W]` must be type `usize`
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:26:9

View file

@ -3,6 +3,8 @@ error: the constant `N` is not of type `usize`
|
LL | fn bar<const N: u8>() -> [u8; N] {}
| ^^^^^^^ expected `usize`, found `u8`
|
= note: the length of array `[u8; N]` must be type `usize`
error: the constant `N` is not of type `u8`
--> $DIR/type_mismatch.rs:2:11

View file

@ -3,6 +3,8 @@ error: the constant `N` is not of type `usize`
|
LL | arr: [i32; N],
| ^^^^^^^^ expected `usize`, found `u8`
|
= note: the length of array `[i32; N]` must be type `usize`
error[E0308]: mismatched types
--> $DIR/bad-array-size-in-type-err.rs:7:38
@ -15,6 +17,8 @@ error: the constant `2` is not of type `usize`
|
LL | let _ = BadArraySize::<2> { arr: [0, 0, 0] };
| ^^^^^^^^^ expected `usize`, found `u8`
|
= note: the length of array `[i32; 2]` must be type `usize`
error: aborting due to 3 previous errors

View file

@ -0,0 +1,9 @@
//@ edition: 2021
fn foo() {}
fn main() {
let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect(); //~ ERROR
let _: Vec<fn()> = [foo].into_iter().collect(); //~ ERROR
let _: Vec<fn()> = Vec::from([foo]); //~ ERROR
}

View file

@ -0,0 +1,59 @@
error[E0277]: a value of type `Vec<(&str, fn())>` cannot be built from an iterator over elements of type `(&str, fn() {foo})`
--> $DIR/casting-fn-item-to-fn-pointer.rs:6:59
|
LL | let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect();
| ^^^^^^^ value of type `Vec<(&str, fn())>` cannot be built from `std::iter::Iterator<Item=(&str, fn() {foo})>`
|
= help: the trait `FromIterator<(&_, fn() {foo})>` is not implemented for `Vec<(&str, fn())>`
but trait `FromIterator<(&_, fn())>` is implemented for it
= help: for that trait implementation, expected `fn()`, found `fn() {foo}`
= note: fn items are distinct from fn pointers
= help: consider casting the fn item to a fn pointer: `foo as fn()`
note: the method call chain might not have had the expected associated types
--> $DIR/casting-fn-item-to-fn-pointer.rs:6:47
|
LL | let _: Vec<(&str, fn())> = [("foo", foo)].into_iter().collect();
| -------------- ^^^^^^^^^^^ `Iterator::Item` is `(&str, fn() {foo})` here
| |
| this expression has type `[(&str, fn() {foo}); 1]`
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `Vec<fn()>` cannot be built from an iterator over elements of type `fn() {foo}`
--> $DIR/casting-fn-item-to-fn-pointer.rs:7:42
|
LL | let _: Vec<fn()> = [foo].into_iter().collect();
| ^^^^^^^ value of type `Vec<fn()>` cannot be built from `std::iter::Iterator<Item=fn() {foo}>`
|
= help: the trait `FromIterator<fn() {foo}>` is not implemented for `Vec<fn()>`
but trait `FromIterator<fn()>` is implemented for it
= help: for that trait implementation, expected `fn()`, found `fn() {foo}`
= note: fn items are distinct from fn pointers
= help: consider casting the fn item to a fn pointer: `foo as fn()`
note: the method call chain might not have had the expected associated types
--> $DIR/casting-fn-item-to-fn-pointer.rs:7:30
|
LL | let _: Vec<fn()> = [foo].into_iter().collect();
| ----- ^^^^^^^^^^^ `Iterator::Item` is `fn() {foo}` here
| |
| this expression has type `[fn() {foo}; 1]`
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0308]: mismatched types
--> $DIR/casting-fn-item-to-fn-pointer.rs:8:24
|
LL | let _: Vec<fn()> = Vec::from([foo]);
| --------- ^^^^^^^^^^^^^^^^ expected `Vec<fn()>`, found `Vec<fn() {foo}>`
| |
| expected due to this
|
= note: expected struct `Vec<fn()>`
found struct `Vec<fn() {foo}>`
= note: fn items are distinct from fn pointers
= help: consider casting the fn item to a fn pointer: `foo as fn()`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View file

@ -7,7 +7,7 @@ LL | self.s.push('x');
help: consider changing this to be a mutable reference
|
LL | fn f(&mut self) {
| ~~~~~~~~~
| +++
error: aborting due to 1 previous error

View file

@ -18,7 +18,7 @@ LL | let _ = &mut self.x;
help: consider changing this to be a mutable reference
|
LL | fn foo<'z>(&'z mut self) {
| ~~~~~~~~~~~~
| +++
error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:20:17
@ -29,7 +29,7 @@ LL | let _ = &mut self.x;
help: consider changing this to be a mutable reference
|
LL | fn foo1(&mut self, other: &Z) {
| ~~~~~~~~~
| +++
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:21:17
@ -51,7 +51,7 @@ LL | let _ = &mut self.x;
help: consider changing this to be a mutable reference
|
LL | fn foo2<'a>(&'a mut self, other: &Z) {
| ~~~~~~~~~~~~
| +++
error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
--> $DIR/issue-39544.rs:26:17

View file

@ -7,7 +7,7 @@ LL | self.how_hungry -= 5;
help: consider changing this to be a mutable reference
|
LL | pub fn eat(&mut self) {
| ~~~~~~~~~
| +++
error: aborting due to 1 previous error

View file

@ -3,7 +3,7 @@ struct X(usize);
impl X {
fn zap(&self) {
//~^ HELP
//~| SUGGESTION &mut self
//~| SUGGESTION mut
self.0 = 32;
//~^ ERROR
}

View file

@ -7,7 +7,7 @@ LL | self.0 = 32;
help: consider changing this to be a mutable reference
|
LL | fn zap(&mut self) {
| ~~~~~~~~~
| +++
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
--> $DIR/suggest-ref-mut.rs:15:5

View file

@ -10,6 +10,8 @@ LL | Self { map }
|
= note: expected struct `HashMap<u16, fn(_) -> Pin<Box<(dyn Future<Output = ()> + Send + 'static)>>>`
found struct `HashMap<{integer}, fn(_) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>`
= note: fn items are distinct from fn pointers
= help: consider casting the fn item to a fn pointer: `<Struct as Trait>::do_something::<'_> as fn(u8) -> Pin<Box<(dyn Future<Output = ()> + Send + 'static)>>`
error: aborting due to 1 previous error

View file

@ -9,6 +9,8 @@ error: the constant `N` is not of type `usize`
|
LL | fn func<const N: u32>() -> [(); N];
| ^^^^^^^ expected `usize`, found `u32`
|
= note: the length of array `[(); N]` must be type `usize`
error: aborting due to 2 previous errors