Skip to content

Commit

Permalink
Auto merge of rust-lang#87509 - JohnTitor:rollup-8iqn6cl, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - rust-lang#86450 (Add flag to configure `large_assignments` lint)
 - rust-lang#86764 (Avoid ICE on type error recovery)
 - rust-lang#87354 (Update VxWork's UNIX support)
 - rust-lang#87427 (get rid of NoMirFor error variant)
 - rust-lang#87446 (macos current_exe using directly libc instead.)
 - rust-lang#87494 (fix typo: whenver -> whenever)
 - rust-lang#87497 (Add long explanation for E0544.)
 - rust-lang#87499 (Remove ASCII fast path from `rustc_lexer::{is_id_continue, is_id_start}`)
 - rust-lang#87502 (Update cargo)
 - rust-lang#87503 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 27, 2021
2 parents 99d6692 + af6c95f commit 3bc9dd0
Show file tree
Hide file tree
Showing 29 changed files with 187 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1880,9 +1880,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "libc"
version = "0.2.93"
version = "0.2.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -5409,9 +5409,9 @@ dependencies = [

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

[[package]]
name = "unicode_categories"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ E0539: include_str!("./error_codes/E0539.md"),
E0541: include_str!("./error_codes/E0541.md"),
E0542: include_str!("./error_codes/E0542.md"),
E0543: include_str!("./error_codes/E0543.md"),
E0544: include_str!("./error_codes/E0544.md"),
E0545: include_str!("./error_codes/E0545.md"),
E0546: include_str!("./error_codes/E0546.md"),
E0547: include_str!("./error_codes/E0547.md"),
Expand Down Expand Up @@ -610,7 +611,6 @@ E0783: include_str!("./error_codes/E0783.md"),
E0523,
// E0526, // shuffle indices are not constant
// E0540, // multiple rustc_deprecated attributes
E0544, // multiple stability levels
// E0548, // replaced with a generic attribute input check
// E0553, // multiple rustc_const_unstable attributes
// E0555, // replaced with a generic attribute input check
Expand Down
29 changes: 29 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0544.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Multiple stability attributes were declared on the same item.

Erroneous code example:

```compile_fail,E0544
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "rust1")]
#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "test", since = "2.0.0")] // invalid
fn foo() {}
```

To fix this issue, ensure that each item has at most one stability attribute.

```
#![feature(staged_api)]
#![stable(since = "1.0.0", feature = "rust1")]
#[stable(feature = "test", since = "2.0.0")] // ok!
fn foo() {}
```

See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
of the Book and the [Stability attributes][stability-attributes] section of the
Rustc Dev Guide for more details.

[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(merge_functions, Some(MergeFunctions::Disabled));
tracked!(mir_emit_retag, true);
tracked!(mir_opt_level, Some(4));
tracked!(move_size_limit, Some(4096));
tracked!(mutable_noalias, Some(true));
tracked!(new_llvm_pass_manager, Some(true));
tracked!(no_generate_arange_section, true);
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool {
/// a formal definition of valid identifier name.
pub fn is_id_start(c: char) -> bool {
// This is XID_Start OR '_' (which formally is not a XID_Start).
// We also add fast-path for ascii idents
('a'..='z').contains(&c)
|| ('A'..='Z').contains(&c)
|| c == '_'
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c))
c == '_' || unicode_xid::UnicodeXID::is_xid_start(c)
}

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

/// The passed string is lexically an identifier.
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_middle/src/middle/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ use std::num::IntErrorKind;
pub fn provide(providers: &mut ty::query::Providers) {
providers.limits = |tcx, ()| Limits {
recursion_limit: get_recursion_limit(tcx.hir().krate_attrs(), tcx.sess),
move_size_limit: get_limit(tcx.hir().krate_attrs(), tcx.sess, sym::move_size_limit, 0),
move_size_limit: get_limit(
tcx.hir().krate_attrs(),
tcx.sess,
sym::move_size_limit,
tcx.sess.opts.debugging_opts.move_size_limit.unwrap_or(0),
),
type_length_limit: get_limit(
tcx.hir().krate_attrs(),
tcx.sess,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,6 @@ impl fmt::Display for UndefinedBehaviorInfo<'_> {
pub enum UnsupportedOpInfo {
/// Free-form case. Only for errors that are never caught!
Unsupported(String),
/// Could not find MIR for a function.
NoMirFor(DefId),
/// Encountered a pointer where we needed raw bytes.
ReadPointerAsBytes,
//
Expand All @@ -421,7 +419,6 @@ impl fmt::Display for UnsupportedOpInfo {
match self {
Unsupported(ref msg) => write!(f, "{}", msg),
ReadExternStatic(did) => write!(f, "cannot read from extern static ({:?})", did),
NoMirFor(did) => write!(f, "no MIR body is available for {:?}", did),
ReadPointerAsBytes => write!(f, "unable to turn pointer into raw bytes",),
ThreadLocalStatic(did) => write!(f, "cannot access thread local static ({:?})", did),
}
Expand Down
19 changes: 4 additions & 15 deletions compiler/rustc_mir/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
if ecx.tcx.is_ctfe_mir_available(def.did) {
Ok(ecx.tcx.mir_for_ctfe_opt_const_arg(def))
} else {
throw_unsup!(NoMirFor(def.did))
let path = ecx.tcx.def_path_str(def.did);
Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path))
.into())
}
}
_ => Ok(ecx.tcx.instance_mir(instance)),
Expand Down Expand Up @@ -247,20 +249,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
}
}
// This is a const fn. Call it.
Ok(Some(match ecx.load_mir(instance.def, None) {
Ok(body) => body,
Err(err) => {
if let err_unsup!(NoMirFor(did)) = err.kind() {
let path = ecx.tcx.def_path_str(*did);
return Err(ConstEvalErrKind::NeedsRfc(format!(
"calling extern function `{}`",
path
))
.into());
}
return Err(err);
}
}))
Ok(Some(ecx.load_mir(instance.def, None)?))
}

