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 8 pull requests #119630

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5c0e62c
Hide foreign `#[doc(hidden)]` paths in import suggestions
Jules-Bertholet Dec 20, 2023
5f56465
Make feature `negative_bounds` internal
fmease Dec 27, 2023
a251974
Deny parenthetical notation for negative bounds
fmease Dec 27, 2023
32cea61
Don't elaborate `!Sized` to `!Sized + Sized`
fmease Dec 27, 2023
977546d
rustc_middle: Pretty-print negative bounds correctly
fmease Dec 27, 2023
90d6fe2
Imply outlives-bounds on lazy type aliases
fmease Dec 27, 2023
1d48f69
Check yield terminator's resume type in borrowck
compiler-errors Jan 4, 2024
4bc3552
cstore: Remove unnecessary locking from `CrateMetadata`
petrochenkov Jan 4, 2024
407cb24
Remove `hir::Guard`
matthewjasper Sep 21, 2023
a549711
Remove `thir::Guard`
matthewjasper Sep 21, 2023
1a267e3
Restore if let guard temporary scoping difference
matthewjasper Jan 3, 2024
44bba54
Update clippy for hir::Guard removal
matthewjasper Jan 4, 2024
6a2bd5a
Use `resolutions(()).effective_visiblities` to avoid cycle errors
compiler-errors Jan 4, 2024
fdb70da
Add support for shell argfiles
djkoloski Dec 6, 2023
a721ccb
Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errors
matthiaskrgr Jan 5, 2024
7a00ce6
Rollup merge of #119151 - Jules-Bertholet:no-foreign-doc-hidden-sugge…
matthiaskrgr Jan 5, 2024
7e58b2f
Rollup merge of #119350 - fmease:lazy-ty-aliases-implied-bounds, r=co…
matthiaskrgr Jan 5, 2024
e0c86de
Rollup merge of #119354 - fmease:negative_bounds-fixes, r=compiler-er…
matthiaskrgr Jan 5, 2024
dd6b824
Rollup merge of #119506 - compiler-errors:visibilities-for-object-saf…
matthiaskrgr Jan 5, 2024
29a1770
Rollup merge of #119554 - matthewjasper:remove-guard-distinction, r=c…
matthiaskrgr Jan 5, 2024
ebbe615
Rollup merge of #119563 - compiler-errors:coroutine-resume, r=oli-obk
matthiaskrgr Jan 5, 2024
b4a7f1e
Rollup merge of #119589 - petrochenkov:cdatalock, r=Mark-Simulacrum
matthiaskrgr Jan 5, 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
Use resolutions(()).effective_visiblities to avoid cycle errors
  • Loading branch information
compiler-errors committed Jan 5, 2024
commit 6a2bd5acd664e6bd118563ea9033245c624fec2e
5 changes: 4 additions & 1 deletion compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ pub fn report_object_safety_error<'tcx>(
};
let externally_visible = if !impls.is_empty()
&& let Some(def_id) = trait_def_id.as_local()
&& tcx.effective_visibilities(()).is_exported(def_id)
// We may be executing this during typeck, which would result in cycle
// if we used effective_visibilities query, which looks into opaque types
// (and therefore calls typeck).
&& tcx.resolutions(()).effective_visibilities.is_exported(def_id)
{
true
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
trait Marker {}
impl Marker for u32 {}

trait MyTrait {
fn foo(&self) -> impl Marker;
}

struct Outer;

impl MyTrait for Outer {
fn foo(&self) -> impl Marker {
42
}
}

impl dyn MyTrait {
//~^ ERROR the trait `MyTrait` cannot be made into an object
fn other(&self) -> impl Marker {
//~^ ERROR the trait `MyTrait` cannot be made into an object
MyTrait::foo(&self)
//~^ ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
//~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
//~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
//~| ERROR the trait `MyTrait` cannot be made into an object
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:22
|
LL | MyTrait::foo(&self)
| ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
| |
| required by a bound introduced by this call
|
= help: the trait `MyTrait` is implemented for `Outer`

error[E0038]: the trait `MyTrait` cannot be made into an object
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9
|
LL | MyTrait::foo(&self)
| ^^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
LL | trait MyTrait {
| ------- this trait cannot be made into an object...
LL | fn foo(&self) -> impl Marker;
| ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type
= help: consider moving `foo` to another trait
= help: only type `Outer` implements the trait, consider using it directly instead

error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9
|
LL | MyTrait::foo(&self)
| ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
= help: the trait `MyTrait` is implemented for `Outer`

error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:20:9
|
LL | MyTrait::foo(&self)
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
= help: the trait `MyTrait` is implemented for `Outer`

error[E0038]: the trait `MyTrait` cannot be made into an object
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:16:6
|
LL | impl dyn MyTrait {
| ^^^^^^^^^^^ `MyTrait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
LL | trait MyTrait {
| ------- this trait cannot be made into an object...
LL | fn foo(&self) -> impl Marker;
| ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type
= help: consider moving `foo` to another trait
= help: only type `Outer` implements the trait, consider using it directly instead

error[E0038]: the trait `MyTrait` cannot be made into an object
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:18:15
|
LL | fn other(&self) -> impl Marker {
| ^^^^ `MyTrait` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/cycle-effective-visibilities-during-object-safety.rs:5:22
|
LL | trait MyTrait {
| ------- this trait cannot be made into an object...
LL | fn foo(&self) -> impl Marker;
| ^^^^^^^^^^^ ...because method `foo` references an `impl Trait` type in its return type
= help: consider moving `foo` to another trait
= help: only type `Outer` implements the trait, consider using it directly instead

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.
Loading