Skip to content

Commit f781bab

Browse files
committed
Auto merge of rust-lang#73924 - Manishearth:rollup-8r51ld9, r=Manishearth
Rollup of 17 pull requests Successful merges: - rust-lang#72071 (Added detailed error code explanation for issue E0687 in Rust compiler.) - rust-lang#72369 (Bring net/parser.rs up to modern up to date with modern rust patterns) - rust-lang#72445 (Stabilize `#[track_caller]`.) - rust-lang#73466 (impl From<char> for String) - rust-lang#73548 (remove rustdoc warnings) - rust-lang#73649 (Fix sentence structure) - rust-lang#73678 (Update Box::from_raw example to generalize better) - rust-lang#73705 (stop taking references in Relate) - rust-lang#73716 (Document the static keyword) - rust-lang#73752 (Remap Windows ERROR_INVALID_PARAMETER to ErrorKind::InvalidInput from Other) - rust-lang#73776 (Move terminator to new module) - rust-lang#73778 (Make `likely` and `unlikely` const, gated by feature `const_unlikely`) - rust-lang#73805 (Document the type keyword) - rust-lang#73806 (Use an 'approximate' universal upper bound when reporting region errors) - rust-lang#73828 (Fix wording for anonymous parameter name help) - rust-lang#73846 (Fix comma in debug_assert! docs) - rust-lang#73847 (Edit cursor.prev() method docs in lexer) Failed merges: r? @ghost
2 parents 1505c12 + c9b3e86 commit f781bab

File tree

121 files changed

+1520
-1234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1520
-1234
lines changed

README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# The Rust Programming Language
1+
<a href = "https://www.rust-lang.org/">
2+
<img width = "90%" height = "auto" src = "https://img.shields.io/badge/Rust-Programming%20Language-black?style=flat&logo=rust" alt = "The Rust Programming Language">
3+
</a>
24

35
This is the main source code repository for [Rust]. It contains the compiler,
4-
standard library, and documentation.
6+
standard library, and documentation.
57

68
[Rust]: https://www.rust-lang.org
79

@@ -17,9 +19,9 @@ Read ["Installation"] from [The Book].
1719
_Note: If you wish to contribute to the compiler, you should read [this
1820
chapter][rustcguidebuild] of the rustc-dev-guide instead of this section._
1921

20-
The Rust build system has a Python script called `x.py` to bootstrap building
21-
the compiler. More information about it may be found by running `./x.py --help`
22-
or reading the [rustc dev guide][rustcguidebuild].
22+
The Rust build system uses a Python script called `x.py` to build the compiler,
23+
which manages the bootstrapping process. More information about it can be found
24+
by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild].
2325

2426
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
2527

@@ -54,9 +56,8 @@ or reading the [rustc dev guide][rustcguidebuild].
5456
$ cp config.toml.example config.toml
5557
```
5658

57-
It is recommended that if you plan to use the Rust build system to create
58-
an installation (using `./x.py install`) that you set the `prefix` value
59-
in the `[install]` section to a directory that you have write permissions.
59+
If you plan to use `x.py install` to create an installation, it is recommended
60+
that you set the `prefix` value in the `[install]` section to a directory.
6061

6162
Create install directory if you are not installing in default directory
6263

@@ -143,8 +144,8 @@ shell with:
143144
```
144145
145146
Currently, building Rust only works with some known versions of Visual Studio. If
146-
you have a more recent version installed the build system doesn't understand
147-
then you may need to force rustbuild to use an older version. This can be done
147+
you have a more recent version installed and the build system doesn't understand,
148+
you may need to force rustbuild to use an older version. This can be done
148149
by manually calling the appropriate vcvars file before running the bootstrap.
149150
150151
```batch

src/doc/unstable-book/src/language-features/track-caller.md

-5
This file was deleted.

src/liballoc/boxed.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ impl<T: ?Sized> Box<T> {
384384
///
385385
/// unsafe {
386386
/// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
387-
/// *ptr = 5;
387+
/// // In general .write is required to avoid attempting to destruct
388+
/// // the (uninitialized) previous contents of `ptr`, though for this
389+
/// // simple example `*ptr = 5` would have worked as well.
390+
/// ptr.write(5);
388391
/// let x = Box::from_raw(ptr);
389392
/// }
390393
/// ```

src/liballoc/string.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2518,3 +2518,11 @@ impl DoubleEndedIterator for Drain<'_> {
25182518

