Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from origin 2020-06-28 #8

Merged
merged 94 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
358dc1d
Added io forwarding methods to the stdio structs
Lucretiel May 28, 2020
93cbad6
Add documentation to point to `!is_dir` instead of `is_file`
poliorcetics Jun 11, 2020
ec63f9d
Added the note to Metadata too
poliorcetics Jun 11, 2020
c1243db
Make a note about is_dir vs is_file in Path too
poliorcetics Jun 11, 2020
b60cefe
Removed write_fmt forwarding, to fix recursive borrow issues
Lucretiel Jun 17, 2020
14d385b
Restore some write_fmts
Lucretiel Jun 17, 2020
4c8ce48
Add partition_point
VillSnow Jun 21, 2020
c9b4915
fix: doc test
VillSnow Jun 21, 2020
810f309
MIR sanity check: validate types on assignment
RalfJung May 30, 2020
50d7dea
prepare visit_statement for checking more kinds of statements
RalfJung May 31, 2020
93e3552
also normalize constants when comparing types
RalfJung May 31, 2020
9576e30
also normalize_erasing_regions
RalfJung Jun 1, 2020
8200771
reveal_all when sanity-checking MIR assignment types
RalfJung Jun 6, 2020
978470f
no need to normalize mutability any more
RalfJung Jun 21, 2020
91f73fb
use a TypeRelation to compare the types
RalfJung Jun 21, 2020
7754322
fix typo
RalfJung Jun 22, 2020
7f8fe6a
also use relator in interpreter assignment sanity check
RalfJung Jun 22, 2020
5e5ae8b
expand a comment
RalfJung Jun 22, 2020
a593728
make layout check a mere sanity check
RalfJung Jun 22, 2020
27b06f1
update: doc comment
VillSnow Jun 22, 2020
8cc6998
add: tests
VillSnow Jun 22, 2020
35911ee
reduce sanity check in debug mode
RalfJung Jun 24, 2020
5e28eb5
Adds a clearer message for when the async keyword is missing from a f…
nellshamrell Jun 18, 2020
49f6166
Prepare for LLVM 11
cuviper Jun 26, 2020
a6417b9
improper_ctypes: fix remaining `Reveal:All`
davidtwco Jun 26, 2020
6654c58
Remove mdbook-linkcheck.
ehuss Jun 23, 2020
6bcbc42
Update mdbook.
ehuss Jun 23, 2020
3678e5c
errors: use `-Z terminal-width` in JSON emitter
davidtwco Jun 26, 2020
558c8a8
Handle stores to projections correctly in liveness analysis
ecstatic-morse Jun 26, 2020
2340197
Add peek test for projections
ecstatic-morse Jun 26, 2020
36ac08e
Make `fn_arg_names` return `Ident` instead of symbol
Aaron1011 Jun 11, 2020
fa6a61c
Explain move errors that occur due to method calls involving `self`
Aaron1011 Jun 11, 2020
a4e7b47
use LocalDefId in module checking
lcnr Jun 27, 2020
1875c79
more LocalDefId in ty::context
lcnr Jun 27, 2020
88fe556
Add test for issue-71381
JohnTitor Jun 27, 2020
2d280a5
more LocalDefId cleanup
lcnr Jun 27, 2020
9308860
fix typo in self-profile.md
atetubou Jun 27, 2020
4c14f9d
Forward Hash::write_iN to Hash::write_uN
nikic Jun 27, 2020
d25d6c5
Update the documentation to point to open instead of is_file and is_dir
poliorcetics Jun 27, 2020
0e0584f
Add links to fs::DirEntry::metadata
robyoung Jun 27, 2020
99884bd
Add test for issue-71382
JohnTitor Jun 27, 2020
7125ce7
Add test for issue-71611
JohnTitor Jun 27, 2020
1d16aed
Add test for issue-72352
JohnTitor Jun 27, 2020
ffcfaa1
Fix comment.
ecstatic-morse Jun 27, 2020
9bdd2db
Auto merge of #73671 - ehuss:update-mdbook, r=Mark-Simulacrum
bors Jun 27, 2020
6d0e5bf
Rename two `Resolver` traits
petrochenkov Jun 27, 2020
8e8c54a
Added the parapgrah to path::Path::is_file too
poliorcetics Jun 27, 2020
c72a5dd
Rename the lint to clashing_extern_declarations.
jumbatm Jun 28, 2020
8291a22
Fix docstring typo
cjrh Jun 28, 2020
3b4a3d6
Auto merge of #72705 - Lucretiel:stdio-forwarding, r=Amanieu
bors Jun 28, 2020
385d85c
Rollup merge of #72796 - RalfJung:mir-assign-sanity, r=matthewjasper
Manishearth Jun 28, 2020
6a944c1
Rollup merge of #73243 - poliorcetics:discourage-is-file, r=Amanieu
Manishearth Jun 28, 2020
45ec25e
Rollup merge of #73525 - cuviper:llvm11, r=nikic
Manishearth Jun 28, 2020
d227a82
Rollup merge of #73672 - nellshamrell:async-fix, r=estebank
Manishearth Jun 28, 2020
b236e49
Rollup merge of #73708 - Aaron1011:feature/reland-move-fn-self-msg, r…
Manishearth Jun 28, 2020
d5205f2
Rollup merge of #73758 - davidtwco:issue-60855-remaining-reveal-all, …
Manishearth Jun 28, 2020
596af5a
Rollup merge of #73763 - davidtwco:terminal-width-json-emitter, r=est…
Manishearth Jun 28, 2020
800d2e3
Rollup merge of #73796 - lcnr:LocalDefId, r=matthewjasper
Manishearth Jun 28, 2020
dc843a8
Rollup merge of #73797 - atetubou:patch-1, r=jonas-schievink
Manishearth Jun 28, 2020
cdb59d9
Rollup merge of #73809 - robyoung:docs/add-links-to-DirEntry-metadata…
Manishearth Jun 28, 2020
52f9762
Add comment on use of unsafe
VillSnow Jun 28, 2020
9335787
Update src/libcore/slice/mod.rs
VillSnow Jun 28, 2020
83d5998
Merge branch 'master' of https://github.com/VillSnow/rust
VillSnow Jun 28, 2020
d720a19
Update doc comment
VillSnow Jun 28, 2020
25687ca
Auto merge of #73830 - Manishearth:rollup-8k68ysm, r=Manishearth
bors Jun 28, 2020
60f2ba2
Update tracking issue number
VillSnow Jun 28, 2020
4d978af
Remove GlobalCtxt::enter_local
bjorn3 Jun 28, 2020
b9f4e0d
Erase all block-only locals at the end of every block, even if they h…
oli-obk Jun 26, 2020
6f8ad3b
Update src/libcore/slice/mod.rs
VillSnow Jun 28, 2020
ec48989
Rollup merge of #73577 - VillSnow:master, r=Amanieu
Manishearth Jun 28, 2020
ccc1bf7
Rollup merge of #73757 - oli-obk:const_prop_hardening, r=wesleywiser
Manishearth Jun 28, 2020
3f826a8
Rollup merge of #73774 - ecstatic-morse:liveness-of-projections, r=ol…
Manishearth Jun 28, 2020
2c1b732
Rollup merge of #73795 - JohnTitor:tests-for-const-fn-ptrs, r=oli-obk
Manishearth Jun 28, 2020
95da53f
Rollup merge of #73800 - nikic:hash_i, r=kennytm
Manishearth Jun 28, 2020
dd81139
Rollup merge of #73813 - petrochenkov:restrait, r=davidtwco
Manishearth Jun 28, 2020
8b92eec
Rollup merge of #73817 - jumbatm:rename-to-clashing-extern-declaratio…
Manishearth Jun 28, 2020
5304511
Rollup merge of #73826 - cjrh:cjrh-patch-1, r=jonas-schievink
Manishearth Jun 28, 2020
117b734
Rollup merge of #73833 - bjorn3:remove_gcx_enter_local, r=matthewjasper
Manishearth Jun 28, 2020
2f517ce
Auto merge of #73838 - Manishearth:rollup-jj57e84, r=Manishearth
bors Jun 28, 2020
66f0cef
Mark feature gate as accepted
ecstatic-morse May 21, 2020
f33a75c
Remove `control_flow_destroyed` and properly lower `&&` and `||`
ecstatic-morse May 21, 2020
48ebd2c
Remove `const_if_match` feature gate from libraries
ecstatic-morse May 21, 2020
4c23838
MIR const-checking
ecstatic-morse May 21, 2020
696084c
HIR const-checking
ecstatic-morse May 21, 2020
d6139f7
Update tests
ecstatic-morse May 21, 2020
69a5cb1
Remove `const_if_match` from unstable book
ecstatic-morse May 21, 2020
565be31
Require `allow_internal_unstable` in HIR const-checker
ecstatic-morse May 21, 2020
86e1555
Mark `const_loop` feature gate as accepted
ecstatic-morse Jun 26, 2020
5bed94c
Remove uses of `const_loop` in `rustc`
ecstatic-morse Jun 26, 2020
7c46e42
Stop checking for `while` and `loop` in a const context
ecstatic-morse Jun 26, 2020
d84f0c8
Update tests
ecstatic-morse Jun 26, 2020
1b28f94
Remove `ignore-tidy-filelength`
ecstatic-morse Jun 26, 2020
8509b69
Use `LocalDefId` in HIR const-checker
ecstatic-morse Jun 28, 2020
c977b87
Auto merge of #72437 - ecstatic-morse:stabilize-const-if-match, r=oli…
bors Jun 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
526 changes: 12 additions & 514 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 2 additions & 17 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::channel;
use crate::channel::GitInfo;
use crate::compile;
use crate::toolstate::ToolState;
use crate::util::{add_dylib_path, exe, CiEnv};
use crate::util::{add_dylib_path, exe};
use crate::Compiler;
use crate::Mode;

