Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0bb8615
interpret: reduce usage of TypingEnv::fully_monomorphized
RalfJung Dec 9, 2024
0dbb31f
Fix an out-of-date comment.
nnethercote Nov 26, 2024
83f67c5
Remove unused dataflow trait impls and bounds.
nnethercote Dec 5, 2024
d490ea1
Remove lifetimes from `BorrowckDomain`.
nnethercote Nov 26, 2024
086233e
Refer to a couple of domains indirectly.
nnethercote Nov 26, 2024
2298104
Call all `Domain` values `state`.
nnethercote Nov 26, 2024
b059ea8
Rename `EntrySets` as `EntryStates`.
nnethercote Nov 26, 2024
119fbd3
Improve terminology in `elaborate_drops.rs`.
nnethercote Nov 26, 2024
1d56943
Rename some `Analysis` and `ResultsVisitor` methods.
nnethercote Nov 26, 2024
dddc09d
Reorder some `Analysis` methods.
nnethercote Nov 26, 2024
dd3b313
Adjust `alias-uninit-value.rs`
jieyouxu Dec 5, 2024
b5c7a55
Adjust `allow-non-lint-warnings.rs`
jieyouxu Dec 5, 2024
d734d22
Adjust `anonymous-higher-ranked-lifetime.rs`
jieyouxu Dec 5, 2024
4652b14
Adjust `artificial-block.rs`
jieyouxu Dec 5, 2024
56efa0a
Adjust `as-precedence.rs`
jieyouxu Dec 8, 2024
3f52583
Add test for resolve errors caused by mod with parse errors
estebank Dec 5, 2024
69fb612
Keep track of parse errors in `mod`s and don't emit resolve errors fo…
estebank Dec 5, 2024
27420c6
Silence `use foo::Bar;` error if `Bar` isn't found in `foo` and `foo.…
estebank Dec 5, 2024
b795264
Pass TyCtxt rather than Queries to after_expansion
bjorn3 Nov 26, 2023
21634cb
Pass rustc_ast::Crate rather than Queries to after_crate_root_parsing
bjorn3 Dec 12, 2024
8355132
Move type size and vtable size printing to start_codegen
bjorn3 Dec 10, 2024
7e37943
Remove 'tcx lifetime from QuerySystemFns
bjorn3 Nov 3, 2024
3b1adfa
Parsing unsafe binders
compiler-errors Aug 30, 2024
2a9e358
Lower AST and resolve lifetimes for unsafe binder types
compiler-errors Dec 10, 2024
3f97c6b
Add unwrap_unsafe_binder and wrap_unsafe_binder macro operators
compiler-errors Sep 13, 2024
c5d0223
Add tests
compiler-errors Dec 10, 2024
b8c5a0f
Fix tools
compiler-errors Dec 10, 2024
6ce7ba4
Fix typos in docs on provenance
purplesyringa Dec 12, 2024
ab0d792
Rollup merge of #133900 - jieyouxu:ui-cleanup-1, r=fmease
matthiaskrgr Dec 13, 2024
c181026
Rollup merge of #133937 - estebank:silence-resolve-errors-from-mod-wi…
matthiaskrgr Dec 13, 2024
c6ebe6f
Rollup merge of #133938 - nnethercote:rustc_mir_dataflow-renamings, r…
matthiaskrgr Dec 13, 2024
97dc513
Rollup merge of #134058 - RalfJung:interpret-typing-env, r=lcnr
matthiaskrgr Dec 13, 2024
9f6b07e
Rollup merge of #134130 - bjorn3:prepare_driver_query_removal, r=oli-obk
matthiaskrgr Dec 13, 2024
5c9b227
Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obk
matthiaskrgr Dec 13, 2024
8cce32a
Rollup merge of #134229 - purplesyringa:provenance-docs, r=saethlin
matthiaskrgr Dec 13, 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
Prev Previous commit
Next Next commit
Fix tools
  • Loading branch information
