Skip to content

Commit fda8d98

Browse files
committed
Auto merge of rust-lang#121705 - matthiaskrgr:rollup-xih05nu, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#120051 (Add `display` method to `OsStr`) - rust-lang#121226 (Fix issues in suggesting importing extern crate paths) - rust-lang#121527 (unix_sigpipe: Simple fixes and improvements in tests) - rust-lang#121572 (Add test case for primitive links in alias js) - rust-lang#121661 (Changing some attributes to only_local.) - rust-lang#121680 (Fix link generation for foreign macro in jump to definition feature) - rust-lang#121686 (Adjust printing for RPITITs) - rust-lang#121689 ([rustdoc] Prevent inclusion of whitespace character after macro_rules ident) - rust-lang#121695 (Split rustc_type_ir to avoid rustc_ast from depending on it) - rust-lang#121698 (CFI: Fix typo in test file names) Failed merges: - rust-lang#121423 (Remove the `UntranslatableDiagnosticTrivial` lint.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ef32456 + 8899f96 commit fda8d98

File tree

54 files changed

+428
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+428
-146
lines changed

Cargo.lock

+14-1
Original file line numberDiff line numberDiff line change
@@ -3417,18 +3417,29 @@ version = "0.0.0"
34173417
dependencies = [
34183418
"bitflags 2.4.2",
34193419
"memchr",
3420+
"rustc_ast_ir",
34203421
"rustc_data_structures",
34213422
"rustc_index",
34223423
"rustc_lexer",
34233424
"rustc_macros",
34243425
"rustc_serialize",
34253426
"rustc_span",
3426-
"rustc_type_ir",
34273427
"smallvec",
34283428
"thin-vec",
34293429
"tracing",
34303430
]
34313431

