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 20 pull requests #126653

Closed
wants to merge 53 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
012a458
Suggest removing unused tuple fields if they are the last fields
May 13, 2024
1e9cd07
Allow constraining opaque types during subtyping in the trait system
oli-obk May 27, 2024
586821e
tip for inaccessible traits
bvanjoi Jun 1, 2024
05b7b46
fix: break inside async closure has incorrect span for enclosing closure
linyihai May 13, 2024
9b05e15
StorageLive: refresh storage (instead of UB) when local is already live
RalfJung Jun 8, 2024
408c8eb
add Miri tests
RalfJung Jun 14, 2024
22d0b1e
delegation: Implement glob delegation
petrochenkov Mar 15, 2024
df1d616
safe transmute: support non-ZST, variantful, uninhabited enums
jswrenn Jun 14, 2024
55fc6bd
Ban `ArrayToPointer` and `MutToConstPointer` from runtime MIR
scottmcm Jun 12, 2024
64bba35
`bug!` more uses of these in runtime stuff
scottmcm Jun 15, 2024
ab0e727
Suggest standalone doctest for non-local impl defs
Urgau Jun 13, 2024
94c2821
Also simplify macro_rules doctest code
Urgau Jun 13, 2024
6b84d75
Add tests
Nadrieril Mar 3, 2024
e74b30e
Tweak simple or-pattern expansion
Nadrieril Mar 20, 2024
5fe2ca6
Always set `otherwise_block`s
Nadrieril Mar 3, 2024
764f086
Use `otherwise_block` for or-pattern shortcutting
Nadrieril Mar 4, 2024
ce374fc
Factor out `finalize_or_candidate`
Nadrieril Mar 20, 2024
7b764be
Expand or-candidates mixed with candidates above
Nadrieril Mar 20, 2024
207c5bc
override user defined channel when using precompiled rustc
onur-ozkan Jun 17, 2024
5ae2446
simplify `Builder::doc_rust_lang_org_channel`
onur-ozkan Jun 17, 2024
6f5b0ef
Add badboy and BlackHoleFox as Mac Catalyst maintainers
madsmtm Jun 17, 2024
b7c2376
Sync fuchsia test runner with clang test runner
erickt May 31, 2024
0f8c3f7
tail expression behind terminating scope
dingxiangfei2009 Apr 12, 2024
475b63f
Add `/rustc-ice*/ to `.gitignore`
tgross35 Jun 18, 2024
af10880
Make async drop code more consistent with regular drop code
zetanumbers Jun 17, 2024
1a8eae1
Apply suggestions from oli-obk's review
zetanumbers Jun 18, 2024
7321e79
Replace `move||` with `move ||` in `compiler/` and `library/`
Vonr Jun 18, 2024
de473a5
Test that opaque types can't have themselves as a hidden type with in…
oli-obk Apr 11, 2024
83cb760
run_make_support nm implementation + bin-emit-no-symbols rmake rewrite
Oneirical May 30, 2024
c1597f9
try implementing suggestions
Oneirical Jun 5, 2024
977d3f6
use llvm_readobj in run-make test instead of nm
Oneirical Jun 18, 2024
bfe6a26
hir_typeck: be more conservative in making "note caller chooses ty pa…
jieyouxu Jun 18, 2024
939026c
tests: update tests for more conservative return ty mismatch note
jieyouxu Jun 16, 2024
e7eb75b
Rollup merge of #123782 - oli-obk:equal_tait_args, r=compiler-errors
jieyouxu Jun 19, 2024
4d2b4ab
Rollup merge of #124135 - petrochenkov:deleglob, r=fmease
jieyouxu Jun 19, 2024
33699c2
Rollup merge of #124580 - gurry:124556-suggest-remove-tuple-field, r=…
jieyouxu Jun 19, 2024
c5009dd
Rollup merge of #125078 - linyihai:issue-124496, r=compiler-errors
jieyouxu Jun 19, 2024
2bae32a
Rollup merge of #125293 - dingxiangfei2009:tail-expr-temp-lifetime, r…
jieyouxu Jun 19, 2024
51ca222
Rollup merge of #125447 - oli-obk:eq_opaque_pred, r=compiler-errors
jieyouxu Jun 19, 2024
03032b8
Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu
jieyouxu Jun 19, 2024
aad1f30
Rollup merge of #125852 - bvanjoi:improve-tip-for-invisible-trait, r=…
jieyouxu Jun 19, 2024
1381b0c
Rollup merge of #126154 - RalfJung:storage-live, r=compiler-errors
jieyouxu Jun 19, 2024
fe0db03
Rollup merge of #126308 - scottmcm:ban-some-coercions, r=saethlin
jieyouxu Jun 19, 2024
fedd86f
Rollup merge of #126422 - Urgau:doctest-impl-non-local-def, r=fmease
jieyouxu Jun 19, 2024
e0ce50b
Rollup merge of #126493 - jswrenn:fix-126460, r=compiler-errors
jieyouxu Jun 19, 2024
da963d6
Rollup merge of #126504 - erickt:bump-fuchsia, r=tmandry
jieyouxu Jun 19, 2024
b32d9ef
Rollup merge of #126553 - Nadrieril:expand-or-pat-into-above, r=matth…
jieyouxu Jun 19, 2024
5ec5dda
Rollup merge of #126558 - jieyouxu:caller-chooses-ty, r=fmease
jieyouxu Jun 19, 2024
187fe5b
Rollup merge of #126572 - onur-ozkan:channel-problem, r=clubby789
jieyouxu Jun 19, 2024
c4712a0
Rollup merge of #126586 - madsmtm:mac-catalyst-maintainers, r=Nilstrieb
jieyouxu Jun 19, 2024
8c38b6a
Rollup merge of #126594 - zetanumbers:fix-cross-crate-async-drop-glue…
jieyouxu Jun 19, 2024
00df302
Rollup merge of #126615 - tgross35:gitignore-ice, r=compiler-errors
jieyouxu Jun 19, 2024
68e12d3
Rollup merge of #126632 - Vonr:fix/moving-closure-formatting-v2, r=Ni…
jieyouxu Jun 19, 2024
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
9 changes: 6 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -3161,13 +3161,16 @@ pub struct Delegation {
pub path: Path,
pub rename: Option<Ident>,
pub body: Option<P<Block>>,
/// The item was expanded from a glob delegation item.
pub from_glob: bool,
}

#[derive(Clone, Encodable, Decodable, Debug)]
pub struct DelegationMac {
pub qself: Option<P<QSelf>>,
pub prefix: Path,
pub suffixes: ThinVec<(Ident, Option<Ident>)>,
// Some for list delegation, and None for glob delegation.
pub suffixes: Option<ThinVec<(Ident, Option<Ident>)>>,
pub body: Option<P<Block>>,
}

@@ -3294,7 +3297,7 @@ pub enum ItemKind {
///
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
Delegation(Box<Delegation>),
/// A list delegation item (`reuse prefix::{a, b, c}`).
/// A list or glob delegation item (`reuse prefix::{a, b, c}`, `reuse prefix::*`).
/// Treated similarly to a macro call and expanded early.
DelegationMac(Box<DelegationMac>),
}
@@ -3375,7 +3378,7 @@ pub enum AssocItemKind {
MacCall(P<MacCall>),
/// An associated delegation item.
Delegation(Box<Delegation>),
/// An associated delegation item list.
/// An associated list or glob delegation item.
DelegationMac(Box<DelegationMac>),
}

38 changes: 28 additions & 10 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
@@ -1162,7 +1162,14 @@ impl NoopVisitItemKind for ItemKind {
}
ItemKind::MacCall(m) => vis.visit_mac_call(m),
ItemKind::MacroDef(def) => vis.visit_macro_def(def),
ItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
ItemKind::Delegation(box Delegation {
id,
qself,
path,
rename,
body,
from_glob: _,
}) => {
vis.visit_id(id);
vis.visit_qself(qself);
vis.visit_path(path);
@@ -1176,10 +1183,12 @@ impl NoopVisitItemKind for ItemKind {
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
vis.visit_qself(qself);
vis.visit_path(prefix);
for (ident, rename) in suffixes {
vis.visit_ident(ident);
if let Some(rename) = rename {
vis.visit_ident(rename);
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
vis.visit_ident(ident);
if let Some(rename) = rename {
vis.visit_ident(rename);
}
}
}
if let Some(body) = body {
@@ -1218,7 +1227,14 @@ impl NoopVisitItemKind for AssocItemKind {
visit_opt(ty, |ty| visitor.visit_ty(ty));
}
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
AssocItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
AssocItemKind::Delegation(box Delegation {
id,
qself,
path,
rename,
body,
from_glob: _,
}) => {
visitor.visit_id(id);
visitor.visit_qself(qself);
visitor.visit_path(path);
@@ -1232,10 +1248,12 @@ impl NoopVisitItemKind for AssocItemKind {
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
visitor.visit_qself(qself);
visitor.visit_path(prefix);
for (ident, rename) in suffixes {
visitor.visit_ident(ident);
if let Some(rename) = rename {
visitor.visit_ident(rename);
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
visitor.visit_ident(ident);
if let Some(rename) = rename {
visitor.visit_ident(rename);
}
}
}
if let Some(body) = body {
38 changes: 28 additions & 10 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
@@ -408,7 +408,14 @@ impl WalkItemKind for ItemKind {
}
ItemKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)),
ItemKind::MacroDef(ts) => try_visit!(visitor.visit_mac_def(ts, item.id)),
ItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
ItemKind::Delegation(box Delegation {
id,
qself,
path,
rename,
body,
from_glob: _,
}) => {
if let Some(qself) = qself {
try_visit!(visitor.visit_ty(&qself.ty));
}
@@ -421,10 +428,12 @@ impl WalkItemKind for ItemKind {
try_visit!(visitor.visit_ty(&qself.ty));
}
try_visit!(visitor.visit_path(prefix, item.id));
for (ident, rename) in suffixes {
visitor.visit_ident(*ident);
if let Some(rename) = rename {
visitor.visit_ident(*rename);
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
visitor.visit_ident(*ident);
if let Some(rename) = rename {
visitor.visit_ident(*rename);
}
}
}
visit_opt!(visitor, visit_block, body);
@@ -837,7 +846,14 @@ impl WalkItemKind for AssocItemKind {
AssocItemKind::MacCall(mac) => {
try_visit!(visitor.visit_mac_call(mac));
}
AssocItemKind::Delegation(box Delegation { id, qself, path, rename, body }) => {
AssocItemKind::Delegation(box Delegation {
id,
qself,
path,
rename,
body,
from_glob: _,
}) => {
if let Some(qself) = qself {
try_visit!(visitor.visit_ty(&qself.ty));
}
@@ -850,10 +866,12 @@ impl WalkItemKind for AssocItemKind {
try_visit!(visitor.visit_ty(&qself.ty));
}
try_visit!(visitor.visit_path(prefix, item.id));
for (ident, rename) in suffixes {
visitor.visit_ident(*ident);
if let Some(rename) = rename {
visitor.visit_ident(*rename);
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
visitor.visit_ident(*ident);
if let Some(rename) = rename {
visitor.visit_ident(*rename);
}
}
}
visit_opt!(visitor, visit_block, body);
51 changes: 32 additions & 19 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,12 @@ use rustc_ast::ptr::P;
use rustc_ast::ModKind;
use rustc_span::symbol::Ident;

enum DelegationKind<'a> {
Single,
List(&'a [(Ident, Option<Ident>)]),
Glob,
}

fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
format!("{}{}", State::to_string(|s| s.print_visibility(vis)), s)
}
@@ -387,15 +393,15 @@ impl<'a> State<'a> {
&item.vis,
&deleg.qself,
&deleg.path,
None,
DelegationKind::Single,
&deleg.body,
),
ast::ItemKind::DelegationMac(deleg) => self.print_delegation(
&item.attrs,
&item.vis,
&deleg.qself,
&deleg.prefix,
Some(&deleg.suffixes),
deleg.suffixes.as_ref().map_or(DelegationKind::Glob, |s| DelegationKind::List(s)),
&deleg.body,
),
}
@@ -579,28 +585,28 @@ impl<'a> State<'a> {
vis,
&deleg.qself,
&deleg.path,
None,
DelegationKind::Single,
&deleg.body,
),
ast::AssocItemKind::DelegationMac(deleg) => self.print_delegation(
&item.attrs,
vis,
&deleg.qself,
&deleg.prefix,
Some(&deleg.suffixes),
deleg.suffixes.as_ref().map_or(DelegationKind::Glob, |s| DelegationKind::List(s)),
&deleg.body,
),
}
self.ann.post(self, AnnNode::SubItem(id))
}

pub(crate) fn print_delegation(
fn print_delegation(
&mut self,
attrs: &[ast::Attribute],
vis: &ast::Visibility,
qself: &Option<P<ast::QSelf>>,
path: &ast::Path,
suffixes: Option<&[(Ident, Option<Ident>)]>,
kind: DelegationKind<'_>,
body: &Option<P<ast::Block>>,
) {
if body.is_some() {
@@ -614,21 +620,28 @@ impl<'a> State<'a> {
} else {
self.print_path(path, false, 0);
}
if let Some(suffixes) = suffixes {
self.word("::");
self.word("{");
for (i, (ident, rename)) in suffixes.iter().enumerate() {
self.print_ident(*ident);
if let Some(rename) = rename {
self.nbsp();
self.word_nbsp("as");
self.print_ident(*rename);
}
if i != suffixes.len() - 1 {
self.word_space(",");
match kind {
DelegationKind::Single => {}
DelegationKind::List(suffixes) => {
self.word("::");
self.word("{");
for (i, (ident, rename)) in suffixes.iter().enumerate() {
self.print_ident(*ident);
if let Some(rename) = rename {
self.nbsp();
self.word_nbsp("as");
self.print_ident(*rename);
}
if i != suffixes.len() - 1 {
self.word_space(",");
}
}
self.word("}");
}
DelegationKind::Glob => {
self.word("::");
self.word("*");
}
self.word("}");
}
if let Some(body) = body {
self.nbsp();
7 changes: 5 additions & 2 deletions compiler/rustc_expand/messages.ftl
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ expand_duplicate_matcher_binding = duplicate matcher binding
.label = duplicate binding
.label2 = previous binding

expand_empty_delegation_list =
empty list delegation is not supported
expand_empty_delegation_mac =
empty {$kind} delegation is not supported

expand_expected_paren_or_brace =
expected `(` or `{"{"}`, found `{$token}`
@@ -58,6 +58,9 @@ expand_feature_removed =
.label = feature has been removed
.reason = {$reason}

expand_glob_delegation_outside_impls =
glob delegation is only supported in impls

expand_helper_attribute_name_invalid =
`{$name}` cannot be a name of derive helper attribute

47 changes: 46 additions & 1 deletion compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
@@ -357,6 +357,10 @@ where
}
}

pub trait GlobDelegationExpander {
fn expand(&self, ecx: &mut ExtCtxt<'_>) -> ExpandResult<Vec<(Ident, Option<Ident>)>, ()>;
}

// Use a macro because forwarding to a simple function has type system issues
macro_rules! make_stmts_default {
($me:expr) => {
@@ -714,6 +718,9 @@ pub enum SyntaxExtensionKind {
/// The produced AST fragment is appended to the input AST fragment.
Box<dyn MultiItemModifier + sync::DynSync + sync::DynSend>,
),

/// A glob delegation.
GlobDelegation(Box<dyn GlobDelegationExpander + sync::DynSync + sync::DynSend>),
}

/// A struct representing a macro definition in "lowered" form ready for expansion.
@@ -748,7 +755,9 @@ impl SyntaxExtension {
/// Returns which kind of macro calls this syntax extension.
pub fn macro_kind(&self) -> MacroKind {
match self.kind {
SyntaxExtensionKind::Bang(..) | SyntaxExtensionKind::LegacyBang(..) => MacroKind::Bang,
SyntaxExtensionKind::Bang(..)
| SyntaxExtensionKind::LegacyBang(..)
| SyntaxExtensionKind::GlobDelegation(..) => MacroKind::Bang,
SyntaxExtensionKind::Attr(..)
| SyntaxExtensionKind::LegacyAttr(..)
| SyntaxExtensionKind::NonMacroAttr => MacroKind::Attr,
@@ -922,6 +931,32 @@ impl SyntaxExtension {
SyntaxExtension::default(SyntaxExtensionKind::NonMacroAttr, edition)
}

pub fn glob_delegation(
trait_def_id: DefId,
impl_def_id: LocalDefId,
edition: Edition,
) -> SyntaxExtension {
struct GlobDelegationExpanderImpl {
trait_def_id: DefId,
impl_def_id: LocalDefId,
}
impl GlobDelegationExpander for GlobDelegationExpanderImpl {
fn expand(
&self,
ecx: &mut ExtCtxt<'_>,
) -> ExpandResult<Vec<(Ident, Option<Ident>)>, ()> {
match ecx.resolver.glob_delegation_suffixes(self.trait_def_id, self.impl_def_id) {
Ok(suffixes) => ExpandResult::Ready(suffixes),
Err(Indeterminate) if ecx.force_mode => ExpandResult::Ready(Vec::new()),
Err(Indeterminate) => ExpandResult::Retry(()),
}
}
}

let expander = GlobDelegationExpanderImpl { trait_def_id, impl_def_id };
SyntaxExtension::default(SyntaxExtensionKind::GlobDelegation(Box::new(expander)), edition)
}

pub fn expn_data(
&self,
parent: LocalExpnId,
@@ -1030,6 +1065,16 @@ pub trait ResolverExpand {

/// Tools registered with `#![register_tool]` and used by tool attributes and lints.
fn registered_tools(&self) -> &RegisteredTools;

/// Mark this invocation id as a glob delegation.
fn register_glob_delegation(&mut self, invoc_id: LocalExpnId);

/// Names of specific methods to which glob delegation expands.
fn glob_delegation_suffixes(
&mut self,
trait_def_id: DefId,
impl_def_id: LocalDefId,
) -> Result<Vec<(Ident, Option<Ident>)>, Indeterminate>;
}

pub trait LintStoreExpand {
12 changes: 10 additions & 2 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
@@ -435,8 +435,16 @@ pub struct ExpectedParenOrBrace<'a> {
}

#[derive(Diagnostic)]
#[diag(expand_empty_delegation_list)]
pub(crate) struct EmptyDelegationList {
#[diag(expand_empty_delegation_mac)]
pub(crate) struct EmptyDelegationMac {
#[primary_span]
pub span: Span,
pub kind: String,
}

#[derive(Diagnostic)]
#[diag(expand_glob_delegation_outside_impls)]
pub(crate) struct GlobDelegationOutsideImpls {
#[primary_span]
pub span: Span,
}
Loading