Skip to content

Commit c1e8f3a

Browse files
committed
Auto merge of #85838 - GuillaumeGomez:rollup-rk2rh7m, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #85285 (Add eslint checks to CI) - #85709 (Use correct edition when parsing `:pat` matchers) - #85762 (Do not try to build LLVM with Zlib on Windows) - #85770 (Remove `--print unversioned-files` from rustdoc ) - #85781 (Add documentation for aarch64-apple-ios-sim target) - #85801 (Add `String::extend_from_within`) - #85817 (Fix a typo) - #85818 (Don't drop `PResult` without handling the error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 758c00e + 71a7f8f commit c1e8f3a

File tree

24 files changed

+197
-45
lines changed

24 files changed

+197
-45
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ pub fn compile_declarative_macro(
467467
&sess.parse_sess,
468468
def.id,
469469
features,
470+
edition,
470471
)
471472
.pop()
472473
.unwrap();
@@ -492,6 +493,7 @@ pub fn compile_declarative_macro(
492493
&sess.parse_sess,
493494
def.id,
494495
features,
496+
edition,
495497
)
496498
.pop()
497499
.unwrap();

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use rustc_feature::Features;
99
use rustc_session::parse::ParseSess;
1010
use rustc_span::symbol::{kw, Ident};
1111

12-
use rustc_span::Span;
12+
use rustc_span::edition::Edition;
13+
use rustc_span::{Span, SyntaxContext};
1314

1415
use rustc_data_structures::sync::Lrc;
1516

