Skip to content

Commit 7be1da0

Browse files
committed
Auto merge of #96263 - Dylan-DPC:rollup-0eofl13, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #90630 (Create real parser for search queries) - #96193 ([fuchsia] Add implementation for `current_exe`) - #96196 (Remove assertion that all paths in `ShouldRun` exist) - #96228 (Fix locations for intrinsics impls and change to links) - #96236 (Add an explicit `Span` field to `OutlivesConstraint`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 09ccb6c + 463c94a commit 7be1da0

40 files changed

+2389
-531
lines changed

compiler/rustc_borrowck/src/constraints/graph.rs

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> {
156156
sup: self.static_region,
157157
sub: next_static_idx.into(),
158158
locations: Locations::All(DUMMY_SP),
159+
span: DUMMY_SP,
159160
category: ConstraintCategory::Internal,
160161
variance_info: VarianceDiagInfo::default(),
161162
})

compiler/rustc_borrowck/src/constraints/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc_data_structures::graph::scc::Sccs;
22
use rustc_index::vec::IndexVec;
33
use rustc_middle::mir::ConstraintCategory;
44
use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
5+
use rustc_span::Span;
56
use std::fmt;
67
use std::ops::Index;
78

@@ -87,6 +88,12 @@ pub struct OutlivesConstraint<'tcx> {
8788
/// Where did this constraint arise?
8889
pub locations: Locations,
8990

91+
/// The `Span` associated with the creation of this constraint.
92+
/// This should be used in preference to obtaining the span from
93+
/// `locations`, since the `locations` may give a poor span
94+
/// in some cases (e.g. converting a constraint from a promoted).
95+
pub span: Span,
96+
9097
/// What caused this constraint?
9198
pub category: ConstraintCategory,
9299

compiler/rustc_borrowck/src/region_infer/dump_mir.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
7474
let mut constraints: Vec<_> = self.constraints.outlives().iter().collect();
7575
constraints.sort_by_key(|c| (c.sup, c.sub));
7676
for constraint in &constraints {
77-
let OutlivesConstraint { sup, sub, locations, category, variance_info: _ } = constraint;
77+
let OutlivesConstraint { sup, sub, locations, category, span, variance_info: _ } =
78+
constraint;
7879
let (name, arg) = match locations {
7980
Locations::All(span) => {
8081
("All", tcx.sess.source_map().span_to_embeddable_string(*span))
8182
}
8283
Locations::Single(loc) => ("Single", format!("{:?}", loc)),
8384
};
84-
with_msg(&format!("{:?}: {:?} due to {:?} at {}({})", sup, sub, category, name, arg))?;
85+
with_msg(&format!(
86+
"{:?}: {:?} due to {:?} at {}({}) ({:?}",
87+
sup, sub, category, name, arg, span
88+
))?;
8589
}
8690

8791
Ok(())

compiler/rustc_borrowck/src/region_infer/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
17331733

17341734
crate fn retrieve_closure_constraint_info(
17351735
&self,
1736-
body: &Body<'tcx>,
1736+
_body: &Body<'tcx>,
17371737
constraint: &OutlivesConstraint<'tcx>,
17381738
) -> BlameConstraint<'tcx> {
17391739
let loc = match constraint.locations {
@@ -1760,7 +1760,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
17601760
.unwrap_or(BlameConstraint {
17611761
category: constraint.category,
17621762
from_closure: false,
1763-
cause: ObligationCause::dummy_with_span(body.source_info(loc).span),
1763+
cause: ObligationCause::dummy_with_span(constraint.span),
17641764
variance_info: constraint.variance_info,
17651765
})
17661766
}
@@ -1869,6 +1869,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
18691869
sup: r,
18701870
sub: constraint.min_choice,
18711871
locations: Locations::All(p_c.definition_span),
1872+
span: p_c.definition_span,
18721873
category: ConstraintCategory::OpaqueType,
18731874
variance_info: ty::VarianceDiagInfo::default(),
18741875
};
@@ -2017,7 +2018,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20172018
category: constraint.category,
20182019
from_closure: false,
20192020
cause: ObligationCause::new(
2020-
constraint.locations.span(body),
2021+
constraint.span,
20212022
CRATE_HIR_ID,
20222023
cause_code.clone(),
20232024
),

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::mir::ConstraintCategory;
88
use rustc_middle::ty::subst::GenericArgKind;
99
use rustc_middle::ty::TypeFoldable;
1010
use rustc_middle::ty::{self, TyCtxt};
11-
use rustc_span::DUMMY_SP;
11+
use rustc_span::{Span, DUMMY_SP};
1212

