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

Rollup of 5 pull requests #96263

Merged
merged 38 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be41750
Greatly improve rustdoc search
GuillaumeGomez Dec 20, 2021
3aeef67
Update search engine and parser to error when quotes are used on quer…
GuillaumeGomez Jan 3, 2022
0f51652
Update tests
GuillaumeGomez Aug 11, 2021
7cefee0
Add possibility to check parsed query
GuillaumeGomez Dec 20, 2021
f5833e7
Add parser tests
GuillaumeGomez Dec 20, 2021
bbcf176
Improve naming of "val" field
GuillaumeGomez Jan 3, 2022
51de26c
* If type filter is in quotes, throw an error.
GuillaumeGomez Jan 3, 2022
99c5394
Add query syntax for the parser
GuillaumeGomez Jan 2, 2022
264064d
* Greatly improve the rustdoc search parser source code
GuillaumeGomez Jan 4, 2022
99d5520
Make query parser more strict and improve display of errors
GuillaumeGomez Jan 9, 2022
4929733
Simplify parser syntax
GuillaumeGomez Feb 9, 2022
c7de1a1
Improve documentation and add some explanations in the code
GuillaumeGomez Feb 11, 2022
699ae36
Apply suggestions:
GuillaumeGomez Mar 20, 2022
f9251ee
Replace unneeded use of regex with a simple if
GuillaumeGomez Mar 22, 2022
8e29ed4
Add isIdentCharacter function to ensure that unexpected characters ar…
GuillaumeGomez Mar 23, 2022
1f5c4c2
Forbid rustdoc search query to end with ->
GuillaumeGomez Mar 28, 2022
da829d8
Improve the BNF description a bit and fix some issues
GuillaumeGomez Mar 28, 2022
e03a950
Handle separators in their own functions and fix missing handling of …
GuillaumeGomez Mar 30, 2022
51b4005
Update the eBNF to allow generics bracket to not be closed if it's EOF
GuillaumeGomez Mar 31, 2022
ab9cf32
Add tests for paths
GuillaumeGomez Apr 8, 2022
a6051c7
Remove unnecessary `elem.name.length === 0` since the rustdoc search …
GuillaumeGomez Apr 16, 2022
6f35475
Parse idents the same way in both quote string elements and "normal" …
GuillaumeGomez Apr 16, 2022
da363b2
Add more tests for quote errors
GuillaumeGomez Apr 16, 2022
d7d538a
Fix some corner cases
GuillaumeGomez Apr 16, 2022
299e8ee
Add an extra check over filter type
GuillaumeGomez Apr 17, 2022
5c6c1e1
Add test to ensure that keywords in path are working
GuillaumeGomez Apr 18, 2022
8d0e10c
Correctly handle single `:`
GuillaumeGomez Apr 18, 2022
b4ca065
Remove assertion that all paths in `ShouldRun` exist
jyn514 Apr 19, 2022
eb6b6a8
[fuchsia] Add implementation for `current_exe`
Apr 18, 2022
671a872
Fix locations for intrinsics impls
mbartlett21 Apr 19, 2022
4879875
Change file locations to be links to GitHub
mbartlett21 Apr 20, 2022
611a06a
Add an explicit `Span` field to `OutlivesConstraint`
Aaron1011 Apr 20, 2022
4d26bde
Extend `handleSingleArg` documentation
GuillaumeGomez Apr 20, 2022
976c6b2
Rollup merge of #90630 - GuillaumeGomez:improve-rustdoc-search, r=not…
Dylan-DPC Apr 20, 2022
1e43aae
Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry
Dylan-DPC Apr 20, 2022
0179aac
Rollup merge of #96196 - jyn514:no-assertion, r=Mark-Simulacrum
Dylan-DPC Apr 20, 2022
e2543d7
Rollup merge of #96228 - mbartlett21:patch-4, r=thomcc
Dylan-DPC Apr 20, 2022
463c94a
Rollup merge of #96236 - Aaron1011:constraint-debug, r=jackh726
Dylan-DPC Apr 20, 2022
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
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/constraints/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> {
sup: self.static_region,
sub: next_static_idx.into(),
locations: Locations::All(DUMMY_SP),
span: DUMMY_SP,
category: ConstraintCategory::Internal,
variance_info: VarianceDiagInfo::default(),
})
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_borrowck/src/constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rustc_data_structures::graph::scc::Sccs;
use rustc_index::vec::IndexVec;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
use rustc_span::Span;
use std::fmt;
use std::ops::Index;

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

