Skip to content

Commit fcc1615

Browse files
committed
Auto merge of rust-lang#134559 - DianQK:rollup-22iraj9, r=DianQK
Rollup of 5 pull requests Successful merges: - rust-lang#134366 (Fix logical error with what text is considered whitespace.) - rust-lang#134514 (Improve dependency_format a bit) - rust-lang#134519 (ci: use ubuntu `24` instead of `latest`) - rust-lang#134551 (coverage: Rename `basic_coverage_blocks` to just `graph`) - rust-lang#134553 (add member constraints comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8a1f803 + 594e74d commit fcc1615

File tree

23 files changed

+206
-189
lines changed

23 files changed

+206
-189
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml.
4747
calculate_matrix:
4848
name: Calculate job matrix
49-
runs-on: ubuntu-latest
49+
runs-on: ubuntu-24.04
5050
outputs:
5151
jobs: ${{ steps.jobs.outputs.jobs }}
5252
run_type: ${{ steps.jobs.outputs.run_type }}
@@ -243,7 +243,7 @@ jobs:
243243
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
244244
outcome:
245245
name: bors build finished
246-
runs-on: ubuntu-latest
246+
runs-on: ubuntu-24.04
247247
needs: [ calculate_matrix, job ]
248248
# !cancelled() executes the job regardless of whether the previous jobs passed or failed
249249
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}

.github/workflows/dependencies.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
not-waiting-on-bors:
2828
if: github.repository_owner == 'rust-lang'
2929
name: skip if S-waiting-on-bors
30-
runs-on: ubuntu-latest
30+
runs-on: ubuntu-24.04
3131
steps:
3232
- env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -47,7 +47,7 @@ jobs:
4747
if: github.repository_owner == 'rust-lang'
4848
name: update dependencies
4949
needs: not-waiting-on-bors
50-
runs-on: ubuntu-latest
50+
runs-on: ubuntu-24.04
5151
steps:
5252
- name: checkout the source code
5353
uses: actions/checkout@v4
@@ -94,7 +94,7 @@ jobs:
9494
if: github.repository_owner == 'rust-lang'
9595
name: amend PR
9696
needs: update
97-
runs-on: ubuntu-latest
97+
runs-on: ubuntu-24.04
9898
permissions:
9999
contents: write
100100
pull-requests: write

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3722,6 +3722,7 @@ dependencies = [
37223722
"rustc_fluent_macro",
37233723
"rustc_hir",
37243724
"rustc_index",
3725+
"rustc_lexer",
37253726
"rustc_lint_defs",
37263727
"rustc_macros",
37273728
"rustc_serialize",

compiler/rustc_borrowck/src/region_infer/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
795795

796796
// If the member region lives in a higher universe, we currently choose
797797
// the most conservative option by leaving it unchanged.
798-
799798
if !self.constraint_sccs().annotation(scc).min_universe().is_root() {
800799
return;
801800
}
@@ -823,12 +822,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
823822
}
824823
debug!(?choice_regions, "after ub");
825824

826-
// At this point we can pick any member of `choice_regions`, but to avoid potential
827-
// non-determinism we will pick the *unique minimum* choice.
825+
// At this point we can pick any member of `choice_regions` and would like to choose
826+
// it to be a small as possible. To avoid potential non-determinism we will pick the
827+
// smallest such choice.
828828
//
829829
// Because universal regions are only partially ordered (i.e, not every two regions are
830830
// comparable), we will ignore any region that doesn't compare to all others when picking
831831
// the minimum choice.
832+
//
832833
// For example, consider `choice_regions = ['static, 'a, 'b, 'c, 'd, 'e]`, where
833834
// `'static: 'a, 'static: 'b, 'a: 'c, 'b: 'c, 'c: 'd, 'c: 'e`.
834835
// `['d, 'e]` are ignored because they do not compare - the same goes for `['a, 'b]`.
@@ -853,6 +854,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
853854
return;
854855
};
855856

