Skip to content

Commit b9f3bdf

Browse files
committed
Auto merge of #97968 - matthiaskrgr:rollup-qtd4i5h, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #93331 (refactor write_output_file to merge two invocation paths into one.) - #97928 (Removes debug settings from wasm32_unknown_emscripten default link args) - #97940 (Use relative links instead of linking to doc.rust-lang.org when possible) - #97941 (nit: Fixed several error_codes/Exxxx.md messages which used UpperCamelCase…) - #97953 (Add regression test for #54378) - #97957 (Make `std::` prefix suggestion test `run-rustfix`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ec55c61 + 5d04bc8 commit b9f3bdf

File tree

13 files changed

+88
-65
lines changed

13 files changed

+88
-65
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,24 @@ pub fn write_output_file<'ll>(
5656
file_type: llvm::FileType,
5757
self_profiler_ref: &SelfProfilerRef,
5858
) -> Result<(), FatalError> {
59+
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
5960
unsafe {
6061
let output_c = path_to_c_string(output);
61-
let result = if let Some(dwo_output) = dwo_output {
62-
let dwo_output_c = path_to_c_string(dwo_output);
63-
llvm::LLVMRustWriteOutputFile(
64-
target,
65-
pm,
66-
m,
67-
output_c.as_ptr(),
68-
dwo_output_c.as_ptr(),
69-
file_type,
70-
)
62+
let dwo_output_c;
63+
let dwo_output_ptr = if let Some(dwo_output) = dwo_output {
64+
dwo_output_c = path_to_c_string(dwo_output);
65+
dwo_output_c.as_ptr()
7166
} else {
72-
llvm::LLVMRustWriteOutputFile(
73-
target,
74-
pm,
75-
m,
76-
output_c.as_ptr(),
77-
std::ptr::null(),
78-
file_type,
79-
)
67+
std::ptr::null()
8068
};
69+
let result = llvm::LLVMRustWriteOutputFile(
70+
target,
71+
pm,
72+
m,
73+
output_c.as_ptr(),
74+
dwo_output_ptr,
75+
file_type,
76+
);
8177

8278
// Record artifact sizes for self-profiling
8379
if result == llvm::LLVMRustResult::Success {

compiler/rustc_error_codes/src/error_codes/E0451.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ A struct constructor with private fields was invoked.
33
Erroneous code example:
44

55
```compile_fail,E0451
6-
mod Bar {
6+
mod bar {
77
pub struct Foo {
88
pub a: isize,
99
b: isize,
1010
}
1111
}
1212
13-
let f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`
13+
let f = bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `bar::Foo`
1414
// is private
1515
```
1616

1717
To fix this error, please ensure that all the fields of the struct are public,
1818
or implement a function for easy instantiation. Examples:
1919

2020
```
21-
mod Bar {
21+
mod bar {
2222
pub struct Foo {
2323
pub a: isize,
2424
pub b: isize, // we set `b` field public
2525
}
2626
}
2727
28-
let f = Bar::Foo{ a: 0, b: 0 }; // ok!
28+
let f = bar::Foo{ a: 0, b: 0 }; // ok!
2929
```
3030

3131
Or:
3232

3333
```
34-
mod Bar {
34+
mod bar {
3535
pub struct Foo {
3636
pub a: isize,
3737
b: isize, // still private
@@ -44,5 +44,5 @@ mod Bar {
4444
}
4545
}
4646
47-
let f = Bar::Foo::new(); // ok!
47+
let f = bar::Foo::new(); // ok!
4848
```

compiler/rustc_error_codes/src/error_codes/E0574.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ expected.
44
Erroneous code example:
55

66
```compile_fail,E0574
7-
mod Mordor {}
7+
mod mordor {}
88
9-
let sauron = Mordor { x: () }; // error!
9+
let sauron = mordor { x: () }; // error!
1010
1111
enum Jak {
1212
Daxter { i: isize },
@@ -19,17 +19,17 @@ match eco {
1919
```
2020

2121
In all these errors, a type was expected. For example, in the first error,
22-
we tried to instantiate the `Mordor` module, which is impossible. If you want
22+
we tried to instantiate the `mordor` module, which is impossible. If you want
2323
to instantiate a type inside a module, you can do it as follow:
2424

2525
```
26-
mod Mordor {
26+
mod mordor {
2727
pub struct TheRing {
2828
pub x: usize,
2929
}
3030
}
3131
32-
let sauron = Mordor::TheRing { x: 1 }; // ok!
32+
let sauron = mordor::TheRing { x: 1 }; // ok!
3333
```
3434

3535
In the second error, we tried to bind the `Jak` enum directly, which is not

compiler/rustc_error_codes/src/error_codes/E0577.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ fn main() {}
1111
```
1212

1313
`Sea` is not a module, therefore it is invalid to use it in a visibility path.
14-
To fix this error we need to ensure `Sea` is a module.
14+
To fix this error we need to ensure `sea` is a module.
1515

1616
Please note that the visibility scope can only be applied on ancestors!
1717

1818
```edition2018
19-
pub mod Sea {
20-
pub (in crate::Sea) struct Shark; // ok!
19+
pub mod sea {
20+
pub (in crate::sea) struct Shark; // ok!
2121
}
2222
2323
fn main() {}

compiler/rustc_error_codes/src/error_codes/E0603.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ A private item was used outside its scope.
33
Erroneous code example:
44

55
```compile_fail,E0603
6-
mod SomeModule {
6+
mod foo {
77
const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we
88
// can't use it outside of the
9-
// `SomeModule` module.
9+
// `foo` module.
1010
}
1111
12-
println!("const value: {}", SomeModule::PRIVATE); // error: constant `PRIVATE`
12+
println!("const value: {}", foo::PRIVATE); // error: constant `PRIVATE`
1313
// is private
1414
```
1515

1616
In order to fix this error, you need to make the item public by using the `pub`
1717
keyword. Example:
1818

1919
```
20-
mod SomeModule {
20+
mod foo {
2121
pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the
2222
// `pub` keyword.
2323
}
2424
25-
println!("const value: {}", SomeModule::PRIVATE); // ok!
25+
println!("const value: {}", foo::PRIVATE); // ok!
2626
```

compiler/rustc_error_codes/src/error_codes/E0742.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ item.
44
Erroneous code example:
55

66
```compile_fail,E0742,edition2018
7-
pub mod Sea {}
7+
pub mod sea {}
88
9-
pub (in crate::Sea) struct Shark; // error!
9+
pub (in crate::sea) struct Shark; // error!
1010
1111
fn main() {}
1212
```
1313

14-
To fix this error, we need to move the `Shark` struct inside the `Sea` module:
14+
To fix this error, we need to move the `Shark` struct inside the `sea` module:
1515

1616
```edition2018
17-
pub mod Sea {
18-
pub (in crate::Sea) struct Shark; // ok!
17+
pub mod sea {
18+
pub (in crate::sea) struct Shark; // ok!
1919
}
2020
2121
fn main() {}
@@ -25,9 +25,9 @@ Of course, you can do it as long as the module you're referring to is an
2525
ancestor:
2626

2727
```edition2018
28-
pub mod Earth {
29-
pub mod Sea {
30-
pub (in crate::Earth) struct Shark; // ok!
28+
pub mod earth {
29+
pub mod sea {
30+
pub (in crate::earth) struct Shark; // ok!
3131
}
3232
}
3333

compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ pub fn target() -> Target {
1616
let mut post_link_args = LinkArgs::new();
1717
post_link_args.insert(
1818
LinkerFlavor::Em,
19-
vec![
20-
"-s".into(),
21-
"ERROR_ON_UNDEFINED_SYMBOLS=1".into(),
22-
"-s".into(),
23-
"ASSERTIONS=1".into(),
24-
"-s".into(),
25-
"ABORTING_MALLOC=0".into(),
26-
"-Wl,--fatal-warnings".into(),
27-
],
19+
vec!["-sABORTING_MALLOC=0".into(), "-Wl,--fatal-warnings".into()],
2820
);
2921

3022
let opts = TargetOptions {

library/core/src/hash/sip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct SipHasher24 {
3838
/// SipHash is a general-purpose hashing function: it runs at a good
3939
/// speed (competitive with Spooky and City) and permits strong _keyed_
4040
/// hashing. This lets you key your hash tables from a strong RNG, such as
41-
/// [`rand::os::OsRng`](https://doc.rust-lang.org/rand/rand/os/struct.OsRng.html).
41+
/// [`rand::os::OsRng`](https://docs.rs/rand/latest/rand/rngs/struct.OsRng.html).
4242
///
4343
/// Although the SipHash algorithm is considered to be generally strong,
4444
/// it is not intended for cryptographic purposes. As such, all

library/core/src/mem/maybe_uninit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ impl<T> MaybeUninit<T> {
865865
///
866866
/// For instance, you cannot [`Read`] into an uninitialized buffer:
867867
///
868-
/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
868+
/// [`Read`]: ../../std/io/trait.Read.html
869869
///
870870
/// ```rust,no_run
871871
/// use std::{io, mem::MaybeUninit};

src/test/ui/lifetimes/issue-54378.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
3+
// Regression test for #54378.
4+
5+
#![feature(never_type)]
6+
7+
use std::marker::PhantomData;
8+
9+
pub trait Machine<'a, 'mir, 'tcx>: Sized {
10+
type MemoryKinds: ::std::fmt::Debug + Copy + Eq;
11+
const MUT_STATIC_KIND: Option<Self::MemoryKinds>;
12+
}
13+
14+
pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> {
15+
pub _data: PhantomData<(&'a (), &'mir (), &'tcx ())>,
16+
}
17+
18+
impl<'a, 'mir, 'tcx: 'a + 'mir> Machine<'a, 'mir, 'tcx>
19+
for CompileTimeEvaluator<'a, 'mir, 'tcx>
20+
{
21+
type MemoryKinds = !;
22+
23+
const MUT_STATIC_KIND: Option<!> = None;
24+
}
25+
26+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// run-rustfix
2+
fn main() {
3+
let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type
4+
let bytes = "hello world".as_bytes();
5+
let string = std::str::from_utf8(bytes).unwrap();
6+
//~^ ERROR no function or associated item named `from_utf8` found
7+
println!("{pi} {bytes:?} {string}");
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
// run-rustfix
12
fn main() {
23
let pi = f32::consts::PI; //~ ERROR ambiguous associated type
34
let bytes = "hello world".as_bytes();
4-
let string = unsafe {
5-
str::from_utf8(bytes) //~ ERROR no function or associated item named `from_utf8` found
6-
};
5+
let string = str::from_utf8(bytes).unwrap();
6+
//~^ ERROR no function or associated item named `from_utf8` found
7+
println!("{pi} {bytes:?} {string}");
78
}

src/test/ui/suggestions/suggest-std-when-using-type.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0223]: ambiguous associated type
2-
--> $DIR/suggest-std-when-using-type.rs:2:14
2+
--> $DIR/suggest-std-when-using-type.rs:3:14
33
|
44
LL | let pi = f32::consts::PI;
55
| ^^^^^^^^^^^
@@ -10,15 +10,15 @@ LL | let pi = std::f32::consts::PI;
1010
| +++++
1111

1212
error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope
13-
--> $DIR/suggest-std-when-using-type.rs:5:14
13+
--> $DIR/suggest-std-when-using-type.rs:5:23
1414
|
15-
LL | str::from_utf8(bytes)
16-
| ^^^^^^^^^ function or associated item not found in `str`
15+
LL | let string = str::from_utf8(bytes).unwrap();
16+
| ^^^^^^^^^ function or associated item not found in `str`
1717
|
1818
help: you are looking for the module in `std`, not the primitive type
1919
|
20-
LL | std::str::from_utf8(bytes)
21-
| +++++
20+
LL | let string = std::str::from_utf8(bytes).unwrap();
21+
| +++++
2222

2323
error: aborting due to 2 previous errors
2424

0 commit comments

Comments
 (0)