/// The `Span` associated with the creation of this constraint.
/// This should be used in preference to obtaining the span from
/// `locations`, since the `locations` may give a poor span
/// in some cases (e.g. converting a constraint from a promoted).
pub span: Span,

/// What caused this constraint?
pub category: ConstraintCategory,

Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_borrowck/src/region_infer/dump_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let mut constraints: Vec<_> = self.constraints.outlives().iter().collect();
constraints.sort_by_key(|c| (c.sup, c.sub));
for constraint in &constraints {
let OutlivesConstraint { sup, sub, locations, category, variance_info: _ } = constraint;
let OutlivesConstraint { sup, sub, locations, category, span, variance_info: _ } =
constraint;
let (name, arg) = match locations {
Locations::All(span) => {
("All", tcx.sess.source_map().span_to_embeddable_string(*span))
}
Locations::Single(loc) => ("Single", format!("{:?}", loc)),
};
with_msg(&format!("{:?}: {:?} due to {:?} at {}({})", sup, sub, category, name, arg))?;
with_msg(&format!(
"{:?}: {:?} due to {:?} at {}({}) ({:?}",
sup, sub, category, name, arg, span
))?;
}

Ok(())
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {

crate fn retrieve_closure_constraint_info(
&self,
body: &Body<'tcx>,
_body: &Body<'tcx>,
constraint: &OutlivesConstraint<'tcx>,
) -> BlameConstraint<'tcx> {
let loc = match constraint.locations {
Expand All @@ -1760,7 +1760,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
.unwrap_or(BlameConstraint {
category: constraint.category,
from_closure: false,
cause: ObligationCause::dummy_with_span(body.source_info(loc).span),
cause: ObligationCause::dummy_with_span(constraint.span),
variance_info: constraint.variance_info,
})
}
Expand Down Expand Up @@ -1869,6 +1869,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
sup: r,
sub: constraint.min_choice,
locations: Locations::All(p_c.definition_span),
span: p_c.definition_span,
category: ConstraintCategory::OpaqueType,
variance_info: ty::VarianceDiagInfo::default(),
};
Expand Down Expand Up @@ -2017,7 +2018,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
category: constraint.category,
from_closure: false,
cause: ObligationCause::new(
constraint.locations.span(body),
constraint.span,
CRATE_HIR_ID,
cause_code.clone(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::DUMMY_SP;
use rustc_span::{Span, DUMMY_SP};

use crate::{
constraints::OutlivesConstraint,
Expand All @@ -26,6 +26,7 @@ crate struct ConstraintConversion<'a, 'tcx> {
implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
category: ConstraintCategory,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
}
Expand All @@ -38,6 +39,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
implicit_region_bound: Option<ty::Region<'tcx>>,
param_env: ty::ParamEnv<'tcx>,
locations: Locations,
span: Span,
category: ConstraintCategory,
constraints: &'a mut MirTypeckRegionConstraints<'tcx>,
) -> Self {
Expand All @@ -49,6 +51,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
implicit_region_bound,
param_env,
locations,
span,
category,
constraints,
}
Expand Down Expand Up @@ -153,6 +156,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
self.constraints.outlives_constraints.push(OutlivesConstraint {
locations: self.locations,
category: self.category,
span: self.span,
sub,
sup,
variance_info: ty::VarianceDiagInfo::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
self.implicit_region_bound,
self.param_env,
Locations::All(DUMMY_SP),
DUMMY_SP,
ConstraintCategory::Internal,
&mut self.constraints,
)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/type_check/input_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Some(self.implicit_region_bound),
self.param_env,
Locations::All(DUMMY_SP),
DUMMY_SP,
ConstraintCategory::Internal,
&mut self.borrowck_context.constraints,
)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Some(self.implicit_region_bound),
self.param_env,
locations,
locations.span(self.body),
category,
&mut self.borrowck_context.constraints,
)
Expand Down Expand Up @@ -2401,6 +2402,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
sup: ref_region.to_region_vid(),
sub: borrow_region.to_region_vid(),
locations: location.to_locations(),
span: location.to_locations().span(body),
category,
variance_info: ty::VarianceDiagInfo::default(),
});
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
sup,
sub,
locations: self.locations,
span: self.locations.span(self.type_checker.body),
category: self.category,
variance_info: info,
},
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Compiler intrinsics.
//!
//! The corresponding definitions are in `compiler/rustc_codegen_llvm/src/intrinsic.rs`.
//! The corresponding const implementations are in `compiler/rustc_mir/src/interpret/intrinsics.rs`
//! The corresponding definitions are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/intrinsic.rs>.
//! The corresponding const implementations are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>.
//!
//! # Const intrinsics
//!
Expand All @@ -10,8 +10,8 @@
//!
//! In order to make an intrinsic usable at compile-time, one needs to copy the implementation
//! from <https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs> to
//! `compiler/rustc_mir/src/interpret/intrinsics.rs` and add a
//! `#[rustc_const_unstable(feature = "foo", issue = "01234")]` to the intrinsic.
//! <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs> and add a
//! `#[rustc_const_unstable(feature = "const_such_and_such", issue = "01234")]` to the intrinsic declaration.
//!
//! If an intrinsic is supposed to be used from a `const fn` with a `rustc_const_stable` attribute,
//! the intrinsic's attribute must be `rustc_const_stable`, too. Such a change should not be done
Expand Down
22 changes: 21 additions & 1 deletion library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
crate::fs::read_to_string("sys:exe").map(PathBuf::from)
}

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

