Skip to content

Commit 3bc9dd0

Browse files
committed
Auto merge of #87509 - JohnTitor:rollup-8iqn6cl, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #86450 (Add flag to configure `large_assignments` lint) - #86764 (Avoid ICE on type error recovery) - #87354 (Update VxWork's UNIX support) - #87427 (get rid of NoMirFor error variant) - #87446 (macos current_exe using directly libc instead.) - #87494 (fix typo: whenver -> whenever) - #87497 (Add long explanation for E0544.) - #87499 (Remove ASCII fast path from `rustc_lexer::{is_id_continue, is_id_start}`) - #87502 (Update cargo) - #87503 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 99d6692 + af6c95f commit 3bc9dd0

File tree

29 files changed

+187
-59
lines changed

29 files changed

+187
-59
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1880,9 +1880,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
18801880

18811881
[[package]]
18821882
name = "libc"
1883-
version = "0.2.93"
1883+
version = "0.2.98"
18841884
source = "registry+https://github.com/rust-lang/crates.io-index"
1885-
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
1885+
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
18861886
dependencies = [
18871887
"rustc-std-workspace-core",
18881888
]
@@ -5409,9 +5409,9 @@ dependencies = [
54095409

54105410
[[package]]
54115411
name = "unicode-xid"
5412-
version = "0.2.1"
5412+
version = "0.2.2"
54135413
source = "registry+https://github.com/rust-lang/crates.io-index"
5414-
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
5414+
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
54155415

54165416
[[package]]
54175417
name = "unicode_categories"

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ E0539: include_str!("./error_codes/E0539.md"),
287287
E0541: include_str!("./error_codes/E0541.md"),
288288
E0542: include_str!("./error_codes/E0542.md"),
289289
E0543: include_str!("./error_codes/E0543.md"),
290+
E0544: include_str!("./error_codes/E0544.md"),
290291
E0545: include_str!("./error_codes/E0545.md"),
291292
E0546: include_str!("./error_codes/E0546.md"),
292293
E0547: include_str!("./error_codes/E0547.md"),
@@ -610,7 +611,6 @@ E0783: include_str!("./error_codes/E0783.md"),
610611
E0523,
611612
// E0526, // shuffle indices are not constant
612613
// E0540, // multiple rustc_deprecated attributes
613-
E0544, // multiple stability levels
614614
// E0548, // replaced with a generic attribute input check
615615
// E0553, // multiple rustc_const_unstable attributes
616616
// E0555, // replaced with a generic attribute input check
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Multiple stability attributes were declared on the same item.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0544
6+
#![feature(staged_api)]
7+
#![stable(since = "1.0.0", feature = "rust1")]
8+
9+
#[stable(feature = "rust1", since = "1.0.0")]
10+
#[stable(feature = "test", since = "2.0.0")] // invalid
11+
fn foo() {}
12+
```
13+
14+
To fix this issue, ensure that each item has at most one stability attribute.
15+
16+
```
17+
#![feature(staged_api)]
18+
#![stable(since = "1.0.0", feature = "rust1")]
19+
20+
#[stable(feature = "test", since = "2.0.0")] // ok!
21+
fn foo() {}
22+
```
23+
24+
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
25+
of the Book and the [Stability attributes][stability-attributes] section of the
26+
Rustc Dev Guide for more details.
27+
28+
[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
29+
[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ fn test_debugging_options_tracking_hash() {
735735
tracked!(merge_functions, Some(MergeFunctions::Disabled));
736736
tracked!(mir_emit_retag, true);
737737
tracked!(mir_opt_level, Some(4));
738+
tracked!(move_size_limit, Some(4096));
738739
tracked!(mutable_noalias, Some(true));
739740
tracked!(new_llvm_pass_manager, Some(true));
740741
tracked!(no_generate_arange_section, true);

compiler/rustc_lexer/src/lib.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool {
273273
/// a formal definition of valid identifier name.
274274
pub fn is_id_start(c: char) -> bool {
275275
// This is XID_Start OR '_' (which formally is not a XID_Start).
276-
// We also add fast-path for ascii idents
277-
('a'..='z').contains(&c)
278-
|| ('A'..='Z').contains(&c)
279-
|| c == '_'
280-
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c))
276+
c == '_' || unicode_xid::UnicodeXID::is_xid_start(c)
281277
}
282278

283279
/// True if `c` is valid as a non-first character of an identifier.
284280
/// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for
285281
/// a formal definition of valid identifier name.
286282
pub fn is_id_continue(c: char) -> bool {
287-
// This is exactly XID_Continue.
288-
// We also add fast-path for ascii idents
289-
('a'..='z').contains(&c)
290-
|| ('A'..='Z').contains(&c)
291-
|| ('0'..='9').contains(&c)
292-
|| c == '_'
293-
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_continue(c))
283+
unicode_xid::UnicodeXID::is_xid_continue(c)
294284
}
295285

296286
/// The passed string is lexically an identifier.

compiler/rustc_middle/src/middle/limits.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ use std::num::IntErrorKind;
2121
pub fn provide(providers: &mut ty::query::Providers) {
2222
providers.limits = |tcx, ()| Limits {
2323
recursion_limit: get_recursion_limit(tcx.hir().krate_attrs(), tcx.sess),
24-
move_size_limit: get_limit(tcx.hir().krate_attrs(), tcx.sess, sym::move_size_limit, 0),
24+
move_size_limit: get_limit(
25+
tcx.hir().krate_attrs(),
26+
tcx.sess,
27+
sym::move_size_limit,
28+
tcx.sess.opts.debugging_opts.move_size_limit.unwrap_or(0),
29+
),
2530
type_length_limit: get_limit(
2631
tcx.hir().krate_attrs(),
2732
tcx.sess,

compiler/rustc_middle/src/mir/interpret/error.rs

-3
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,6 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
402402
pub enum UnsupportedOpInfo {
403403
/// Free-form case. Only for errors that are never caught!
404404
Unsupported(String),
405-
/// Could not find MIR for a function.
406-
NoMirFor(DefId),
407405
/// Encountered a pointer where we needed raw bytes.
408406
ReadPointerAsBytes,
409407
//
@@ -421,7 +419,6 @@ impl fmt::Display for UnsupportedOpInfo {
421419
match self {
422420
Unsupported(ref msg) => write!(f, "{}", msg),
423421
ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
424-
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
425422
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
426423
ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
427424
}

compiler/rustc_mir/src/const_eval/machine.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
212212
if ecx.tcx.is_ctfe_mir_available(def.did) {
213213
Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def))
214214
} else {
215-
throw_unsup!(NoMirFor(def.did))
215+
let path = ecx.tcx.def_path_str(def.did);
216+
Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path))
217+
.into())
216218
}
217219
}
218220
_ => Ok(ecx.tcx.instance_mir(instance)),
@@ -247,20 +249,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
247249
}
248250
}
249251
// This is a const fn. Call it.
250-
Ok(Some(match ecx.load_mir(instance.def, None) {
251-
Ok(body) => body,
252-
Err(err) => {
253-
if let err_unsup!(NoMirFor(did)) = err.kind() {
254-
let path = ecx.tcx.def_path_str(*did);
255-
return Err(ConstEvalErrKind::NeedsRfc(format!(
256-
"calling extern function `{}`",
257-
path
258-
))
259-
.into());
260-
}
261-
return Err(err);
262-
}
263-
}))
252+
Ok(Some(ecx.load_mir(instance.def, None)?))
264253
}
265254

266255
fn call_intrinsic(

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,8 @@ options! {
11481148
(default: no)"),
11491149
mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
11501150
"MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1151+
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
1152+
"the size at which the `large_assignments` lint starts to be emitted"),
11511153
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
11521154
"emit noalias metadata for mutable references (default: yes for LLVM >= 12, otherwise no)"),
11531155
new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],

compiler/rustc_typeck/src/astconv/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
2121
use rustc_hir::intravisit::{walk_generics, Visitor as _};
2222
use rustc_hir::lang_items::LangItem;
2323
use rustc_hir::{Constness, GenericArg, GenericArgs};
24-
use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
24+
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
2525
use rustc_middle::ty::GenericParamDefKind;
2626
use rustc_middle::ty::{self, Const, DefIdTree, Ty, TyCtxt, TypeFoldable};
2727
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
@@ -488,12 +488,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
488488
tcx.ty_error().into()
489489
} else {
490490
// This is a default type parameter.
491+
let substs = substs.unwrap();
492+
if substs.iter().any(|arg| match arg.unpack() {
493+
GenericArgKind::Type(ty) => ty.references_error(),
494+
_ => false,
495+
}) {
496+
// Avoid ICE #86756 when type error recovery goes awry.
497+
return tcx.ty_error().into();
498+
}
491499
self.astconv
492500
.normalize_ty(
493501
self.span,
494502
tcx.at(self.span).type_of(param.def_id).subst_spanned(
495503
tcx,
496-
substs.unwrap(),
504+
substs,
497505
Some(self.span),
498506
),
499507
)

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl<T> Cell<[T]> {
583583
pub struct RefCell<T: ?Sized> {
584584
borrow: Cell<BorrowFlag>,
585585
// Stores the location of the earliest currently active borrow.
586-
// This gets updated whenver we go from having zero borrows
586+
// This gets updated whenever we go from having zero borrows
587587
// to having a single borrow. When a borrow occurs, this gets included
588588
// in the generated `BorrowError/`BorrowMutError`
589589
#[cfg(feature = "debug_refcell")]

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
1616
panic_unwind = { path = "../panic_unwind", optional = true }
1717
panic_abort = { path = "../panic_abort" }
1818
core = { path = "../core" }
19-
libc = { version = "0.2.93", default-features = false, features = ['rustc-dep-of-std'] }
19+
libc = { version = "0.2.98", default-features = false, features = ['rustc-dep-of-std'] }
2020
compiler_builtins = { version = "0.1.44" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }

library/std/src/sys/unix/os.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,14 @@ pub fn current_exe() -> io::Result<PathBuf> {
350350

351351
#[cfg(any(target_os = "macos", target_os = "ios"))]
352352
pub fn current_exe() -> io::Result<PathBuf> {
353-
extern "C" {
354-
fn _NSGetExecutablePath(buf: *mut libc::c_char, bufsize: *mut u32) -> libc::c_int;
355-
}
356353
unsafe {
357354
let mut sz: u32 = 0;
358-
_NSGetExecutablePath(ptr::null_mut(), &mut sz);
355+
libc::_NSGetExecutablePath(ptr::null_mut(), &mut sz);
359356
if sz == 0 {
360357
return Err(io::Error::last_os_error());
361358
}
362359
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
363-
let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
360+
let err = libc::_NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
364361
if err != 0 {
365362
return Err(io::Error::last_os_error());
366363
}

library/std/src/sys/unix/os/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use super::*;
22

33
#[test]
4+
#[cfg(not(target_os = "vxworks"))]
45
fn test_glibc_version() {
56
// This mostly just tests that the weak linkage doesn't panic wildly...
67
glibc_version();
78
}
89

910
#[test]
11+
#[cfg(not(target_os = "vxworks"))]
1012
fn test_parse_glibc_version() {
1113
let cases = [
1214
("0.0", Some((0, 0))),

library/std/src/sys/unix/process/process_common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ cfg_if::cfg_if! {
5050
raw[bit / 8] |= 1 << (bit % 8);
5151
return 0;
5252
}
53-
} else if #[cfg(not(target_os = "vxworks"))] {
53+
} else {
5454
pub use libc::{sigemptyset, sigaddset};
5555
}
5656
}

src/doc/book

Submodule book updated 39 files

src/doc/nomicon

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `move_size_limit`
2+
3+
--------------------
4+
5+
The `-Zmove-size-limit=N` compiler flag enables `large_assignments` lints which
6+
will warn when moving objects whose size exceeds `N` bytes.
7+
8+
Lint warns only about moves in functions that participate in code generation.
9+
Consequently it will be ineffective for compiler invocatation that emit
10+
metadata only, i.e., `cargo check` like workflows.

src/test/ui/async-await/large_moves.stderr renamed to src/test/ui/async-await/large_moves.attribute.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: moving 10024 bytes
2-
--> $DIR/large_moves.rs:10:13
2+
--> $DIR/large_moves.rs:12:13
33
|
44
LL | let x = async {
55
| _____________^
@@ -17,19 +17,19 @@ LL | #![deny(large_assignments)]
1717
| ^^^^^^^^^^^^^^^^^
1818

1919
error: moving 10024 bytes
20-
--> $DIR/large_moves.rs:16:14
20+
--> $DIR/large_moves.rs:18:14
2121
|
2222
LL | let z = (x, 42);
2323
| ^ value moved from here
2424

2525
error: moving 10024 bytes
26-
--> $DIR/large_moves.rs:16:13
26+
--> $DIR/large_moves.rs:18:13
2727
|
2828
LL | let z = (x, 42);
2929
| ^^^^^^^ value moved from here
3030

3131
error: moving 10024 bytes
32-
--> $DIR/large_moves.rs:18:13
32+
--> $DIR/large_moves.rs:20:13
3333
|
3434
LL | let a = z.0;
3535
| ^^^ value moved from here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: moving 10024 bytes
2+
--> $DIR/large_moves.rs:12:13
3+
|
4+
LL | let x = async {
5+
| _____________^
6+
LL | | let y = [0; 9999];
7+
LL | | dbg!(y);
8+
LL | | thing(&y).await;
9+
LL | | dbg!(y);
10+
LL | | };
11+
| |_____^ value moved from here
12+
|
13+
note: the lint level is defined here
14+
--> $DIR/large_moves.rs:1:9
15+
|
16+
LL | #![deny(large_assignments)]
17+
| ^^^^^^^^^^^^^^^^^
18+
19+
error: moving 10024 bytes
20+
--> $DIR/large_moves.rs:18:14
21+
|
22+
LL | let z = (x, 42);
23+
| ^ value moved from here
24+
25+
error: moving 10024 bytes
26+
--> $DIR/large_moves.rs:18:13
27+
|
28+
LL | let z = (x, 42);
29+
| ^^^^^^^ value moved from here
30+
31+
error: moving 10024 bytes
32+
--> $DIR/large_moves.rs:20:13
33+
|
34+
LL | let a = z.0;
35+
| ^^^ value moved from here
36+
37+
error: aborting due to 4 previous errors
38+

src/test/ui/async-await/large_moves.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![deny(large_assignments)]
22
#![feature(large_assignments)]
3-
#![move_size_limit = "1000"]
3+
#![cfg_attr(attribute, move_size_limit = "1000")]
44
// build-fail
55
// only-x86_64
6+
// revisions: attribute option
7+
// [option]compile-flags: -Zmove-size-limit=1000
68

79
// edition:2018
810

src/test/ui/issues/issue-86756.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait Foo<T, T = T> {}
2+
//~^ ERROR the name `T` is already used for a generic parameter in this item's generic parameters
3+
4+
fn eq<A, B>() {
5+
eq::<dyn, Foo>
6+
//~^ ERROR cannot find type `dyn` in this scope
7+
//~| ERROR missing generics for trait `Foo`
8+
//~| WARN trait objects without an explicit `dyn` are deprecated
9+
//~| WARN this is accepted in the current edition
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)