diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e155e253784aa..aadc7c48ea839 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ and we appreciate all of them. The best way to get started is by asking for help in the [#new members](https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members) -Zulip stream. We have lots of docs below of how to get started on your own, but +Zulip stream. We have a lot of documentation below on how to get started on your own, but the Zulip stream is the best place to *ask* for help. Documentation for contributing to the compiler or tooling is located in the [Guide to Rustc @@ -14,7 +14,7 @@ standard library in the [Standard library developers Guide][std-dev-guide], comm ## Making changes to subtrees and submodules -For submodules, changes need to be made against the repository corresponding the +For submodules, changes need to be made against the repository corresponding to the submodule, and not the main `rust-lang/rust` repository. For subtrees, prefer sending a PR against the subtree's repository if it does @@ -25,7 +25,7 @@ rustc-dev-guide change that does not accompany a compiler change). The [rustc-dev-guide] is meant to help document how rustc –the Rust compiler– works, as well as to help new contributors get involved in rustc development. It is recommended -to read and understand the [rustc-dev-guide] before making a contribution. This guide +that you read and understand the [rustc-dev-guide] before making a contribution. This guide talks about the different bots in the Rust ecosystem, the Rust development tools, bootstrapping, the compiler architecture, source code representation, and more. @@ -33,7 +33,7 @@ bootstrapping, the compiler architecture, source code representation, and more. There are many ways you can get help when you're stuck. Rust has many platforms for this: [internals], [rust-zulip], and [rust-discord]. It is recommended to ask for help on -the [rust-zulip], but any of these platforms are a great way to seek help and even +the [rust-zulip], but any of these platforms are great ways to seek help and even find a mentor! You can learn more about asking questions and getting help in the [Asking Questions](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions) chapter of the [rustc-dev-guide]. diff --git a/compiler/rustc_attr_data_structures/src/version.rs b/compiler/rustc_attr_data_structures/src/version.rs index 69b0e041d819d..030e952094056 100644 --- a/compiler/rustc_attr_data_structures/src/version.rs +++ b/compiler/rustc_attr_data_structures/src/version.rs @@ -1,4 +1,5 @@ use std::fmt::{self, Display}; +use std::sync::OnceLock; use rustc_macros::{ Decodable, Encodable, HashStable_Generic, PrintAttribute, current_rustc_version, @@ -16,8 +17,29 @@ pub struct RustcVersion { impl RustcVersion { pub const CURRENT: Self = current_rustc_version!(); + pub fn current_overridable() -> Self { + *CURRENT_OVERRIDABLE.get_or_init(|| { + if let Ok(override_var) = std::env::var("RUSTC_OVERRIDE_VERSION_STRING") + && let Some(override_) = Self::parse_str(&override_var) + { + override_ + } else { + Self::CURRENT + } + }) + } + fn parse_str(value: &str) -> Option { + // Ignore any suffixes such as "-dev" or "-nightly". + let mut components = value.split('-').next().unwrap().splitn(3, '.'); + let major = components.next()?.parse().ok()?; + let minor = components.next()?.parse().ok()?; + let patch = components.next().unwrap_or("0").parse().ok()?; + Some(RustcVersion { major, minor, patch }) + } } +static CURRENT_OVERRIDABLE: OnceLock = OnceLock::new(); + impl Display for RustcVersion { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch) diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index 7cb1fede1741a..528f56dfac7da 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -129,9 +129,9 @@ pub fn eval_condition( // See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details if sess.psess.assume_incomplete_release { - RustcVersion::CURRENT > min_version + RustcVersion::current_overridable() > min_version } else { - RustcVersion::CURRENT >= min_version + RustcVersion::current_overridable() >= min_version } } MetaItemKind::List(mis) => { diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index a614b4f00ffe4..53b5dff9c6b50 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -291,6 +291,14 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { probe::ObjectPick => { let trait_def_id = pick.item.container_id(self.tcx); + // If the trait is not object safe (specifically, we care about when + // the receiver is not valid), then there's a chance that we will not + // actually be able to recover the object by derefing the receiver like + // we should if it were valid. + if !self.tcx.is_dyn_compatible(trait_def_id) { + return ty::GenericArgs::extend_with_error(self.tcx, trait_def_id, &[]); + } + // This shouldn't happen for non-region error kinds, but may occur // when we have error regions. Specifically, since we canonicalize // during method steps, we may successfully deref when we assemble diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index b7d203e3cd78c..e233358f3866e 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -382,6 +382,9 @@ fn extend_type_not_partial_eq<'tcx>( fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result { match ty.kind() { ty::Dynamic(..) => return ControlFlow::Break(()), + // Unsafe binders never implement `PartialEq`, so avoid walking into them + // which would require instantiating its binder with placeholders too. + ty::UnsafeBinder(..) => return ControlFlow::Break(()), ty::FnPtr(..) => return ControlFlow::Continue(()), ty::Adt(def, _args) => { let ty_def_id = def.did(); diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs index d3e0a32c8b8fa..6587abb2ba7e4 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs @@ -22,6 +22,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(128), // FIXME: The leak sanitizer currently fails the tests, see #88132. supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD, + supports_xray: true, ..opts }, } diff --git a/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs index 2f868e38f1a51..64c1705478054 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs @@ -23,6 +23,7 @@ pub(crate) fn target() -> Target { | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD, + supports_xray: true, ..opts }, } diff --git a/library/std/src/sys/pal/windows/os.rs b/library/std/src/sys/pal/windows/os.rs index 1ebbbec9e914f..f331282d2d72a 100644 --- a/library/std/src/sys/pal/windows/os.rs +++ b/library/std/src/sys/pal/windows/os.rs @@ -202,8 +202,6 @@ fn home_dir_crt() -> Option { |buf, mut sz| { // GetUserProfileDirectoryW does not quite use the usual protocol for // negotiating the buffer size, so we have to translate. - // FIXME(#141254): We rely on the *undocumented* property that this function will - // always set the size, not just on failure. match c::GetUserProfileDirectoryW( ptr::without_provenance_mut(CURRENT_PROCESS_TOKEN), buf, diff --git a/src/doc/rustc/src/platform-support/solaris.md b/src/doc/rustc/src/platform-support/solaris.md index 0452d76f6c28f..c22b5c24c125d 100644 --- a/src/doc/rustc/src/platform-support/solaris.md +++ b/src/doc/rustc/src/platform-support/solaris.md @@ -8,6 +8,7 @@ Rust for Solaris operating system. ## Target maintainers [@psumbera](https://github.com/psumbera) +[@kulikjak](https://github.com/kulikjak) ## Requirements diff --git a/src/tools/miri/src/shims/windows/env.rs b/src/tools/miri/src/shims/windows/env.rs index 0cbabc52d2a5d..a7c26d601e502 100644 --- a/src/tools/miri/src/shims/windows/env.rs +++ b/src/tools/miri/src/shims/windows/env.rs @@ -230,7 +230,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { interp_ok(match directories::UserDirs::new() { Some(dirs) => { let home = dirs.home_dir(); - let size_avail = if this.ptr_is_null(size.ptr())? { + let size_avail = if this.ptr_is_null(buf)? { 0 // if the buf pointer is null, we can't write to it; `size` will be updated to the required length } else { this.read_scalar(&size)?.to_u32()? @@ -238,8 +238,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Of course we cannot use `windows_check_buffer_size` here since this uses // a different method for dealing with a too-small buffer than the other functions... let (success, len) = this.write_path_to_wide_str(home, buf, size_avail.into())?; - // The Windows docs just say that this is written on failure, but std relies on it - // always being written. Also see . + // As per , the size is always + // written, not just on failure. this.write_scalar(Scalar::from_u32(len.try_into().unwrap()), &size)?; if success { Scalar::from_i32(1) // return TRUE diff --git a/tests/assembly/x86_64-xray.rs b/tests/assembly/x86_64-xray.rs new file mode 100644 index 0000000000000..d82c4ae99dcd9 --- /dev/null +++ b/tests/assembly/x86_64-xray.rs @@ -0,0 +1,15 @@ +//@ assembly-output: emit-asm +//@ compile-flags: --crate-type lib -Zinstrument-xray=always -C llvm-args=-x86-asm-syntax=intel +//@ only-x86_64 +//@ ignore-sgx + +// CHECK-LABEL: xray_func: +#[no_mangle] +pub fn xray_func() { + // CHECK: nop word ptr [rax + rax + 512] + + std::hint::black_box(()); + + // CHECK: ret + // CHECK-NEXT: nop word ptr cs:[rax + rax + 512] +} diff --git a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr index bf20473924bc5..07c3fd3527f28 100644 --- a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr +++ b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr @@ -42,30 +42,6 @@ LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; = help: consider moving `async_dispatch` to another trait = note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait>` -error[E0277]: the trait bound `dyn AsyncTrait: AsyncTrait` is not satisfied - --> $DIR/mut-is-pointer-like.rs:36:11 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^ the trait `AsyncTrait` is not implemented for `dyn AsyncTrait` - -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/mut-is-pointer-like.rs:36:9 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/mut-is-pointer-like.rs:16:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -... -LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output; - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted -Some errors have detailed explanations: E0038, E0277. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/dyn/works.stderr b/tests/ui/async-await/dyn/works.stderr index 47abeab5aacb5..1fe2b28eca82f 100644 --- a/tests/ui/async-await/dyn/works.stderr +++ b/tests/ui/async-await/dyn/works.stderr @@ -42,40 +42,6 @@ LL | async fn async_dispatch(&self); = help: consider moving `async_dispatch` to another trait = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:28:11 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/works.rs:14:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error[E0038]: the trait `AsyncTrait` is not dyn compatible - --> $DIR/works.rs:28:9 - | -LL | x.async_dispatch().await; - | ^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/works.rs:14:14 - | -LL | trait AsyncTrait { - | ---------- this trait is not dyn compatible... -LL | async fn async_dispatch(&self); - | ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async` - = help: consider moving `async_dispatch` to another trait - = help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead. - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs index 9ab715d01f7a0..da9a75b50efa2 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.rs @@ -15,7 +15,7 @@ impl Foo for () { } fn use_dyn(v: &dyn Foo) { //~ERROR the trait `Foo` is not dyn compatible - v.test(); //~ERROR the trait `Foo` is not dyn compatible + v.test(); } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr index 8bc6ef093d046..120ee435e2563 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-ret.stderr @@ -17,25 +17,6 @@ LL | fn test(&self) -> [u8; bar::()]; = help: consider moving `test` to another trait = help: only type `()` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility-err-ret.rs:18:5 - | -LL | v.test(); - | ^^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compatibility-err-ret.rs:8:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn test(&self) -> [u8; bar::()]; - | ^^^^ ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type - | | - | ...because method `test` references the `Self` type in its `where` clause - = help: consider moving `test` to another trait - = help: only type `()` implements `Foo`; consider using it directly instead. - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs index a7b771cd4f840..8b735188f3261 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.rs @@ -15,7 +15,6 @@ impl Foo for () { fn use_dyn(v: &dyn Foo) { //~^ ERROR the trait `Foo` is not dyn compatible v.test(); - //~^ ERROR the trait `Foo` is not dyn compatible } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr index f5eaaa37916db..c2ad4d1498843 100644 --- a/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr +++ b/tests/ui/const-generics/generic_const_exprs/dyn-compatibility-err-where-bounds.stderr @@ -15,23 +15,6 @@ LL | fn test(&self) where [u8; bar::()]: Sized; = help: consider moving `test` to another trait = help: only type `()` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility-err-where-bounds.rs:17:5 - | -LL | v.test(); - | ^^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compatibility-err-where-bounds.rs:8:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn test(&self) where [u8; bar::()]: Sized; - | ^^^^ ...because method `test` references the `Self` type in its `where` clause - = help: consider moving `test` to another trait - = help: only type `()` implements `Foo`; consider using it directly instead. - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs index ec32bec7785ac..ac3c2aadf2907 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.rs @@ -25,5 +25,4 @@ pub fn foo() { let fetcher = fetcher(); //~^ ERROR the trait `Fetcher` is not dyn compatible let _ = fetcher.get(); - //~^ ERROR the trait `Fetcher` is not dyn compatible } diff --git a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr index 1299167159e24..867a719e2ebfd 100644 --- a/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr +++ b/tests/ui/dyn-compatibility/undispatchable-receiver-and-wc-references-Self.stderr @@ -34,24 +34,6 @@ LL | pub trait Fetcher: Send + Sync { LL | fn get<'a>(self: &'a Box) -> Pin> + 'a>> | ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on -error[E0038]: the trait `Fetcher` is not dyn compatible - --> $DIR/undispatchable-receiver-and-wc-references-Self.rs:27:13 - | -LL | fn get<'a>(self: &'a Box) -> Pin> + 'a>> - | ------------- help: consider changing method `get`'s `self` parameter to be `&self`: `&Self` -... -LL | let _ = fetcher.get(); - | ^^^^^^^^^^^^^ `Fetcher` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/undispatchable-receiver-and-wc-references-Self.rs:11:22 - | -LL | pub trait Fetcher: Send + Sync { - | ------- this trait is not dyn compatible... -LL | fn get<'a>(self: &'a Box) -> Pin> + 'a>> - | ^^^^^^^^^^^^^ ...because method `get`'s `self` parameter cannot be dispatched on - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/error-codes/E0038.rs b/tests/ui/error-codes/E0038.rs index a467767c3faaa..9757e2ab10c7a 100644 --- a/tests/ui/error-codes/E0038.rs +++ b/tests/ui/error-codes/E0038.rs @@ -5,8 +5,6 @@ trait Trait { fn call_foo(x: Box) { //~^ ERROR E0038 let y = x.foo(); - //~^ ERROR E0038 - //~| ERROR E0277 } fn main() { diff --git a/tests/ui/error-codes/E0038.stderr b/tests/ui/error-codes/E0038.stderr index 63a5249a38645..e09aefaa0dd1a 100644 --- a/tests/ui/error-codes/E0038.stderr +++ b/tests/ui/error-codes/E0038.stderr @@ -14,33 +14,6 @@ LL | fn foo(&self) -> Self; | ^^^^ ...because method `foo` references the `Self` type in its return type = help: consider moving `foo` to another trait -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/E0038.rs:7:13 - | -LL | let y = x.foo(); - | ^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/E0038.rs:2:22 - | -LL | trait Trait { - | ----- this trait is not dyn compatible... -LL | fn foo(&self) -> Self; - | ^^^^ ...because method `foo` references the `Self` type in its return type - = help: consider moving `foo` to another trait - -error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/E0038.rs:7:9 - | -LL | let y = x.foo(); - | ^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `dyn Trait` - = note: all local variables must have a statically known size - = help: unsized locals are gated as an unstable feature - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0277. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/feature-gates/cfg-version-expand.rs b/tests/ui/feature-gates/cfg-version-expand.rs new file mode 100644 index 0000000000000..8c426b4a41f51 --- /dev/null +++ b/tests/ui/feature-gates/cfg-version-expand.rs @@ -0,0 +1,30 @@ +//@ run-pass +//@ rustc-env:RUSTC_OVERRIDE_VERSION_STRING=1.50.3 + +#![feature(cfg_version)] + +#[cfg(version("1.49.0"))] +const ON_1_49_0: bool = true; +#[cfg(version("1.50"))] +const ON_1_50_0: bool = true; +#[cfg(not(version("1.51")))] +const ON_1_51_0: bool = false; + +// This one uses the wrong syntax, so doesn't eval to true +#[warn(unexpected_cfgs)] +#[cfg(not(version = "1.48.0"))] //~ WARN unexpected `cfg` condition name: `version` +const ON_1_48_0: bool = false; + +fn main() { + assert!(!ON_1_48_0); + assert!(ON_1_49_0); + assert!(ON_1_50_0); + assert!(!ON_1_51_0); + assert!(cfg!(version("1.1"))); + assert!(cfg!(version("1.49"))); + assert!(cfg!(version("1.50.0"))); + assert!(cfg!(version("1.50.3"))); + assert!(!cfg!(version("1.50.4"))); + assert!(!cfg!(version("1.51"))); + assert!(!cfg!(version("1.100"))); +} diff --git a/tests/ui/feature-gates/cfg-version-expand.stderr b/tests/ui/feature-gates/cfg-version-expand.stderr new file mode 100644 index 0000000000000..8b9d821ede38d --- /dev/null +++ b/tests/ui/feature-gates/cfg-version-expand.stderr @@ -0,0 +1,13 @@ +warning: unexpected `cfg` condition name: `version` + --> $DIR/cfg-version-expand.rs:15:11 + | +LL | #[cfg(not(version = "1.48.0"))] + | ^^^^^^^^^^^^^^^^^^ + | + = help: expected names are: `FALSE` and `test` and 31 more + = help: to expect this configuration use `--check-cfg=cfg(version, values("1.48.0"))` + = note: see for more information about checking conditional configuration + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs index 278a5451e842e..50e5fd1ab7a85 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.rs @@ -7,8 +7,6 @@ trait Foo { async fn takes_dyn_trait(x: &dyn Foo) { //~^ ERROR the trait `Foo` is not dyn compatible x.bar().await; - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr index ab8c092a82654..fd94b0babdb0c 100644 --- a/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr +++ b/tests/ui/feature-gates/feature-gate-async-fn-in-dyn-trait.stderr @@ -14,38 +14,6 @@ LL | async fn bar(&self); | ^^^ ...because method `bar` is `async` = help: consider moving `bar` to another trait -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:7 - | -LL | x.bar().await; - | ^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | async fn bar(&self); - | ^^^ ...because method `bar` is `async` - = help: consider moving `bar` to another trait - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:9:5 - | -LL | x.bar().await; - | ^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/feature-gate-async-fn-in-dyn-trait.rs:4:14 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | async fn bar(&self); - | ^^^ ...because method `bar` is `async` - = help: consider moving `bar` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/generic-associated-types/trait-objects.rs b/tests/ui/generic-associated-types/trait-objects.rs index 256cfee4c8098..87817111b546e 100644 --- a/tests/ui/generic-associated-types/trait-objects.rs +++ b/tests/ui/generic-associated-types/trait-objects.rs @@ -8,8 +8,6 @@ trait StreamingIterator { fn min_size(x: &mut dyn for<'a> StreamingIterator = &'a i32>) -> usize { //~^ ERROR the trait `StreamingIterator` is not dyn compatible x.size_hint().0 - //~^ ERROR the trait `StreamingIterator` is not dyn compatible - //~| ERROR the trait `StreamingIterator` is not dyn compatible } fn main() {} diff --git a/tests/ui/generic-associated-types/trait-objects.stderr b/tests/ui/generic-associated-types/trait-objects.stderr index 7d95718ec874b..8c3af6b654ab7 100644 --- a/tests/ui/generic-associated-types/trait-objects.stderr +++ b/tests/ui/generic-associated-types/trait-objects.stderr @@ -14,38 +14,6 @@ LL | type Item<'a> where Self: 'a; | ^^^^ ...because it contains the generic associated type `Item` = help: consider moving `Item` to another trait -error[E0038]: the trait `StreamingIterator` is not dyn compatible - --> $DIR/trait-objects.rs:10:7 - | -LL | x.size_hint().0 - | ^^^^^^^^^ `StreamingIterator` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/trait-objects.rs:2:10 - | -LL | trait StreamingIterator { - | ----------------- this trait is not dyn compatible... -LL | type Item<'a> where Self: 'a; - | ^^^^ ...because it contains the generic associated type `Item` - = help: consider moving `Item` to another trait - -error[E0038]: the trait `StreamingIterator` is not dyn compatible - --> $DIR/trait-objects.rs:10:5 - | -LL | x.size_hint().0 - | ^^^^^^^^^^^^^ `StreamingIterator` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/trait-objects.rs:2:10 - | -LL | trait StreamingIterator { - | ----------------- this trait is not dyn compatible... -LL | type Item<'a> where Self: 'a; - | ^^^^ ...because it contains the generic associated type `Item` - = help: consider moving `Item` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs index 85b1ba269fc8c..92203c470bba5 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.rs +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.rs @@ -15,6 +15,4 @@ fn main() { //~^ ERROR the trait `Foo` is not dyn compatible //~| ERROR the trait `Foo` is not dyn compatible let s = i.baz(); - //~^ ERROR the trait `Foo` is not dyn compatible - //~| ERROR the trait `Foo` is not dyn compatible } diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr index 840c27e183f09..5c498548affdf 100644 --- a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr +++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr @@ -15,40 +15,6 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait = help: only type `u32` implements `Foo`; consider using it directly instead. -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:17:15 - | -LL | let s = i.baz(); - | ^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compatibility.rs:4:22 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = help: only type `u32` implements `Foo`; consider using it directly instead. - -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/dyn-compatibility.rs:17:13 - | -LL | let s = i.baz(); - | ^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/dyn-compatibility.rs:4:22 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn baz(&self) -> impl Debug; - | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type - = help: consider moving `baz` to another trait - = help: only type `u32` implements `Foo`; consider using it directly instead. - error[E0038]: the trait `Foo` is not dyn compatible --> $DIR/dyn-compatibility.rs:14:13 | @@ -67,6 +33,6 @@ LL | fn baz(&self) -> impl Debug; = help: only type `u32` implements `Foo`; consider using it directly instead. = note: required for the cast from `Box` to `Box` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/instrument-xray/platform-support.rs b/tests/ui/instrument-xray/platform-support.rs new file mode 100644 index 0000000000000..238018b348dee --- /dev/null +++ b/tests/ui/instrument-xray/platform-support.rs @@ -0,0 +1,27 @@ +//@ only-nightly (flag is still unstable) +//@ needs-xray + +//@ revisions: unsupported +//@[unsupported] needs-llvm-components: x86 +//@[unsupported] compile-flags: -Z instrument-xray --target=x86_64-pc-windows-msvc + +//@ revisions: x86_64-linux +//@[x86_64-linux] needs-llvm-components: x86 +//@[x86_64-linux] compile-flags: -Z instrument-xray --target=x86_64-unknown-linux-gnu +//@[x86_64-linux] check-pass + +//@ revisions: x86_64-darwin +//@[x86_64-darwin] needs-llvm-components: x86 +//@[x86_64-darwin] compile-flags: -Z instrument-xray --target=x86_64-apple-darwin +//@[x86_64-darwin] check-pass + +//@ revisions: aarch64-darwin +//@[aarch64-darwin] needs-llvm-components: aarch64 +//@[aarch64-darwin] compile-flags: -Z instrument-xray --target=aarch64-apple-darwin +//@[aarch64-darwin] check-pass + +#![feature(no_core)] +#![no_core] +#![no_main] + +//[unsupported]~? ERROR XRay instrumentation is not supported for this target diff --git a/tests/ui/instrument-xray/target-not-supported.stderr b/tests/ui/instrument-xray/platform-support.unsupported.stderr similarity index 100% rename from tests/ui/instrument-xray/target-not-supported.stderr rename to tests/ui/instrument-xray/platform-support.unsupported.stderr diff --git a/tests/ui/instrument-xray/target-not-supported.rs b/tests/ui/instrument-xray/target-not-supported.rs deleted file mode 100644 index 2045913b186cd..0000000000000 --- a/tests/ui/instrument-xray/target-not-supported.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Verifies that `-Z instrument-xray` cannot be used with unsupported targets, -// -//@ needs-llvm-components: x86 -//@ compile-flags: -Z instrument-xray --target x86_64-apple-darwin - -#![feature(no_core)] -#![no_core] -#![no_main] - -//~? ERROR XRay instrumentation is not supported for this target diff --git a/tests/ui/issues/issue-18959.rs b/tests/ui/issues/issue-18959.rs index 6aeb34879ea1c..dbc73bafce9e5 100644 --- a/tests/ui/issues/issue-18959.rs +++ b/tests/ui/issues/issue-18959.rs @@ -11,7 +11,6 @@ impl Foo for Thing { fn foo(b: &dyn Bar) { //~^ ERROR E0038 b.foo(&0) - //~^ ERROR E0038 } fn main() { diff --git a/tests/ui/issues/issue-18959.stderr b/tests/ui/issues/issue-18959.stderr index 1e050b115e573..7ddfdb49d9594 100644 --- a/tests/ui/issues/issue-18959.stderr +++ b/tests/ui/issues/issue-18959.stderr @@ -15,23 +15,7 @@ LL | pub trait Bar: Foo { } = help: consider moving `foo` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:13:5 - | -LL | b.foo(&0) - | ^^^^^^^^^ `Bar` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/issue-18959.rs:1:20 - | -LL | pub trait Foo { fn foo(&self, ext_thing: &T); } - | ^^^ ...because method `foo` has generic type parameters -LL | pub trait Bar: Foo { } - | --- this trait is not dyn compatible... - = help: consider moving `foo` to another trait - -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:19:26 + --> $DIR/issue-18959.rs:18:26 | LL | let test: &dyn Bar = &mut thing; | ^^^^^^^^^^ `Bar` is not dyn compatible @@ -48,7 +32,7 @@ LL | pub trait Bar: Foo { } = note: required for the cast from `&mut Thing` to `&dyn Bar` error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/issue-18959.rs:19:15 + --> $DIR/issue-18959.rs:18:15 | LL | let test: &dyn Bar = &mut thing; | ^^^^^^^^ `Bar` is not dyn compatible @@ -63,6 +47,6 @@ LL | pub trait Bar: Foo { } | --- this trait is not dyn compatible... = help: consider moving `foo` to another trait -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs new file mode 100644 index 0000000000000..af35d1e0359db --- /dev/null +++ b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.rs @@ -0,0 +1,18 @@ +// Regression test for . + +use std::ops::Deref; + +struct W; + +trait Foo: Deref { + fn method(self: &W) {} + //~^ ERROR invalid `self` parameter type: `&W` +} + +fn test(x: &dyn Foo) { + //~^ ERROR the trait `Foo` is not dyn compatible + x.method(); + //~^ ERROR the trait `Foo` is not dyn compatible +} + +fn main() {} diff --git a/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr new file mode 100644 index 0000000000000..237bbc5671515 --- /dev/null +++ b/tests/ui/self/dispatch-dyn-incompatible-that-does-not-deref.stderr @@ -0,0 +1,49 @@ +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:12:13 + | +LL | fn method(self: &W) {} + | -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self` +... +LL | fn test(x: &dyn Foo) { + | ^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | trait Foo: Deref { + | --- this trait is not dyn compatible... +LL | fn method(self: &W) {} + | ^^ ...because method `method`'s `self` parameter cannot be dispatched on + +error[E0307]: invalid `self` parameter type: `&W` + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | fn method(self: &W) {} + | ^^ + | + = 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: Rc`, `self: Arc`, or `self: Pin

` (where P is one of the previous types except `Self`) + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:14:5 + | +LL | fn method(self: &W) {} + | -- help: consider changing method `method`'s `self` parameter to be `&self`: `&Self` +... +LL | x.method(); + | ^^^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $DIR/dispatch-dyn-incompatible-that-does-not-deref.rs:8:21 + | +LL | trait Foo: Deref { + | --- this trait is not dyn compatible... +LL | fn method(self: &W) {} + | ^^ ...because method `method`'s `self` parameter cannot be dispatched on + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0038, E0307. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/test-2.rs b/tests/ui/traits/test-2.rs index ffb778a014140..4ee880da87ad6 100644 --- a/tests/ui/traits/test-2.rs +++ b/tests/ui/traits/test-2.rs @@ -13,5 +13,4 @@ fn main() { (Box::new(10) as Box).dup(); //~^ ERROR E0038 //~| ERROR E0038 - //~| ERROR E0038 } diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 6a6cb503aa4dc..b52839c300ef7 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -49,29 +49,6 @@ LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead -error[E0038]: the trait `bar` is not dyn compatible - --> $DIR/test-2.rs:13:5 - | -LL | (Box::new(10) as Box).dup(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/test-2.rs:4:30 - | -LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } - | --- ^^^^ ^^^^ ...because method `blah` has generic type parameters - | | | - | | ...because method `dup` references the `Self` type in its return type - | this trait is not dyn compatible... - = help: consider moving `dup` to another trait - = help: consider moving `blah` to another trait - = help: the following types implement `bar`: - i32 - u32 - consider defining an enum where each variant holds one of these types, - implementing `bar` for this new enum and using it instead - error[E0038]: the trait `bar` is not dyn compatible --> $DIR/test-2.rs:13:6 | @@ -96,7 +73,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } implementing `bar` for this new enum and using it instead = note: required for the cast from `Box<{integer}>` to `Box` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.rs b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs new file mode 100644 index 0000000000000..e021e9567e5c8 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.rs @@ -0,0 +1,17 @@ +// regression test for . + +#![feature(unsafe_binders)] +#![allow(incomplete_features)] + +#[derive(Copy, Clone)] +struct Adt<'a>(&'a ()); + +const C: Option<(unsafe<'a> Adt<'a>, Box)> = None; + +fn main() { + match None { + C => {} + //~^ ERROR constant of non-structural type + _ => {} + } +} diff --git a/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr new file mode 100644 index 0000000000000..ab23210b2e577 --- /dev/null +++ b/tests/ui/unsafe-binders/non-strucutral-type-diag.stderr @@ -0,0 +1,13 @@ +error: constant of non-structural type `Option<(unsafe<'a> Adt<'a>, Box)>` in a pattern + --> $DIR/non-strucutral-type-diag.rs:13:9 + | +LL | const C: Option<(unsafe<'a> Adt<'a>, Box)> = None; + | ---------------------------------------------------- constant defined here +... +LL | C => {} + | ^ constant of non-structural type + | + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details + +error: aborting due to 1 previous error + diff --git a/triagebot.toml b/triagebot.toml index fd7a861bc92dc..cfcd100003dae 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -44,8 +44,6 @@ remove_labels = ["S-waiting-on-author"] # Those labels are added when PR author requests a review from an assignee add_labels = ["S-waiting-on-review"] -[glacier] - [ping.icebreakers-llvm] message = """\ Hey LLVM ICE-breakers! This bug has been identified as a good