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 6 pull requests #96566

Merged
merged 20 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ae93e6e
Small JS code improvements
GuillaumeGomez Apr 25, 2022
cb8da88
Migrate externs.js to ES6
GuillaumeGomez Apr 25, 2022
016334a
Migrate main.js to ES6
GuillaumeGomez Apr 25, 2022
6faa40d
Migrate source-script to ES6
GuillaumeGomez Apr 25, 2022
724c4bd
Migrate storage.js to ES6
GuillaumeGomez Apr 25, 2022
509b145
Migrate scrape-examples.js to ES6
GuillaumeGomez Apr 25, 2022
4e0be6d
Remove dead code in main.js
GuillaumeGomez Apr 25, 2022
e8ae06a
RustWrapper: explicitly don't handle DXILPointerTyID
durin42 Apr 28, 2022
346065f
rustdoc: fix missing method list for primitive deref target
notriddle Apr 28, 2022
8743ce8
rustdoc: prevent B -> C -> B -> C loops from stack overflowing
notriddle Apr 29, 2022
f66de50
Use the correct lifetime binder for elided lifetimes in path.
cjgillot Apr 29, 2022
7704cf2
Remove unnecessary environment variable in cf-protection documentation
abrown Apr 29, 2022
3614bd3
Fix duplicate directory separator in --remap-path-prefix.
michaelwoerister Apr 29, 2022
6e349c7
Remove `error` variable.
cjgillot Apr 29, 2022
bfb13ec
Rollup merge of #96390 - GuillaumeGomez:es6-part2, r=notriddle
Dylan-DPC Apr 29, 2022
041f3b6
Rollup merge of #96527 - durin42:llvm-15-werror-wswitch, r=nikic
Dylan-DPC Apr 29, 2022
0b96be7
Rollup merge of #96536 - rust-lang:notriddle/deref-slice-core, r=Guil…
Dylan-DPC Apr 29, 2022
2003d83
Rollup merge of #96559 - cjgillot:elided-path-fn, r=petrochenkov
Dylan-DPC Apr 29, 2022
2986bef
Rollup merge of #96560 - abrown:update-docs, r=Dylan-DPC
Dylan-DPC Apr 29, 2022
548fca6
Rollup merge of #96562 - michaelwoerister:path-remapping-fixes, r=oli…
Dylan-DPC Apr 29, 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
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,11 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
return LLVMBFloatTypeKind;
case Type::X86_AMXTyID:
return LLVMX86_AMXTypeKind;
#if LLVM_VERSION_GE(15, 0)
case Type::DXILPointerTyID:
report_fatal_error("Rust does not support DirectX typed pointers.");
break;
#endif
}
report_fatal_error("Unhandled TypeID.");
}
Expand Down
25 changes: 13 additions & 12 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
| PathSource::Struct
| PathSource::TupleStruct(..) => false,
};
let mut error = false;
let mut res = LifetimeRes::Error;
for rib in self.lifetime_ribs.iter().rev() {
match rib.kind {
// In create-parameter mode we error here because we don't want to support
Expand All @@ -1329,7 +1329,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
// impl Foo for std::cell::Ref<u32> // note lack of '_
// async fn foo(_: std::cell::Ref<u32>) { ... }
LifetimeRibKind::AnonymousCreateParameter(_) => {
error = true;
break;
}
// `PassThrough` is the normal case.
Expand All @@ -1338,19 +1337,21 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
// `PathSegment`, for which there is no associated `'_` or `&T` with no explicit
// lifetime. Instead, we simply create an implicit lifetime, which will be checked
// later, at which point a suitable error will be emitted.
LifetimeRibKind::AnonymousPassThrough(..)
| LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::Item => break,
LifetimeRibKind::AnonymousPassThrough(binder) => {
res = LifetimeRes::Anonymous { binder, elided: true };
break;
}
LifetimeRibKind::AnonymousReportError | LifetimeRibKind::Item => {
// FIXME(cjgillot) This resolution is wrong, but this does not matter
// since these cases are erroneous anyway. Lifetime resolution should
// emit a "missing lifetime specifier" diagnostic.
res = LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true };
break;
}
_ => {}
}
}

let res = if error {
LifetimeRes::Error
} else {
LifetimeRes::Anonymous { binder: segment_id, elided: true }
};