compiler-errors committed Dec 12, 2024
commit b8c5a0f0eba036700775a33c924deaeeb34f3974
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2893,7 +2893,7 @@ pub enum TyKind<'hir> {
Ref(&'hir Lifetime, MutTy<'hir>),
/// A bare function (e.g., `fn(usize) -> bool`).
BareFn(&'hir BareFnTy<'hir>),
/// Uwu
/// An unsafe binder type (e.g. `unsafe<'a> Foo<'a>`).
UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
/// The never type (`!`).
Never,
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,9 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
TyKind::Infer | TyKind::Err(_) | TyKind::Typeof(..) | TyKind::InferDelegation(..) => Infer,
TyKind::UnsafeBinder(..) => {
unimplemented!("unsafe binders are not supported yet")
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ impl TyCoercionStability {
| TyKind::TraitObject(..)
| TyKind::InferDelegation(..)
| TyKind::Err(_) => Self::Reborrow,
TyKind::UnsafeBinder(..) => Self::None,
};
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/loops/never_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ fn never_loop_expr<'tcx>(
| ExprKind::Field(e, _)
| ExprKind::AddrOf(_, _, e)
| ExprKind::Repeat(e, _)
| ExprKind::DropTemps(e) => never_loop_expr(cx, e, local_labels, main_loop_id),
| ExprKind::DropTemps(e)
| ExprKind::UnsafeBinderCast(_, e, _) => never_loop_expr(cx, e, local_labels, main_loop_id),
ExprKind::Let(let_expr) => never_loop_expr(cx, let_expr.init, local_labels, main_loop_id),
ExprKind::Array(es) | ExprKind::Tup(es) => never_loop_expr_all(cx, es.iter(), local_labels, main_loop_id),
ExprKind::MethodCall(_, receiver, es, _) => {
Expand Down
3 changes: 3 additions & 0 deletions src/tools/clippy/clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
kind!("DropTemps({expr})");
self.expr(expr);
},
ExprKind::UnsafeBinderCast(..) => {
unimplemented!("unsafe binders are not implemented yet");
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_utils/src/eager_or_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
| ExprKind::AddrOf(..)
| ExprKind::Repeat(..)
| ExprKind::Block(Block { stmts: [], .. }, _)
| ExprKind::OffsetOf(..) => (),
| ExprKind::OffsetOf(..)
| ExprKind::UnsafeBinderCast(..) => (),

// Assignment might be to a local defined earlier, so don't eagerly evaluate.
// Blocks with multiple statements might be expensive, so don't eagerly evaluate.
Expand Down
15 changes: 15 additions & 0 deletions src/tools/clippy/clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ impl HirEqInterExpr<'_, '_, '_> {
&& self.eq_expr(l_receiver, r_receiver)
&& self.eq_exprs(l_args, r_args)
},
(&ExprKind::UnsafeBinderCast(lkind, le, None), &ExprKind::UnsafeBinderCast(rkind, re, None)) =>
lkind == rkind && self.eq_expr(le, re),
(&ExprKind::UnsafeBinderCast(lkind, le, Some(lt)), &ExprKind::UnsafeBinderCast(rkind, re, Some(rt))) =>
lkind == rkind && self.eq_expr(le, re) && self.eq_ty(lt, rt),
(&ExprKind::OffsetOf(l_container, l_fields), &ExprKind::OffsetOf(r_container, r_fields)) => {
self.eq_ty(l_container, r_container) && over(l_fields, r_fields, |l, r| l.name == r.name)
},
Expand Down Expand Up @@ -424,6 +428,7 @@ impl HirEqInterExpr<'_, '_, '_> {
| &ExprKind::Type(..)
| &ExprKind::Unary(..)
| &ExprKind::Yield(..)
| &ExprKind::UnsafeBinderCast(..)

// --- Special cases that do not have a positive branch.

Expand Down Expand Up @@ -1032,6 +1037,13 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
std::mem::discriminant(&lop).hash(&mut self.s);
self.hash_expr(le);
},
ExprKind::UnsafeBinderCast(kind, expr, ty) => {
std::mem::discriminant(&kind).hash(&mut self.s);
self.hash_expr(expr);
if let Some(ty) = ty {
self.hash_ty(ty);
}
}
ExprKind::Err(_) => {},
}
}
Expand Down Expand Up @@ -1241,6 +1253,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
TyKind::Typeof(anon_const) => {
self.hash_body(anon_const.body);
},
TyKind::UnsafeBinder(binder) => {
self.hash_ty(binder.inner_ty);
}
TyKind::Err(_)
| TyKind::Infer
| TyKind::Never
Expand Down
6 changes: 4 additions & 2 deletions src/tools/clippy/clippy_utils/src/sugg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ impl<'a> Sugg<'a> {
| ExprKind::Become(..)
| ExprKind::Struct(..)
| ExprKind::Tup(..)
| ExprKind::Err(_) => Sugg::NonParen(get_snippet(expr.span)),
| ExprKind::Err(_)
| ExprKind::UnsafeBinderCast(..) => Sugg::NonParen(get_snippet(expr.span)),
ExprKind::DropTemps(inner) => Self::hir_from_snippet(inner, get_snippet),
ExprKind::Assign(lhs, rhs, _) => {
Sugg::BinOp(AssocOp::Assign, get_snippet(lhs.span), get_snippet(rhs.span))
Expand Down Expand Up @@ -226,7 +227,8 @@ impl<'a> Sugg<'a> {
| ast::ExprKind::While(..)
| ast::ExprKind::Await(..)
| ast::ExprKind::Err(_)
| ast::ExprKind::Dummy => Sugg::NonParen(snippet(expr.span)),
| ast::ExprKind::Dummy
| ast::ExprKind::UnsafeBinderCast(..) => Sugg::NonParen(snippet(expr.span)),
ast::ExprKind::Range(ref lhs, ref rhs, RangeLimits::HalfOpen) => Sugg::BinOp(
AssocOp::DotDot,
lhs.as_ref().map_or("".into(), |lhs| snippet(lhs.span)),
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/visitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
| ExprKind::Continue(_)
| ExprKind::InlineAsm(_)
| ExprKind::OffsetOf(..)
| ExprKind::UnsafeBinderCast(..)
| ExprKind::Err(_) => (),
}
ControlFlow::Continue(())
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rustfmt/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ pub(crate) fn format_expr(
ast::ExprKind::FormatArgs(..)
| ast::ExprKind::Type(..)
| ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::OffsetOf(..) => {
| ast::ExprKind::OffsetOf(..)
| ast::ExprKind::UnsafeBinderCast(..) => {
// These don't normally occur in the AST because macros aren't expanded. However,
// rustfmt tries to parse macro arguments when formatting macros, so it's not totally
// impossible for rustfmt to come across one of these nodes when formatting a file.
Expand Down
25 changes: 25 additions & 0 deletions src/tools/rustfmt/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,31 @@ impl Rewrite for ast::Ty {
let pat = pat.rewrite_result(context, shape)?;
Ok(format!("{ty} is {pat}"))
}
ast::TyKind::UnsafeBinder(ref binder) => {
let mut result = String::new();
if let Some(ref lifetime_str) =
rewrite_bound_params(context, shape, &binder.generic_params)
{
result.push_str("unsafe<");
result.push_str(lifetime_str);
result.push_str("> ");
}

let inner_ty_shape = if context.use_block_indent() {
shape
.offset_left(result.len())
.max_width_error(shape.width, self.span())?
} else {
shape
.visual_indent(result.len())
.sub_width(result.len())
.max_width_error(shape.width, self.span())?
};

let rewrite = binder.inner_ty.rewrite_result(context, inner_ty_shape)?;
result.push_str(&rewrite);
Ok(result)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/tools/rustfmt/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
| ast::ExprKind::IncludedBytes(..)
| ast::ExprKind::InlineAsm(..)
| ast::ExprKind::OffsetOf(..)
| ast::ExprKind::UnsafeBinderCast(..)
| ast::ExprKind::Let(..)
| ast::ExprKind::Path(..)
| ast::ExprKind::Range(..)
Expand Down
11 changes: 11 additions & 0 deletions src/tools/rustfmt/tests/source/unsafe-binders.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn foo() -> unsafe<'a>
&'a () {}

struct Foo {
x: unsafe<'a>
&'a (),
}

struct Bar(unsafe<'a> &'a ());

impl Trait for unsafe<'a> &'a () {}
9 changes: 9 additions & 0 deletions src/tools/rustfmt/tests/target/unsafe-binders.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn foo() -> unsafe<'a> &'a () {}

struct Foo {
x: unsafe<'a> &'a (),
}

struct Bar(unsafe<'a> &'a ());

impl Trait for unsafe<'a> &'a () {}
Loading