Skip to content

Commit

Permalink
Auto merge of #86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #84961 (Rework SESSION_GLOBALS API)
 - #86726 (Use diagnostic items instead of lang items for rfc2229 migrations)
 - #86789 (Update BTreeSet::drain_filter documentation)
 - #86838 (Checking that function is const if marked with rustc_const_unstable)
 - #86903 (Fix small headers display)
 - #86913 (Document rustdoc with `--document-private-items`)
 - #86957 (Update .mailmap file)
 - #86971 (mailmap: Add alternative addresses for myself)

Failed merges:

 - #86869 (Account for capture kind in auto traits migration)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 8, 2021
2 parents d0485c7 + 6056682 commit aa65b08
Show file tree
Hide file tree
Showing 46 changed files with 412 additions and 150 deletions.
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ Hanna Kruppe <[email protected]> <[email protected]>
Heather <[email protected]> <[email protected]>
Heather <[email protected]> <[email protected]>
Herman J. Radtke III <[email protected]> Herman J. Radtke III <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
Ilyong Cho <[email protected]>
inquisitivecrystal <[email protected]>
Ivan Ivaschenko <[email protected]>
J. J. Weber <[email protected]>
Jacob Pratt <[email protected]> <[email protected]>
Jakub Adam Wieczorek <[email protected]> <[email protected]>
Jakub Adam Wieczorek <[email protected]> <[email protected]>
Jakub Adam Wieczorek <[email protected]> <[email protected]>
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast/src/util/comments/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::*;
use rustc_span::with_default_session_globals;
use rustc_span::create_default_session_globals_then;