1313
use crate::{
1414
constraints::OutlivesConstraint,
@@ -26,6 +26,7 @@ crate struct ConstraintConversion<'a, 'tcx> {
2626
implicit_region_bound: Option<ty::Region<'tcx>>,
2727
param_env: ty::ParamEnv<'tcx>,
2828
locations: Locations,
29+
span: Span,
2930
category: ConstraintCategory,
3031
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
3132
}
@@ -38,6 +39,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
3839
implicit_region_bound: Option<ty::Region<'tcx>>,
3940
param_env: ty::ParamEnv<'tcx>,
4041
locations: Locations,
42+
span: Span,
4143
category: ConstraintCategory,
4244
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
4345
) -> Self {
@@ -49,6 +51,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
4951
implicit_region_bound,
5052
param_env,
5153
locations,
54+
span,
5255
category,
5356
constraints,
5457
}
@@ -153,6 +156,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
153156
self.constraints.outlives_constraints.push(OutlivesConstraint {
154157
locations: self.locations,
155158
category: self.category,
159+
span: self.span,
156160
sub,
157161
sup,
158162
variance_info: ty::VarianceDiagInfo::default(),

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
316316
self.implicit_region_bound,
317317
self.param_env,
318318
Locations::All(DUMMY_SP),
319+
DUMMY_SP,
319320
ConstraintCategory::Internal,
320321
&mut self.constraints,
321322
)

compiler/rustc_borrowck/src/type_check/input_output.rs

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
235235
Some(self.implicit_region_bound),
236236
self.param_env,
237237
Locations::All(DUMMY_SP),
238+
DUMMY_SP,
238239
ConstraintCategory::Internal,
239240
&mut self.borrowck_context.constraints,
240241
)

compiler/rustc_borrowck/src/type_check/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11411141
Some(self.implicit_region_bound),
11421142
self.param_env,
11431143
locations,
1144+
locations.span(self.body),
11441145
category,
11451146
&mut self.borrowck_context.constraints,
11461147
)
@@ -2401,6 +2402,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24012402
sup: ref_region.to_region_vid(),
24022403
sub: borrow_region.to_region_vid(),
24032404
locations: location.to_locations(),
2405+
span: location.to_locations().span(body),
24042406
category,
24052407
variance_info: ty::VarianceDiagInfo::default(),
24062408
});

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
116116
sup,
117117
sub,
118118
locations: self.locations,
119+
span: self.locations.span(self.type_checker.body),
119120
category: self.category,
120121
variance_info: info,
121122
},

library/core/src/intrinsics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Compiler intrinsics.
22
//!
3-
//! The corresponding definitions are in `compiler/rustc_codegen_llvm/src/intrinsic.rs`.
4-
//! The corresponding const implementations are in `compiler/rustc_mir/src/interpret/intrinsics.rs`
3+
//! The corresponding definitions are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/intrinsic.rs>.
4+
//! The corresponding const implementations are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>.
55
//!
66
//! # Const intrinsics
77
//!
@@ -10,8 +10,8 @@
1010
//!
1111
//! In order to make an intrinsic usable at compile-time, one needs to copy the implementation
1212
//! from <https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs> to
13-
//! `compiler/rustc_mir/src/interpret/intrinsics.rs` and add a
14-
//! `#[rustc_const_unstable(feature = "foo", issue = "01234")]` to the intrinsic.
13+
//! <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs> and add a
14+
//! `#[rustc_const_unstable(feature = "const_such_and_such", issue = "01234")]` to the intrinsic declaration.
1515
//!
1616
//! If an intrinsic is supposed to be used from a `const fn` with a `rustc_const_stable` attribute,
1717
//! the intrinsic's attribute must be `rustc_const_stable`, too. Such a change should not be done

