Auto merge of #124993 - jieyouxu:rollup-u02aso7, r=jieyouxu
Rollup of 5 pull requests Successful merges: - #124233 (Add `-lmingwex` second time in `mingw_libs`) - #124318 (ignore generics args in attribute paths) - #124899 (bootstrap: add comments for the automatic dry run) - #124904 (reachable computation: extend explanation of what this does, and why) - #124930 (Make sure we consume a generic arg when checking mistyped turbofish) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
f9a3fd9661
@ -1223,7 +1223,11 @@ impl<'a> Parser<'a> {
|
|||||||
let x = self.parse_seq_to_before_end(
|
let x = self.parse_seq_to_before_end(
|
||||||
&token::Gt,
|
&token::Gt,
|
||||||
SeqSep::trailing_allowed(token::Comma),
|
SeqSep::trailing_allowed(token::Comma),
|
||||||
|p| p.parse_generic_arg(None),
|
|p| match p.parse_generic_arg(None)? {
|
||||||
|
Some(arg) => Ok(arg),
|
||||||
|
// If we didn't eat a generic arg, then we should error.
|
||||||
|
None => p.unexpected_any(),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
match x {
|
match x {
|
||||||
Ok((_, _, Recovered::No)) => {
|
Ok((_, _, Recovered::No)) => {
|
||||||
|
@ -160,7 +160,7 @@ impl<'a> Parser<'a> {
|
|||||||
style: PathStyle,
|
style: PathStyle,
|
||||||
ty_generics: Option<&Generics>,
|
ty_generics: Option<&Generics>,
|
||||||
) -> PResult<'a, Path> {
|
) -> PResult<'a, Path> {
|
||||||
let reject_generics_if_mod_style = |parser: &Parser<'_>, path: &Path| {
|
let reject_generics_if_mod_style = |parser: &Parser<'_>, path: Path| {
|
||||||
// Ensure generic arguments don't end up in attribute paths, such as:
|
// Ensure generic arguments don't end up in attribute paths, such as:
|
||||||
//
|
//
|
||||||
// macro_rules! m {
|
// macro_rules! m {
|
||||||
@ -178,21 +178,26 @@ impl<'a> Parser<'a> {
|
|||||||
.map(|arg| arg.span())
|
.map(|arg| arg.span())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
parser.dcx().emit_err(errors::GenericsInPath { span });
|
parser.dcx().emit_err(errors::GenericsInPath { span });
|
||||||
|
// Ignore these arguments to prevent unexpected behaviors.
|
||||||
|
let segments = path
|
||||||
|
.segments
|
||||||
|
.iter()
|
||||||
|
.map(|segment| PathSegment { ident: segment.ident, id: segment.id, args: None })
|
||||||
|
.collect();
|
||||||
|
Path { segments, ..path }
|
||||||
|
} else {
|
||||||
|
path
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
maybe_whole!(self, NtPath, |path| {
|
maybe_whole!(self, NtPath, |path| reject_generics_if_mod_style(self, path.into_inner()));
|
||||||
reject_generics_if_mod_style(self, &path);
|
|
||||||
path.into_inner()
|
|
||||||
});
|
|
||||||
|
|
||||||
if let token::Interpolated(nt) = &self.token.kind {
|
if let token::Interpolated(nt) = &self.token.kind {
|
||||||
if let token::NtTy(ty) = &nt.0 {
|
if let token::NtTy(ty) = &nt.0 {
|
||||||
if let ast::TyKind::Path(None, path) = &ty.kind {
|
if let ast::TyKind::Path(None, path) = &ty.kind {
|
||||||
let path = path.clone();
|
let path = path.clone();
|
||||||
self.bump();
|
self.bump();
|
||||||
reject_generics_if_mod_style(self, &path);
|
return Ok(reject_generics_if_mod_style(self, path));
|
||||||
return Ok(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,26 @@
|
|||||||
//! Finds local items that are externally reachable, which means that other crates need access to
|
//! Finds local items that are "reachable", which means that other crates need access to their
|
||||||
//! their compiled machine code or their MIR.
|
//! compiled code or their *runtime* MIR. (Compile-time MIR is always encoded anyway, so we don't
|
||||||
|
//! worry about that here.)
|
||||||
//!
|
//!
|
||||||
//! An item is "externally reachable" if it is relevant for other crates. This obviously includes
|
//! An item is "reachable" if codegen that happens in downstream crates can end up referencing this
|
||||||
//! all public items. However, some of these items cannot be compiled to machine code (because they
|
//! item. This obviously includes all public items. However, some of these items cannot be codegen'd
|
||||||
//! are generic), and for some the machine code is not sufficient (because we want to cross-crate
|
//! (because they are generic), and for some the compiled code is not sufficient (because we want to
|
||||||
//! inline them). These items "need cross-crate MIR". When a reachable function `f` needs
|
//! cross-crate inline them). These items "need cross-crate MIR". When a reachable function `f`
|
||||||
//! cross-crate MIR, then all the functions it calls also become reachable, as they will be
|
//! needs cross-crate MIR, then its MIR may be codegen'd in a downstream crate, and hence items it
|
||||||
//! necessary to use the MIR of `f` from another crate. Furthermore, an item can become "externally
|
//! mentions need to be considered reachable.
|
||||||
//! reachable" by having a `const`/`const fn` return a pointer to that item, so we also need to
|
//!
|
||||||
//! recurse into reachable `const`/`const fn`.
|
//! Furthermore, if a `const`/`const fn` is reachable, then it can return pointers to other items,
|
||||||
|
//! making those reachable as well. For instance, consider a `const fn` returning a pointer to an
|
||||||
|
//! otherwise entirely private function: if a downstream crate calls that `const fn` to compute the
|
||||||
|
//! initial value of a `static`, then it needs to generate a direct reference to this function --
|
||||||
|
//! i.e., the function is directly reachable from that downstream crate! Hence we have to recurse
|
||||||
|
//! into `const` and `const fn`.
|
||||||
|
//!
|
||||||
|
//! Conversely, reachability *stops* when it hits a monomorphic non-`const` function that we do not
|
||||||
|
//! want to cross-crate inline. That function will just be codegen'd in this crate, which means the
|
||||||
|
//! monomorphization collector will consider it a root and then do another graph traversal to
|
||||||
|
//! codegen everything called by this function -- but that's a very different graph from what we are
|
||||||
|
//! considering here as at that point, everything is monomorphic.
|
||||||
|
|
||||||
use hir::def_id::LocalDefIdSet;
|
use hir::def_id::LocalDefIdSet;
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
|
@ -40,6 +40,9 @@ pub fn opts() -> TargetOptions {
|
|||||||
//
|
//
|
||||||
// See https://github.com/rust-lang/rust/pull/47483 for some more details.
|
// See https://github.com/rust-lang/rust/pull/47483 for some more details.
|
||||||
"-lmsvcrt",
|
"-lmsvcrt",
|
||||||
|
// Math functions missing in MSVCRT (they are present in UCRT) require
|
||||||
|
// this dependency cycle: `libmingwex.a` -> `libmsvcrt.a` -> `libmingwex.a`.
|
||||||
|
"-lmingwex",
|
||||||
"-luser32",
|
"-luser32",
|
||||||
"-lkernel32",
|
"-lkernel32",
|
||||||
];
|
];
|
||||||
|
@ -88,6 +88,9 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
|
|||||||
|
|
||||||
/// Primary function to execute this rule. Can call `builder.ensure()`
|
/// Primary function to execute this rule. Can call `builder.ensure()`
|
||||||
/// with other steps to run those.
|
/// with other steps to run those.
|
||||||
|
///
|
||||||
|
/// This gets called twice during a normal `./x.py` execution: first
|
||||||
|
/// with `dry_run() == true`, and then for real.
|
||||||
fn run(self, builder: &Builder<'_>) -> Self::Output;
|
fn run(self, builder: &Builder<'_>) -> Self::Output;
|
||||||
|
|
||||||
/// When bootstrap is passed a set of paths, this controls whether this rule
|
/// When bootstrap is passed a set of paths, this controls whether this rule
|
||||||
|
@ -683,6 +683,8 @@ impl Build {
|
|||||||
|
|
||||||
if !self.config.dry_run() {
|
if !self.config.dry_run() {
|
||||||
{
|
{
|
||||||
|
// We first do a dry-run. This is a sanity-check to ensure that
|
||||||
|
// steps don't do anything expensive in the dry-run.
|
||||||
self.config.dry_run = DryRun::SelfCheck;
|
self.config.dry_run = DryRun::SelfCheck;
|
||||||
let builder = builder::Builder::new(self);
|
let builder = builder::Builder::new(self);
|
||||||
builder.execute_cli();
|
builder.execute_cli();
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
//@ known-bug: #123911
|
|
||||||
|
|
||||||
macro_rules! m {
|
|
||||||
($attr_path: path) => {
|
|
||||||
#[$attr_path]
|
|
||||||
fn f() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m!(inline<{
|
|
||||||
let a = CharCharFloat { a: 1 };
|
|
||||||
let b = rustrt::rust_dbg_abi_4(a);
|
|
||||||
println!("a: {}", b.a);
|
|
||||||
}>);
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -1,15 +0,0 @@
|
|||||||
//@ known-bug: #123912
|
|
||||||
|
|
||||||
macro_rules! m {
|
|
||||||
($attr_path: path) => {
|
|
||||||
#[$attr_path]
|
|
||||||
fn f() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m!(inline<{
|
|
||||||
let a = CharCharFloat { a: 1 };
|
|
||||||
println!("a: {}", a);
|
|
||||||
}>);
|
|
||||||
|
|
||||||
fn main() {}
|
|
@ -1,7 +1,6 @@
|
|||||||
//@ known-bug: #97006
|
|
||||||
//@ compile-flags: -Zunpretty=hir
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
|
||||||
#![allow(unused)]
|
// issue#97006
|
||||||
|
|
||||||
macro_rules! m {
|
macro_rules! m {
|
||||||
($attr_path: path) => {
|
($attr_path: path) => {
|
8
tests/ui/macros/genercs-in-path-with-prettry-hir.stderr
Normal file
8
tests/ui/macros/genercs-in-path-with-prettry-hir.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
error: unexpected generic arguments in path
|
||||||
|
--> $DIR/genercs-in-path-with-prettry-hir.rs:12:10
|
||||||
|
|
|
||||||
|
LL | m!(inline<u8>);
|
||||||
|
| ^^^^
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
15
tests/ui/macros/genercs-in-path-with-prettry-hir.stdout
Normal file
15
tests/ui/macros/genercs-in-path-with-prettry-hir.stdout
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#[prelude_import]
|
||||||
|
use ::std::prelude::rust_2015::*;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate std;
|
||||||
|
//@ compile-flags: -Zunpretty=hir
|
||||||
|
|
||||||
|
// issue#97006
|
||||||
|
|
||||||
|
macro_rules! m { ($attr_path: path) => { #[$attr_path] fn f() {} } }
|
||||||
|
#[
|
||||||
|
|
||||||
|
inline]
|
||||||
|
fn f() { }
|
||||||
|
|
||||||
|
fn main() { }
|
19
tests/ui/macros/macro-expand-within-generics-in-path.rs
Normal file
19
tests/ui/macros/macro-expand-within-generics-in-path.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// issue#123911
|
||||||
|
// issue#123912
|
||||||
|
|
||||||
|
macro_rules! m {
|
||||||
|
($p: path) => {
|
||||||
|
#[$p]
|
||||||
|
struct S;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! p {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
m!(generic<p!()>);
|
||||||
|
//~^ ERROR: unexpected generic arguments in path
|
||||||
|
//~| ERROR: cannot find attribute `generic` in this scope
|
||||||
|
|
||||||
|
fn main() {}
|
14
tests/ui/macros/macro-expand-within-generics-in-path.stderr
Normal file
14
tests/ui/macros/macro-expand-within-generics-in-path.stderr
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
error: unexpected generic arguments in path
|
||||||
|
--> $DIR/macro-expand-within-generics-in-path.rs:15:11
|
||||||
|
|
|
||||||
|
LL | m!(generic<p!()>);
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: cannot find attribute `generic` in this scope
|
||||||
|
--> $DIR/macro-expand-within-generics-in-path.rs:15:4
|
||||||
|
|
|
||||||
|
LL | m!(generic<p!()>);
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
fn foo() {
|
||||||
|
let x = Tr<A, A:>;
|
||||||
|
//~^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
@ -0,0 +1,14 @@
|
|||||||
|
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
|
||||||
|
--> $DIR/turbofish-arg-with-stray-colon.rs:2:17
|
||||||
|
|
|
||||||
|
LL | let x = Tr<A, A:>;
|
||||||
|
| ^ expected one of 8 possible tokens
|
||||||
|
|
|
||||||
|
= note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
|
||||||
|
help: maybe write a path separator here
|
||||||
|
|
|
||||||
|
LL | let x = Tr<A, A::>;
|
||||||
|
| ~~
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
@ -11,5 +11,4 @@ fn main() {
|
|||||||
foo::<>!(); //~ ERROR generic arguments in macro path
|
foo::<>!(); //~ ERROR generic arguments in macro path
|
||||||
m!(Default<>);
|
m!(Default<>);
|
||||||
//~^ ERROR unexpected generic arguments in path
|
//~^ ERROR unexpected generic arguments in path
|
||||||
//~^^ ERROR generic arguments in macro path
|
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,5 @@ error: unexpected generic arguments in path
|
|||||||
LL | m!(Default<>);
|
LL | m!(Default<>);
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: generic arguments in macro path
|
error: aborting due to 3 previous errors
|
||||||
--> $DIR/macro-ty-params.rs:12:15
|
|
||||||
|
|
|
||||||
LL | m!(Default<>);
|
|
||||||
| ^^
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user