Skip to content

Commit 5dbf406

Browse files
committed
Auto merge of #148885 - Zalathar:rollup-wrvewer, r=Zalathar
Rollup of 7 pull requests Successful merges: - #147701 (rustdoc: don't ignore path distance for doc aliases) - #148735 (Fix ICE caused by invalid spans for shrink_file) - #148839 (fix rtsan_nonblocking_async lint closure ICE) - #148846 (add a test for combining RPIT with explicit tail calls) - #148872 (fix: Do not ICE when missing match arm with ill-formed subty is met) - #148880 (Remove explicit install of `eslint` inside of `tidy`'s Dockerfile) - #148883 (bootstrap: dont require cmake if local-rebuild is enabled) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 503dce3 + 314a6cd commit 5dbf406

File tree

20 files changed

+280
-29
lines changed

20 files changed

+280
-29
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,18 @@ fn check_result(
469469
})
470470
}
471471

472-
// warn for nonblocking async fn.
472+
// warn for nonblocking async functions, blocks and closures.
473473
// This doesn't behave as expected, because the executor can run blocking code without the sanitizer noticing.
474474
if codegen_fn_attrs.sanitizers.rtsan_setting == RtsanSetting::Nonblocking
475475
&& let Some(sanitize_span) = interesting_spans.sanitize
476-
// async function
477-
&& (tcx.asyncness(did).is_async() || (tcx.is_closure_like(did.into())
476+
// async fn
477+
&& (tcx.asyncness(did).is_async()
478478
// async block
479-
&& (tcx.coroutine_is_async(did.into())
480-
// async closure
481-
|| tcx.coroutine_is_async(tcx.coroutine_for_closure(did)))))
479+
|| tcx.is_coroutine(did.into())
480+
// async closure
481+
|| (tcx.is_closure_like(did.into())
482+
&& tcx.hir_node_by_def_id(did).expect_closure().kind
483+
!= rustc_hir::ClosureKind::Closure))
482484
{
483485
let hir_id = tcx.local_def_id_to_hir_id(did);
484486
tcx.node_span_lint(

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,27 @@ impl AnnotateSnippetEmitter {
350350
"all spans must be disjoint",
351351
);
352352

353+
let lo = subst.parts.iter().map(|part| part.span.lo()).min()?;
354+
let lo_file = sm.lookup_source_file(lo);
355+
let hi = subst.parts.iter().map(|part| part.span.hi()).max()?;
356+
let hi_file = sm.lookup_source_file(hi);
357+
358+
// The different spans might belong to different contexts, if so ignore suggestion.
359+
if lo_file.stable_id != hi_file.stable_id {
360+
return None;
361+
}
362+
363+
// We can't splice anything if the source is unavailable.
364+
if !sm.ensure_source_file_source_present(&lo_file) {
365+
return None;
366+
}
367+
353368
// Account for cases where we are suggesting the same code that's already
354369
// there. This shouldn't happen often, but in some cases for multipart
355370
// suggestions it's much easier to handle it here than in the origin.
356371
subst.parts.retain(|p| is_different(sm, &p.snippet, p.span));
357372

358-
let item_span = subst.parts.first()?;
359-
let file = sm.lookup_source_file(item_span.span.lo());
360-
if should_show_source_code(
361-
&self.ignored_directories_in_source_blocks,
362-
sm,
363-
&file,
364-
) {
365-
Some(subst)
366-
} else {
367-
None
368-
}
373+
if subst.parts.is_empty() { None } else { Some(subst) }
369374
})
370375
.collect::<Vec<_>>();
371376