#[test]
fn test_block_doc_comment_1() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let comment = "\n * Test \n ** Test\n * Test\n";
let stripped = beautify_doc_string(Symbol::intern(comment));
assert_eq!(stripped.as_str(), " Test \n* Test\n Test");
Expand All @@ -12,7 +12,7 @@ fn test_block_doc_comment_1() {

#[test]
fn test_block_doc_comment_2() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let comment = "\n * Test\n * Test\n";
let stripped = beautify_doc_string(Symbol::intern(comment));
assert_eq!(stripped.as_str(), " Test\n Test");
Expand All @@ -21,7 +21,7 @@ fn test_block_doc_comment_2() {

#[test]
fn test_block_doc_comment_3() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let comment = "\n let a: *i32;\n *a = 5;\n";
let stripped = beautify_doc_string(Symbol::intern(comment));
assert_eq!(stripped.as_str(), " let a: *i32;\n *a = 5;");
Expand All @@ -30,7 +30,7 @@ fn test_block_doc_comment_3() {

#[test]
fn test_line_doc_comment() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let stripped = beautify_doc_string(Symbol::intern(" test"));
assert_eq!(stripped.as_str(), " test");
let stripped = beautify_doc_string(Symbol::intern("! test"));
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_pretty/src/pprust/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::*;

use rustc_ast as ast;
use rustc_span::create_default_session_globals_then;
use rustc_span::symbol::Ident;
use rustc_span::with_default_session_globals;

fn fun_to_string(
decl: &ast::FnDecl,
Expand All @@ -24,7 +24,7 @@ fn variant_to_string(var: &ast::Variant) -> String {

#[test]
fn test_fun_to_string() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let abba_ident = Ident::from_str("abba");

let decl =
Expand All @@ -39,7 +39,7 @@ fn test_fun_to_string() {

#[test]
fn test_variant_to_string() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let ident = Ident::from_str("principal_skinner");

let var = ast::Variant {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0542.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Erroneous code example:
fn _stable_fn() {}
#[rustc_const_stable(feature = "_stable_const_fn")] // invalid
fn _stable_const_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
Expand All @@ -29,7 +29,7 @@ To fix this issue, you need to provide the `since` field. Example:
fn _stable_fn() {}
#[rustc_const_stable(feature = "_stable_const_fn", since = "1.0.0")] // ok!
fn _stable_const_fn() {}
const fn _stable_const_fn() {}
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
#[rustc_deprecated(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0545.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Erroneous code example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "0")] // invalid
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```

To fix this issue, you need to provide a correct value in the `issue` field.
Expand All @@ -24,7 +24,7 @@ Example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "1")] // ok!
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```

See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0547.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Erroneous code example:
fn _unstable_fn() {}
#[rustc_const_unstable(feature = "_unstable_const_fn")] // invalid
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```

To fix this issue, you need to provide the `issue` field. Example:
Expand All @@ -26,7 +26,7 @@ fn _unstable_fn() {}
feature = "_unstable_const_fn",
issue = "none"
)] // ok!
fn _unstable_const_fn() {}
const fn _unstable_const_fn() {}
```

See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_errors/src/json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,11 @@ impl<T: Write> Write for Shared<T> {
}
}

fn with_default_session_globals(f: impl FnOnce()) {
let session_globals = rustc_span::SessionGlobals::new(rustc_span::edition::DEFAULT_EDITION);
rustc_span::SESSION_GLOBALS.set(&session_globals, f);
}

/// Test the span yields correct positions in JSON.
fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
let expected_output = TestData { spans: vec![expected_output] };

with_default_session_globals(|| {
rustc_span::create_default_session_globals_then(|| {
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned());

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_expand/src/mut_visit/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::tests::{matches_codepattern, string_to_crate};
use rustc_ast as ast;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast_pretty::pprust;
use rustc_span::create_default_session_globals_then;
use rustc_span::symbol::Ident;
use rustc_span::with_default_session_globals;

// This version doesn't care about getting comments or doc-strings in.
fn print_crate_items(krate: &ast::Crate) -> String {
Expand Down Expand Up @@ -38,7 +38,7 @@ macro_rules! assert_pred {
// Make sure idents get transformed everywhere.
#[test]
fn ident_transformation() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate =
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
Expand All @@ -55,7 +55,7 @@ fn ident_transformation() {
// Make sure idents get transformed even inside macro defs.
#[test]
fn ident_transformation_in_defs() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let mut zz_visitor = ToZzIdentMutVisitor;
let mut krate = string_to_crate(
"macro_rules! a {(b $c:expr $(d $e:token)f+ => \
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_expand/src/parse/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use rustc_errors::PResult;
use rustc_parse::new_parser_from_source_str;
use rustc_parse::parser::ForceCollect;
use rustc_session::parse::ParseSess;
use rustc_span::create_default_session_globals_then;
use rustc_span::source_map::FilePathMapping;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::with_default_session_globals;
use rustc_span::{BytePos, FileName, Pos, Span};

use std::path::PathBuf;
Expand Down Expand Up @@ -51,15 +51,15 @@ fn string_to_item(source_str: String) -> Option<P<ast::Item>> {
#[should_panic]
#[test]
fn bad_path_expr_1() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
string_to_expr("::abc::def::return".to_string());
})
}

// Checks the token-tree-ization of macros.
#[test]
fn string_to_tts_macro() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let tts: Vec<_> =
string_to_stream("macro_rules! zip (($a)=>($a))".to_string()).trees().collect();
let tts: &[TokenTree] = &tts[..];
Expand Down Expand Up @@ -96,7 +96,7 @@ fn string_to_tts_macro() {

#[test]
fn string_to_tts_1() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let tts = string_to_stream("fn a (b : i32) { b; }".to_string());

let expected = TokenStream::new(vec![
Expand Down Expand Up @@ -131,7 +131,7 @@ fn string_to_tts_1() {

#[test]
fn parse_use() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let use_s = "use foo::bar::baz;";
let vitem = string_to_item(use_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
Expand All @@ -146,7 +146,7 @@ fn parse_use() {

#[test]
fn parse_extern_crate() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let ex_s = "extern crate foo;";
let vitem = string_to_item(ex_s.to_string()).unwrap();
let vitem_s = item_to_string(&vitem);
Expand Down Expand Up @@ -184,7 +184,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec<Span> {

#[test]
fn span_of_self_arg_pat_idents_are_correct() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let srcs = [
"impl z { fn a (&self, &myarg: i32) {} }",
"impl z { fn a (&mut self, &myarg: i32) {} }",
Expand All @@ -208,7 +208,7 @@ fn span_of_self_arg_pat_idents_are_correct() {

#[test]
fn parse_exprs() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
// just make sure that they parse....
string_to_expr("3 + 4".to_string());
string_to_expr("a::z.froob(b,&(987+3))".to_string());
Expand All @@ -217,7 +217,7 @@ fn parse_exprs() {

#[test]
fn attrs_fix_bug() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
string_to_item(
"pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
-> Result<Box<Writer>, String> {
Expand All @@ -238,7 +238,7 @@ let mut fflags: c_int = wb();

#[test]
fn crlf_doc_comments() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let sess = sess();

let name_1 = FileName::Custom("crlf_source_1".to_string());
Expand Down Expand Up @@ -272,7 +272,7 @@ fn ttdelim_span() {
new_parser_from_source_str(sess, name, source).parse_expr()
}

with_default_session_globals(|| {
create_default_session_globals_then(|| {
let sess = sess();
let expr = parse_expr_from_source_str(
PathBuf::from("foo").into(),
Expand Down Expand Up @@ -300,7 +300,7 @@ fn ttdelim_span() {
// See `recurse_into_file_modules` in the parser.
#[test]
fn out_of_line_mod() {
with_default_session_globals(|| {
create_default_session_globals_then(|| {
let item = parse_item_from_source_str(
PathBuf::from("foo").into(),
"mod foo { struct S; mod this_does_not_exist; }".to_owned(),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use rustc_ast as ast;
use rustc_ast::tokenstream::TokenStream;
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
use rustc_session::parse::ParseSess;
use rustc_span::create_default_session_if_not_set_then;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::with_default_session_globals;
use rustc_span::{BytePos, MultiSpan, Span};

use rustc_data_structures::sync::Lrc;
Expand Down Expand Up @@ -124,7 +124,7 @@ impl<T: Write> Write for Shared<T> {
}

fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
with_default_session_globals(|| {
create_default_session_if_not_set_then(|_| {
let output = Arc::new(Mutex::new(Vec::new()));

let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));
Expand Down
Loading

0 comments on commit aa65b08

Please sign in to comment.