diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 99e30531c226f..50f8949c8974d 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -56,28 +56,24 @@ pub fn write_output_file<'ll>( file_type: llvm::FileType, self_profiler_ref: &SelfProfilerRef, ) -> Result<(), FatalError> { + debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output); unsafe { let output_c = path_to_c_string(output); - let result = if let Some(dwo_output) = dwo_output { - let dwo_output_c = path_to_c_string(dwo_output); - llvm::LLVMRustWriteOutputFile( - target, - pm, - m, - output_c.as_ptr(), - dwo_output_c.as_ptr(), - file_type, - ) + let dwo_output_c; + let dwo_output_ptr = if let Some(dwo_output) = dwo_output { + dwo_output_c = path_to_c_string(dwo_output); + dwo_output_c.as_ptr() } else { - llvm::LLVMRustWriteOutputFile( - target, - pm, - m, - output_c.as_ptr(), - std::ptr::null(), - file_type, - ) + std::ptr::null() }; + let result = llvm::LLVMRustWriteOutputFile( + target, + pm, + m, + output_c.as_ptr(), + dwo_output_ptr, + file_type, + ); // Record artifact sizes for self-profiling if result == llvm::LLVMRustResult::Success { diff --git a/compiler/rustc_error_codes/src/error_codes/E0451.md b/compiler/rustc_error_codes/src/error_codes/E0451.md index 821073fe16eae..a12378a206de2 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0451.md +++ b/compiler/rustc_error_codes/src/error_codes/E0451.md @@ -3,14 +3,14 @@ A struct constructor with private fields was invoked. Erroneous code example: ```compile_fail,E0451 -mod Bar { +mod bar { pub struct Foo { pub a: isize, b: isize, } } -let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo` +let f = bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `bar::Foo` // is private ``` @@ -18,20 +18,20 @@ To fix this error, please ensure that all the fields of the struct are public, or implement a function for easy instantiation. Examples: ``` -mod Bar { +mod bar { pub struct Foo { pub a: isize, pub b: isize, // we set `b` field public } } -let f = Bar::Foo{ a: 0, b: 0 }; // ok! +let f = bar::Foo{ a: 0, b: 0 }; // ok! ``` Or: ``` -mod Bar { +mod bar { pub struct Foo { pub a: isize, b: isize, // still private @@ -44,5 +44,5 @@ mod Bar { } } -let f = Bar::Foo::new(); // ok! +let f = bar::Foo::new(); // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0574.md b/compiler/rustc_error_codes/src/error_codes/E0574.md index 8154d5b782e36..4881f61d0bc48 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0574.md +++ b/compiler/rustc_error_codes/src/error_codes/E0574.md @@ -4,9 +4,9 @@ expected. Erroneous code example: ```compile_fail,E0574 -mod Mordor {} +mod mordor {} -let sauron = Mordor { x: () }; // error! +let sauron = mordor { x: () }; // error! enum Jak { Daxter { i: isize }, @@ -19,17 +19,17 @@ match eco { ``` In all these errors, a type was expected. For example, in the first error, -we tried to instantiate the `Mordor` module, which is impossible. If you want +we tried to instantiate the `mordor` module, which is impossible. If you want to instantiate a type inside a module, you can do it as follow: ``` -mod Mordor { +mod mordor { pub struct TheRing { pub x: usize, } } -let sauron = Mordor::TheRing { x: 1 }; // ok! +let sauron = mordor::TheRing { x: 1 }; // ok! ``` In the second error, we tried to bind the `Jak` enum directly, which is not diff --git a/compiler/rustc_error_codes/src/error_codes/E0577.md b/compiler/rustc_error_codes/src/error_codes/E0577.md index 1feb9c0acf364..eba2d3b14175b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0577.md +++ b/compiler/rustc_error_codes/src/error_codes/E0577.md @@ -11,13 +11,13 @@ fn main() {} ``` `Sea` is not a module, therefore it is invalid to use it in a visibility path. -To fix this error we need to ensure `Sea` is a module. +To fix this error we need to ensure `sea` is a module. Please note that the visibility scope can only be applied on ancestors! ```edition2018 -pub mod Sea { - pub (in crate::Sea) struct Shark; // ok! +pub mod sea { + pub (in crate::sea) struct Shark; // ok! } fn main() {} diff --git a/compiler/rustc_error_codes/src/error_codes/E0603.md b/compiler/rustc_error_codes/src/error_codes/E0603.md index 69fefce3908fd..eb293118acc86 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0603.md +++ b/compiler/rustc_error_codes/src/error_codes/E0603.md @@ -3,13 +3,13 @@ A private item was used outside its scope. Erroneous code example: ```compile_fail,E0603 -mod SomeModule { +mod foo { const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we // can't use it outside of the - // `SomeModule` module. + // `foo` module. } -println!("const value: {}", SomeModule::PRIVATE); // error: constant `PRIVATE` +println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE` // is private ``` @@ -17,10 +17,10 @@ In order to fix this error, you need to make the item public by using the `pub` keyword. Example: ``` -mod SomeModule { +mod foo { pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the // `pub` keyword. } -println!("const value: {}", SomeModule::PRIVATE); // ok! +println!("const value: {}", foo::PRIVATE); // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0742.md b/compiler/rustc_error_codes/src/error_codes/E0742.md index fed9f1f4cee9c..e10c1639dd38a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0742.md +++ b/compiler/rustc_error_codes/src/error_codes/E0742.md @@ -4,18 +4,18 @@ item. Erroneous code example: ```compile_fail,E0742,edition2018 -pub mod Sea {} +pub mod sea {} -pub (in crate::Sea) struct Shark; // error! +pub (in crate::sea) struct Shark; // error! fn main() {} ``` -To fix this error, we need to move the `Shark` struct inside the `Sea` module: +To fix this error, we need to move the `Shark` struct inside the `sea` module: ```edition2018 -pub mod Sea { - pub (in crate::Sea) struct Shark; // ok! +pub mod sea { + pub (in crate::sea) struct Shark; // ok! } fn main() {} @@ -25,9 +25,9 @@ Of course, you can do it as long as the module you're referring to is an ancestor: ```edition2018 -pub mod Earth { - pub mod Sea { - pub (in crate::Earth) struct Shark; // ok! +pub mod earth { + pub mod sea { + pub (in crate::earth) struct Shark; // ok! } } diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index b34cac41d78ca..975051100b039 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -16,15 +16,7 @@ pub fn target() -> Target { let mut post_link_args = LinkArgs::new(); post_link_args.insert( LinkerFlavor::Em, - vec![ - "-s".into(), - "ERROR_ON_UNDEFINED_SYMBOLS=1".into(), - "-s".into(), - "ASSERTIONS=1".into(), - "-s".into(), - "ABORTING_MALLOC=0".into(), - "-Wl,--fatal-warnings".into(), - ], + vec!["-sABORTING_MALLOC=0".into(), "-Wl,--fatal-warnings".into()], ); let opts = TargetOptions { diff --git a/library/core/src/hash/sip.rs b/library/core/src/hash/sip.rs index 97e32ca77db82..81bf1dfdf4510 100644 --- a/library/core/src/hash/sip.rs +++ b/library/core/src/hash/sip.rs @@ -38,7 +38,7 @@ struct SipHasher24 { /// SipHash is a general-purpose hashing function: it runs at a good /// speed (competitive with Spooky and City) and permits strong _keyed_ /// hashing. This lets you key your hash tables from a strong RNG, such as -/// [`rand::os::OsRng`](https://doc.rust-lang.org/rand/rand/os/struct.OsRng.html). +/// [`rand::os::OsRng`](https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html). /// /// Although the SipHash algorithm is considered to be generally strong, /// it is not intended for cryptographic purposes. As such, all diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index cac7f435573a5..b4ea536083392 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -865,7 +865,7 @@ impl MaybeUninit { /// /// For instance, you cannot [`Read`] into an uninitialized buffer: /// - /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html + /// [`Read`]: ../../std/io/trait.Read.html /// /// ```rust,no_run /// use std::{io, mem::MaybeUninit}; diff --git a/src/test/ui/lifetimes/issue-54378.rs b/src/test/ui/lifetimes/issue-54378.rs new file mode 100644 index 0000000000000..aa42d4a7c41f6 --- /dev/null +++ b/src/test/ui/lifetimes/issue-54378.rs @@ -0,0 +1,26 @@ +// check-pass + +// Regression test for #54378. + +#![feature(never_type)] + +use std::marker::PhantomData; + +pub trait Machine<'a, 'mir, 'tcx>: Sized { + type MemoryKinds: ::std::fmt::Debug + Copy + Eq; + const MUT_STATIC_KIND: Option; +} + +pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> { + pub _data: PhantomData<(&'a (), &'mir (), &'tcx ())>, +} + +impl<'a, 'mir, 'tcx: 'a + 'mir> Machine<'a, 'mir, 'tcx> + for CompileTimeEvaluator<'a, 'mir, 'tcx> +{ + type MemoryKinds = !; + + const MUT_STATIC_KIND: Option = None; +} + +fn main() {} diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.fixed b/src/test/ui/suggestions/suggest-std-when-using-type.fixed new file mode 100644 index 0000000000000..102c5c1868fbf --- /dev/null +++ b/src/test/ui/suggestions/suggest-std-when-using-type.fixed @@ -0,0 +1,8 @@ +// run-rustfix +fn main() { + let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type + let bytes = "hello world".as_bytes(); + let string = std::str::from_utf8(bytes).unwrap(); + //~^ ERROR no function or associated item named `from_utf8` found + println!("{pi} {bytes:?} {string}"); +} diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.rs b/src/test/ui/suggestions/suggest-std-when-using-type.rs index 9ca68a635da96..5abc016deb076 100644 --- a/src/test/ui/suggestions/suggest-std-when-using-type.rs +++ b/src/test/ui/suggestions/suggest-std-when-using-type.rs @@ -1,7 +1,8 @@ +// run-rustfix fn main() { let pi = f32::consts::PI; //~ ERROR ambiguous associated type let bytes = "hello world".as_bytes(); - let string = unsafe { - str::from_utf8(bytes) //~ ERROR no function or associated item named `from_utf8` found - }; + let string = str::from_utf8(bytes).unwrap(); + //~^ ERROR no function or associated item named `from_utf8` found + println!("{pi} {bytes:?} {string}"); } diff --git a/src/test/ui/suggestions/suggest-std-when-using-type.stderr b/src/test/ui/suggestions/suggest-std-when-using-type.stderr index 2840fa121a75f..6f890b87b24bd 100644 --- a/src/test/ui/suggestions/suggest-std-when-using-type.stderr +++ b/src/test/ui/suggestions/suggest-std-when-using-type.stderr @@ -1,5 +1,5 @@ error[E0223]: ambiguous associated type - --> $DIR/suggest-std-when-using-type.rs:2:14 + --> $DIR/suggest-std-when-using-type.rs:3:14 | LL | let pi = f32::consts::PI; | ^^^^^^^^^^^ @@ -10,15 +10,15 @@ LL | let pi = std::f32::consts::PI; | +++++ error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope - --> $DIR/suggest-std-when-using-type.rs:5:14 + --> $DIR/suggest-std-when-using-type.rs:5:23 | -LL | str::from_utf8(bytes) - | ^^^^^^^^^ function or associated item not found in `str` +LL | let string = str::from_utf8(bytes).unwrap(); + | ^^^^^^^^^ function or associated item not found in `str` | help: you are looking for the module in `std`, not the primitive type | -LL | std::str::from_utf8(bytes) - | +++++ +LL | let string = std::str::from_utf8(bytes).unwrap(); + | +++++ error: aborting due to 2 previous errors