fn call_intrinsic(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,8 @@ options! {
(default: no)"),
mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
"MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
"the size at which the `large_assignments` lint starts to be emitted"),
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
"emit noalias metadata for mutable references (default: yes for LLVM >= 12, otherwise no)"),
new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
Expand Down
12 changes: 10 additions & 2 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{walk_generics, Visitor as _};
use rustc_hir::lang_items::LangItem;
use rustc_hir::{Constness, GenericArg, GenericArgs};
use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
use rustc_middle::ty::GenericParamDefKind;
use rustc_middle::ty::{self, Const, DefIdTree, Ty, TyCtxt, TypeFoldable};
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
Expand Down Expand Up @@ -488,12 +488,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx.ty_error().into()
} else {
// This is a default type parameter.
let substs = substs.unwrap();
if substs.iter().any(|arg| match arg.unpack() {
GenericArgKind::Type(ty) => ty.references_error(),
_ => false,
}) {
// Avoid ICE #86756 when type error recovery goes awry.
return tcx.ty_error().into();
}
self.astconv
.normalize_ty(
self.span,
tcx.at(self.span).type_of(param.def_id).subst_spanned(
tcx,
substs.unwrap(),
substs,
Some(self.span),
),
)
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ impl<T> Cell<[T]> {
pub struct RefCell<T: ?Sized> {
borrow: Cell<BorrowFlag>,
// Stores the location of the earliest currently active borrow.
// This gets updated whenver we go from having zero borrows
// This gets updated whenever we go from having zero borrows
// to having a single borrow. When a borrow occurs, this gets included
// in the generated `BorrowError/`BorrowMutError`
#[cfg(feature = "debug_refcell")]
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
libc = { version = "0.2.93", default-features = false, features = ['rustc-dep-of-std'] }
libc = { version = "0.2.98", default-features = false, features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "0.1.44" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
Expand Down
7 changes: 2 additions & 5 deletions library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,14 @@ pub fn current_exe() -> io::Result<PathBuf> {

#[cfg(any(target_os = "macos", target_os = "ios"))]
pub fn current_exe() -> io::Result<PathBuf> {
extern "C" {
fn _NSGetExecutablePath(buf: *mut libc::c_char, bufsize: *mut u32) -> libc::c_int;
}
unsafe {
let mut sz: u32 = 0;
_NSGetExecutablePath(ptr::null_mut(), &mut sz);
libc::_NSGetExecutablePath(ptr::null_mut(), &mut sz);
if sz == 0 {
return Err(io::Error::last_os_error());
}
let mut v: Vec<u8> = Vec::with_capacity(sz as usize);
let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
let err = libc::_NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz);
if err != 0 {
return Err(io::Error::last_os_error());
}
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/sys/unix/os/tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use super::*;

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

#[test]
#[cfg(not(target_os = "vxworks"))]
fn test_parse_glibc_version() {
let cases = [
("0.0", Some((0, 0))),
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cfg_if::cfg_if! {
raw[bit / 8] |= 1 << (bit % 8);
return 0;
}
} else if #[cfg(not(target_os = "vxworks"))] {
} else {
pub use libc::{sigemptyset, sigaddset};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 39 files
+13 −0 .github/ISSUE_TEMPLATE/bug_report.md
+7 −0 .github/ISSUE_TEMPLATE/new_translation.md
+2 −2 .github/workflows/main.yml
+13 −7 CONTRIBUTING.md
+12 −0 README.md
+1 −1 listings/ch03-common-programming-concepts/listing-03-05/src/main.rs
+1 −1 listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/output.txt
+2 −1 listings/ch03-common-programming-concepts/no-listing-03-shadowing/output.txt
+4 −1 listings/ch03-common-programming-concepts/no-listing-03-shadowing/src/main.rs
+1 −0 listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/src/main.rs
+1 −2 listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/output.txt
+3 −4 listings/ch03-common-programming-concepts/no-listing-18-functions-with-multiple-parameters/src/main.rs
+5 −0 listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.lock
+6 −0 listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/Cargo.toml
+12 −0 listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/output.txt
+21 −0 listings/ch03-common-programming-concepts/no-listing-32-5-loop-labels/src/main.rs
+4 −4 listings/ch04-understanding-ownership/listing-04-04/src/main.rs
+2 −2 listings/ch04-understanding-ownership/listing-04-09/src/main.rs
+1 −1 listings/ch11-writing-automated-tests/no-listing-11-ignore-a-test/output.txt
+1 −1 listings/ch12-an-io-project/listing-12-16/output.txt
+2 −2 listings/ch12-an-io-project/listing-12-19/output.txt
+2 −2 listings/ch12-an-io-project/listing-12-21/output.txt
+1 −1 listings/ch13-functional-features/no-listing-01-failing-cacher-test/output.txt
+1 −1 listings/ch15-smart-pointers/listing-15-23/output.txt
+1,659 −0 nostarch/chapter03.md
+1,314 −0 nostarch/chapter04.md
+1 −1 rust-toolchain
+4 −2 src/ch01-01-installation.md
+1 −1 src/ch03-00-common-programming-concepts.md
+32 −22 src/ch03-01-variables-and-mutability.md
+24 −15 src/ch03-02-data-types.md
+12 −12 src/ch03-03-how-functions-work.md
+29 −6 src/ch03-05-control-flow.md
+19 −16 src/ch04-01-what-is-ownership.md
+32 −19 src/ch04-02-references-and-borrowing.md
+10 −7 src/ch04-03-slices.md
+13 −9 src/ch05-01-defining-structs.md
+6 −5 src/ch06-02-match.md
+1 −1 src/title-page.md
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+128 −3 src/dot-operator.md
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide
10 changes: 10 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/move-size-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# `move_size_limit`

--------------------

The `-Zmove-size-limit=N` compiler flag enables `large_assignments` lints which
will warn when moving objects whose size exceeds `N` bytes.

Lint warns only about moves in functions that participate in code generation.
Consequently it will be ineffective for compiler invocatation that emit
metadata only, i.e., `cargo check` like workflows.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: moving 10024 bytes
--> $DIR/large_moves.rs:10:13
--> $DIR/large_moves.rs:12:13
|
LL | let x = async {
| _____________^
Expand All @@ -17,19 +17,19 @@ LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^

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

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

error: moving 10024 bytes
--> $DIR/large_moves.rs:18:13
--> $DIR/large_moves.rs:20:13
|
LL | let a = z.0;
| ^^^ value moved from here
Expand Down
38 changes: 38 additions & 0 deletions src/test/ui/async-await/large_moves.option.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
error: moving 10024 bytes
--> $DIR/large_moves.rs:12:13
|
LL | let x = async {
| _____________^
LL | | let y = [0; 9999];
LL | | dbg!(y);
LL | | thing(&y).await;
LL | | dbg!(y);
LL | | };
| |_____^ value moved from here
|
note: the lint level is defined here
--> $DIR/large_moves.rs:1:9
|
LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^

error: moving 10024 bytes
--> $DIR/large_moves.rs:18:14
|
LL | let z = (x, 42);
| ^ value moved from here

error: moving 10024 bytes
--> $DIR/large_moves.rs:18:13
|
LL | let z = (x, 42);
| ^^^^^^^ value moved from here

error: moving 10024 bytes
--> $DIR/large_moves.rs:20:13
|
LL | let a = z.0;
| ^^^ value moved from here

error: aborting due to 4 previous errors

4 changes: 3 additions & 1 deletion src/test/ui/async-await/large_moves.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#![deny(large_assignments)]
#![feature(large_assignments)]
#![move_size_limit = "1000"]
#![cfg_attr(attribute, move_size_limit = "1000")]
// build-fail
// only-x86_64
// revisions: attribute option
// [option]compile-flags: -Zmove-size-limit=1000

// edition:2018

Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/issues/issue-86756.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait Foo<T, T = T> {}
//~^ ERROR the name `T` is already used for a generic parameter in this item's generic parameters

fn eq<A, B>() {
eq::<dyn, Foo>
//~^ ERROR cannot find type `dyn` in this scope
//~| ERROR missing generics for trait `Foo`
//~| WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition
}

fn main() {}
Loading

0 comments on commit 3bc9dd0

Please sign in to comment.