@@ -745,14 +750,20 @@ fn shrink_file(
745750
) -> Option<(Span, String, usize)> {
746751
let lo_byte = spans.iter().map(|s| s.lo()).min()?;
747752
let lo_loc = sm.lookup_char_pos(lo_byte);
748-
let lo = lo_loc.file.line_bounds(lo_loc.line.saturating_sub(1)).start;
749753

750754
let hi_byte = spans.iter().map(|s| s.hi()).max()?;
751755
let hi_loc = sm.lookup_char_pos(hi_byte);
752-
let hi = lo_loc.file.line_bounds(hi_loc.line.saturating_sub(1)).end;
756+
757+
if lo_loc.file.stable_id != hi_loc.file.stable_id {
758+
// this may happen when spans cross file boundaries due to macro expansion.
759+
return None;
760+
}
761+
762+
let lo = lo_loc.file.line_bounds(lo_loc.line.saturating_sub(1)).start;
763+
let hi = hi_loc.file.line_bounds(hi_loc.line.saturating_sub(1)).end;
753764

754765
let bounding_span = Span::with_root_ctxt(lo, hi);
755-
let source = sm.span_to_snippet(bounding_span).unwrap_or_default();
766+
let source = sm.span_to_snippet(bounding_span).ok()?;
756767
let offset_line = sm.doctest_offset_line(file_name, lo_loc.line);
757768

758769
Some((bounding_span, source, offset_line))

compiler/rustc_pattern_analysis/src/rustc.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,18 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
191191
variant.fields.iter().map(move |field| {
192192
let ty = field.ty(self.tcx, args);
193193
// `field.ty()` doesn't normalize after instantiating.
194-
let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty);
194+
let ty =
195+
self.tcx.try_normalize_erasing_regions(self.typing_env, ty).unwrap_or_else(|e| {
196+
self.tcx.dcx().span_delayed_bug(
197+
self.scrut_span,
198+
format!(
199+
"Failed to normalize {:?} in typing_env={:?} while getting variant sub tys for {ty:?}",
200+
e.get_type_for_failure(),
201+
self.typing_env,
202+
),
203+
);
204+
ty
205+
});
195206
let ty = self.reveal_opaque_ty(ty);
196207
(field, ty)
197208
})

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub fn check(build: &mut Build) {
142142

143143
// We need cmake, but only if we're actually building LLVM or sanitizers.
144144
let building_llvm = !build.config.llvm_from_ci
145+
&& !build.config.local_rebuild
145146
&& build.hosts.iter().any(|host| {
146147
build.config.llvm_enabled(*host)
147148
&& build

src/ci/docker/host-x86_64/tidy/Dockerfile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ COPY scripts/nodejs.sh /scripts/
2828
RUN sh /scripts/nodejs.sh /node
2929
ENV PATH="/node/bin:${PATH}"
3030

31-
# Install eslint
32-
COPY host-x86_64/tidy/eslint.version /tmp/
33-
3431
COPY scripts/sccache.sh /scripts/
3532
RUN sh /scripts/sccache.sh
3633

@@ -40,8 +37,6 @@ RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-require
4037

4138
COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
4239

43-
RUN bash -c 'npm install -g eslint@$(cat /tmp/eslint.version)'
44-
4540
# NOTE: intentionally uses python2 for x.py so we can test it still works.
4641
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
4742
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \

src/ci/docker/host-x86_64/tidy/eslint.version

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/librustdoc/html/static/js/search.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,16 +3926,25 @@ class DocSearch {
39263926
* @returns {Promise<rustdoc.PlainResultObject?>}
39273927
*/
39283928
const handleAlias = async(name, alias, dist, index) => {
3929+
const item = nonnull(await this.getRow(alias, false));
3930+
// space both is an alias for ::,
3931+
// and is also allowed to appear in doc alias names
3932+
const path_dist = name.includes(" ") || parsedQuery.elems.length === 0 ?
3933+
0 : checkRowPath(parsedQuery.elems[0].pathWithoutLast, item);
3934+
// path distance exceeds max, omit alias from results
3935+
if (path_dist === null) {
3936+
return null;
3937+
}
39293938
return {
39303939
id: alias,
39313940
dist,
3932-
path_dist: 0,
3941+
path_dist,
39333942
index,
39343943
alias: name,
39353944
is_alias: true,
39363945
elems: [], // only used in type-based queries
39373946
returned: [], // only used in type-based queries
3938-
item: nonnull(await this.getRow(alias, false)),
3947+
item,
39393948
};
39403949
};
39413950
/**
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// exact-check
2+
3+
// consider path distance for doc aliases
4+
// regression test for <https://github.com/rust-lang/rust/issues/146214>
5+
6+
const EXPECTED = [
7+
{
8+
'query': 'Foo::zzz',
9+
'others': [
10+
{ 'path': 'alias_path_distance::Foo', 'name': 'baz' },
11+
],
12+
},
13+
{
14+
'query': '"Foo::zzz"',
15+
'others': [
16+
{ 'path': 'alias_path_distance::Foo', 'name': 'baz' },
17+
],
18+
},
19+
{
20+
'query': 'Foo::zzzz',
21+
'others': [
22+
{ 'path': 'alias_path_distance::Foo', 'name': 'baz' },
23+
],
24+
},
25+
{
26+
'query': 'zzzz',
27+
'others': [
28+
{ 'path': 'alias_path_distance::Foo', 'name': 'baz' },
29+
{ 'path': 'alias_path_distance::Bar', 'name': 'baz' },
30+
],
31+
},
32+
];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_name = "alias_path_distance"]
2+
3+
pub struct Foo;
4+
pub struct Bar;
5+
6+
impl Foo {
7+
#[doc(alias = "zzz")]
8+
pub fn baz() {}
9+
}
10+
11+
impl Bar {
12+
#[doc(alias = "zzz")]
13+
pub fn baz() {}
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// rank doc aliases lower than exact matches
2+
// regression test for <https://github.com/rust-lang/rust/issues/140968>
3+
4+
const EXPECTED = {
5+
'query': 'Foo',
6+
'others': [
7+
{ 'path': 'alias_rank_lower', 'name': 'Foo' },
8+
{ 'path': 'alias_rank_lower', 'name': 'Bar' },
9+
],
10+
};

0 commit comments

Comments
 (0)