#[cfg(target_os = "fuchsia")]
pub fn current_exe() -> io::Result<PathBuf> {
use crate::io::ErrorKind;

#[cfg(test)]
use realstd::env;

#[cfg(not(test))]
use crate::env;

let exe_path = env::args().next().ok_or(io::const_io_error!(
ErrorKind::Uncategorized,
"an executable path was not found because no arguments were provided through argv"
))?;
let path = PathBuf::from(exe_path);

// Prepend the current working directory to the path if it's not absolute.
if !path.is_absolute() { getcwd().map(|cwd| cwd.join(path)) } else { Ok(path) }
}

pub struct Env {
iter: vec::IntoIter<(OsString, OsString)>,
}
Expand Down
12 changes: 7 additions & 5 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,13 @@ impl<'a> ShouldRun<'a> {
paths
.iter()
.map(|p| {
assert!(
self.builder.src.join(p).exists(),
"`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
p
);
// FIXME(#96188): make sure this is actually a path.
// This currently breaks for paths within submodules.
//assert!(
// self.builder.src.join(p).exists(),
// "`should_run.paths` should correspond to real on-disk paths - use `alias` if there is no relevant path: {}",
// p
//);
TaskPath { path: p.into(), kind: Some(self.kind) }
})
.collect(),
Expand Down
59 changes: 55 additions & 4 deletions src/librustdoc/html/static/js/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,34 @@ function initSearch(searchIndex){}

/**
* @typedef {{
* raw: string,
* query: string,
* type: string,
* id: string,
* name: string,
* fullPath: Array<string>,
* pathWithoutLast: Array<string>,
* pathLast: string,
* generics: Array<QueryElement>,
* }}
*/
var QueryElement;

/**
* @typedef {{
* pos: number,
* totalElems: number,
* typeFilter: (null|string),
* userQuery: string,
* }}
*/
var ParserState;

/**
* @typedef {{
* original: string,
* userQuery: string,
* typeFilter: number,
* elems: Array<QueryElement>,
* args: Array<QueryElement>,
* returned: Array<QueryElement>,
* foundElems: number,
* }}
*/
var ParsedQuery;
Expand All @@ -30,3 +54,30 @@ var ParsedQuery;
* }}
*/
var Row;

/**
* @typedef {{
* in_args: Array<Object>,
* returned: Array<Object>,
* others: Array<Object>,
* query: ParsedQuery,
* }}
*/
var ResultsTable;

/**
* @typedef {{
* desc: string,
* displayPath: string,
* fullPath: string,
* href: string,
* id: number,
* lev: number,
* name: string,
* normalizedName: string,
* parent: (Object|undefined),
* path: string,
* ty: number,
* }}
*/
var Results;
Loading