857+
// As we require `'scc: 'min_choice`, we have definitely already computed
858+
// its `scc_values` at this point.
856859
let min_choice_scc = self.constraint_sccs.scc(min_choice);
857860
debug!(?min_choice, ?min_choice_scc);
858861
if self.scc_values.add_region(scc, min_choice_scc) {

compiler/rustc_codegen_cranelift/src/driver/jit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn dep_symbol_lookup_fn(
294294
// search path.
295295
for &cnum in crate_info.used_crates.iter().rev() {
296296
let src = &crate_info.used_crate_source[&cnum];
297-
match data[cnum.as_usize() - 1] {
297+
match data[cnum] {
298298
Linkage::NotLinked | Linkage::IncludedFromDylib => {}
299299
Linkage::Static => {
300300
let name = crate_info.crate_name[&cnum];

compiler/rustc_codegen_ssa/src/back/link.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ pub fn each_linked_rlib(
234234
crate_type: Option<CrateType>,
235235
f: &mut dyn FnMut(CrateNum, &Path),
236236
) -> Result<(), errors::LinkRlibError> {
237-
let crates = info.used_crates.iter();
238-
239237
let fmts = if let Some(crate_type) = crate_type {
240238
let Some(fmts) = info.dependency_formats.get(&crate_type) else {
241239
return Err(errors::LinkRlibError::MissingFormat);
@@ -261,8 +259,9 @@ pub fn each_linked_rlib(
261259
info.dependency_formats.first().unwrap().1
262260
};
263261

264-
for &cnum in crates {
265-
match fmts.get(cnum.as_usize() - 1) {
262+
let used_dep_crates = info.used_crates.iter();
263+
for &cnum in used_dep_crates {
264+
match fmts.get(cnum) {
266265
Some(&Linkage::NotLinked | &Linkage::Dynamic | &Linkage::IncludedFromDylib) => continue,
267266
Some(_) => {}
268267
None => return Err(errors::LinkRlibError::MissingFormat),
@@ -624,7 +623,7 @@ fn link_staticlib(
624623

625624
let mut all_rust_dylibs = vec![];
626625
for &cnum in crates {
627-
match fmts.get(cnum.as_usize() - 1) {
626+
match fmts.get(cnum) {
628627
Some(&Linkage::Dynamic) => {}
629628
_ => continue,
630629
}
@@ -2361,8 +2360,8 @@ fn linker_with_args(
23612360
.crate_info
23622361
.native_libraries
23632362
.iter()
2364-
.filter_map(|(cnum, libraries)| {
2365-
(dependency_linkage[cnum.as_usize() - 1] != Linkage::Static).then_some(libraries)
2363+
.filter_map(|(&cnum, libraries)| {
2364+
(dependency_linkage[cnum] != Linkage::Static).then_some(libraries)
23662365
})
23672366
.flatten()
23682367
.collect::<Vec<_>>();
@@ -2754,7 +2753,7 @@ fn add_upstream_rust_crates(
27542753
// (e.g. `libstd` when `-C prefer-dynamic` is used).
27552754
// FIXME: `dependency_formats` can report `profiler_builtins` as `NotLinked` for some
27562755
// reason, it shouldn't do that because `profiler_builtins` should indeed be linked.
2757-
let linkage = data[cnum.as_usize() - 1];
2756+
let linkage = data[cnum];
27582757
let link_static_crate = linkage == Linkage::Static
27592758
|| (linkage == Linkage::IncludedFromDylib || linkage == Linkage::NotLinked)
27602759
&& (codegen_results.crate_info.compiler_builtins == Some(cnum)

compiler/rustc_codegen_ssa/src/back/linker.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1744,15 +1744,10 @@ fn for_each_exported_symbols_include_dep<'tcx>(
17441744
crate_type: CrateType,
17451745
mut callback: impl FnMut(ExportedSymbol<'tcx>, SymbolExportInfo, CrateNum),
17461746
) {
1747-
for &(symbol, info) in tcx.exported_symbols(LOCAL_CRATE).iter() {
1748-
callback(symbol, info, LOCAL_CRATE);
1749-
}
1750-
17511747
let formats = tcx.dependency_formats(());
17521748
let deps = &formats[&crate_type];
17531749

1754-
for (index, dep_format) in deps.iter().enumerate() {
1755-
let cnum = CrateNum::new(index + 1);
1750+
for (cnum, dep_format) in deps.iter_enumerated() {
17561751
// For each dependency that we are linking to statically ...
17571752
if *dep_format == Linkage::Static {
17581753
for &(symbol, info) in tcx.exported_symbols(cnum).iter() {

compiler/rustc_errors/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rustc_error_messages = { path = "../rustc_error_messages" }
1616
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1717
rustc_hir = { path = "../rustc_hir" }
1818
rustc_index = { path = "../rustc_index" }
19+
rustc_lexer = { path = "../rustc_lexer" }
1920
rustc_lint_defs = { path = "../rustc_lint_defs" }
2021
rustc_macros = { path = "../rustc_macros" }
2122
rustc_serialize = { path = "../rustc_serialize" }

compiler/rustc_errors/src/emitter.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use derive_setters::Setters;
1919
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
2020
use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc};
2121
use rustc_error_messages::{FluentArgs, SpanLabel};
22+
use rustc_lexer;
2223
use rustc_lint_defs::pluralize;
2324
use rustc_span::hygiene::{ExpnKind, MacroKind};
2425
use rustc_span::source_map::SourceMap;
@@ -1698,9 +1699,14 @@ impl HumanEmitter {
16981699
if let Some(source_string) =
16991700
line.line_index.checked_sub(1).and_then(|l| file.get_line(l))
17001701
{
1702+
// Whitespace can only be removed (aka considered leading)
1703+
// if the lexer considers it whitespace.
1704+
// non-rustc_lexer::is_whitespace() chars are reported as an
1705+
// error (ex. no-break-spaces \u{a0}), and thus can't be considered
1706+
// for removal during error reporting.
17011707
let leading_whitespace = source_string
17021708
.chars()
1703-
.take_while(|c| c.is_whitespace())
1709+
.take_while(|c| rustc_lexer::is_whitespace(*c))
17041710
.map(|c| {
17051711
match c {
17061712
// Tabs are displayed as 4 spaces
@@ -1709,7 +1715,7 @@ impl HumanEmitter {
17091715
}
17101716
})
17111717
.sum();
1712-
if source_string.chars().any(|c| !c.is_whitespace()) {
1718+
if source_string.chars().any(|c| !rustc_lexer::is_whitespace(c)) {
17131719
whitespace_margin = min(whitespace_margin, leading_whitespace);
17141720
}
17151721
}

compiler/rustc_interface/src/passes.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_incremental::setup_dep_graph;
1919
use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_store};
2020
use rustc_metadata::creader::CStore;
2121
use rustc_middle::arena::Arena;
22-
use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt};
22+
use rustc_middle::ty::{self, CurrentGcx, GlobalCtxt, RegisteredTools, TyCtxt};
2323
use rustc_middle::util::Providers;
2424
use rustc_parse::{
2525
new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal, validate_attr,
@@ -770,15 +770,14 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
770770
// subtyping for GlobalCtxt::enter to be allowed.
771771
let inner: Box<
772772
dyn for<'tcx> FnOnce(
773-
&'tcx Compiler,
773+
&'tcx Session,
774+
CurrentGcx,
774775
&'tcx OnceLock<GlobalCtxt<'tcx>>,
775776
&'tcx WorkerLocal<Arena<'tcx>>,
776777
&'tcx WorkerLocal<rustc_hir::Arena<'tcx>>,
777778
F,
778779
) -> T,
779-
> = Box::new(move |compiler, gcx_cell, arena, hir_arena, f| {
780-
let sess = &compiler.sess;
781-
780+
> = Box::new(move |sess, current_gcx, gcx_cell, arena, hir_arena, f| {
782781
TyCtxt::create_global_ctxt(
783782
gcx_cell,
784783
sess,
@@ -796,15 +795,15 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
796795
incremental,
797796
),
798797
providers.hooks,
799-
compiler.current_gcx.clone(),
798+
current_gcx,
800799
|tcx| {
801800
let feed = tcx.create_crate_num(stable_crate_id).unwrap();
802801
assert_eq!(feed.key(), LOCAL_CRATE);
803802
feed.crate_name(crate_name);
804803

805804
let feed = tcx.feed_unit_query();
806805
feed.features_query(tcx.arena.alloc(rustc_expand::config::features(
807-
sess,
806+
tcx.sess,
808807
&pre_configured_attrs,
809808
crate_name,
810809
)));
@@ -819,7 +818,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
819818
)
820819
});
821820

822-
inner(compiler, &gcx_cell, &arena, &hir_arena, f)
821+
inner(&compiler.sess, compiler.current_gcx.clone(), &gcx_cell, &arena, &hir_arena, f)
823822
}
824823

825824
/// Runs all analyses that we guarantee to run, even if errors were reported in earlier analyses.

0 commit comments

Comments
 (0)