@@ -32,6 +33,7 @@ const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
3233
/// - `sess`: the parsing session. Any errors will be emitted to this session.
3334
/// - `node_id`: the NodeId of the macro we are parsing.
3435
/// - `features`: language features so we can do feature gating.
36+
/// - `edition`: the edition of the crate defining the macro
3537
///
3638
/// # Returns
3739
///
@@ -42,6 +44,7 @@ pub(super) fn parse(
4244
sess: &ParseSess,
4345
node_id: NodeId,
4446
features: &Features,
47+
edition: Edition,
4548
) -> Vec<TokenTree> {
4649
// Will contain the final collection of `self::TokenTree`
4750
let mut result = Vec::new();
@@ -52,7 +55,7 @@ pub(super) fn parse(
5255
while let Some(tree) = trees.next() {
5356
// Given the parsed tree, if there is a metavar and we are expecting matchers, actually
5457
// parse out the matcher (i.e., in `$id:ident` this would parse the `:` and `ident`).
55-
let tree = parse_tree(tree, &mut trees, expect_matchers, sess, node_id, features);
58+
let tree = parse_tree(tree, &mut trees, expect_matchers, sess, node_id, features, edition);
5659
match tree {
5760
TokenTree::MetaVar(start_sp, ident) if expect_matchers => {
5861
let span = match trees.next() {
@@ -64,7 +67,19 @@ pub(super) fn parse(
6467

6568
let kind =
6669
token::NonterminalKind::from_symbol(frag.name, || {
67-
span.edition()
70+
// FIXME(#85708) - once we properly decode a foreign
71+
// crate's `SyntaxContext::root`, then we can replace
72+
// this with just `span.edition()`. A
73+
// `SyntaxContext::root()` from the current crate will
74+
// have the edition of the current crate, and a
75+
// `SyntaxxContext::root()` from a foreign crate will
76+
// have the edition of that crate (which we manually
77+
// retrieve via the `edition` parameter).
78+
if span.ctxt() == SyntaxContext::root() {
79+
edition
80+
} else {
81+
span.edition()
82+
}
6883
})
6984
.unwrap_or_else(
7085
|| {
@@ -117,13 +132,15 @@ pub(super) fn parse(
117132
/// - `expect_matchers`: same as for `parse` (see above).
118133
/// - `sess`: the parsing session. Any errors will be emitted to this session.
119134
/// - `features`: language features so we can do feature gating.
135+
/// - `edition` - the edition of the crate defining the macro
120136
fn parse_tree(
121137
tree: tokenstream::TokenTree,
122138
outer_trees: &mut impl Iterator<Item = tokenstream::TokenTree>,
123139
expect_matchers: bool,
124140
sess: &ParseSess,
125141
node_id: NodeId,
126142
features: &Features,
143+
edition: Edition,
127144
) -> TokenTree {
128145
// Depending on what `tree` is, we could be parsing different parts of a macro
129146
match tree {
@@ -151,7 +168,7 @@ fn parse_tree(
151168
sess.span_diagnostic.span_err(span.entire(), &msg);
152169
}
153170
// Parse the contents of the sequence itself
154-
let sequence = parse(tts, expect_matchers, sess, node_id, features);
171+
let sequence = parse(tts, expect_matchers, sess, node_id, features, edition);
155172
// Get the Kleene operator and optional separator
156173
let (separator, kleene) =
157174
parse_sep_and_kleene_op(&mut trees, span.entire(), sess);
@@ -204,7 +221,7 @@ fn parse_tree(
204221
span,
205222
Lrc::new(Delimited {
206223
delim,
207-
tts: parse(tts, expect_matchers, sess, node_id, features),
224+
tts: parse(tts, expect_matchers, sess, node_id, features, edition),
208225
}),
209226
),
210227
}

compiler/rustc_parse/src/parser/item.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,10 @@ impl<'a> Parser<'a> {
14741474
self.sess.gated_spans.gate(sym::unnamed_fields, lo);
14751475
} else {
14761476
let err = if self.check_fn_front_matter(false) {
1477-
let _ = self.parse_fn(&mut Vec::new(), |_| true, lo);
1477+
// We use `parse_fn` to get a span for the function
1478+
if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
1479+
db.delay_as_bug();
1480+
}
14781481
let mut err = self.struct_span_err(
14791482
lo.to(self.prev_token.span),
14801483
&format!("functions are not allowed in {} definitions", adt_ty),

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
#![feature(associated_type_bounds)]
145145
#![feature(slice_group_by)]
146146
#![feature(decl_macro)]
147+
#![feature(bindings_after_at)]
147148
// Allow testing this library
148149

149150
#[cfg(test)]

library/alloc/src/string.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,42 @@ impl String {
843843
self.vec.extend_from_slice(string.as_bytes())
844844
}
845845

846+
/// Copies elements from `src` range to the end of the string.
847+
///
848+
/// ## Panics
849+
///
850+
/// Panics if the starting point or end point do not lie on a [`char`]
851+
/// boundary, or if they're out of bounds.
852+
///
853+
/// ## Examples
854+
///
855+
/// ```
856+
/// #![feature(string_extend_from_within)]
857+
/// let mut string = String::from("abcde");
858+
///
859+
/// string.extend_from_within(2..);
860+
/// assert_eq!(string, "abcdecde");
861+
///
862+
/// string.extend_from_within(..2);
863+
/// assert_eq!(string, "abcdecdeab");
864+
///
865+
/// string.extend_from_within(4..8);
866+
/// assert_eq!(string, "abcdecdeabecde");
867+
/// ```
868+
#[cfg(not(no_global_oom_handling))]
869+
#[unstable(feature = "string_extend_from_within", issue = "none")]
870+
pub fn extend_from_within<R>(&mut self, src: R)
871+
where
872+
R: RangeBounds<usize>,
873+
{
874+
let src @ Range { start, end } = slice::range(src, ..self.len());
875+
876+
assert!(self.is_char_boundary(start));
877+
assert!(self.is_char_boundary(end));
878+
879+
self.vec.extend_from_within(src);
880+
}
881+
846882
/// Returns this `String`'s capacity, in bytes.
847883
///
848884
/// # Examples

library/alloc/src/vec/is_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
7373
// `Option<num::NonZeroU32>` and similar have a representation guarantee that
7474
// they're the same size as the corresponding `u32` type, as well as a guarantee
7575
// that transmuting between `NonZeroU32` and `Option<num::NonZeroU32>` works.
76-
// While the documentation officially makes in UB to transmute from `None`,
76+
// While the documentation officially makes it UB to transmute from `None`,
7777
// we're the standard library so we can make extra inferences, and we know that
7878
// the only niche available to represent `None` is the one that's all zeros.
7979

src/bootstrap/native.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl Step for Llvm {
181181
.define("LLVM_TARGET_ARCH", target_native.split('-').next().unwrap())
182182
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native);
183183

184-
if target != "aarch64-apple-darwin" {
184+
if target != "aarch64-apple-darwin" && !target.contains("windows") {
185185
cfg.define("LLVM_ENABLE_ZLIB", "ON");
186186
} else {
187187
cfg.define("LLVM_ENABLE_ZLIB", "OFF");

src/ci/docker/host-x86_64/mingw-check/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
2222
# Install es-check
2323
# Pin its version to prevent unrelated CI failures due to future es-check versions.
2424
RUN npm install es-check@5.2.3 -g
25+
RUN npm install eslint@7.20.0 -g
2526

2627
COPY scripts/sccache.sh /scripts/
2728
RUN sh /scripts/sccache.sh
@@ -37,4 +38,5 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
3738
python3 ../x.py doc --stage 0 library/test && \
3839
/scripts/validate-toolstate.sh && \
3940
# Runs checks to ensure that there are no ES5 issues in our JS code.
40-
es-check es5 ../src/librustdoc/html/static/*.js
41+
es-check es5 ../src/librustdoc/html/static/*.js && \
42+
eslint ../src/librustdoc/html/static/*.js

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [JSON Output](json.md)
1414
- [Tests](tests/index.md)
1515
- [Platform Support](platform-support.md)
16+
- [aarch64-apple-ios-sim](platform-support/aarch64-apple-ios-sim.md)
1617
- [Target Tier Policy](target-tier-policy.md)
1718
- [Targets](targets/index.md)
1819
- [Built-in Targets](targets/built-in.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ host tools.
196196
target | std | host | notes
197197
-------|:---:|:----:|-------
198198
`aarch64-apple-ios-macabi` | ? | | Apple Catalyst on ARM64
199-
`aarch64-apple-ios-sim` | ? | | Apple iOS Simulator on ARM64
199+
[`aarch64-apple-ios-sim`](platform-support/aarch64-apple-ios-sim.md) | | | Apple iOS Simulator on ARM64
200200
`aarch64-apple-tvos` | * | | ARM64 tvOS
201201
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
202202
`aarch64-unknown-hermit` | ? | |

0 commit comments

Comments
 (0)