8000 Rollup of 9 pull requests by Centril · Pull Request #62966 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 9 pull requests #62966

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

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
962bf69
Take substs into account in `conservative_is_privately_uninhabited`
varkor Jun 30, 2019
5397dfc
Remove obsolete “should not have to exist” reasons
SimonSapin Jul 8, 2019
01d93bf
Split the SliceConcat trait into Concat and Join
SimonSapin Jul 8, 2019
283f676
Take separator by value in `[T]::join`
SimonSapin Jul 8, 2019
b62a77b
Add joining slices of slices with a slice separator, not just a singl…
SimonSapin Jul 8, 2019
d0635ee
Update src/liballoc/slice.rs
SimonSapin Jul 9, 2019
bbc9366
Update src/liballoc/slice.rs
SimonSapin Jul 9, 2019
5f7768a
Update src/liballoc/str.rs
SimonSapin Jul 9, 2019
156173f
Add tests for overlapping explicitly dropped locals in generators
JohnTitor Jul 16, 2019
21b502b
warn that raw pointers must be aligned when used, and that writes cau…
RalfJung Jul 20, 2019
2e6b13a
references must be aligned; also move up the warning that fn ptrs mus…
RalfJung Jul 20, 2019
f502bf7
sync with nomicon: raw ptr must be non-dangling and aligned every tim…
RalfJung Jul 21, 2019
4081222
apply feedback
RalfJung Jul 21, 2019
a7b9246
weasle, weasle
RalfJung Jul 22, 2019
9196781
account for non-drop-glue types
RalfJung Jul 22, 2019
f78cd4d
Fix building_llvm in sanity check, add swig sanity check.
golddranks Jun 16, 2019
ba78db3
libsyntax: factor out file path resolving
jonas-schievink May 14, 2019
138e08c
Make #[doc(include)] paths behave like other paths
jonas-schievink May 18, 2019
1cc7c21
Adjust docs to new #[doc(include)] behaviour
jonas-schievink May 19, 2019
8ccf52c
stage0 -> bootstrap
jonas-schievink Jun 22, 2019
edb2187
Make path::resolve a method on ExtCtxt
jonas-schievink Jun 22, 2019
7c42259
Update stdarch submodule
jonas-schievink Jul 17, 2019
dd5045e
Apply suggestions from code review
RalfJung Jul 23, 2019
65cf10d
word things more like we usually do
RalfJung Jul 23, 2019
218ab4c
Update test
jonas-schievink Jul 23, 2019
bd8813e
Add method disambiguation help for trait implementation
iluuu1994 Jul 23, 2019
be510db
Adjust tests for method disambiguation help
iluuu1994 Jul 24, 2019
a93fdfe
Merge `rustc_allocator` into `libsyntax_ext`
petrochenkov Jul 16, 2019
4330241
syntax_ext: Turn `#[global_allocator]` into a regular attribute macro
petrochenkov Jul 18, 2019
76b1ffa
syntax_ext: Reuse built-in attribute template checking for macro attr…
petrochenkov Jul 18, 2019
bf8fc8a
syntax_ext: Improve and simplify code generated by `#[global_allocator]`
petrochenkov Jul 18, 2019
6e4f161
Demote template check error to a lint for `#[test]` and `#[bench]`
petrochenkov Jul 20, 2019
a0c2c64
Fix rebase
petrochenkov Jul 20, 2019
c091818
Use match ergonomics in Condvar documentation
KevinWMatthews Jul 24, 2019
4042811
Use Foo instead of raw arrays
JohnTitor Jul 24, 2019
1433a4b
Rollup merge of #60938 - jonas-schievink:doc-include-paths, r=petroch…
Centril Jul 25, 2019
1492b2d
Rollup merge of #61890 - golddranks:fix_sanity_check_llvm, r=Dylan-DPC
Centril Jul 25, 2019
44bbc38
Rollup merge of #62261 - varkor:conservative_is_privately_uninhabited…
Centril Jul 25, 2019
7bb341e
Rollup merge of #62528 - SimonSapin:concat, r=alexcrichton
Centril Jul 25, 2019
dfa79f3
Rollup merge of #62707 - JohnTitor:add-test-for-61922, r=tmandry
Centril Jul 25, 2019
ba07b39
Rollup merge of #62735 - petrochenkov:galloc, r=alexcrichton
Centril Jul 25, 2019
8bc8562
Rollup merge of #62822 - RalfJung:pointers, r=Centril
Centril Jul 25, 2019
c30c8ac
Rollup merge of #62921 - iluuu1994:improve-help-for-method-disambigua…
Centril Jul 25, 2019
d4c96f2
Rollup merge of #62942 - KevinWMatthews:condvar_docs_match_ergo, r=sf…
Centril Jul 25, 2019
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
Prev Previous commit
Next Next commit
Make path::resolve a method on ExtCtxt
  • Loading branch information