let node_ids = self.r.next_node_ids(expected_lifetimes);
self.record_lifetime_res(
segment_id,
Expand All @@ -1374,7 +1375,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
// originating from macros, since the segment's span might be from a macro arg.
segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span)
};
if error {
if let LifetimeRes::Error = res {
let sess = self.r.session;
let mut err = rustc_errors::struct_span_err!(
sess,
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_span/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,19 @@ impl FilePathMapping {
// take precedence.
for &(ref from, ref to) in self.mapping.iter().rev() {
if let Ok(rest) = path.strip_prefix(from) {
return (to.join(rest), true);
let remapped = if rest.as_os_str().is_empty() {
// This is subtle, joining an empty path onto e.g. `foo/bar` will
// result in `foo/bar/`, that is, there'll be an additional directory
// separator at the end. This can lead to duplicated directory separators
// in remapped paths down the line.
// So, if we have an exact match, we just return that without a call
// to `Path::join()`.
to.clone()
} else {
to.join(rest)
};

return (remapped, true);
}
}

Expand Down
80 changes: 80 additions & 0 deletions compiler/rustc_span/src/source_map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,83 @@ impl SourceMapExtension for SourceMap {
}
}
}

fn map_path_prefix(mapping: &FilePathMapping, path: &str) -> String {
// It's important that we convert to a string here because that's what
// later stages do too (e.g. in the backend), and comparing `Path` values
// won't catch some differences at the string level, e.g. "abc" and "abc/"
// compare as equal.
mapping.map_prefix(path.into()).0.to_string_lossy().to_string()
}

#[cfg(unix)]
#[test]
fn path_prefix_remapping() {
// Relative to relative
{
let mapping = &FilePathMapping::new(vec![("abc/def".into(), "foo".into())]);

assert_eq!(map_path_prefix(mapping, "abc/def/src/main.rs"), "foo/src/main.rs");
assert_eq!(map_path_prefix(mapping, "abc/def"), "foo");
}

// Relative to absolute
{
let mapping = &FilePathMapping::new(vec![("abc/def".into(), "/foo".into())]);

assert_eq!(map_path_prefix(mapping, "abc/def/src/main.rs"), "/foo/src/main.rs");
assert_eq!(map_path_prefix(mapping, "abc/def"), "/foo");
}

// Absolute to relative
{
let mapping = &FilePathMapping::new(vec![("/abc/def".into(), "foo".into())]);

assert_eq!(map_path_prefix(mapping, "/abc/def/src/main.rs"), "foo/src/main.rs");
assert_eq!(map_path_prefix(mapping, "/abc/def"), "foo");
}

// Absolute to absolute
{
let mapping = &FilePathMapping::new(vec![("/abc/def".into(), "/foo".into())]);

assert_eq!(map_path_prefix(mapping, "/abc/def/src/main.rs"), "/foo/src/main.rs");
assert_eq!(map_path_prefix(mapping, "/abc/def"), "/foo");
}
}

#[cfg(windows)]
#[test]
fn path_prefix_remapping_from_relative2() {
// Relative to relative
{
let mapping = &FilePathMapping::new(vec![("abc\\def".into(), "foo".into())]);

assert_eq!(map_path_prefix(mapping, "abc\\def\\src\\main.rs"), "foo\\src\\main.rs");
assert_eq!(map_path_prefix(mapping, "abc\\def"), "foo");
}

// Relative to absolute
{
let mapping = &FilePathMapping::new(vec![("abc\\def".into(), "X:\\foo".into())]);

assert_eq!(map_path_prefix(mapping, "abc\\def\\src\\main.rs"), "X:\\foo\\src\\main.rs");
assert_eq!(map_path_prefix(mapping, "abc\\def"), "X:\\foo");
}

// Absolute to relative
{
let mapping = &FilePathMapping::new(vec![("X:\\abc\\def".into(), "foo".into())]);

assert_eq!(map_path_prefix(mapping, "X:\\abc\\def\\src\\main.rs"), "foo\\src\\main.rs");
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def"), "foo");
}

// Absolute to absolute
{
let mapping = &FilePathMapping::new(vec![("X:\\abc\\def".into(), "X:\\foo".into())]);

assert_eq!(map_path_prefix(mapping, "X:\\abc\\def\\src\\main.rs"), "X:\\foo\\src\\main.rs");
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def"), "X:\\foo");
}
}
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/compiler-flags/cf-protection.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ standard library does not ship with CET enabled by default, so you may need to r
modules with a `cargo` command like:

```sh
$ RUSTFLAGS="-Z cf-protection=full" RUSTC="rustc-custom" cargo +nightly build -Z build-std --target x86_64-unknown-linux-gnu
$ RUSTFLAGS="-Z cf-protection=full" cargo +nightly build -Z build-std --target x86_64-unknown-linux-gnu
```

### Detection
Expand Down
17 changes: 10 additions & 7 deletions src/librustdoc/html/static/js/externs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// This file contains type definitions that are processed by the Closure Compiler but are
// not put into the JavaScript we include as part of the documentation. It is used for
// type checking. See README.md in this directory for more info.
/* eslint-env es6 */
/* eslint no-var: "error" */
/* eslint prefer-const: "error" */

/* eslint-disable */
var searchState;
let searchState;
function initSearch(searchIndex){}

/**
Expand All @@ -15,7 +18,7 @@ function initSearch(searchIndex){}
* generics: Array<QueryElement>,
* }}
*/
var QueryElement;
let QueryElement;

/**
* @typedef {{
Expand All @@ -25,7 +28,7 @@ var QueryElement;
* userQuery: string,
* }}
*/
var ParserState;
let ParserState;

/**
* @typedef {{
Expand All @@ -38,7 +41,7 @@ var ParserState;
* foundElems: number,
* }}
*/
var ParsedQuery;
let ParsedQuery;

/**
* @typedef {{
Expand All @@ -53,7 +56,7 @@ var ParsedQuery;
* type: (Array<?>|null)
* }}
*/
var Row;
let Row;

/**
* @typedef {{
Expand All @@ -63,7 +66,7 @@ var Row;
* query: ParsedQuery,
* }}
*/
var ResultsTable;
let ResultsTable;

/**
* @typedef {{
Expand All @@ -80,4 +83,4 @@ var ResultsTable;
* ty: number,
* }}
*/
var Results;
let Results;
Loading