3432+
[[package]]
3433+
name = "rustc_ast_ir"
3434+
version = "0.0.0"
3435+
dependencies = [
3436+
"rustc_data_structures",
3437+
"rustc_macros",
3438+
"rustc_serialize",
3439+
"rustc_span",
3440+
"smallvec",
3441+
]
3442+
34323443
[[package]]
34333444
name = "rustc_ast_lowering"
34343445
version = "0.0.0"
@@ -4181,6 +4192,7 @@ dependencies = [
41814192
"rustc_apfloat",
41824193
"rustc_arena",
41834194
"rustc_ast",
4195+
"rustc_ast_ir",
41844196
"rustc_attr",
41854197
"rustc_data_structures",
41864198
"rustc_error_messages",
@@ -4661,6 +4673,7 @@ version = "0.0.0"
46614673
dependencies = [
46624674
"bitflags 2.4.2",
46634675
"derivative",
4676+
"rustc_ast_ir",
46644677
"rustc_data_structures",
46654678
"rustc_index",
46664679
"rustc_macros",

compiler/rustc_ast/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ edition = "2021"
88
# tidy-alphabetical-start
99
bitflags = "2.4.1"
1010
memchr = "=2.5.0"
11+
rustc_ast_ir = { path = "../rustc_ast_ir" }
1112
rustc_data_structures = { path = "../rustc_data_structures" }
1213
rustc_index = { path = "../rustc_index" }
1314
rustc_lexer = { path = "../rustc_lexer" }
1415
rustc_macros = { path = "../rustc_macros" }
1516
rustc_serialize = { path = "../rustc_serialize" }
1617
rustc_span = { path = "../rustc_span" }
17-
# For Mutability and Movability, which could be uplifted into a common crate.
18-
rustc_type_ir = { path = "../rustc_type_ir" }
1918
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2019
thin-vec = "0.2.12"
2120
tracing = "0.1"

compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub use UnsafeSource::*;
2727
use crate::ptr::P;
2828
use crate::token::{self, CommentKind, Delimiter};
2929
use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
30+
pub use rustc_ast_ir::{Movability, Mutability};
3031
use rustc_data_structures::packed::Pu128;
3132
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3233
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -35,7 +36,6 @@ use rustc_macros::HashStable_Generic;
3536
use rustc_span::source_map::{respan, Spanned};
3637
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3738
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
38-
pub use rustc_type_ir::{Movability, Mutability};
3939
use std::fmt;
4040
use std::mem;
4141
use thin_vec::{thin_vec, ThinVec};

compiler/rustc_ast_ir/Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "rustc_ast_ir"
3+
version = "0.0.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
# tidy-alphabetical-start
8+
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
9+
rustc_macros = { path = "../rustc_macros", optional = true }
10+
rustc_serialize = { path = "../rustc_serialize", optional = true }
11+
rustc_span = { path = "../rustc_span", optional = true }
12+
smallvec = { version = "1.8.1" }
13+
# tidy-alphabetical-end
14+
15+
[features]
16+
default = ["nightly"]
17+
nightly = [
18+
"rustc_serialize",
19+
"rustc_data_structures",
20+
"rustc_macros",
21+
"rustc_span",
22+
]

compiler/rustc_ast_ir/src/lib.rs

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
2+
#![cfg_attr(feature = "nightly", allow(internal_features))]
3+
4+
#[cfg(feature = "nightly")]
5+
#[macro_use]
6+
extern crate rustc_macros;
7+
8+
/// The movability of a coroutine / closure literal:
9+
/// whether a coroutine contains self-references, causing it to be `!Unpin`.
10+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
11+
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
12+
pub enum Movability {
13+
/// May contain self-references, `!Unpin`.
14+
Static,
15+
/// Must not contain self-references, `Unpin`.
16+
Movable,
17+
}
18+
19+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
20+
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
21+
pub enum Mutability {
22+
// N.B. Order is deliberate, so that Not < Mut
23+
Not,
24+
Mut,
25+
}
26+
27+
impl Mutability {
28+
pub fn invert(self) -> Self {
29+
match self {
30+
Mutability::Mut => Mutability::Not,
31+
Mutability::Not => Mutability::Mut,
32+
}
33+
}
34+
35+
/// Returns `""` (empty string) or `"mut "` depending on the mutability.
36+
pub fn prefix_str(self) -> &'static str {
37+
match self {
38+
Mutability::Mut => "mut ",
39+
Mutability::Not => "",
40+
}
41+
}
42+
43+
/// Returns `"&"` or `"&mut "` depending on the mutability.
44+
pub fn ref_prefix_str(self) -> &'static str {
45+
match self {
46+
Mutability::Not => "&",
47+
Mutability::Mut => "&mut ",
48+
}
49+
}
50+
51+
/// Returns `""` (empty string) or `"mutably "` depending on the mutability.
52+
pub fn mutably_str(self) -> &'static str {
53+
match self {
54+
Mutability::Not => "",
55+
Mutability::Mut => "mutably ",
56+
}
57+
}
58+
59+
/// Return `true` if self is mutable
60+
pub fn is_mut(self) -> bool {
61+
matches!(self, Self::Mut)
62+
}
63+
64+
/// Return `true` if self is **not** mutable
65+
pub fn is_not(self) -> bool {
66+
matches!(self, Self::Not)
67+
}
68+
}

compiler/rustc_const_eval/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use rustc_middle::mir::interpret::{
1111
PointerKind, ResourceExhaustionInfo, UndefinedBehaviorInfo, UnsupportedOpInfo,
1212
ValidationErrorInfo,
1313
};
14-
use rustc_middle::ty::{self, Ty};
14+
use rustc_middle::ty::{self, Mutability, Ty};
1515
use rustc_span::Span;
1616
use rustc_target::abi::call::AdjustForForeignAbiError;
1717
use rustc_target::abi::{Size, WrappingRange};
18-
use rustc_type_ir::Mutability;
1918

2019
use crate::interpret::InternKind;
2120

compiler/rustc_const_eval/src/util/caller_location.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use rustc_hir::LangItem;
22
use rustc_middle::mir;
33
use rustc_middle::query::TyCtxtAt;
4-
use rustc_middle::ty;
54
use rustc_middle::ty::layout::LayoutOf;
5+
use rustc_middle::ty::{self, Mutability};
66
use rustc_span::symbol::Symbol;
7-
use rustc_type_ir::Mutability;
87