jonas-schievink committed Jul 23, 2019
commit edb21873cced7a179571aa3a9c25eb1cfc05c2db
27 changes: 26 additions & 1 deletion src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ast::{self, Attribute, Name, PatKind};
use crate::attr::{HasAttrs, Stability, Deprecation};
use crate::source_map::{SourceMap, Spanned, respan};
use crate::source_map::{SourceMap, Spanned, FileName, respan};
use crate::edition::Edition;
use crate::ext::expand::{self, AstFragment, Invocation};
use crate::ext::hygiene::{ExpnId, SyntaxContext, Transparency};
Expand Down Expand Up @@ -889,6 +889,31 @@ impl<'a> ExtCtxt<'a> {
pub fn check_unused_macros(&self) {
self.resolver.check_unused_macros();
}

/// Resolve a path mentioned inside Rust code.
///
/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths.
///
/// Returns an absolute path to the file that `path` refers to.
pub fn resolve_path(&self, path: impl Into<PathBuf>, span: Span) -> PathBuf {
let path = path.into();

// Relative paths are resolved relative to the file in which they are found
// after macro expansion (that is, they are unhygienic).
if !path.is_absolute() {
let callsite = span.source_callsite();
let mut result = match self.source_map().span_to_unmapped_path(callsite) {
FileName::Real(path) => path,
FileName::DocTest(path, _) => path,
other => panic!("cannot resolve relative path in non-file source `{}`", other),
};
result.pop();
result.push(path);
result
} else {
path
}
}
}

/// Extracts a string literal from the macro expanded version of `expr`,
Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::symbol::{sym, Symbol};
use crate::tokenstream::{TokenStream, TokenTree};
use crate::visit::{self, Visitor};
use crate::util::map_in_place::MapInPlace;
use crate::util::path;

use errors::{Applicability, FatalError};
use smallvec::{smallvec, SmallVec};
Expand Down Expand Up @@ -1254,7 +1253,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
return noop_visit_attribute(at, self);
}

let filename = path::resolve(&*file.as_str(), it.span(), self.cx.source_map());
let filename = self.cx.resolve_path(&*file.as_str(), it.span());
match fs::read_to_string(&filename) {
Ok(src) => {
let src_interned = Symbol::intern(&src);
Expand Down
7 changes: 3 additions & 4 deletions src/libsyntax/ext/source_util.rs
10000
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::print::pprust;
use crate::ptr::P;
use crate::symbol::Symbol;
use crate::tokenstream;
use crate::util::path;

use smallvec::SmallVec;
use syntax_pos::{self, Pos, Span};
Expand Down Expand Up @@ -78,7 +77,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt<'_>, sp: Span, tts: &[tokenstrea
None => return DummyResult::any(sp),
};
// The file will be added to the code map by the parser
let file = path::resolve(file, sp, cx.source_map());
let file = cx.resolve_path(file, sp);
let directory_ownership = DirectoryOwnership::Owned { relative: None };
let p = parse::new_sub_parser_from_file(cx.parse_sess(), &file, directory_ownership, None, sp);

Expand Down Expand Up @@ -115,7 +114,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::To
Some(f) => f,
None => return DummyResult::expr(sp)
};
let file = path::resolve(file, sp, cx.source_map());
let file = cx.resolve_path(file, sp);
match fs::read_to_string(&file) {
Ok(src) => {
let interned_src = Symbol::intern(&src);
Expand Down Expand Up @@ -143,7 +142,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt<'_>, sp: Span, tts: &[tokenstream::
Some(f) => f,
None => return DummyResult::expr(sp)
};
let file = path::resolve(file, sp, cx.source_map());
let file = cx.resolve_path(file, sp);
match fs::read(&file) {
Ok(bytes) => {
// Add the contents to the source map if it contains UTF-8.
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ pub mod util {
#[cfg(test)]
pub mod parser_testing;
pub mod map_in_place;
pub mod path;
}

pub mod json;
Expand Down
28 changes: 0 additions & 28 deletions src/libsyntax/util/path.rs

This file was deleted.

0