25192519
#[stable(feature = "fused", since = "1.26.0")]
25202520
impl FusedIterator for Drain<'_> {}
2521+
2522+
#[stable(feature = "from_char_for_string", since = "1.46.0")]
2523+
impl From<char> for String {
2524+
#[inline]
2525+
fn from(c: char) -> Self {
2526+
c.to_string()
2527+
}
2528+
}

src/liballoc/tests/string.rs

+7
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,10 @@ fn test_try_reserve_exact() {
714714
}
715715
}
716716
}
717+
718+
#[test]
719+
fn test_from_char() {
720+
assert_eq!(String::from('a'), 'a'.to_string());
721+
let s: String = 'x'.into();
722+
assert_eq!(s, 'x'.to_string());
723+
}

src/libcore/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ extern "rust-intrinsic" {
952952
/// Any use other than with `if` statements will probably not have an effect.
953953
///
954954
/// This intrinsic does not have a stable counterpart.
955+
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
955956
pub fn likely(b: bool) -> bool;
956957

957958
/// Hints to the compiler that branch condition is likely to be false.
@@ -960,6 +961,7 @@ extern "rust-intrinsic" {
960961
/// Any use other than with `if` statements will probably not have an effect.
961962
///
962963
/// This intrinsic does not have a stable counterpart.
964+
#[rustc_const_unstable(feature = "const_likely", issue = "none")]
963965
pub fn unlikely(b: bool) -> bool;
964966

965967
/// Executes a breakpoint trap, for inspection by a debugger.

src/libcore/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#![feature(const_slice_from_raw_parts)]
9393
#![feature(const_slice_ptr_len)]
9494
#![feature(const_type_name)]
95+
#![feature(const_likely)]
9596
#![feature(custom_inner_attributes)]
9697
#![feature(decl_macro)]
9798
#![feature(doc_cfg)]
@@ -118,7 +119,7 @@
118119
#![feature(staged_api)]
119120
#![feature(std_internals)]
120121
#![feature(stmt_expr_attributes)]
121-
#![feature(track_caller)]
122+
#![cfg_attr(bootstrap, feature(track_caller))]
122123
#![feature(transparent_unions)]
123124
#![feature(unboxed_closures)]
124125
#![feature(unsized_locals)]

src/libcore/macros/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[doc(include = "panic.md")]
22
#[macro_export]
3-
#[allow_internal_unstable(core_panic, track_caller)]
3+
#[allow_internal_unstable(core_panic, const_caller_location)]
44
#[stable(feature = "core", since = "1.6.0")]
55
macro_rules! panic {
66
() => (
@@ -151,7 +151,7 @@ macro_rules! assert_ne {
151151
/// An unchecked assertion allows a program in an inconsistent state to keep
152152
/// running, which might have unexpected consequences but does not introduce
153153
/// unsafety as long as this only happens in safe code. The performance cost
154-
/// of assertions, is however, not measurable in general. Replacing [`assert!`]
154+
/// of assertions, however, is not measurable in general. Replacing [`assert!`]
155155
/// with `debug_assert!` is thus only encouraged after thorough profiling, and
156156
/// more importantly, only in safe code!
157157
///

src/libcore/panic.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ impl<'a> Location<'a> {
190190
/// # Examples
191191
///
192192
/// ```
193-
/// #![feature(track_caller)]
194193
/// use core::panic::Location;
195194
///
196195
/// /// Returns the [`Location`] at which it is called.
@@ -206,7 +205,7 @@ impl<'a> Location<'a> {
206205
///
207206
/// let fixed_location = get_just_one_location();
208207
/// assert_eq!(fixed_location.file(), file!());
209-
/// assert_eq!(fixed_location.line(), 15);
208+
/// assert_eq!(fixed_location.line(), 14);
210209
/// assert_eq!(fixed_location.column(), 5);
211210
///
212211
/// // running the same untracked function in a different location gives us the same result
@@ -217,7 +216,7 @@ impl<'a> Location<'a> {
217216
///
218217
/// let this_location = get_caller_location();
219218
/// assert_eq!(this_location.file(), file!());
220-
/// assert_eq!(this_location.line(), 29);
219+
/// assert_eq!(this_location.line(), 28);
221220
/// assert_eq!(this_location.column(), 21);
222221
///
223222
/// // running the tracked function in a different location produces a different value
@@ -226,13 +225,8 @@ impl<'a> Location<'a> {
226225
/// assert_ne!(this_location.line(), another_location.line());
227226
/// assert_ne!(this_location.column(), another_location.column());
228227
/// ```
229-
// FIXME: When stabilizing this method, please also update the documentation
230-
// of `intrinsics::caller_location`.
231-
#[unstable(
232-
feature = "track_caller",
233-
reason = "uses #[track_caller] which is not yet stable",
234-
issue = "47809"
235-
)]
228+
#[stable(feature = "track_caller", since = "1.46.0")]
229+
#[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]
236230
#[track_caller]
237231
pub const fn caller() -> &'static Location<'static> {
238232
crate::intrinsics::caller_location()

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ E0668: include_str!("./error_codes/E0668.md"),
382382
E0669: include_str!("./error_codes/E0669.md"),
383383
E0670: include_str!("./error_codes/E0670.md"),
384384
E0671: include_str!("./error_codes/E0671.md"),
385+
E0687: include_str!("./error_codes/E0687.md"),
385386
E0689: include_str!("./error_codes/E0689.md"),
386387
E0690: include_str!("./error_codes/E0690.md"),
387388
E0691: include_str!("./error_codes/E0691.md"),
@@ -613,7 +614,6 @@ E0766: include_str!("./error_codes/E0766.md"),
613614
E0640, // infer outlives requirements
614615
// E0645, // trait aliases not finished
615616
E0667, // `impl Trait` in projections
616-
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
617617
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
618618
// E0694, // an unknown tool name found in scoped attributes
619619
// E0702, // replaced with a generic attribute input check
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
In-band lifetimes cannot be used in `fn`/`Fn` syntax.
2+
3+
Erroneous code examples:
4+
5+
```compile_fail,E0687
6+
#![feature(in_band_lifetimes)]
7+
8+
fn foo(x: fn(&'a u32)) {} // error!
9+
10+
fn bar(x: &Fn(&'a u32)) {} // error!
11+
12+
fn baz(x: fn(&'a u32), y: &'a u32) {} // error!
13+
14+
struct Foo<'a> { x: &'a u32 }
15+
16+
impl Foo<'a> {
17+
fn bar(&self, x: fn(&'a u32)) {} // error!
18+
}
19+
```
20+
21+
Lifetimes used in `fn` or `Fn` syntax must be explicitly
22+
declared using `<...>` binders. For example:
23+
24+
```
25+
fn foo<'a>(x: fn(&'a u32)) {} // ok!
26+
27+
fn bar<'a>(x: &Fn(&'a u32)) {} // ok!
28+
29+
fn baz<'a>(x: fn(&'a u32), y: &'a u32) {} // ok!
30+
31+
struct Foo<'a> { x: &'a u32 }
32+
33+
impl<'a> Foo<'a> {
34+
fn bar(&self, x: fn(&'a u32)) {} // ok!
35+
}
36+
```

src/librustc_error_codes/error_codes/E0736.md

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Erroneous code example:
44

55
```compile_fail,E0736
6-
#![feature(track_caller)]
7-
86
#[naked]
97
#[track_caller]
108
fn foo() {}

src/librustc_error_codes/error_codes/E0737.md

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ restrictions.
55
Erroneous code example:
66

77
```compile_fail,E0737
8-
#![feature(track_caller)]
9-
108
#[track_caller]
119
extern "C" fn foo() {}
1210
```

src/librustc_error_codes/error_codes/E0739.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Erroneous code example:
44

55
```compile_fail,E0739
6-
#![feature(track_caller)]
76
#[track_caller]
87
struct Bar {
98
a: u8,

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
66
#![feature(crate_visibility_modifier)]
77
#![feature(nll)]
8-
#![feature(track_caller)]
8+
#![cfg_attr(bootstrap, feature(track_caller))]
99

1010
pub use emitter::ColorConfig;
1111

src/librustc_feature/accepted.rs

+3
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ declare_features! (
265265
(accepted, const_if_match, "1.45.0", Some(49146), None),
266266
/// Allows the use of `loop` and `while` in constants.
267267
(accepted, const_loop, "1.45.0", Some(52000), None),
268+
/// Allows `#[track_caller]` to be used which provides
269+
/// accurate caller location reporting during panic (RFC 2091).
270+
(accepted, track_caller, "1.46.0", Some(47809), None),
268271

269272
// -------------------------------------------------------------------------
270273
// feature-group-end: accepted features

src/librustc_feature/active.rs

-4
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,6 @@ declare_features! (
494494
/// Allows the use of raw-dylibs (RFC 2627).
495495
(active, raw_dylib, "1.40.0", Some(58713), None),
496496

497-
/// Allows `#[track_caller]` to be used which provides
498-
/// accurate caller location reporting during panic (RFC 2091).
499-
(active, track_caller, "1.40.0", Some(47809), None),
500-
501497
/// Allows making `dyn Trait` well-formed even if `Trait` is not object safe.
502498
/// In that case, `dyn Trait: Trait` does not hold. Moreover, coercions and
503499
/// casts in safe Rust to `dyn Trait` for such a `Trait` is also forbidden.

src/librustc_feature/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
260260
ungated!(cold, Whitelisted, template!(Word)),
261261
ungated!(no_builtins, Whitelisted, template!(Word)),
262262
ungated!(target_feature, Whitelisted, template!(List: r#"enable = "name""#)),
263+
ungated!(track_caller, Whitelisted, template!(Word)),
263264
gated!(
264265
no_sanitize, Whitelisted,
265266
template!(List: "address, memory, thread"),
@@ -333,7 +334,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
333334
gated!(ffi_returns_twice, Whitelisted, template!(Word), experimental!(ffi_returns_twice)),
334335
gated!(ffi_pure, Whitelisted, template!(Word), experimental!(ffi_pure)),
335336
gated!(ffi_const, Whitelisted, template!(Word), experimental!(ffi_const)),
336-
gated!(track_caller, Whitelisted, template!(Word), experimental!(track_caller)),
337337
gated!(
338338
register_attr, CrateLevel, template!(List: "attr1, attr2, ..."),
339339
experimental!(register_attr),

src/librustc_infer/infer/at.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
8282
where
8383
T: ToTrace<'tcx>,
8484
{
85-
self.trace_exp(a_is_expected, a, b).sub(&a, &b)
85+
self.trace_exp(a_is_expected, a, b).sub(a, b)
8686
}
8787

8888
/// Makes `actual <: expected`. For example, if type-checking a
@@ -109,15 +109,15 @@ impl<'a, 'tcx> At<'a, 'tcx> {
109109
where
110110
T: ToTrace<'tcx>,
111111
{
112-
self.trace_exp(a_is_expected, a, b).eq(&a, &b)
112+
self.trace_exp(a_is_expected, a, b).eq(a, b)
113113
}
114114

115115
/// Makes `expected <: actual`.
116116
pub fn eq<T>(self, expected: T, actual: T) -> InferResult<'tcx, ()>
117117
where
118118
T: ToTrace<'tcx>,
119119
{
120-
self.trace(expected, actual).eq(&expected, &actual)
120+
self.trace(expected, actual).eq(expected, actual)
121121
}
122122

123123
pub fn relate<T>(self, expected: T, variance: ty::Variance, actual: T) -> InferResult<'tcx, ()>
@@ -147,7 +147,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
147147
where
148148
T: ToTrace<'tcx>,
149149
{
150-
self.trace(expected, actual).lub(&expected, &actual)
150+
self.trace(expected, actual).lub(expected, actual)
151151
}
152152

153153
/// Computes the greatest-lower-bound, or mutual subtype, of two
@@ -157,7 +157,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
157157
where
158158
T: ToTrace<'tcx>,
159159
{
160-
self.trace(expected, actual).glb(&expected, &actual)
160+
self.trace(expected, actual).glb(expected, actual)
161161
}
162162

163163
/// Sets the "trace" values that will be used for
@@ -186,7 +186,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
186186
impl<'a, 'tcx> Trace<'a, 'tcx> {
187187
/// Makes `a <: b` where `a` may or may not be expected (if
188188
/// `a_is_expected` is true, then `a` is expected).
189-
pub fn sub<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
189+
pub fn sub<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
190190
where
191191
T: Relate<'tcx>,
192192
{
@@ -203,7 +203,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
203203

204204
/// Makes `a == b`; the expectation is set by the call to
205205
/// `trace()`.
206-
pub fn eq<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
206+
pub fn eq<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
207207
where
208208
T: Relate<'tcx>,
209209
{
@@ -218,7 +218,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
218218
})
219219
}
220220

221-
pub fn lub<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
221+
pub fn lub<T>(self, a: T, b: T) -> InferResult<'tcx, T>
222222
where
223223
T: Relate<'tcx>,
224224
{
@@ -233,7 +233,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
233233
})
234234
}
235235

236-
pub fn glb<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
236+
pub fn glb<T>(self, a: T, b: T) -> InferResult<'tcx, T>
237237
where
238238
T: Relate<'tcx>,
239239
{

0 commit comments

Comments
 (0)