Expand Down Expand Up @@ -236,7 +236,6 @@ pub fn prepare_tool_cargo(
|| path.ends_with("rls")
|| path.ends_with("clippy")
|| path.ends_with("miri")
|| path.ends_with("rustbook")
|| path.ends_with("rustfmt")
{
cargo.env("LIBZ_SYS_STATIC", "1");
Expand Down Expand Up @@ -272,20 +271,6 @@ pub fn prepare_tool_cargo(
cargo
}

fn rustbook_features() -> Vec<String> {
let mut features = Vec::new();

// Due to CI budged and risk of spurious failures we want to limit jobs running this check.
// At same time local builds should run it regardless of the platform.
// `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
// explicitly enable it on single job
if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
features.push("linkcheck".to_string());
}

features
}

macro_rules! bootstrap_tool {
($(
$name:ident, $path:expr, $tool_name:expr
Expand Down Expand Up @@ -368,7 +353,7 @@ macro_rules! bootstrap_tool {
}

bootstrap_tool!(
Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
Rustbook, "src/tools/rustbook", "rustbook";
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
Tidy, "src/tools/tidy", "tidy";
Linkchecker, "src/tools/linkchecker", "linkchecker";
Expand Down
3 changes: 0 additions & 3 deletions src/ci/docker/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ RUN sh /scripts/sccache.sh

COPY x86_64-gnu-tools/checktools.sh /tmp/

# Run rustbook with `linkcheck` feature enabled
ENV CHECK_LINKS 1

ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--save-toolstates=/tmp/toolstate/toolstates.json
Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/compiler-flags/self-profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For example:
First, run a compilation session and provide the `-Zself-profile` flag:

```console
$ rustc --crate-name foo -Zself-profile`
$ rustc --crate-name foo -Zself-profile
```

This will generate three files in the working directory such as:
Expand Down
14 changes: 0 additions & 14 deletions src/doc/unstable-book/src/language-features/const-if-match.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#![feature(const_generic_impls_guard)]
#![feature(const_generics)]
#![feature(const_in_array_repeat_expressions)]
#![feature(const_if_match)]
#![cfg_attr(bootstrap, feature(const_if_match))]
#![feature(cow_is_borrowed)]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
Expand Down
1 change: 1 addition & 0 deletions src/libcore/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::task::{Context, Poll};
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[stable(feature = "futures_api", since = "1.36.0")]
#[lang = "future_trait"]
#[rustc_on_unimplemented(label = "`{Self}` is not a future", message = "`{Self}` is not a future")]
pub trait Future {
/// The type of value produced on completion.
#[stable(feature = "futures_api", since = "1.36.0")]
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,31 +333,31 @@ pub trait Hasher {
#[inline]
#[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i16(&mut self, i: i16) {
self.write(&i.to_ne_bytes())
self.write_u16(i as u16)
}
/// Writes a single `i32` into this hasher.
#[inline]
#[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i32(&mut self, i: i32) {
self.write(&i.to_ne_bytes())
self.write_u32(i as u32)
}
/// Writes a single `i64` into this hasher.
#[inline]
#[stable(feature = "hasher_write", since = "1.3.0")]
fn write_i64(&mut self, i: i64) {
self.write(&i.to_ne_bytes())
self.write_u64(i as u64)
}
/// Writes a single `i128` into this hasher.
#[inline]
#[stable(feature = "i128", since = "1.26.0")]
fn write_i128(&mut self, i: i128) {
self.write(&i.to_ne_bytes())
self.write_u128(i as u128)
}
/// Writes a single `isize` into this hasher.
#[inline]
#[stable(feature = "hasher_write", since = "1.3.0")]
fn write_isize(&mut self, i: isize) {
self.write(&i.to_ne_bytes())
self.write_usize(i as usize)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
#![feature(const_ascii_ctype_on_intrinsics)]
#![feature(const_alloc_layout)]
#![feature(const_discriminant)]
#![feature(const_if_match)]
#![feature(const_loop)]
#![cfg_attr(bootstrap, feature(const_if_match))]
#![cfg_attr(bootstrap, feature(const_loop))]
#![feature(const_checked_int_methods)]
#![feature(const_euclidean_int_methods)]
#![feature(const_overflowing_int_methods)]
Expand Down Expand Up @@ -279,9 +279,9 @@ pub mod primitive;
// crate uses the this crate as its libcore.
#[path = "../stdarch/crates/core_arch/src/mod.rs"]
#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_decl is
// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
#[cfg_attr(not(bootstrap), allow(clashing_extern_decl))]
#[cfg_attr(not(bootstrap), allow(clashing_extern_declarations))]
#[unstable(feature = "stdsimd", issue = "48556")]
mod core_arch;

Expand Down
6 changes: 3 additions & 3 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ $EndFeature, "
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
#[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
#[inline]
pub const fn wrapping_abs(self) -> Self {
if self.is_negative() {
Expand Down Expand Up @@ -1867,7 +1867,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
#[stable(feature = "wrapping", since = "1.7.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
#[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
pub const fn overflowing_neg(self) -> (Self, bool) {
if self == Self::MIN {
(Self::MIN, true)
Expand Down Expand Up @@ -2160,7 +2160,7 @@ $EndFeature, "
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
#[cfg_attr(bootstrap, allow_internal_unstable(const_if_match))]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn abs(self) -> Self {
Expand Down
54 changes: 54 additions & 0 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,60 @@ impl<T> [T] {
{
self.iter().is_sorted_by_key(f)
}

/// Returns the index of the partition point according to the given predicate
/// (the index of the first element of the second partition).
///
/// The slice is assumed to be partitioned according to the given predicate.
/// This means that all elements for which the predicate returns true are at the start of the slice
/// and all elements for which the predicate returns false are at the end.
/// For example, [7, 15, 3, 5, 4, 12, 6] is a partitioned under the predicate x % 2 != 0
/// (all odd numbers are at the start, all even at the end).
///
/// If this slice is not partitioned, the returned result is unspecified and meaningless,
/// as this method performs a kind of binary search.
///
/// # Examples
///
/// ```
/// #![feature(partition_point)]
///
/// let v = [1, 2, 3, 3, 5, 6, 7];
/// let i = v.partition_point(|&x| x < 5);
///
/// assert_eq!(i, 4);
/// assert!(v[..i].iter().all(|&x| x < 5));
/// assert!(v[i..].iter().all(|&x| !(x < 5)));
/// ```
#[unstable(feature = "partition_point", reason = "new API", issue = "73831")]
pub fn partition_point<P>(&self, mut pred: P) -> usize
where
P: FnMut(&T) -> bool,
{
let mut left = 0;
let mut right = self.len();

while left != right {
let mid = left + (right - left) / 2;
// SAFETY:
// When left < right, left <= mid < right.
// Therefore left always increases and right always decreases,
// and eigher of them is selected.
// In both cases left <= right is satisfied.
// Therefore if left < right in a step,
// left <= right is satisfied in the next step.
// Therefore as long as left != right, 0 <= left < right <= len is satisfied
// and if this case 0 <= mid < len is satisfied too.
let value = unsafe { self.get_unchecked(mid) };
if pred(value) {
left = mid + 1;
} else {
right = mid;
}
}

left
}
}

#[lang = "slice_u8"]
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#![feature(const_forget)]
#![feature(option_unwrap_none)]
#![feature(peekable_next_if)]
#![feature(partition_point)]

extern crate test;

Expand Down
40 changes: 40 additions & 0 deletions src/libcore/tests/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,46 @@ fn test_binary_search_implementation_details() {
assert_eq!(b.binary_search(&3), Ok(8));
}

#[test]
fn test_partition_point() {
let b: [i32; 0] = [];
assert_eq!(b.partition_point(|&x| x < 5), 0);

let b = [4];
assert_eq!(b.partition_point(|&x| x < 3), 0);
assert_eq!(b.partition_point(|&x| x < 4), 0);
assert_eq!(b.partition_point(|&x| x < 5), 1);

let b = [1, 2, 4, 6, 8, 9];
assert_eq!(b.partition_point(|&x| x < 5), 3);
assert_eq!(b.partition_point(|&x| x < 6), 3);
assert_eq!(b.partition_point(|&x| x < 7), 4);
assert_eq!(b.partition_point(|&x| x < 8), 4);

let b = [1, 2, 4, 5, 6, 8];
assert_eq!(b.partition_point(|&x| x < 9), 6);

let b = [1, 2, 4, 6, 7, 8, 9];
assert_eq!(b.partition_point(|&x| x < 6), 3);
assert_eq!(b.partition_point(|&x| x < 5), 3);
assert_eq!(b.partition_point(|&x| x < 8), 5);

let b = [1, 2, 4, 5, 6, 8, 9];
assert_eq!(b.partition_point(|&x| x < 7), 5);
assert_eq!(b.partition_point(|&x| x < 0), 0);

let b = [1, 3, 3, 3, 7];
assert_eq!(b.partition_point(|&x| x < 0), 0);
assert_eq!(b.partition_point(|&x| x < 1), 0);
assert_eq!(b.partition_point(|&x| x < 2), 1);
assert_eq!(b.partition_point(|&x| x < 3), 1);
assert_eq!(b.partition_point(|&x| x < 4), 4);
assert_eq!(b.partition_point(|&x| x < 5), 4);
assert_eq!(b.partition_point(|&x| x < 6), 4);
assert_eq!(b.partition_point(|&x| x < 7), 4);
assert_eq!(b.partition_point(|&x| x < 8), 5);
}

#[test]
fn test_iterator_nth() {
let v: &[_] = &[0, 1, 2, 3, 4];
Expand Down
16 changes: 10 additions & 6 deletions src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ fn main() {
"InstrProfilingUtil.c",
"InstrProfilingValue.c",
"InstrProfilingWriter.c",
// This file was renamed in LLVM 10.
"InstrProfilingRuntime.cc",
"InstrProfilingRuntime.cpp",
// These files were added in LLVM 11.
"InstrProfilingInternal.c",
"InstrProfilingBiasVar.c",
];

if target.contains("msvc") {
Expand Down Expand Up @@ -69,14 +75,12 @@ fn main() {

let src_root = root.join("lib").join("profile");
for src in profile_sources {
cfg.file(src_root.join(src));
let path = src_root.join(src);
if path.exists() {
cfg.file(path);
}
}

// The file was renamed in LLVM 10.
let old_runtime_path = src_root.join("InstrProfilingRuntime.cc");
let new_runtime_path = src_root.join("InstrProfilingRuntime.cpp");
cfg.file(if old_runtime_path.exists() { old_runtime_path } else { new_runtime_path });

cfg.include(root.join("include"));
cfg.warnings(false);
cfg.compile("profiler-rt");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(const_if_match)]
#![cfg_attr(bootstrap, feature(const_if_match))]
#![feature(const_fn)] // For the `transmute` in `P::new`
#![feature(const_panic)]
#![feature(const_transmute)]
Expand Down
17 changes: 14 additions & 3 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
use rustc_span::source_map::{respan, DesugaringKind, ForLoopLoc, Span, Spanned};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_target::asm;
use std::collections::hash_map::Entry;
Expand Down Expand Up @@ -1361,9 +1361,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
body: &Block,
opt_label: Option<Label>,
) -> hir::Expr<'hir> {
let orig_head_span = head.span;
// expand <head>
let mut head = self.lower_expr_mut(head);
let desugared_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
let desugared_span = self.mark_span_with_reason(
DesugaringKind::ForLoop(ForLoopLoc::Head),
orig_head_span,
None,
);
head.span = desugared_span;

let iter = Ident::with_dummy_span(sym::iter);
Expand Down Expand Up @@ -1458,10 +1463,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `mut iter => { ... }`
let iter_arm = self.arm(iter_pat, loop_expr);

let into_iter_span = self.mark_span_with_reason(
DesugaringKind::ForLoop(ForLoopLoc::IntoIter),
orig_head_span,
None,
);

// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
let into_iter_expr = {
let into_iter_path = &[sym::iter, sym::IntoIterator, sym::into_iter];
self.expr_call_std_path(desugared_span, into_iter_path, arena_vec![self; head])
self.expr_call_std_path(into_iter_span, into_iter_path, arena_vec![self; head])
};

let match_expr = self.arena.alloc(self.expr_match(
Expand Down
Loading