library/std/src/sys/unix/os.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
427427
crate::fs::read_to_string("sys:exe").map(PathBuf::from)
428428
}
429429

430-
#[cfg(any(target_os = "fuchsia", target_os = "l4re"))]
430+
#[cfg(target_os = "l4re")]
431431
pub fn current_exe() -> io::Result<PathBuf> {
432432
use crate::io::ErrorKind;
433433
Err(io::const_io_error!(ErrorKind::Unsupported, "Not yet implemented!"))
@@ -451,6 +451,26 @@ pub fn current_exe() -> io::Result<PathBuf> {
451451
super::unsupported::unsupported()
452452
}
453453

454+
#[cfg(target_os = "fuchsia")]
455+
pub fn current_exe() -> io::Result<PathBuf> {
456+
use crate::io::ErrorKind;
457+
458+
#[cfg(test)]
459+
use realstd::env;
460+
461+
#[cfg(not(test))]
462+
use crate::env;
463+
464+
let exe_path = env::args().next().ok_or(io::const_io_error!(
465+
ErrorKind::Uncategorized,
466+
"an executable path was not found because no arguments were provided through argv"
467+
))?;
468+
let path = PathBuf::from(exe_path);
469+
470+
// Prepend the current working directory to the path if it's not absolute.
471+
if !path.is_absolute() { getcwd().map(|cwd| cwd.join(path)) } else { Ok(path) }
472+
}
473+
454474
pub struct Env {
455475
iter: vec::IntoIter<(OsString, OsString)>,
456476
}

src/bootstrap/builder.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,13 @@ impl<'a> ShouldRun<'a> {
388388
paths
389389
.iter()
390390
.map(|p| {
391-
assert!(
392-
self.builder.src.join(p).exists(),
393-
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
394-
p
395-
);
391+
// FIXME(#96188): make sure this is actually a path.
392+
// This currently breaks for paths within submodules.
393+
//assert!(
394+
// self.builder.src.join(p).exists(),
395+
// "`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
396+
// p
397+
//);
396398
TaskPath { path: p.into(), kind: Some(self.kind) }
397399
})
398400
.collect(),

src/librustdoc/html/static/js/externs.js

+55-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,34 @@ function initSearch(searchIndex){}
88

99
/**
1010
* @typedef {{
11-
* raw: string,
12-
* query: string,
13-
* type: string,
14-
* id: string,
11+
* name: string,
12+
* fullPath: Array<string>,
13+
* pathWithoutLast: Array<string>,
14+
* pathLast: string,
15+
* generics: Array<QueryElement>,
16+
* }}
17+
*/
18+
var QueryElement;
19+
20+
/**
21+
* @typedef {{
22+
* pos: number,
23+
* totalElems: number,
24+
* typeFilter: (null|string),
25+
* userQuery: string,
26+
* }}
27+
*/
28+
var ParserState;
29+
30+
/**
31+
* @typedef {{
32+
* original: string,
33+
* userQuery: string,
34+
* typeFilter: number,
35+
* elems: Array<QueryElement>,
36+
* args: Array<QueryElement>,
37+
* returned: Array<QueryElement>,
38+
* foundElems: number,
1539
* }}
1640
*/
1741
var ParsedQuery;
@@ -30,3 +54,30 @@ var ParsedQuery;
3054
* }}
3155
*/
3256
var Row;
57+
58+
/**
59+
* @typedef {{
60+
* in_args: Array<Object>,
61+
* returned: Array<Object>,
62+
* others: Array<Object>,
63+
* query: ParsedQuery,
64+
* }}
65+
*/
66+
var ResultsTable;
67+
68+
/**
69+
* @typedef {{
70+
* desc: string,
71+
* displayPath: string,
72+
* fullPath: string,
73+
* href: string,
74+
* id: number,
75+
* lev: number,
76+
* name: string,
77+
* normalizedName: string,
78+
* parent: (Object|undefined),
79+
* path: string,
80+
* ty: number,
81+
* }}
82+
*/
83+
var Results;

0 commit comments

Comments
 (0)