98
use crate::const_eval::{mk_eval_cx_to_read_const_val, CanAccessMutGlobal, CompileTimeEvalContext};
109
use crate::interpret::*;

compiler/rustc_feature/src/builtin_attrs.rs

+41-22
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,21 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
390390

391391
// Entry point:
392392
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
393-
ungated!(start, Normal, template!(Word), WarnFollowing),
394-
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
395-
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
393+
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
394+
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
395+
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
396396

397397
// Modules, prelude, and resolution:
398-
ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing),
399-
ungated!(no_std, CrateLevel, template!(Word), WarnFollowing),
400-
ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing),
398+
ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing, @only_local: true),
399+
ungated!(no_std, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
400+
ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing, @only_local: true),
401401
ungated!(non_exhaustive, Normal, template!(Word), WarnFollowing),
402402

403403
// Runtime
404404
ungated!(
405405
windows_subsystem, CrateLevel,
406-
template!(NameValueStr: "windows|console"), FutureWarnFollowing
406+
template!(NameValueStr: "windows|console"), FutureWarnFollowing,
407+
@only_local: true
407408
),
408409
ungated!(panic_handler, Normal, template!(Word), WarnFollowing), // RFC 2070
409410

@@ -416,13 +417,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
416417
DuplicatesOk, @only_local: true,
417418
),
418419
ungated!(track_caller, Normal, template!(Word), WarnFollowing),
419-
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding),
420+
ungated!(instruction_set, Normal, template!(List: "set"), ErrorPreceding, @only_local: true),
420421
gated!(
421422
no_sanitize, Normal,
422423
template!(List: "address, kcfi, memory, thread"), DuplicatesOk,
423-
experimental!(no_sanitize)
424+
@only_local: true, experimental!(no_sanitize)
425+
),
426+
gated!(
427+
coverage, Normal, template!(Word, List: "on|off"),
428+
WarnFollowing, @only_local: true,
429+
coverage_attribute, experimental!(coverage)
424430
),
425-
gated!(coverage, Normal, template!(Word, List: "on|off"), WarnFollowing, coverage_attribute, experimental!(coverage)),
426431

427432
ungated!(
428433
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
@@ -431,7 +436,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
431436
// Debugging
432437
ungated!(
433438
debugger_visualizer, Normal,
434-
template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk
439+
template!(List: r#"natvis_file = "...", gdb_script_file = "...""#),
440+
DuplicatesOk, @only_local: true
435441
),
436442

437443
// ==========================================================================
@@ -455,26 +461,35 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
455461
marker_trait_attr, experimental!(marker)
456462
),
457463
gated!(
458-
thread_local, Normal, template!(Word), WarnFollowing,
464+
thread_local, Normal, template!(Word), WarnFollowing, @only_local: true,
459465
"`#[thread_local]` is an experimental feature, and does not currently handle destructors",
460466
),
461-
gated!(no_core, CrateLevel, template!(Word), WarnFollowing, experimental!(no_core)),
467+
gated!(
468+
no_core, CrateLevel, template!(Word), WarnFollowing,
469+
@only_local: true, experimental!(no_core)
470+
),
462471
// RFC 2412
463472
gated!(
464-
optimize, Normal, template!(List: "size|speed"), ErrorPreceding, optimize_attribute,
465-
experimental!(optimize),
473+
optimize, Normal, template!(List: "size|speed"), ErrorPreceding,
474+
@only_local: true, optimize_attribute, experimental!(optimize)
466475
),
467476

468-
gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
469-
gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
477+
gated!(
478+
ffi_pure, Normal, template!(Word), WarnFollowing,
479+
@only_local: true, experimental!(ffi_pure)
480+
),
481+
gated!(
482+
ffi_const, Normal, template!(Word), WarnFollowing,
483+
@only_local: true, experimental!(ffi_const)
484+
),
470485
gated!(
471486
register_tool, CrateLevel, template!(List: "tool1, tool2, ..."), DuplicatesOk,
472-
experimental!(register_tool),
487+
@only_local: true, experimental!(register_tool),
473488
),
474489

475490
gated!(
476491
cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
477-
experimental!(cmse_nonsecure_entry)
492+
@only_local: true, experimental!(cmse_nonsecure_entry)
478493
),
479494
// RFC 2632
480495
gated!(
@@ -492,11 +507,14 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
492507
// `#[collapse_debuginfo]`
493508
gated!(
494509
collapse_debuginfo, Normal, template!(Word, List: "no|external|yes"), ErrorFollowing,
495-
experimental!(collapse_debuginfo)
510+
@only_local: true, experimental!(collapse_debuginfo)
496511
),
497512

498513
// RFC 2397
499-
gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)),
514+
gated!(
515+
do_not_recommend, Normal, template!(Word), WarnFollowing,
516+
@only_local: true, experimental!(do_not_recommend)
517+
),
500518

