mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 05:56:56 +00:00
Auto merge of #134294 - matthiaskrgr:rollup-anh6io8, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #134252 (Fix `Path::is_absolute` on Hermit) - #134254 (Fix building `std` for Hermit after `c_char` change) - #134255 (Update includes in `/library/core/src/error.rs`.) - #134261 (Document the symbol Visibility enum) - #134262 (Arbitrary self types v2: adjust diagnostic.) - #134265 (Rename `ty_def_id` so people will stop using it by accident) - #134271 (Arbitrary self types v2: better feature gate test) - #134274 (Add check-pass test for `&raw`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ed14192604
@ -246,6 +246,12 @@ hir_analysis_invalid_receiver_ty = invalid `self` parameter type: `{$receiver_ty
|
||||
hir_analysis_invalid_receiver_ty_help =
|
||||
consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types =
|
||||
consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
hir_analysis_invalid_receiver_ty_no_arbitrary_self_types = invalid `self` parameter type: `{$receiver_ty}`
|
||||
.note = type of `self` must be `Self` or a type that dereferences to it
|
||||
|
||||
hir_analysis_invalid_union_field =
|
||||
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
|
||||
.note = union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
|
||||
|
@ -1748,9 +1748,15 @@ fn check_method_receiver<'tcx>(
|
||||
// Report error; would not have worked with `arbitrary_self_types[_pointers]`.
|
||||
{
|
||||
match receiver_validity_err {
|
||||
ReceiverValidityError::DoesNotDeref => {
|
||||
ReceiverValidityError::DoesNotDeref if arbitrary_self_types_level.is_some() => {
|
||||
tcx.dcx().emit_err(errors::InvalidReceiverTy { span, receiver_ty })
|
||||
}
|
||||
ReceiverValidityError::DoesNotDeref => {
|
||||
tcx.dcx().emit_err(errors::InvalidReceiverTyNoArbitrarySelfTypes {
|
||||
span,
|
||||
receiver_ty,
|
||||
})
|
||||
}
|
||||
ReceiverValidityError::MethodGenericParamUsed => {
|
||||
tcx.dcx().emit_err(errors::InvalidGenericReceiverTy { span, receiver_ty })
|
||||
}
|
||||
|
@ -1655,6 +1655,16 @@ pub(crate) struct NonConstRange {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_analysis_invalid_receiver_ty_no_arbitrary_self_types, code = E0307)]
|
||||
#[note]
|
||||
#[help(hir_analysis_invalid_receiver_ty_help_no_arbitrary_self_types)]
|
||||
pub(crate) struct InvalidReceiverTyNoArbitrarySelfTypes<'tcx> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub receiver_ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(hir_analysis_invalid_receiver_ty, code = E0307)]
|
||||
#[note]
|
||||
|
@ -9,7 +9,6 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::query::Key;
|
||||
use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _};
|
||||
use rustc_middle::ty::{
|
||||
self, AdtDef, Binder, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeVisitableExt,
|
||||
@ -1007,8 +1006,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||
)),
|
||||
..
|
||||
}) = node
|
||||
&& let Some(ty_def_id) = qself_ty.ty_def_id()
|
||||
&& let [inherent_impl] = tcx.inherent_impls(ty_def_id)
|
||||
&& let Some(adt_def) = qself_ty.ty_adt_def()
|
||||
&& let [inherent_impl] = tcx.inherent_impls(adt_def.did())
|
||||
&& let name = format!("{ident2}_{ident3}")
|
||||
&& let Some(ty::AssocItem { kind: ty::AssocKind::Fn, .. }) = tcx
|
||||
.associated_items(inherent_impl)
|
||||
|
@ -294,10 +294,22 @@ pub enum Linkage {
|
||||
Common,
|
||||
}
|
||||
|
||||
/// Specifies the symbol visibility with regards to dynamic linking.
|
||||
///
|
||||
/// Visibility doesn't have any effect when linkage is internal.
|
||||
///
|
||||
/// DSO means dynamic shared object, that is a dynamically linked executable or dylib.
|
||||
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
|
||||
pub enum Visibility {
|
||||
/// Export the symbol from the DSO and apply overrides of the symbol by outside DSOs to within
|
||||
/// the DSO if the object file format supports this.
|
||||
Default,
|
||||
/// Hide the symbol outside of the defining DSO even when external linkage is used to export it
|
||||
/// from the object file.
|
||||
Hidden,
|
||||
/// Export the symbol from the DSO, but don't apply overrides of the symbol by outside DSOs to
|
||||
/// within the DSO. Equivalent to default visibility with object file formats that don't support
|
||||
/// overriding exported symbols by another DSO.
|
||||
Protected,
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,8 @@ pub trait Key: Sized {
|
||||
None
|
||||
}
|
||||
|
||||
fn ty_def_id(&self) -> Option<DefId> {
|
||||
/// Used to detect when ADT def ids are used as keys in a cycle for better error reporting.
|
||||
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@ -423,7 +424,7 @@ impl<'tcx> Key for Ty<'tcx> {
|
||||
DUMMY_SP
|
||||
}
|
||||
|
||||
fn ty_def_id(&self) -> Option<DefId> {
|
||||
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
||||
match *self.kind() {
|
||||
ty::Adt(adt, _) => Some(adt.did()),
|
||||
ty::Coroutine(def_id, ..) => Some(def_id),
|
||||
@ -471,8 +472,8 @@ impl<'tcx, T: Key> Key for ty::PseudoCanonicalInput<'tcx, T> {
|
||||
self.value.default_span(tcx)
|
||||
}
|
||||
|
||||
fn ty_def_id(&self) -> Option<DefId> {
|
||||
self.value.ty_def_id()
|
||||
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
||||
self.value.def_id_for_ty_in_cycle()
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,7 +594,7 @@ impl<'tcx> Key for (ValidityRequirement, ty::PseudoCanonicalInput<'tcx, Ty<'tcx>
|
||||
DUMMY_SP
|
||||
}
|
||||
|
||||
fn ty_def_id(&self) -> Option<DefId> {
|
||||
fn def_id_for_ty_in_cycle(&self) -> Option<DefId> {
|
||||
match self.1.value.kind() {
|
||||
ty::Adt(adt, _) => Some(adt.did()),
|
||||
_ => None,
|
||||
|
@ -100,7 +100,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
|
||||
}
|
||||
for info in &cycle_error.cycle {
|
||||
if info.query.dep_kind == dep_kinds::representability_adt_ty
|
||||
&& let Some(def_id) = info.query.ty_def_id
|
||||
&& let Some(def_id) = info.query.def_id_for_ty_in_cycle
|
||||
&& let Some(def_id) = def_id.as_local()
|
||||
&& !item_and_field_ids.iter().any(|&(id, _)| id == def_id)
|
||||
{
|
||||
@ -182,7 +182,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
|
||||
&cycle_error.cycle,
|
||||
|cycle| {
|
||||
if cycle[0].query.dep_kind == dep_kinds::layout_of
|
||||
&& let Some(def_id) = cycle[0].query.ty_def_id
|
||||
&& let Some(def_id) = cycle[0].query.def_id_for_ty_in_cycle
|
||||
&& let Some(def_id) = def_id.as_local()
|
||||
&& let def_kind = tcx.def_kind(def_id)
|
||||
&& matches!(def_kind, DefKind::Closure)
|
||||
@ -209,7 +209,7 @@ impl<'tcx, T> Value<TyCtxt<'tcx>> for Result<T, &'_ ty::layout::LayoutError<'_>>
|
||||
if frame.query.dep_kind != dep_kinds::layout_of {
|
||||
continue;
|
||||
}
|
||||
let Some(frame_def_id) = frame.query.ty_def_id else {
|
||||
let Some(frame_def_id) = frame.query.def_id_for_ty_in_cycle else {
|
||||
continue;
|
||||
};
|
||||
let Some(frame_coroutine_kind) = tcx.coroutine_kind(frame_def_id) else {
|
||||
|
@ -349,9 +349,9 @@ pub(crate) fn create_query_frame<
|
||||
hasher.finish::<Hash64>()
|
||||
})
|
||||
};
|
||||
let ty_def_id = key.ty_def_id();
|
||||
let def_id_for_ty_in_cycle = key.def_id_for_ty_in_cycle();
|
||||
|
||||
QueryStackFrame::new(description, span, def_id, def_kind, kind, ty_def_id, hash)
|
||||
QueryStackFrame::new(description, span, def_id, def_kind, kind, def_id_for_ty_in_cycle, hash)
|
||||
}
|
||||
|
||||
pub(crate) fn encode_query_results<'a, 'tcx, Q>(
|
||||
|
@ -33,7 +33,7 @@ pub struct QueryStackFrame {
|
||||
pub def_id: Option<DefId>,
|
||||
pub def_kind: Option<DefKind>,
|
||||
/// A def-id that is extracted from a `Ty` in a query key
|
||||
pub ty_def_id: Option<DefId>,
|
||||
pub def_id_for_ty_in_cycle: Option<DefId>,
|
||||
pub dep_kind: DepKind,
|
||||
/// This hash is used to deterministically pick
|
||||
/// a query to remove cycles in the parallel compiler.
|
||||
@ -48,10 +48,10 @@ impl QueryStackFrame {
|
||||
def_id: Option<DefId>,
|
||||
def_kind: Option<DefKind>,
|
||||
dep_kind: DepKind,
|
||||
ty_def_id: Option<DefId>,
|
||||
def_id_for_ty_in_cycle: Option<DefId>,
|
||||
hash: impl FnOnce() -> Hash64,
|
||||
) -> Self {
|
||||
Self { description, span, def_id, def_kind, ty_def_id, dep_kind, hash: hash() }
|
||||
Self { description, span, def_id, def_kind, def_id_for_ty_in_cycle, dep_kind, hash: hash() }
|
||||
}
|
||||
|
||||
// FIXME(eddyb) Get more valid `Span`s on queries.
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![stable(feature = "error_in_core", since = "1.81.0")]
|
||||
|
||||
use crate::any::TypeId;
|
||||
use crate::fmt::{Debug, Display, Formatter, Result};
|
||||
use crate::fmt::{self, Debug, Display, Formatter};
|
||||
|
||||
/// `Error` is a trait representing the basic expectations for error values,
|
||||
/// i.e., values of type `E` in [`Result<T, E>`].
|
||||
@ -857,7 +857,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
#[unstable(feature = "error_generic_member_access", issue = "99301")]
|
||||
impl<'a> Debug for Request<'a> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Request").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
@ -2327,7 +2327,9 @@ impl Path {
|
||||
// FIXME: Allow Redox prefixes
|
||||
self.has_root() || has_redox_scheme(self.as_u8_slice())
|
||||
} else {
|
||||
self.has_root() && (cfg!(any(unix, target_os = "wasi")) || self.prefix().is_some())
|
||||
self.has_root()
|
||||
&& (cfg!(any(unix, target_os = "hermit", target_os = "wasi"))
|
||||
|| self.prefix().is_some())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use super::hermit_abi::{
|
||||
self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
|
||||
O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
|
||||
};
|
||||
use crate::ffi::{CStr, OsStr, OsString};
|
||||
use crate::ffi::{CStr, OsStr, OsString, c_char};
|
||||
use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
|
||||
use crate::os::hermit::ffi::OsStringExt;
|
||||
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
|
||||
@ -204,7 +204,7 @@ impl Iterator for ReadDir {
|
||||
// the size of dirent64. The file name is always a C string and terminated by `\0`.
|
||||
// Consequently, we are able to ignore the last byte.
|
||||
let name_bytes =
|
||||
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const i8).to_bytes() };
|
||||
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const c_char).to_bytes() };
|
||||
let entry = DirEntry {
|
||||
root: self.inner.root.clone(),
|
||||
ino: dir.d_ino,
|
||||
@ -445,7 +445,7 @@ impl DirBuilder {
|
||||
|
||||
pub fn mkdir(&self, path: &Path) -> io::Result<()> {
|
||||
run_path_with_cstr(path, &|path| {
|
||||
cvt(unsafe { hermit_abi::mkdir(path.as_ptr(), self.mode.into()) }).map(|_| ())
|
||||
cvt(unsafe { hermit_abi::mkdir(path.as_ptr().cast(), self.mode.into()) }).map(|_| ())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ pub unsafe extern "C" fn runtime_entry(
|
||||
}
|
||||
|
||||
// initialize environment
|
||||
os::init_environment(env as *const *const i8);
|
||||
os::init_environment(env);
|
||||
|
||||
let result = unsafe { main(argc as isize, argv) };
|
||||
|
||||
|
@ -3,7 +3,7 @@ use core::slice::memchr;
|
||||
use super::hermit_abi;
|
||||
use crate::collections::HashMap;
|
||||
use crate::error::Error as StdError;
|
||||
use crate::ffi::{CStr, OsStr, OsString};
|
||||
use crate::ffi::{CStr, OsStr, OsString, c_char};
|
||||
use crate::marker::PhantomData;
|
||||
use crate::os::hermit::ffi::OsStringExt;
|
||||
use crate::path::{self, PathBuf};
|
||||
@ -70,7 +70,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
||||
|
||||
static ENV: Mutex<Option<HashMap<OsString, OsString>>> = Mutex::new(None);
|
||||
|
||||
pub fn init_environment(env: *const *const i8) {
|
||||
pub fn init_environment(env: *const *const c_char) {
|
||||
let mut guard = ENV.lock().unwrap();
|
||||
let map = guard.insert(HashMap::new());
|
||||
|
||||
|
@ -3,13 +3,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::ty::is_copy;
|
||||
use clippy_utils::usage::mutated_variables;
|
||||
use clippy_utils::visitors::{Descend, for_each_expr_without_closures};
|
||||
use clippy_utils::{MaybePath, is_res_lang_ctor, is_trait_method, path_res, path_to_local_id};
|
||||
use clippy_utils::{is_res_lang_ctor, is_trait_method, path_res, path_to_local_id};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::query::Key;
|
||||
use rustc_middle::ty;
|
||||
use rustc_span::sym;
|
||||
|
||||
@ -44,7 +43,6 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>, a
|
||||
if name == "filter_map"
|
||||
&& let hir::ExprKind::Call(expr, args) = body.value.kind
|
||||
&& is_res_lang_ctor(cx, path_res(cx, expr), OptionSome)
|
||||
&& arg_id.ty_def_id() == args[0].hir_id().ty_def_id()
|
||||
&& let hir::ExprKind::Path(_) = args[0].kind
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&dyn Foo`
|
||||
LL | async fn foo(self: &dyn Foo) {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/inference_var_self_argument.rs:5:5
|
||||
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `T`
|
||||
LL | fn is_some(self: T);
|
||||
| ^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-66312.rs:9:8
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0658]: `*const Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:8:18
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:11:18
|
||||
|
|
||||
LL | fn foo(self: *const Self) {}
|
||||
| ^^^^^^^^^^^
|
||||
@ -10,7 +10,7 @@ LL | fn foo(self: *const Self) {}
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
error[E0658]: `*mut Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:12:18
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:15:18
|
||||
|
|
||||
LL | fn bar(self: *mut Self) {}
|
||||
| ^^^^^^^^^
|
||||
@ -21,7 +21,7 @@ LL | fn bar(self: *mut Self) {}
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:2:18
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:5:18
|
||||
|
|
||||
LL | fn foo(self: *const Self);
|
||||
| ^^^^^^^^^^^
|
@ -0,0 +1,36 @@
|
||||
error[E0658]: `*const Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:11:18
|
||||
|
|
||||
LL | fn foo(self: *const Self) {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
|
||||
= help: add `#![feature(arbitrary_self_types_pointers)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
error[E0658]: `*mut Bar` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:15:18
|
||||
|
|
||||
LL | fn bar(self: *mut Self) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
|
||||
= help: add `#![feature(arbitrary_self_types_pointers)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types_pointers` feature
|
||||
--> $DIR/feature-gate-arbitrary-self-types-pointers.rs:5:18
|
||||
|
|
||||
LL | fn foo(self: *const Self);
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
|
||||
= help: add `#![feature(arbitrary_self_types_pointers)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,3 +1,6 @@
|
||||
//@ revisions: default feature
|
||||
#![cfg_attr(feature, feature(arbitrary_self_types))]
|
||||
|
||||
trait Foo {
|
||||
fn foo(self: *const Self); //~ ERROR `*const Self` cannot be used as the type of `self`
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Cell<&Self>`
|
||||
LL | fn cell(self: Cell<&Self>);
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Box<(dyn Trait + 'static)>`
|
||||
LL | fn dyn_instead_of_self(self: Box<dyn Trait>);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
//! The token sequence `&raw` *only* starts a raw borrow expr if it's immediately
|
||||
//! followed by either `const` or `mut`. If that's not the case, the `&` denotes
|
||||
//! the start of a normal borrow expr where `raw` is interpreted as a regular
|
||||
//! identifier and thus denotes the start of a path expr.
|
||||
//!
|
||||
//! This test ensures that we never commit too early/overzealously in the parser
|
||||
//! when encountering the sequence `&raw` (even during parse error recovery) so
|
||||
//! as not to regress preexisting code.
|
||||
|
||||
//@ check-pass
|
||||
|
||||
fn main() { // the odd formatting in here is intentional
|
||||
let raw = 0;
|
||||
let _ = &raw;
|
||||
|
||||
let raw = 0;
|
||||
let local = 1;
|
||||
let _: i32 = &raw *local;
|
||||
|
||||
let raw = |_| ();
|
||||
let local = [0];
|
||||
let () = &raw (local[0]);
|
||||
}
|
||||
|
||||
macro_rules! check {
|
||||
($e:expr) => { compile_error!("expr"); };
|
||||
(&raw $e:expr) => {};
|
||||
}
|
||||
|
||||
check!(&raw local);
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `Bar`
|
||||
LL | fn foo(self: Bar) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: item does not constrain `Bar::{opaque#0}`, but has it in its signature
|
||||
--> $DIR/arbitrary-self-opaque.rs:7:8
|
||||
|
@ -4,8 +4,8 @@ error[E0307]: invalid `self` parameter type: `&SomeType`
|
||||
LL | fn handler(self: &SomeType);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -32,8 +32,8 @@ error[E0307]: invalid `self` parameter type: `()`
|
||||
LL | fn bar(self: ()) {}
|
||||
| ^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -61,8 +61,8 @@ error[E0307]: invalid `self` parameter type: `Smaht<Self, T>`
|
||||
LL | fn foo(self: Smaht<Self, T>);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures
|
||||
--> $DIR/issue-78372.rs:3:1
|
||||
|
@ -22,8 +22,8 @@ error[E0307]: invalid `self` parameter type: `isize`
|
||||
LL | fn foo(self: isize, x: isize) -> isize {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0307]: invalid `self` parameter type: `Bar<isize>`
|
||||
--> $DIR/ufcs-explicit-self-bad.rs:19:18
|
||||
@ -31,8 +31,8 @@ error[E0307]: invalid `self` parameter type: `Bar<isize>`
|
||||
LL | fn foo(self: Bar<isize>, x: isize) -> isize {
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0307]: invalid `self` parameter type: `&Bar<usize>`
|
||||
--> $DIR/ufcs-explicit-self-bad.rs:23:18
|
||||
@ -40,8 +40,8 @@ error[E0307]: invalid `self` parameter type: `&Bar<usize>`
|
||||
LL | fn bar(self: &Bar<usize>, x: isize) -> isize {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or some type implementing `Receiver`
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error[E0308]: mismatched `self` parameter type
|
||||
--> $DIR/ufcs-explicit-self-bad.rs:37:21
|
||||
|
Loading…
Reference in New Issue
Block a user