501519
// `#[cfi_encoding = ""]`
502520
gated!(
@@ -528,7 +546,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
528546
),
529547
ungated!(
530548
rustc_default_body_unstable, Normal,
531-
template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk
549+
template!(List: r#"feature = "name", reason = "...", issue = "N""#),
550+
DuplicatesOk, @only_local: true
532551
),
533552
gated!(
534553
allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,

compiler/rustc_hir/src/definitions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ impl DefPathData {
420420
pub fn name(&self) -> DefPathDataName {
421421
use self::DefPathData::*;
422422
match *self {
423-
TypeNs(name) if name == kw::Empty => DefPathDataName::Anon { namespace: sym::opaque },
423+
TypeNs(name) if name == kw::Empty => {
424+
DefPathDataName::Anon { namespace: sym::synthetic }
425+
}
424426
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => {
425427
DefPathDataName::Named(name)
426428
}

compiler/rustc_hir_analysis/src/check/errs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use rustc_hir as hir;
22
use rustc_hir_pretty::qpath_to_string;
33
use rustc_lint_defs::builtin::STATIC_MUT_REFS;
4-
use rustc_middle::ty::TyCtxt;
4+
use rustc_middle::ty::{Mutability, TyCtxt};
55
use rustc_span::Span;
6-
use rustc_type_ir::Mutability;
76

87
use crate::errors;
98

compiler/rustc_middle/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rustc-rayon-core = { version = "0.5.0", optional = true }
1717
rustc_apfloat = "0.2.0"
1818
rustc_arena = { path = "../rustc_arena" }
1919
rustc_ast = { path = "../rustc_ast" }
20+
rustc_ast_ir = { path = "../rustc_ast_ir" }
2021
rustc_attr = { path = "../rustc_attr" }
2122
rustc_data_structures = { path = "../rustc_data_structures" }
2223
rustc_error_messages = { path = "../rustc_error_messages" } # Used for intra-doc links

compiler/rustc_middle/src/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::error;
44
use crate::mir::{ConstAlloc, ConstValue};
55
use crate::ty::{layout, tls, Ty, TyCtxt, ValTree};
66

7+
use rustc_ast_ir::Mutability;
78
use rustc_data_structures::sync::Lock;
89
use rustc_errors::{
910
DiagnosticArgName, DiagnosticArgValue, DiagnosticMessage, ErrorGuaranteed, IntoDiagnosticArg,
@@ -12,7 +13,6 @@ use rustc_macros::HashStable;
1213
use rustc_session::CtfeBacktrace;
1314
use rustc_span::{def_id::DefId, Span, DUMMY_SP};
1415
use rustc_target::abi::{call, Align, Size, VariantIdx, WrappingRange};
15-
use rustc_type_ir::Mutability;
1616

1717
use std::borrow::Cow;
1818
use std::{any::Any, backtrace::Backtrace, fmt};

compiler/rustc_middle/src/ty/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub use generic_args::*;
3232
pub use generics::*;
3333
use rustc_ast as ast;
3434
use rustc_ast::node_id::NodeMap;
35+
pub use rustc_ast_ir::{Movability, Mutability};
3536
use rustc_attr as attr;
3637
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
3738
use rustc_data_structures::intern::Interned;

0 commit comments

Comments
 (0)